From: Marko Kreen Date: Mon, 6 Sep 2010 10:49:29 +0000 (+0300) Subject: Make possible to disallow SELECT statement. X-Git-Tag: plproxy_2_2_rc1~8 X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=98e52413838fad3f4096074cfb042087eb454d54;p=plproxy.git Make possible to disallow SELECT statement. make NO_SELECT=1 make install --- diff --git a/Makefile b/Makefile index a01f081..48029b4 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,9 @@ # PL/Proxy version PLPROXY_VERSION = 2.1 +# set to 1 to disallow functions containing SELECT +NO_SELECT = 0 + # libpq config PG_CONFIG = pg_config PQINC = $(shell $(PG_CONFIG) --includedir) @@ -18,7 +21,7 @@ SRCS = src/cluster.c src/execute.c src/function.c src/main.c \ OBJS = src/scanner.o src/parser.tab.o $(SRCS:.c=.o) DATA_built = plproxy.sql EXTRA_CLEAN = src/scanner.[ch] src/parser.tab.[ch] plproxy.sql.in -PG_CPPFLAGS = -I$(PQINC) +PG_CPPFLAGS = -I$(PQINC) -DNO_SELECT=$(NO_SELECT) SHLIB_LINK = -L$(PQLIB) -lpq TARNAME = plproxy-$(PLPROXY_VERSION) diff --git a/src/parser.y b/src/parser.y index cd5f327..13c7295 100644 --- a/src/parser.y +++ b/src/parser.y @@ -231,6 +231,12 @@ void plproxy_run_parser(ProxyFunction *func, const char *body, int len) yyerror("CLUSTER statement missing"); } + /* disallow SELECT if requested */ +#if NO_SELECT + if (select_sql) + yyerror("SELECT statement not allowed"); +#endif + /* release scanner resources */ plproxy_yylex_destroy();