mirror of
https://github.com/postgres/postgres.git
synced 2025-06-29 10:41:53 +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:
@ -35,7 +35,7 @@
|
||||
|
||||
typedef struct FixedParamState
|
||||
{
|
||||
Oid *paramTypes; /* array of parameter type OIDs */
|
||||
const Oid *paramTypes; /* array of parameter type OIDs */
|
||||
int numParams; /* number of array entries */
|
||||
} FixedParamState;
|
||||
|
||||
@ -64,8 +64,8 @@ static bool query_contains_extern_params_walker(Node *node, void *context);
|
||||
* Set up to process a query containing references to fixed parameters.
|
||||
*/
|
||||
void
|
||||
parse_fixed_parameters(ParseState *pstate,
|
||||
Oid *paramTypes, int numParams)
|
||||
setup_parse_fixed_parameters(ParseState *pstate,
|
||||
const Oid *paramTypes, int numParams)
|
||||
{
|
||||
FixedParamState *parstate = palloc(sizeof(FixedParamState));
|
||||
|
||||
@ -80,7 +80,7 @@ parse_fixed_parameters(ParseState *pstate,
|
||||
* Set up to process a query containing references to variable parameters.
|
||||
*/
|
||||
void
|
||||
parse_variable_parameters(ParseState *pstate,
|
||||
setup_parse_variable_parameters(ParseState *pstate,
|
||||
Oid **paramTypes, int *numParams)
|
||||
{
|
||||
VarParamState *parstate = palloc(sizeof(VarParamState));
|
||||
|
Reference in New Issue
Block a user