mirror of
https://github.com/postgres/postgres.git
synced 2025-08-25 20:23:07 +03:00
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
This commit is contained in:
@@ -439,7 +439,7 @@ BeginCopyTo(ParseState *pstate,
|
||||
* Run parse analysis and rewrite. Note this also acquires sufficient
|
||||
* locks on the source table(s).
|
||||
*/
|
||||
rewritten = pg_analyze_and_rewrite(raw_query,
|
||||
rewritten = pg_analyze_and_rewrite_fixedparams(raw_query,
|
||||
pstate->p_sourcetext, NULL, 0,
|
||||
NULL);
|
||||
|
||||
|
@@ -757,7 +757,7 @@ execute_sql_string(const char *sql)
|
||||
/* Be sure parser can see any DDL done so far */
|
||||
CommandCounterIncrement();
|
||||
|
||||
stmt_list = pg_analyze_and_rewrite(parsetree,
|
||||
stmt_list = pg_analyze_and_rewrite_fixedparams(parsetree,
|
||||
sql,
|
||||
NULL,
|
||||
0,
|
||||
|
@@ -172,7 +172,7 @@ CreateSchemaCommand(CreateSchemaStmt *stmt, const char *queryString,
|
||||
/*
|
||||
* Execute each command contained in the CREATE SCHEMA. Since the grammar
|
||||
* allows only utility commands in CREATE SCHEMA, there is no need to pass
|
||||
* them through parse_analyze() or the rewriter; we can just hand them
|
||||
* them through parse_analyze_*() or the rewriter; we can just hand them
|
||||
* straight to ProcessUtility.
|
||||
*/
|
||||
foreach(parsetree_item, parsetree_list)
|
||||
|
@@ -13181,7 +13181,7 @@ ATPostAlterTypeParse(Oid oldId, Oid oldRelId, Oid refRelId, char *cmd,
|
||||
/*
|
||||
* We expect that we will get only ALTER TABLE and CREATE INDEX
|
||||
* statements. Hence, there is no need to pass them through
|
||||
* parse_analyze() or the rewriter, but instead we need to pass them
|
||||
* parse_analyze_*() or the rewriter, but instead we need to pass them
|
||||
* through parse_utilcmd.c to make them ready for execution.
|
||||
*/
|
||||
raw_parsetree_list = raw_parser(cmd, RAW_PARSE_DEFAULT);
|
||||
|
@@ -439,7 +439,7 @@ DefineView(ViewStmt *stmt, const char *queryString,
|
||||
rawstmt->stmt_location = stmt_location;
|
||||
rawstmt->stmt_len = stmt_len;
|
||||
|
||||
viewParse = parse_analyze(rawstmt, queryString, NULL, 0, NULL);
|
||||
viewParse = parse_analyze_fixedparams(rawstmt, queryString, NULL, 0, NULL);
|
||||
|
||||
/*
|
||||
* The grammar should ensure that the result is a single SELECT Query.
|
||||
|
Reference in New Issue
Block a user