-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Roman Kulikov
committed
Nov 22, 2022
1 parent
b3a61b6
commit 471535a
Showing
11 changed files
with
168 additions
and
23 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
FROM postgres:13-alpine as build | ||
|
||
RUN echo https://dl-2.alpinelinux.org/alpine/edge/community/ >> /etc/apk/repositories \ | ||
&& apk --no-cache add git make cmake libc-dev flex bison gcc postgresql-dev | ||
|
||
COPY ./extension /tmp/annotate_query | ||
|
||
RUN cd /tmp/annotate_query \ | ||
&& make USE_PGXS=1 \ | ||
&& make USE_PGXS=1 install | ||
|
||
RUN echo 1 \ | ||
&& ls -la /tmp/annotate_query \ | ||
&& cat /tmp/annotate_query/annotate_query--1.0.0.sql \ | ||
&& cat /tmp/annotate_query/annotate_query--1.0.0.sql.in | ||
|
||
FROM postgres:13-alpine as result | ||
|
||
COPY --from=build /usr/local/share/postgresql/extension/annotate_query* /usr/local/share/postgresql/extension/ | ||
COPY --from=build /usr/local/lib/postgresql/annotate_query* /usr/local/lib/postgresql/ | ||
COPY --from=build /usr/local/lib/postgresql/bitcode/annotate_query/ /usr/local/lib/postgresql/bitcode/annotate_query/ | ||
COPY --from=build /usr/local/lib/postgresql/bitcode/annotate_query.index.bc /usr/local/lib/postgresql/bitcode/annotate_query.index.bc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
MODULES = annotate_query | ||
EXTENSION = annotate_query | ||
DATA_built = annotate_query--1.0.0.sql | ||
|
||
PG_CONFIG = pg_config | ||
PGXS := $(shell $(PG_CONFIG) --pgxs) | ||
include $(PGXS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- complain if script is sourced in psql, rather than via CREATE EXTENSION | ||
\echo Use "CREATE EXTENSION annotate_query" to load this file. \quit | ||
|
||
CREATE OR REPLACE FUNCTION annotate_query(query text) | ||
RETURNS text | ||
AS '$libdir/annotate_query' | ||
LANGUAGE C IMMUTABLE STRICT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include "postgres.h" | ||
#include "fmgr.h" | ||
#include "utils/builtins.h" | ||
#include "parser/parser.h" | ||
#include "nodes/print.h" | ||
|
||
PG_MODULE_MAGIC; | ||
|
||
|
||
PG_FUNCTION_INFO_V1(annotate_query); | ||
|
||
Datum | ||
annotate_query(PG_FUNCTION_ARGS) | ||
{ | ||
text *sql_t = PG_GETARG_TEXT_P(0); | ||
text *out_t; | ||
char *sql, *out; | ||
List *tree; | ||
|
||
sql = text_to_cstring(sql_t); | ||
tree = raw_parser(sql); | ||
|
||
out = nodeToString(tree); | ||
|
||
out_t = cstring_to_text(out); | ||
PG_RETURN_TEXT_P(out_t); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# annotate_query extension | ||
comment = 'annotate_query' | ||
default_version = '1.0.0' | ||
module_pathname = '$libdir/annotate_query' | ||
relocatable = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/sh | ||
docker-compose exec -u 0 rvkulikov.pg-deps-management.pgsql sh $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters