diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2022-03-04 14:49:37 +0100 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2022-03-04 14:50:22 +0100 |
commit | 791b1b71da35d9d4264f72a87e4078b85a2fcfb4 (patch) | |
tree | 016287b8c51ff0d9d591bceed27f7b223d46a8d0 /src/include | |
parent | d816f366bc427cacba29c1e4b1696afa620e73a7 (diff) | |
download | postgresql-791b1b71da35d9d4264f72a87e4078b85a2fcfb4.tar.gz |
Parse/analyze function renaming
There are three parallel ways to call parse/analyze: with fixed
parameters, with variable parameters, and by supplying your own parser
callback. Some of the involved functions were confusingly named and
made this API structure more confusing. This patch renames some
functions to make this clearer:
parse_analyze() -> parse_analyze_fixedparams()
pg_analyze_and_rewrite() -> pg_analyze_and_rewrite_fixedparams()
(Otherwise one might think this variant doesn't accept parameters, but
in fact all three ways accept parameters.)
pg_analyze_and_rewrite_params() -> pg_analyze_and_rewrite_withcb()
(Before, and also when considering pg_analyze_and_rewrite(), one might
think this is the only way to pass parameters. Moreover, the parser
callback doesn't necessarily need to parse only parameters, it's just
one of the things it could do.)
parse_fixed_parameters() -> setup_parse_fixed_parameters()
parse_variable_parameters() -> setup_parse_variable_parameters()
(These functions don't actually do any parsing, they just set up
callbacks to use during parsing later.)
This patch also adds some const decorations to the fixed-parameters
API, so the distinction from the variable-parameters API is more
clear.
Reviewed-by: Nathan Bossart <bossartn@amazon.com>
Discussion: https://www.postgresql.org/message-id/flat/c67ce276-52b4-0239-dc0e-39875bf81840@enterprisedb.com
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/parser/analyze.h | 4 | ||||
-rw-r--r-- | src/include/parser/parse_param.h | 6 | ||||
-rw-r--r-- | src/include/tcop/tcopprot.h | 6 |
3 files changed, 8 insertions, 8 deletions
diff --git a/src/include/parser/analyze.h b/src/include/parser/analyze.h index 0022184de0..ed989bb141 100644 --- a/src/include/parser/analyze.h +++ b/src/include/parser/analyze.h @@ -24,8 +24,8 @@ typedef void (*post_parse_analyze_hook_type) (ParseState *pstate, extern PGDLLIMPORT post_parse_analyze_hook_type post_parse_analyze_hook; -extern Query *parse_analyze(RawStmt *parseTree, const char *sourceText, - Oid *paramTypes, int numParams, QueryEnvironment *queryEnv); +extern Query *parse_analyze_fixedparams(RawStmt *parseTree, const char *sourceText, + const Oid *paramTypes, int numParams, QueryEnvironment *queryEnv); extern Query *parse_analyze_varparams(RawStmt *parseTree, const char *sourceText, Oid **paramTypes, int *numParams); diff --git a/src/include/parser/parse_param.h b/src/include/parser/parse_param.h index 18e608093c..d6f0b65649 100644 --- a/src/include/parser/parse_param.h +++ b/src/include/parser/parse_param.h @@ -15,9 +15,9 @@ #include "parser/parse_node.h" -extern void parse_fixed_parameters(ParseState *pstate, - Oid *paramTypes, int numParams); -extern void parse_variable_parameters(ParseState *pstate, +extern void setup_parse_fixed_parameters(ParseState *pstate, + const Oid *paramTypes, int numParams); +extern void setup_parse_variable_parameters(ParseState *pstate, Oid **paramTypes, int *numParams); extern void check_variable_parameters(ParseState *pstate, Query *query); extern bool query_contains_extern_params(Query *query); diff --git a/src/include/tcop/tcopprot.h b/src/include/tcop/tcopprot.h index 15a11bc3ff..00c20966ab 100644 --- a/src/include/tcop/tcopprot.h +++ b/src/include/tcop/tcopprot.h @@ -45,11 +45,11 @@ extern PGDLLIMPORT int log_statement; extern List *pg_parse_query(const char *query_string); extern List *pg_rewrite_query(Query *query); -extern List *pg_analyze_and_rewrite(RawStmt *parsetree, +extern List *pg_analyze_and_rewrite_fixedparams(RawStmt *parsetree, const char *query_string, - Oid *paramTypes, int numParams, + const Oid *paramTypes, int numParams, QueryEnvironment *queryEnv); -extern List *pg_analyze_and_rewrite_params(RawStmt *parsetree, +extern List *pg_analyze_and_rewrite_withcb(RawStmt *parsetree, const char *query_string, ParserSetupHook parserSetup, void *parserSetupArg, |