diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index c466453..455e458 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -105,7 +105,8 @@ int max_stack_depth = 100; /* wait N seconds to allow attach from a debugger */ int PostAuthDelay = 0; - +/* Hook for plugins to be able to manipulate the parsed raw queries */ +post_raw_parse_hook_type post_raw_parse_hook = NULL; /* ---------------- * private variables @@ -881,6 +882,13 @@ exec_simple_query(const char *query_string) */ parsetree_list = pg_parse_query(query_string); + /* + * Plugins may have a chance to look at or modify the parsed + * queries + */ + if (post_raw_parse_hook) + (*post_raw_parse_hook) (parsetree_list); + /* Log immediately if dictated by log_statement */ if (check_log_statement(parsetree_list)) { diff --git a/src/include/tcop/tcopprot.h b/src/include/tcop/tcopprot.h index 035a442..c0df7cd 100644 --- a/src/include/tcop/tcopprot.h +++ b/src/include/tcop/tcopprot.h @@ -46,6 +46,10 @@ typedef enum extern int log_statement; +/* Hook for plugins to be able to manipulate the parsed raw queries */ +typedef void (*post_raw_parse_hook_type) (List * parsedRawQueries); +extern PGDLLIMPORT post_raw_parse_hook_type post_raw_parse_hook; + extern List *pg_parse_query(const char *query_string); extern List *pg_analyze_and_rewrite(Node *parsetree, const char *query_string, Oid *paramTypes, int numParams);