Commit 49eb0fd0 authored by Peter Eisentraut's avatar Peter Eisentraut

Add location field to DefElem

Add a location field to the DefElem struct, used to parse many utility
commands.  Update various error messages to supply error position
information.

To propogate the error position information in a more systematic way,
create a ParseState in standard_ProcessUtility() and pass that to
interested functions implementing the utility commands.  This seems
better than passing the query string and then reassembling a parse state
ad hoc, which violates the encapsulation of the ParseState type.
Reviewed-by: default avatarPavel Stehule <pavel.stehule@gmail.com>
parent 975768f8
...@@ -293,7 +293,7 @@ file_fdw_validator(PG_FUNCTION_ARGS) ...@@ -293,7 +293,7 @@ file_fdw_validator(PG_FUNCTION_ARGS)
/* /*
* Now apply the core COPY code's validation logic for more checks. * Now apply the core COPY code's validation logic for more checks.
*/ */
ProcessCopyOptions(NULL, true, other_options); ProcessCopyOptions(NULL, NULL, true, other_options);
/* /*
* Filename option is required for file_fdw foreign tables. * Filename option is required for file_fdw foreign tables.
...@@ -455,10 +455,10 @@ get_file_fdw_attribute_options(Oid relid) ...@@ -455,10 +455,10 @@ get_file_fdw_attribute_options(Oid relid)
* force_null options set * force_null options set
*/ */
if (fnncolumns != NIL) if (fnncolumns != NIL)
options = lappend(options, makeDefElem("force_not_null", (Node *) fnncolumns)); options = lappend(options, makeDefElem("force_not_null", (Node *) fnncolumns, -1));
if (fncolumns != NIL) if (fncolumns != NIL)
options = lappend(options, makeDefElem("force_null", (Node *) fncolumns)); options = lappend(options, makeDefElem("force_null", (Node *) fncolumns, -1));
return options; return options;
} }
...@@ -511,7 +511,7 @@ fileGetForeignPaths(PlannerInfo *root, ...@@ -511,7 +511,7 @@ fileGetForeignPaths(PlannerInfo *root,
foreigntableid, foreigntableid,
&columns)) &columns))
coptions = list_make1(makeDefElem("convert_selectively", coptions = list_make1(makeDefElem("convert_selectively",
(Node *) columns)); (Node *) columns, -1));
/* Estimate costs */ /* Estimate costs */
estimate_costs(root, baserel, fdw_private, estimate_costs(root, baserel, fdw_private,
...@@ -632,7 +632,8 @@ fileBeginForeignScan(ForeignScanState *node, int eflags) ...@@ -632,7 +632,8 @@ fileBeginForeignScan(ForeignScanState *node, int eflags)
* Create CopyState from FDW options. We always acquire all columns, so * Create CopyState from FDW options. We always acquire all columns, so
* as to match the expected ScanTupleSlot signature. * as to match the expected ScanTupleSlot signature.
*/ */
cstate = BeginCopyFrom(node->ss.ss_currentRelation, cstate = BeginCopyFrom(NULL,
node->ss.ss_currentRelation,
filename, filename,
false, false,
NIL, NIL,
...@@ -705,7 +706,8 @@ fileReScanForeignScan(ForeignScanState *node) ...@@ -705,7 +706,8 @@ fileReScanForeignScan(ForeignScanState *node)
EndCopyFrom(festate->cstate); EndCopyFrom(festate->cstate);
festate->cstate = BeginCopyFrom(node->ss.ss_currentRelation, festate->cstate = BeginCopyFrom(NULL,
node->ss.ss_currentRelation,
festate->filename, festate->filename,
false, false,
NIL, NIL,
...@@ -1053,7 +1055,7 @@ file_acquire_sample_rows(Relation onerel, int elevel, ...@@ -1053,7 +1055,7 @@ file_acquire_sample_rows(Relation onerel, int elevel,
/* /*
* Create CopyState from FDW options. * Create CopyState from FDW options.
*/ */
cstate = BeginCopyFrom(onerel, filename, false, NIL, options); cstate = BeginCopyFrom(NULL, onerel, filename, false, NIL, options);
/* /*
* Use per-tuple memory context to prevent leak of memory used to read * Use per-tuple memory context to prevent leak of memory used to read
......
...@@ -888,7 +888,7 @@ untransformRelOptions(Datum options) ...@@ -888,7 +888,7 @@ untransformRelOptions(Datum options)
*p++ = '\0'; *p++ = '\0';
val = (Node *) makeString(pstrdup(p)); val = (Node *) makeString(pstrdup(p));
} }
result = lappend(result, makeDefElem(pstrdup(s), val)); result = lappend(result, makeDefElem(pstrdup(s), val, -1));
} }
return result; return result;
......
...@@ -849,7 +849,7 @@ getRelationsInNamespace(Oid namespaceId, char relkind) ...@@ -849,7 +849,7 @@ getRelationsInNamespace(Oid namespaceId, char relkind)
* ALTER DEFAULT PRIVILEGES statement * ALTER DEFAULT PRIVILEGES statement
*/ */
void void
ExecAlterDefaultPrivilegesStmt(AlterDefaultPrivilegesStmt *stmt) ExecAlterDefaultPrivilegesStmt(ParseState *pstate, AlterDefaultPrivilegesStmt *stmt)
{ {
GrantStmt *action = stmt->action; GrantStmt *action = stmt->action;
InternalDefaultACL iacls; InternalDefaultACL iacls;
...@@ -871,7 +871,8 @@ ExecAlterDefaultPrivilegesStmt(AlterDefaultPrivilegesStmt *stmt) ...@@ -871,7 +871,8 @@ ExecAlterDefaultPrivilegesStmt(AlterDefaultPrivilegesStmt *stmt)
if (dnspnames) if (dnspnames)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dnspnames = defel; dnspnames = defel;
} }
else if (strcmp(defel->defname, "roles") == 0) else if (strcmp(defel->defname, "roles") == 0)
...@@ -879,7 +880,8 @@ ExecAlterDefaultPrivilegesStmt(AlterDefaultPrivilegesStmt *stmt) ...@@ -879,7 +880,8 @@ ExecAlterDefaultPrivilegesStmt(AlterDefaultPrivilegesStmt *stmt)
if (drolespecs) if (drolespecs)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
drolespecs = defel; drolespecs = defel;
} }
else else
......
...@@ -52,8 +52,7 @@ ...@@ -52,8 +52,7 @@
* "parameters" is a list of DefElem representing the agg's definition clauses. * "parameters" is a list of DefElem representing the agg's definition clauses.
*/ */
ObjectAddress ObjectAddress
DefineAggregate(List *name, List *args, bool oldstyle, List *parameters, DefineAggregate(ParseState *pstate, List *name, List *args, bool oldstyle, List *parameters)
const char *queryString)
{ {
char *aggName; char *aggName;
Oid aggNamespace; Oid aggNamespace;
...@@ -287,10 +286,10 @@ DefineAggregate(List *name, List *args, bool oldstyle, List *parameters, ...@@ -287,10 +286,10 @@ DefineAggregate(List *name, List *args, bool oldstyle, List *parameters,
errmsg("basetype is redundant with aggregate input type specification"))); errmsg("basetype is redundant with aggregate input type specification")));
numArgs = list_length(args); numArgs = list_length(args);
interpret_function_parameter_list(args, interpret_function_parameter_list(pstate,
args,
InvalidOid, InvalidOid,
true, /* is an aggregate */ true, /* is an aggregate */
queryString,
&parameterTypes, &parameterTypes,
&allParameterTypes, &allParameterTypes,
&parameterModes, &parameterModes,
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
* CREATE COLLATION * CREATE COLLATION
*/ */
ObjectAddress ObjectAddress
DefineCollation(List *names, List *parameters) DefineCollation(ParseState *pstate, List *names, List *parameters)
{ {
char *collName; char *collName;
Oid collNamespace; Oid collNamespace;
...@@ -78,7 +78,8 @@ DefineCollation(List *names, List *parameters) ...@@ -78,7 +78,8 @@ DefineCollation(List *names, List *parameters)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("collation attribute \"%s\" not recognized", errmsg("collation attribute \"%s\" not recognized",
defel->defname))); defel->defname),
parser_errposition(pstate, defel->location)));
break; break;
} }
......
...@@ -279,12 +279,12 @@ static const char BinarySignature[11] = "PGCOPY\n\377\r\n\0"; ...@@ -279,12 +279,12 @@ static const char BinarySignature[11] = "PGCOPY\n\377\r\n\0";
/* non-export function prototypes */ /* non-export function prototypes */
static CopyState BeginCopy(bool is_from, Relation rel, Node *raw_query, static CopyState BeginCopy(ParseState *pstate, bool is_from, Relation rel, Node *raw_query,
const char *queryString, const Oid queryRelId, List *attnamelist, const Oid queryRelId, List *attnamelist,
List *options); List *options);
static void EndCopy(CopyState cstate); static void EndCopy(CopyState cstate);
static void ClosePipeToProgram(CopyState cstate); static void ClosePipeToProgram(CopyState cstate);
static CopyState BeginCopyTo(Relation rel, Node *query, const char *queryString, static CopyState BeginCopyTo(ParseState *pstate, Relation rel, Node *query,
const Oid queryRelId, const char *filename, bool is_program, const Oid queryRelId, const char *filename, bool is_program,
List *attnamelist, List *options); List *attnamelist, List *options);
static void EndCopyTo(CopyState cstate); static void EndCopyTo(CopyState cstate);
...@@ -787,7 +787,7 @@ CopyLoadRawBuf(CopyState cstate) ...@@ -787,7 +787,7 @@ CopyLoadRawBuf(CopyState cstate)
* the table or the specifically requested columns. * the table or the specifically requested columns.
*/ */
Oid Oid
DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed) DoCopy(ParseState *pstate, const CopyStmt *stmt, uint64 *processed)
{ {
CopyState cstate; CopyState cstate;
bool is_from = stmt->is_from; bool is_from = stmt->is_from;
...@@ -936,7 +936,7 @@ DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed) ...@@ -936,7 +936,7 @@ DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed)
PreventCommandIfReadOnly("COPY FROM"); PreventCommandIfReadOnly("COPY FROM");
PreventCommandIfParallelMode("COPY FROM"); PreventCommandIfParallelMode("COPY FROM");
cstate = BeginCopyFrom(rel, stmt->filename, stmt->is_program, cstate = BeginCopyFrom(pstate, rel, stmt->filename, stmt->is_program,
stmt->attlist, stmt->options); stmt->attlist, stmt->options);
cstate->range_table = range_table; cstate->range_table = range_table;
*processed = CopyFrom(cstate); /* copy from file to database */ *processed = CopyFrom(cstate); /* copy from file to database */
...@@ -944,7 +944,7 @@ DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed) ...@@ -944,7 +944,7 @@ DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed)
} }
else else
{ {
cstate = BeginCopyTo(rel, query, queryString, relid, cstate = BeginCopyTo(pstate, rel, query, relid,
stmt->filename, stmt->is_program, stmt->filename, stmt->is_program,
stmt->attlist, stmt->options); stmt->attlist, stmt->options);
*processed = DoCopyTo(cstate); /* copy from database to file */ *processed = DoCopyTo(cstate); /* copy from database to file */
...@@ -980,7 +980,8 @@ DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed) ...@@ -980,7 +980,8 @@ DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed)
* self-consistency of the options list. * self-consistency of the options list.
*/ */
void void
ProcessCopyOptions(CopyState cstate, ProcessCopyOptions(ParseState *pstate,
CopyState cstate,
bool is_from, bool is_from,
List *options) List *options)
{ {
...@@ -1005,7 +1006,8 @@ ProcessCopyOptions(CopyState cstate, ...@@ -1005,7 +1006,8 @@ ProcessCopyOptions(CopyState cstate,
if (format_specified) if (format_specified)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
format_specified = true; format_specified = true;
if (strcmp(fmt, "text") == 0) if (strcmp(fmt, "text") == 0)
/* default format */ ; /* default format */ ;
...@@ -1016,14 +1018,16 @@ ProcessCopyOptions(CopyState cstate, ...@@ -1016,14 +1018,16 @@ ProcessCopyOptions(CopyState cstate,
else else
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("COPY format \"%s\" not recognized", fmt))); errmsg("COPY format \"%s\" not recognized", fmt),
parser_errposition(pstate, defel->location)));
} }
else if (strcmp(defel->defname, "oids") == 0) else if (strcmp(defel->defname, "oids") == 0)
{ {
if (cstate->oids) if (cstate->oids)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
cstate->oids = defGetBoolean(defel); cstate->oids = defGetBoolean(defel);
} }
else if (strcmp(defel->defname, "freeze") == 0) else if (strcmp(defel->defname, "freeze") == 0)
...@@ -1031,7 +1035,8 @@ ProcessCopyOptions(CopyState cstate, ...@@ -1031,7 +1035,8 @@ ProcessCopyOptions(CopyState cstate,
if (cstate->freeze) if (cstate->freeze)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
cstate->freeze = defGetBoolean(defel); cstate->freeze = defGetBoolean(defel);
} }
else if (strcmp(defel->defname, "delimiter") == 0) else if (strcmp(defel->defname, "delimiter") == 0)
...@@ -1039,7 +1044,8 @@ ProcessCopyOptions(CopyState cstate, ...@@ -1039,7 +1044,8 @@ ProcessCopyOptions(CopyState cstate,
if (cstate->delim) if (cstate->delim)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
cstate->delim = defGetString(defel); cstate->delim = defGetString(defel);
} }
else if (strcmp(defel->defname, "null") == 0) else if (strcmp(defel->defname, "null") == 0)
...@@ -1047,7 +1053,8 @@ ProcessCopyOptions(CopyState cstate, ...@@ -1047,7 +1053,8 @@ ProcessCopyOptions(CopyState cstate,
if (cstate->null_print) if (cstate->null_print)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
cstate->null_print = defGetString(defel); cstate->null_print = defGetString(defel);
} }
else if (strcmp(defel->defname, "header") == 0) else if (strcmp(defel->defname, "header") == 0)
...@@ -1055,7 +1062,8 @@ ProcessCopyOptions(CopyState cstate, ...@@ -1055,7 +1062,8 @@ ProcessCopyOptions(CopyState cstate,
if (cstate->header_line) if (cstate->header_line)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
cstate->header_line = defGetBoolean(defel); cstate->header_line = defGetBoolean(defel);
} }
else if (strcmp(defel->defname, "quote") == 0) else if (strcmp(defel->defname, "quote") == 0)
...@@ -1063,7 +1071,8 @@ ProcessCopyOptions(CopyState cstate, ...@@ -1063,7 +1071,8 @@ ProcessCopyOptions(CopyState cstate,
if (cstate->quote) if (cstate->quote)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
cstate->quote = defGetString(defel); cstate->quote = defGetString(defel);
} }
else if (strcmp(defel->defname, "escape") == 0) else if (strcmp(defel->defname, "escape") == 0)
...@@ -1071,7 +1080,8 @@ ProcessCopyOptions(CopyState cstate, ...@@ -1071,7 +1080,8 @@ ProcessCopyOptions(CopyState cstate,
if (cstate->escape) if (cstate->escape)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
cstate->escape = defGetString(defel); cstate->escape = defGetString(defel);
} }
else if (strcmp(defel->defname, "force_quote") == 0) else if (strcmp(defel->defname, "force_quote") == 0)
...@@ -1079,7 +1089,8 @@ ProcessCopyOptions(CopyState cstate, ...@@ -1079,7 +1089,8 @@ ProcessCopyOptions(CopyState cstate,
if (cstate->force_quote || cstate->force_quote_all) if (cstate->force_quote || cstate->force_quote_all)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
if (defel->arg && IsA(defel->arg, A_Star)) if (defel->arg && IsA(defel->arg, A_Star))
cstate->force_quote_all = true; cstate->force_quote_all = true;
else if (defel->arg && IsA(defel->arg, List)) else if (defel->arg && IsA(defel->arg, List))
...@@ -1088,21 +1099,24 @@ ProcessCopyOptions(CopyState cstate, ...@@ -1088,21 +1099,24 @@ ProcessCopyOptions(CopyState cstate,
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("argument to option \"%s\" must be a list of column names", errmsg("argument to option \"%s\" must be a list of column names",
defel->defname))); defel->defname),
parser_errposition(pstate, defel->location)));
} }
else if (strcmp(defel->defname, "force_not_null") == 0) else if (strcmp(defel->defname, "force_not_null") == 0)
{ {
if (cstate->force_notnull) if (cstate->force_notnull)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
if (defel->arg && IsA(defel->arg, List)) if (defel->arg && IsA(defel->arg, List))
cstate->force_notnull = (List *) defel->arg; cstate->force_notnull = (List *) defel->arg;
else else
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("argument to option \"%s\" must be a list of column names", errmsg("argument to option \"%s\" must be a list of column names",
defel->defname))); defel->defname),
parser_errposition(pstate, defel->location)));
} }
else if (strcmp(defel->defname, "force_null") == 0) else if (strcmp(defel->defname, "force_null") == 0)
{ {
...@@ -1116,7 +1130,8 @@ ProcessCopyOptions(CopyState cstate, ...@@ -1116,7 +1130,8 @@ ProcessCopyOptions(CopyState cstate,
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("argument to option \"%s\" must be a list of column names", errmsg("argument to option \"%s\" must be a list of column names",
defel->defname))); defel->defname),
parser_errposition(pstate, defel->location)));
} }
else if (strcmp(defel->defname, "convert_selectively") == 0) else if (strcmp(defel->defname, "convert_selectively") == 0)
{ {
...@@ -1128,7 +1143,8 @@ ProcessCopyOptions(CopyState cstate, ...@@ -1128,7 +1143,8 @@ ProcessCopyOptions(CopyState cstate,
if (cstate->convert_selectively) if (cstate->convert_selectively)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
cstate->convert_selectively = true; cstate->convert_selectively = true;
if (defel->arg == NULL || IsA(defel->arg, List)) if (defel->arg == NULL || IsA(defel->arg, List))
cstate->convert_select = (List *) defel->arg; cstate->convert_select = (List *) defel->arg;
...@@ -1136,26 +1152,30 @@ ProcessCopyOptions(CopyState cstate, ...@@ -1136,26 +1152,30 @@ ProcessCopyOptions(CopyState cstate,
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("argument to option \"%s\" must be a list of column names", errmsg("argument to option \"%s\" must be a list of column names",
defel->defname))); defel->defname),
parser_errposition(pstate, defel->location)));
} }
else if (strcmp(defel->defname, "encoding") == 0) else if (strcmp(defel->defname, "encoding") == 0)
{ {
if (cstate->file_encoding >= 0) if (cstate->file_encoding >= 0)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
cstate->file_encoding = pg_char_to_encoding(defGetString(defel)); cstate->file_encoding = pg_char_to_encoding(defGetString(defel));
if (cstate->file_encoding < 0) if (cstate->file_encoding < 0)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("argument to option \"%s\" must be a valid encoding name", errmsg("argument to option \"%s\" must be a valid encoding name",
defel->defname))); defel->defname),
parser_errposition(pstate, defel->location)));
} }
else else
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("option \"%s\" not recognized", errmsg("option \"%s\" not recognized",
defel->defname))); defel->defname),
parser_errposition(pstate, defel->location)));
} }
/* /*
...@@ -1318,10 +1338,10 @@ ProcessCopyOptions(CopyState cstate, ...@@ -1318,10 +1338,10 @@ ProcessCopyOptions(CopyState cstate,
* NULL values as <null_print>. * NULL values as <null_print>.
*/ */
static CopyState static CopyState
BeginCopy(bool is_from, BeginCopy(ParseState *pstate,
bool is_from,
Relation rel, Relation rel,
Node *raw_query, Node *raw_query,
const char *queryString,
const Oid queryRelId, const Oid queryRelId,
List *attnamelist, List *attnamelist,
List *options) List *options)
...@@ -1345,7 +1365,7 @@ BeginCopy(bool is_from, ...@@ -1345,7 +1365,7 @@ BeginCopy(bool is_from,
oldcontext = MemoryContextSwitchTo(cstate->copycontext); oldcontext = MemoryContextSwitchTo(cstate->copycontext);
/* Extract options from the statement node tree */ /* Extract options from the statement node tree */
ProcessCopyOptions(cstate, is_from, options); ProcessCopyOptions(pstate, cstate, is_from, options);
/* Process the source/target relation or query */ /* Process the source/target relation or query */
if (rel) if (rel)
...@@ -1390,7 +1410,7 @@ BeginCopy(bool is_from, ...@@ -1390,7 +1410,7 @@ BeginCopy(bool is_from,
* DECLARE CURSOR and PREPARE.) XXX FIXME someday. * DECLARE CURSOR and PREPARE.) XXX FIXME someday.
*/ */
rewritten = pg_analyze_and_rewrite((Node *) copyObject(raw_query), rewritten = pg_analyze_and_rewrite((Node *) copyObject(raw_query),
queryString, NULL, 0); pstate->p_sourcetext, NULL, 0);
/* check that we got back something we can work with */ /* check that we got back something we can work with */
if (rewritten == NIL) if (rewritten == NIL)
...@@ -1490,7 +1510,7 @@ BeginCopy(bool is_from, ...@@ -1490,7 +1510,7 @@ BeginCopy(bool is_from,
((DR_copy *) dest)->cstate = cstate; ((DR_copy *) dest)->cstate = cstate;
/* Create a QueryDesc requesting no output */ /* Create a QueryDesc requesting no output */
cstate->queryDesc = CreateQueryDesc(plan, queryString, cstate->queryDesc = CreateQueryDesc(plan, pstate->p_sourcetext,
GetActiveSnapshot(), GetActiveSnapshot(),
InvalidSnapshot, InvalidSnapshot,
dest, NULL, 0); dest, NULL, 0);
...@@ -1678,9 +1698,9 @@ EndCopy(CopyState cstate) ...@@ -1678,9 +1698,9 @@ EndCopy(CopyState cstate)
* Setup CopyState to read tuples from a table or a query for COPY TO. * Setup CopyState to read tuples from a table or a query for COPY TO.
*/ */
static CopyState static CopyState
BeginCopyTo(Relation rel, BeginCopyTo(ParseState *pstate,
Relation rel,
Node *query, Node *query,
const char *queryString,
const Oid queryRelId, const Oid queryRelId,
const char *filename, const char *filename,
bool is_program, bool is_program,
...@@ -1723,7 +1743,7 @@ BeginCopyTo(Relation rel, ...@@ -1723,7 +1743,7 @@ BeginCopyTo(Relation rel,
RelationGetRelationName(rel)))); RelationGetRelationName(rel))));
} }
cstate = BeginCopy(false, rel, query, queryString, queryRelId, attnamelist, cstate = BeginCopy(pstate, false, rel, query, queryRelId, attnamelist,
options); options);
oldcontext = MemoryContextSwitchTo(cstate->copycontext); oldcontext = MemoryContextSwitchTo(cstate->copycontext);
...@@ -2645,7 +2665,8 @@ CopyFromInsertBatch(CopyState cstate, EState *estate, CommandId mycid, ...@@ -2645,7 +2665,8 @@ CopyFromInsertBatch(CopyState cstate, EState *estate, CommandId mycid,
* Returns a CopyState, to be passed to NextCopyFrom and related functions. * Returns a CopyState, to be passed to NextCopyFrom and related functions.
*/ */
CopyState CopyState
BeginCopyFrom(Relation rel, BeginCopyFrom(ParseState *pstate,
Relation rel,
const char *filename, const char *filename,
bool is_program, bool is_program,
List *attnamelist, List *attnamelist,
...@@ -2666,7 +2687,7 @@ BeginCopyFrom(Relation rel, ...@@ -2666,7 +2687,7 @@ BeginCopyFrom(Relation rel,
MemoryContext oldcontext; MemoryContext oldcontext;
bool volatile_defexprs; bool volatile_defexprs;
cstate = BeginCopy(true, rel, NULL, NULL, InvalidOid, attnamelist, options); cstate = BeginCopy(pstate, true, rel, NULL, InvalidOid, attnamelist, options);
oldcontext = MemoryContextSwitchTo(cstate->copycontext); oldcontext = MemoryContextSwitchTo(cstate->copycontext);
/* Initialize state variables */ /* Initialize state variables */
......
...@@ -96,7 +96,7 @@ static int errdetail_busy_db(int notherbackends, int npreparedxacts); ...@@ -96,7 +96,7 @@ static int errdetail_busy_db(int notherbackends, int npreparedxacts);
* CREATE DATABASE * CREATE DATABASE
*/ */
Oid Oid
createdb(const CreatedbStmt *stmt) createdb(ParseState *pstate, const CreatedbStmt *stmt)
{ {
HeapScanDesc scan; HeapScanDesc scan;
Relation rel; Relation rel;
...@@ -152,7 +152,8 @@ createdb(const CreatedbStmt *stmt) ...@@ -152,7 +152,8 @@ createdb(const CreatedbStmt *stmt)
if (dtablespacename) if (dtablespacename)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dtablespacename = defel; dtablespacename = defel;
} }
else if (strcmp(defel->defname, "owner") == 0) else if (strcmp(defel->defname, "owner") == 0)
...@@ -160,7 +161,8 @@ createdb(const CreatedbStmt *stmt) ...@@ -160,7 +161,8 @@ createdb(const CreatedbStmt *stmt)
if (downer) if (downer)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
downer = defel; downer = defel;
} }
else if (strcmp(defel->defname, "template") == 0) else if (strcmp(defel->defname, "template") == 0)
...@@ -168,7 +170,8 @@ createdb(const CreatedbStmt *stmt) ...@@ -168,7 +170,8 @@ createdb(const CreatedbStmt *stmt)
if (dtemplate) if (dtemplate)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dtemplate = defel; dtemplate = defel;
} }
else if (strcmp(defel->defname, "encoding") == 0) else if (strcmp(defel->defname, "encoding") == 0)
...@@ -176,7 +179,8 @@ createdb(const CreatedbStmt *stmt) ...@@ -176,7 +179,8 @@ createdb(const CreatedbStmt *stmt)
if (dencoding) if (dencoding)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dencoding = defel; dencoding = defel;
} }
else if (strcmp(defel->defname, "lc_collate") == 0) else if (strcmp(defel->defname, "lc_collate") == 0)
...@@ -184,7 +188,8 @@ createdb(const CreatedbStmt *stmt) ...@@ -184,7 +188,8 @@ createdb(const CreatedbStmt *stmt)
if (dcollate) if (dcollate)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dcollate = defel; dcollate = defel;
} }
else if (strcmp(defel->defname, "lc_ctype") == 0) else if (strcmp(defel->defname, "lc_ctype") == 0)
...@@ -192,7 +197,8 @@ createdb(const CreatedbStmt *stmt) ...@@ -192,7 +197,8 @@ createdb(const CreatedbStmt *stmt)
if (dctype) if (dctype)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dctype = defel; dctype = defel;
} }
else if (strcmp(defel->defname, "is_template") == 0) else if (strcmp(defel->defname, "is_template") == 0)
...@@ -200,7 +206,8 @@ createdb(const CreatedbStmt *stmt) ...@@ -200,7 +206,8 @@ createdb(const CreatedbStmt *stmt)
if (distemplate) if (distemplate)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
distemplate = defel; distemplate = defel;
} }
else if (strcmp(defel->defname, "allow_connections") == 0) else if (strcmp(defel->defname, "allow_connections") == 0)
...@@ -208,7 +215,8 @@ createdb(const CreatedbStmt *stmt) ...@@ -208,7 +215,8 @@ createdb(const CreatedbStmt *stmt)
if (dallowconnections) if (dallowconnections)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dallowconnections = defel; dallowconnections = defel;
} }
else if (strcmp(defel->defname, "connection_limit") == 0) else if (strcmp(defel->defname, "connection_limit") == 0)
...@@ -216,7 +224,8 @@ createdb(const CreatedbStmt *stmt) ...@@ -216,7 +224,8 @@ createdb(const CreatedbStmt *stmt)
if (dconnlimit) if (dconnlimit)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dconnlimit = defel; dconnlimit = defel;
} }
else if (strcmp(defel->defname, "location") == 0) else if (strcmp(defel->defname, "location") == 0)
...@@ -224,12 +233,14 @@ createdb(const CreatedbStmt *stmt) ...@@ -224,12 +233,14 @@ createdb(const CreatedbStmt *stmt)
ereport(WARNING, ereport(WARNING,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("LOCATION is not supported anymore"), errmsg("LOCATION is not supported anymore"),
errhint("Consider using tablespaces instead."))); errhint("Consider using tablespaces instead."),
parser_errposition(pstate, defel->location)));
} }
else else
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("option \"%s\" not recognized", defel->defname))); errmsg("option \"%s\" not recognized", defel->defname),
parser_errposition(pstate, defel->location)));
} }
if (downer && downer->arg) if (downer && downer->arg)
...@@ -249,7 +260,8 @@ createdb(const CreatedbStmt *stmt) ...@@ -249,7 +260,8 @@ createdb(const CreatedbStmt *stmt)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT), (errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("%d is not a valid encoding code", errmsg("%d is not a valid encoding code",
encoding))); encoding),
parser_errposition(pstate, dencoding->location)));
} }
else else
{ {
...@@ -259,7 +271,8 @@ createdb(const CreatedbStmt *stmt) ...@@ -259,7 +271,8 @@ createdb(const CreatedbStmt *stmt)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT), (errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("%s is not a valid encoding name", errmsg("%s is not a valid encoding name",
encoding_name))); encoding_name),
parser_errposition(pstate, dencoding->location)));
} }
} }
if (dcollate && dcollate->arg) if (dcollate && dcollate->arg)
...@@ -1364,7 +1377,7 @@ movedb_failure_callback(int code, Datum arg) ...@@ -1364,7 +1377,7 @@ movedb_failure_callback(int code, Datum arg)
* ALTER DATABASE name ... * ALTER DATABASE name ...
*/ */
Oid Oid
AlterDatabase(AlterDatabaseStmt *stmt, bool isTopLevel) AlterDatabase(ParseState *pstate, AlterDatabaseStmt *stmt, bool isTopLevel)
{ {
Relation rel; Relation rel;
Oid dboid; Oid dboid;
...@@ -1394,7 +1407,8 @@ AlterDatabase(AlterDatabaseStmt *stmt, bool isTopLevel) ...@@ -1394,7 +1407,8 @@ AlterDatabase(AlterDatabaseStmt *stmt, bool isTopLevel)
if (distemplate) if (distemplate)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
distemplate = defel; distemplate = defel;
} }
else if (strcmp(defel->defname, "allow_connections") == 0) else if (strcmp(defel->defname, "allow_connections") == 0)
...@@ -1402,7 +1416,8 @@ AlterDatabase(AlterDatabaseStmt *stmt, bool isTopLevel) ...@@ -1402,7 +1416,8 @@ AlterDatabase(AlterDatabaseStmt *stmt, bool isTopLevel)
if (dallowconnections) if (dallowconnections)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dallowconnections = defel; dallowconnections = defel;
} }
else if (strcmp(defel->defname, "connection_limit") == 0) else if (strcmp(defel->defname, "connection_limit") == 0)
...@@ -1410,7 +1425,8 @@ AlterDatabase(AlterDatabaseStmt *stmt, bool isTopLevel) ...@@ -1410,7 +1425,8 @@ AlterDatabase(AlterDatabaseStmt *stmt, bool isTopLevel)
if (dconnlimit) if (dconnlimit)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dconnlimit = defel; dconnlimit = defel;
} }
else if (strcmp(defel->defname, "tablespace") == 0) else if (strcmp(defel->defname, "tablespace") == 0)
...@@ -1418,13 +1434,15 @@ AlterDatabase(AlterDatabaseStmt *stmt, bool isTopLevel) ...@@ -1418,13 +1434,15 @@ AlterDatabase(AlterDatabaseStmt *stmt, bool isTopLevel)
if (dtablespace) if (dtablespace)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dtablespace = defel; dtablespace = defel;
} }
else else
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("option \"%s\" not recognized", defel->defname))); errmsg("option \"%s\" not recognized", defel->defname),
parser_errposition(pstate, defel->location)));
} }
if (dtablespace) if (dtablespace)
...@@ -1438,7 +1456,8 @@ AlterDatabase(AlterDatabaseStmt *stmt, bool isTopLevel) ...@@ -1438,7 +1456,8 @@ AlterDatabase(AlterDatabaseStmt *stmt, bool isTopLevel)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("option \"%s\" cannot be specified with other options", errmsg("option \"%s\" cannot be specified with other options",
dtablespace->defname))); dtablespace->defname),
parser_errposition(pstate, dtablespace->location)));
/* this case isn't allowed within a transaction block */ /* this case isn't allowed within a transaction block */
PreventTransactionChain(isTopLevel, "ALTER DATABASE SET TABLESPACE"); PreventTransactionChain(isTopLevel, "ALTER DATABASE SET TABLESPACE");
movedb(stmt->dbname, defGetString(dtablespace)); movedb(stmt->dbname, defGetString(dtablespace));
......
...@@ -319,12 +319,3 @@ defGetTypeLength(DefElem *def) ...@@ -319,12 +319,3 @@ defGetTypeLength(DefElem *def)
def->defname, defGetString(def)))); def->defname, defGetString(def))));
return 0; /* keep compiler quiet */ return 0; /* keep compiler quiet */
} }
/*
* Create a DefElem setting "oids" to the specified value.
*/
DefElem *
defWithOids(bool value)
{
return makeDefElem("oids", (Node *) makeInteger(value));
}
...@@ -140,7 +140,7 @@ static void escape_yaml(StringInfo buf, const char *str); ...@@ -140,7 +140,7 @@ static void escape_yaml(StringInfo buf, const char *str);
* execute an EXPLAIN command * execute an EXPLAIN command
*/ */
void void
ExplainQuery(ExplainStmt *stmt, const char *queryString, ExplainQuery(ParseState *pstate, ExplainStmt *stmt, const char *queryString,
ParamListInfo params, DestReceiver *dest) ParamListInfo params, DestReceiver *dest)
{ {
ExplainState *es = NewExplainState(); ExplainState *es = NewExplainState();
...@@ -183,13 +183,15 @@ ExplainQuery(ExplainStmt *stmt, const char *queryString, ...@@ -183,13 +183,15 @@ ExplainQuery(ExplainStmt *stmt, const char *queryString,
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("unrecognized value for EXPLAIN option \"%s\": \"%s\"", errmsg("unrecognized value for EXPLAIN option \"%s\": \"%s\"",
opt->defname, p))); opt->defname, p),
parser_errposition(pstate, opt->location)));
} }
else else
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("unrecognized EXPLAIN option \"%s\"", errmsg("unrecognized EXPLAIN option \"%s\"",
opt->defname))); opt->defname),
parser_errposition(pstate, opt->location)));
} }
if (es->buffers && !es->analyze) if (es->buffers && !es->analyze)
......
...@@ -1175,7 +1175,7 @@ find_update_path(List *evi_list, ...@@ -1175,7 +1175,7 @@ find_update_path(List *evi_list,
* installed, allowing us to error out if we recurse to one of those. * installed, allowing us to error out if we recurse to one of those.
*/ */
static ObjectAddress static ObjectAddress
CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents) CreateExtensionInternal(ParseState *pstate, CreateExtensionStmt *stmt, List *parents)
{ {
DefElem *d_schema = NULL; DefElem *d_schema = NULL;
DefElem *d_new_version = NULL; DefElem *d_new_version = NULL;
...@@ -1215,7 +1215,8 @@ CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents) ...@@ -1215,7 +1215,8 @@ CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents)
if (d_schema) if (d_schema)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
d_schema = defel; d_schema = defel;
} }
else if (strcmp(defel->defname, "new_version") == 0) else if (strcmp(defel->defname, "new_version") == 0)
...@@ -1223,7 +1224,8 @@ CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents) ...@@ -1223,7 +1224,8 @@ CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents)
if (d_new_version) if (d_new_version)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
d_new_version = defel; d_new_version = defel;
} }
else if (strcmp(defel->defname, "old_version") == 0) else if (strcmp(defel->defname, "old_version") == 0)
...@@ -1231,7 +1233,8 @@ CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents) ...@@ -1231,7 +1233,8 @@ CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents)
if (d_old_version) if (d_old_version)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
d_old_version = defel; d_old_version = defel;
} }
else if (strcmp(defel->defname, "cascade") == 0) else if (strcmp(defel->defname, "cascade") == 0)
...@@ -1239,7 +1242,8 @@ CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents) ...@@ -1239,7 +1242,8 @@ CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents)
if (d_cascade) if (d_cascade)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
d_cascade = defel; d_cascade = defel;
cascade = defGetBoolean(d_cascade); cascade = defGetBoolean(d_cascade);
} }
...@@ -1458,7 +1462,7 @@ CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents) ...@@ -1458,7 +1462,7 @@ CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents)
lappend(list_copy(parents), stmt->extname); lappend(list_copy(parents), stmt->extname);
/* Create the required extension. */ /* Create the required extension. */
addr = CreateExtensionInternal(ces, cascade_parents); addr = CreateExtensionInternal(pstate, ces, cascade_parents);
/* Get its newly-assigned OID. */ /* Get its newly-assigned OID. */
reqext = addr.objectId; reqext = addr.objectId;
...@@ -1515,7 +1519,7 @@ CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents) ...@@ -1515,7 +1519,7 @@ CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents)
* CREATE EXTENSION * CREATE EXTENSION
*/ */
ObjectAddress ObjectAddress
CreateExtension(CreateExtensionStmt *stmt) CreateExtension(ParseState *pstate, CreateExtensionStmt *stmt)
{ {
/* Check extension name validity before any filesystem access */ /* Check extension name validity before any filesystem access */
check_valid_extension_name(stmt->extname); check_valid_extension_name(stmt->extname);
...@@ -1553,7 +1557,7 @@ CreateExtension(CreateExtensionStmt *stmt) ...@@ -1553,7 +1557,7 @@ CreateExtension(CreateExtensionStmt *stmt)
errmsg("nested CREATE EXTENSION is not supported"))); errmsg("nested CREATE EXTENSION is not supported")));
/* Finally create the extension. */ /* Finally create the extension. */
return CreateExtensionInternal(stmt, NIL); return CreateExtensionInternal(pstate, stmt, NIL);
} }
/* /*
...@@ -2671,7 +2675,7 @@ AlterExtensionNamespace(List *names, const char *newschema, Oid *oldschema) ...@@ -2671,7 +2675,7 @@ AlterExtensionNamespace(List *names, const char *newschema, Oid *oldschema)
* Execute ALTER EXTENSION UPDATE * Execute ALTER EXTENSION UPDATE
*/ */
ObjectAddress ObjectAddress
ExecAlterExtensionStmt(AlterExtensionStmt *stmt) ExecAlterExtensionStmt(ParseState *pstate, AlterExtensionStmt *stmt)
{ {
DefElem *d_new_version = NULL; DefElem *d_new_version = NULL;
char *versionName; char *versionName;
...@@ -2757,7 +2761,8 @@ ExecAlterExtensionStmt(AlterExtensionStmt *stmt) ...@@ -2757,7 +2761,8 @@ ExecAlterExtensionStmt(AlterExtensionStmt *stmt)
if (d_new_version) if (d_new_version)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
d_new_version = defel; d_new_version = defel;
} }
else else
......
...@@ -167,7 +167,6 @@ compute_return_type(TypeName *returnType, Oid languageOid, ...@@ -167,7 +167,6 @@ compute_return_type(TypeName *returnType, Oid languageOid,
* parameters: list of FunctionParameter structs * parameters: list of FunctionParameter structs
* languageOid: OID of function language (InvalidOid if it's CREATE AGGREGATE) * languageOid: OID of function language (InvalidOid if it's CREATE AGGREGATE)
* is_aggregate: needed only to determine error handling * is_aggregate: needed only to determine error handling
* queryString: likewise, needed only for error handling
* *
* Results are stored into output parameters. parameterTypes must always * Results are stored into output parameters. parameterTypes must always
* be created, but the other arrays are set to NULL if not needed. * be created, but the other arrays are set to NULL if not needed.
...@@ -177,10 +176,10 @@ compute_return_type(TypeName *returnType, Oid languageOid, ...@@ -177,10 +176,10 @@ compute_return_type(TypeName *returnType, Oid languageOid,
* else it is set to the OID of the implied result type. * else it is set to the OID of the implied result type.
*/ */
void void
interpret_function_parameter_list(List *parameters, interpret_function_parameter_list(ParseState *pstate,
List *parameters,
Oid languageOid, Oid languageOid,
bool is_aggregate, bool is_aggregate,
const char *queryString,
oidvector **parameterTypes, oidvector **parameterTypes,
ArrayType **allParameterTypes, ArrayType **allParameterTypes,
ArrayType **parameterModes, ArrayType **parameterModes,
...@@ -201,7 +200,6 @@ interpret_function_parameter_list(List *parameters, ...@@ -201,7 +200,6 @@ interpret_function_parameter_list(List *parameters,
bool have_defaults = false; bool have_defaults = false;
ListCell *x; ListCell *x;
int i; int i;
ParseState *pstate;
*variadicArgType = InvalidOid; /* default result */ *variadicArgType = InvalidOid; /* default result */
*requiredResultType = InvalidOid; /* default result */ *requiredResultType = InvalidOid; /* default result */
...@@ -212,10 +210,6 @@ interpret_function_parameter_list(List *parameters, ...@@ -212,10 +210,6 @@ interpret_function_parameter_list(List *parameters,
paramNames = (Datum *) palloc0(parameterCount * sizeof(Datum)); paramNames = (Datum *) palloc0(parameterCount * sizeof(Datum));
*parameterDefaults = NIL; *parameterDefaults = NIL;
/* may need a pstate for parse analysis of default exprs */
pstate = make_parsestate(NULL);
pstate->p_sourcetext = queryString;
/* Scan the list and extract data into work arrays */ /* Scan the list and extract data into work arrays */
i = 0; i = 0;
foreach(x, parameters) foreach(x, parameters)
...@@ -413,8 +407,6 @@ interpret_function_parameter_list(List *parameters, ...@@ -413,8 +407,6 @@ interpret_function_parameter_list(List *parameters,
i++; i++;
} }
free_parsestate(pstate);
/* Now construct the proper outputs as needed */ /* Now construct the proper outputs as needed */
*parameterTypes = buildoidvector(inTypes, inCount); *parameterTypes = buildoidvector(inTypes, inCount);
...@@ -458,7 +450,8 @@ interpret_function_parameter_list(List *parameters, ...@@ -458,7 +450,8 @@ interpret_function_parameter_list(List *parameters,
* SET parameters though --- if you're redundant, the last one wins.) * SET parameters though --- if you're redundant, the last one wins.)
*/ */
static bool static bool
compute_common_attribute(DefElem *defel, compute_common_attribute(ParseState *pstate,
DefElem *defel,
DefElem **volatility_item, DefElem **volatility_item,
DefElem **strict_item, DefElem **strict_item,
DefElem **security_item, DefElem **security_item,
...@@ -530,7 +523,8 @@ compute_common_attribute(DefElem *defel, ...@@ -530,7 +523,8 @@ compute_common_attribute(DefElem *defel,
duplicate_error: duplicate_error:
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
return false; /* keep compiler quiet */ return false; /* keep compiler quiet */
} }
...@@ -609,7 +603,8 @@ update_proconfig_value(ArrayType *a, List *set_items) ...@@ -609,7 +603,8 @@ update_proconfig_value(ArrayType *a, List *set_items)
* attributes. * attributes.
*/ */
static void static void
compute_attributes_sql_style(List *options, compute_attributes_sql_style(ParseState *pstate,
List *options,
List **as, List **as,
char **language, char **language,
Node **transform, Node **transform,
...@@ -646,7 +641,8 @@ compute_attributes_sql_style(List *options, ...@@ -646,7 +641,8 @@ compute_attributes_sql_style(List *options,
if (as_item) if (as_item)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
as_item = defel; as_item = defel;
} }
else if (strcmp(defel->defname, "language") == 0) else if (strcmp(defel->defname, "language") == 0)
...@@ -654,7 +650,8 @@ compute_attributes_sql_style(List *options, ...@@ -654,7 +650,8 @@ compute_attributes_sql_style(List *options,
if (language_item) if (language_item)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
language_item = defel; language_item = defel;
} }
else if (strcmp(defel->defname, "transform") == 0) else if (strcmp(defel->defname, "transform") == 0)
...@@ -662,7 +659,8 @@ compute_attributes_sql_style(List *options, ...@@ -662,7 +659,8 @@ compute_attributes_sql_style(List *options,
if (transform_item) if (transform_item)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
transform_item = defel; transform_item = defel;
} }
else if (strcmp(defel->defname, "window") == 0) else if (strcmp(defel->defname, "window") == 0)
...@@ -670,10 +668,12 @@ compute_attributes_sql_style(List *options, ...@@ -670,10 +668,12 @@ compute_attributes_sql_style(List *options,
if (windowfunc_item) if (windowfunc_item)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
windowfunc_item = defel; windowfunc_item = defel;
} }
else if (compute_common_attribute(defel, else if (compute_common_attribute(pstate,
defel,
&volatility_item, &volatility_item,
&strict_item, &strict_item,
&security_item, &security_item,
...@@ -763,7 +763,7 @@ compute_attributes_sql_style(List *options, ...@@ -763,7 +763,7 @@ compute_attributes_sql_style(List *options,
*------------ *------------
*/ */
static void static void
compute_attributes_with_style(List *parameters, bool *isStrict_p, char *volatility_p) compute_attributes_with_style(ParseState *pstate, List *parameters, bool *isStrict_p, char *volatility_p)
{ {
ListCell *pl; ListCell *pl;
...@@ -783,7 +783,8 @@ compute_attributes_with_style(List *parameters, bool *isStrict_p, char *volatili ...@@ -783,7 +783,8 @@ compute_attributes_with_style(List *parameters, bool *isStrict_p, char *volatili
ereport(WARNING, ereport(WARNING,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("unrecognized function attribute \"%s\" ignored", errmsg("unrecognized function attribute \"%s\" ignored",
param->defname))); param->defname),
parser_errposition(pstate, param->location)));
} }
} }
...@@ -858,7 +859,7 @@ interpret_AS_clause(Oid languageOid, const char *languageName, ...@@ -858,7 +859,7 @@ interpret_AS_clause(Oid languageOid, const char *languageName,
* Execute a CREATE FUNCTION utility statement. * Execute a CREATE FUNCTION utility statement.
*/ */
ObjectAddress ObjectAddress
CreateFunction(CreateFunctionStmt *stmt, const char *queryString) CreateFunction(ParseState *pstate, CreateFunctionStmt *stmt)
{ {
char *probin_str; char *probin_str;
char *prosrc_str; char *prosrc_str;
...@@ -915,7 +916,8 @@ CreateFunction(CreateFunctionStmt *stmt, const char *queryString) ...@@ -915,7 +916,8 @@ CreateFunction(CreateFunctionStmt *stmt, const char *queryString)
parallel = PROPARALLEL_UNSAFE; parallel = PROPARALLEL_UNSAFE;
/* override attributes from explicit list */ /* override attributes from explicit list */
compute_attributes_sql_style(stmt->options, compute_attributes_sql_style(pstate,
stmt->options,
&as_clause, &language, &transformDefElem, &as_clause, &language, &transformDefElem,
&isWindowFunc, &volatility, &isWindowFunc, &volatility,
&isStrict, &security, &isLeakProof, &isStrict, &security, &isLeakProof,
...@@ -987,10 +989,10 @@ CreateFunction(CreateFunctionStmt *stmt, const char *queryString) ...@@ -987,10 +989,10 @@ CreateFunction(CreateFunctionStmt *stmt, const char *queryString)
* Convert remaining parameters of CREATE to form wanted by * Convert remaining parameters of CREATE to form wanted by
* ProcedureCreate. * ProcedureCreate.
*/ */
interpret_function_parameter_list(stmt->parameters, interpret_function_parameter_list(pstate,
stmt->parameters,
languageOid, languageOid,
false, /* not an aggregate */ false, /* not an aggregate */
queryString,
&parameterTypes, &parameterTypes,
&allParameterTypes, &allParameterTypes,
&parameterModes, &parameterModes,
...@@ -1045,7 +1047,7 @@ CreateFunction(CreateFunctionStmt *stmt, const char *queryString) ...@@ -1045,7 +1047,7 @@ CreateFunction(CreateFunctionStmt *stmt, const char *queryString)
trftypes = NULL; trftypes = NULL;
} }
compute_attributes_with_style(stmt->withClause, &isStrict, &volatility); compute_attributes_with_style(pstate, stmt->withClause, &isStrict, &volatility);
interpret_AS_clause(languageOid, language, funcname, as_clause, interpret_AS_clause(languageOid, language, funcname, as_clause,
&prosrc_str, &probin_str); &prosrc_str, &probin_str);
...@@ -1163,7 +1165,7 @@ RemoveFunctionById(Oid funcOid) ...@@ -1163,7 +1165,7 @@ RemoveFunctionById(Oid funcOid)
* ALTER framework). * ALTER framework).
*/ */
ObjectAddress ObjectAddress
AlterFunction(AlterFunctionStmt *stmt) AlterFunction(ParseState *pstate, AlterFunctionStmt *stmt)
{ {
HeapTuple tup; HeapTuple tup;
Oid funcOid; Oid funcOid;
...@@ -1208,7 +1210,8 @@ AlterFunction(AlterFunctionStmt *stmt) ...@@ -1208,7 +1210,8 @@ AlterFunction(AlterFunctionStmt *stmt)
{ {
DefElem *defel = (DefElem *) lfirst(l); DefElem *defel = (DefElem *) lfirst(l);
if (compute_common_attribute(defel, if (compute_common_attribute(pstate,
defel,
&volatility_item, &volatility_item,
&strict_item, &strict_item,
&security_def_item, &security_def_item,
......
...@@ -94,7 +94,7 @@ static void create_seq_hashtable(void); ...@@ -94,7 +94,7 @@ static void create_seq_hashtable(void);
static void init_sequence(Oid relid, SeqTable *p_elm, Relation *p_rel); static void init_sequence(Oid relid, SeqTable *p_elm, Relation *p_rel);
static Form_pg_sequence read_seq_tuple(SeqTable elm, Relation rel, static Form_pg_sequence read_seq_tuple(SeqTable elm, Relation rel,
Buffer *buf, HeapTuple seqtuple); Buffer *buf, HeapTuple seqtuple);
static void init_params(List *options, bool isInit, static void init_params(ParseState *pstate, List *options, bool isInit,
Form_pg_sequence new, List **owned_by); Form_pg_sequence new, List **owned_by);
static void do_setval(Oid relid, int64 next, bool iscalled); static void do_setval(Oid relid, int64 next, bool iscalled);
static void process_owned_by(Relation seqrel, List *owned_by); static void process_owned_by(Relation seqrel, List *owned_by);
...@@ -105,7 +105,7 @@ static void process_owned_by(Relation seqrel, List *owned_by); ...@@ -105,7 +105,7 @@ static void process_owned_by(Relation seqrel, List *owned_by);
* Creates a new sequence relation * Creates a new sequence relation
*/ */
ObjectAddress ObjectAddress
DefineSequence(CreateSeqStmt *seq) DefineSequence(ParseState *pstate, CreateSeqStmt *seq)
{ {
FormData_pg_sequence new; FormData_pg_sequence new;
List *owned_by; List *owned_by;
...@@ -145,7 +145,7 @@ DefineSequence(CreateSeqStmt *seq) ...@@ -145,7 +145,7 @@ DefineSequence(CreateSeqStmt *seq)
} }
/* Check and set all option values */ /* Check and set all option values */
init_params(seq->options, true, &new, &owned_by); init_params(pstate, seq->options, true, &new, &owned_by);
/* /*
* Create relation (and fill value[] and null[] for the tuple) * Create relation (and fill value[] and null[] for the tuple)
...@@ -404,7 +404,7 @@ fill_seq_with_data(Relation rel, HeapTuple tuple) ...@@ -404,7 +404,7 @@ fill_seq_with_data(Relation rel, HeapTuple tuple)
* Modify the definition of a sequence relation * Modify the definition of a sequence relation
*/ */
ObjectAddress ObjectAddress
AlterSequence(AlterSeqStmt *stmt) AlterSequence(ParseState *pstate, AlterSeqStmt *stmt)
{ {
Oid relid; Oid relid;
SeqTable elm; SeqTable elm;
...@@ -440,7 +440,7 @@ AlterSequence(AlterSeqStmt *stmt) ...@@ -440,7 +440,7 @@ AlterSequence(AlterSeqStmt *stmt)
memcpy(&new, seq, sizeof(FormData_pg_sequence)); memcpy(&new, seq, sizeof(FormData_pg_sequence));
/* Check and set new values */ /* Check and set new values */
init_params(stmt->options, false, &new, &owned_by); init_params(pstate, stmt->options, false, &new, &owned_by);
/* Clear local cache so that we don't think we have cached numbers */ /* Clear local cache so that we don't think we have cached numbers */
/* Note that we do not change the currval() state */ /* Note that we do not change the currval() state */
...@@ -1163,7 +1163,7 @@ read_seq_tuple(SeqTable elm, Relation rel, Buffer *buf, HeapTuple seqtuple) ...@@ -1163,7 +1163,7 @@ read_seq_tuple(SeqTable elm, Relation rel, Buffer *buf, HeapTuple seqtuple)
* otherwise, do not change existing options that aren't explicitly overridden. * otherwise, do not change existing options that aren't explicitly overridden.
*/ */
static void static void
init_params(List *options, bool isInit, init_params(ParseState *pstate, List *options, bool isInit,
Form_pg_sequence new, List **owned_by) Form_pg_sequence new, List **owned_by)
{ {
DefElem *start_value = NULL; DefElem *start_value = NULL;
...@@ -1186,7 +1186,8 @@ init_params(List *options, bool isInit, ...@@ -1186,7 +1186,8 @@ init_params(List *options, bool isInit,
if (increment_by) if (increment_by)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
increment_by = defel; increment_by = defel;
} }
else if (strcmp(defel->defname, "start") == 0) else if (strcmp(defel->defname, "start") == 0)
...@@ -1194,7 +1195,8 @@ init_params(List *options, bool isInit, ...@@ -1194,7 +1195,8 @@ init_params(List *options, bool isInit,
if (start_value) if (start_value)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
start_value = defel; start_value = defel;
} }
else if (strcmp(defel->defname, "restart") == 0) else if (strcmp(defel->defname, "restart") == 0)
...@@ -1202,7 +1204,8 @@ init_params(List *options, bool isInit, ...@@ -1202,7 +1204,8 @@ init_params(List *options, bool isInit,
if (restart_value) if (restart_value)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
restart_value = defel; restart_value = defel;
} }
else if (strcmp(defel->defname, "maxvalue") == 0) else if (strcmp(defel->defname, "maxvalue") == 0)
...@@ -1210,7 +1213,8 @@ init_params(List *options, bool isInit, ...@@ -1210,7 +1213,8 @@ init_params(List *options, bool isInit,
if (max_value) if (max_value)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
max_value = defel; max_value = defel;
} }
else if (strcmp(defel->defname, "minvalue") == 0) else if (strcmp(defel->defname, "minvalue") == 0)
...@@ -1218,7 +1222,8 @@ init_params(List *options, bool isInit, ...@@ -1218,7 +1222,8 @@ init_params(List *options, bool isInit,
if (min_value) if (min_value)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
min_value = defel; min_value = defel;
} }
else if (strcmp(defel->defname, "cache") == 0) else if (strcmp(defel->defname, "cache") == 0)
...@@ -1226,7 +1231,8 @@ init_params(List *options, bool isInit, ...@@ -1226,7 +1231,8 @@ init_params(List *options, bool isInit,
if (cache_value) if (cache_value)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
cache_value = defel; cache_value = defel;
} }
else if (strcmp(defel->defname, "cycle") == 0) else if (strcmp(defel->defname, "cycle") == 0)
...@@ -1234,7 +1240,8 @@ init_params(List *options, bool isInit, ...@@ -1234,7 +1240,8 @@ init_params(List *options, bool isInit,
if (is_cycled) if (is_cycled)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
is_cycled = defel; is_cycled = defel;
} }
else if (strcmp(defel->defname, "owned_by") == 0) else if (strcmp(defel->defname, "owned_by") == 0)
...@@ -1242,7 +1249,8 @@ init_params(List *options, bool isInit, ...@@ -1242,7 +1249,8 @@ init_params(List *options, bool isInit,
if (*owned_by) if (*owned_by)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
*owned_by = defGetQualifiedName(defel); *owned_by = defGetQualifiedName(defel);
} }
else else
......
...@@ -1700,7 +1700,7 @@ deserialize_deflist(Datum txt) ...@@ -1700,7 +1700,7 @@ deserialize_deflist(Datum txt)
*wsptr++ = '\0'; *wsptr++ = '\0';
result = lappend(result, result = lappend(result,
makeDefElem(pstrdup(workspace), makeDefElem(pstrdup(workspace),
(Node *) makeString(pstrdup(startvalue)))); (Node *) makeString(pstrdup(startvalue)), -1));
state = CS_WAITKEY; state = CS_WAITKEY;
} }
} }
...@@ -1732,7 +1732,7 @@ deserialize_deflist(Datum txt) ...@@ -1732,7 +1732,7 @@ deserialize_deflist(Datum txt)
*wsptr++ = '\0'; *wsptr++ = '\0';
result = lappend(result, result = lappend(result,
makeDefElem(pstrdup(workspace), makeDefElem(pstrdup(workspace),
(Node *) makeString(pstrdup(startvalue)))); (Node *) makeString(pstrdup(startvalue)), -1));
state = CS_WAITKEY; state = CS_WAITKEY;
} }
} }
...@@ -1747,7 +1747,7 @@ deserialize_deflist(Datum txt) ...@@ -1747,7 +1747,7 @@ deserialize_deflist(Datum txt)
*wsptr++ = '\0'; *wsptr++ = '\0';
result = lappend(result, result = lappend(result,
makeDefElem(pstrdup(workspace), makeDefElem(pstrdup(workspace),
(Node *) makeString(pstrdup(startvalue)))); (Node *) makeString(pstrdup(startvalue)), -1));
state = CS_WAITKEY; state = CS_WAITKEY;
} }
else else
...@@ -1766,7 +1766,7 @@ deserialize_deflist(Datum txt) ...@@ -1766,7 +1766,7 @@ deserialize_deflist(Datum txt)
*wsptr++ = '\0'; *wsptr++ = '\0';
result = lappend(result, result = lappend(result,
makeDefElem(pstrdup(workspace), makeDefElem(pstrdup(workspace),
(Node *) makeString(pstrdup(startvalue)))); (Node *) makeString(pstrdup(startvalue)), -1));
} }
else if (state != CS_WAITKEY) else if (state != CS_WAITKEY)
ereport(ERROR, ereport(ERROR,
......
...@@ -111,7 +111,7 @@ static char *domainAddConstraint(Oid domainOid, Oid domainNamespace, ...@@ -111,7 +111,7 @@ static char *domainAddConstraint(Oid domainOid, Oid domainNamespace,
* Registers a new base type. * Registers a new base type.
*/ */
ObjectAddress ObjectAddress
DefineType(List *names, List *parameters) DefineType(ParseState *pstate, List *names, List *parameters)
{ {
char *typeName; char *typeName;
Oid typeNamespace; Oid typeNamespace;
...@@ -286,13 +286,15 @@ DefineType(List *names, List *parameters) ...@@ -286,13 +286,15 @@ DefineType(List *names, List *parameters)
ereport(WARNING, ereport(WARNING,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("type attribute \"%s\" not recognized", errmsg("type attribute \"%s\" not recognized",
defel->defname))); defel->defname),
parser_errposition(pstate, defel->location)));
continue; continue;
} }
if (*defelp != NULL) if (*defelp != NULL)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
*defelp = defel; *defelp = defel;
} }
......
...@@ -69,7 +69,7 @@ have_createrole_privilege(void) ...@@ -69,7 +69,7 @@ have_createrole_privilege(void)
* CREATE ROLE * CREATE ROLE
*/ */
Oid Oid
CreateRole(CreateRoleStmt *stmt) CreateRole(ParseState *pstate, CreateRoleStmt *stmt)
{ {
Relation pg_authid_rel; Relation pg_authid_rel;
TupleDesc pg_authid_dsc; TupleDesc pg_authid_dsc;
...@@ -136,7 +136,8 @@ CreateRole(CreateRoleStmt *stmt) ...@@ -136,7 +136,8 @@ CreateRole(CreateRoleStmt *stmt)
if (dpassword) if (dpassword)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dpassword = defel; dpassword = defel;
if (strcmp(defel->defname, "encryptedPassword") == 0) if (strcmp(defel->defname, "encryptedPassword") == 0)
encrypt_password = true; encrypt_password = true;
...@@ -153,7 +154,8 @@ CreateRole(CreateRoleStmt *stmt) ...@@ -153,7 +154,8 @@ CreateRole(CreateRoleStmt *stmt)
if (dissuper) if (dissuper)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dissuper = defel; dissuper = defel;
} }
else if (strcmp(defel->defname, "inherit") == 0) else if (strcmp(defel->defname, "inherit") == 0)
...@@ -161,7 +163,8 @@ CreateRole(CreateRoleStmt *stmt) ...@@ -161,7 +163,8 @@ CreateRole(CreateRoleStmt *stmt)
if (dinherit) if (dinherit)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dinherit = defel; dinherit = defel;
} }
else if (strcmp(defel->defname, "createrole") == 0) else if (strcmp(defel->defname, "createrole") == 0)
...@@ -169,7 +172,8 @@ CreateRole(CreateRoleStmt *stmt) ...@@ -169,7 +172,8 @@ CreateRole(CreateRoleStmt *stmt)
if (dcreaterole) if (dcreaterole)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dcreaterole = defel; dcreaterole = defel;
} }
else if (strcmp(defel->defname, "createdb") == 0) else if (strcmp(defel->defname, "createdb") == 0)
...@@ -177,7 +181,8 @@ CreateRole(CreateRoleStmt *stmt) ...@@ -177,7 +181,8 @@ CreateRole(CreateRoleStmt *stmt)
if (dcreatedb) if (dcreatedb)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dcreatedb = defel; dcreatedb = defel;
} }
else if (strcmp(defel->defname, "canlogin") == 0) else if (strcmp(defel->defname, "canlogin") == 0)
...@@ -185,7 +190,8 @@ CreateRole(CreateRoleStmt *stmt) ...@@ -185,7 +190,8 @@ CreateRole(CreateRoleStmt *stmt)
if (dcanlogin) if (dcanlogin)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dcanlogin = defel; dcanlogin = defel;
} }
else if (strcmp(defel->defname, "isreplication") == 0) else if (strcmp(defel->defname, "isreplication") == 0)
...@@ -193,7 +199,8 @@ CreateRole(CreateRoleStmt *stmt) ...@@ -193,7 +199,8 @@ CreateRole(CreateRoleStmt *stmt)
if (disreplication) if (disreplication)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
disreplication = defel; disreplication = defel;
} }
else if (strcmp(defel->defname, "connectionlimit") == 0) else if (strcmp(defel->defname, "connectionlimit") == 0)
...@@ -201,7 +208,8 @@ CreateRole(CreateRoleStmt *stmt) ...@@ -201,7 +208,8 @@ CreateRole(CreateRoleStmt *stmt)
if (dconnlimit) if (dconnlimit)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dconnlimit = defel; dconnlimit = defel;
} }
else if (strcmp(defel->defname, "addroleto") == 0) else if (strcmp(defel->defname, "addroleto") == 0)
...@@ -209,7 +217,8 @@ CreateRole(CreateRoleStmt *stmt) ...@@ -209,7 +217,8 @@ CreateRole(CreateRoleStmt *stmt)
if (daddroleto) if (daddroleto)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
daddroleto = defel; daddroleto = defel;
} }
else if (strcmp(defel->defname, "rolemembers") == 0) else if (strcmp(defel->defname, "rolemembers") == 0)
...@@ -217,7 +226,8 @@ CreateRole(CreateRoleStmt *stmt) ...@@ -217,7 +226,8 @@ CreateRole(CreateRoleStmt *stmt)
if (drolemembers) if (drolemembers)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
drolemembers = defel; drolemembers = defel;
} }
else if (strcmp(defel->defname, "adminmembers") == 0) else if (strcmp(defel->defname, "adminmembers") == 0)
...@@ -225,7 +235,8 @@ CreateRole(CreateRoleStmt *stmt) ...@@ -225,7 +235,8 @@ CreateRole(CreateRoleStmt *stmt)
if (dadminmembers) if (dadminmembers)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dadminmembers = defel; dadminmembers = defel;
} }
else if (strcmp(defel->defname, "validUntil") == 0) else if (strcmp(defel->defname, "validUntil") == 0)
...@@ -233,7 +244,8 @@ CreateRole(CreateRoleStmt *stmt) ...@@ -233,7 +244,8 @@ CreateRole(CreateRoleStmt *stmt)
if (dvalidUntil) if (dvalidUntil)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dvalidUntil = defel; dvalidUntil = defel;
} }
else if (strcmp(defel->defname, "bypassrls") == 0) else if (strcmp(defel->defname, "bypassrls") == 0)
...@@ -241,7 +253,8 @@ CreateRole(CreateRoleStmt *stmt) ...@@ -241,7 +253,8 @@ CreateRole(CreateRoleStmt *stmt)
if (dbypassRLS) if (dbypassRLS)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"))); errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dbypassRLS = defel; dbypassRLS = defel;
} }
else else
......
...@@ -434,11 +434,11 @@ DefineView(ViewStmt *stmt, const char *queryString) ...@@ -434,11 +434,11 @@ DefineView(ViewStmt *stmt, const char *queryString)
if (stmt->withCheckOption == LOCAL_CHECK_OPTION) if (stmt->withCheckOption == LOCAL_CHECK_OPTION)
stmt->options = lappend(stmt->options, stmt->options = lappend(stmt->options,
makeDefElem("check_option", makeDefElem("check_option",
(Node *) makeString("local"))); (Node *) makeString("local"), -1));
else if (stmt->withCheckOption == CASCADED_CHECK_OPTION) else if (stmt->withCheckOption == CASCADED_CHECK_OPTION)
stmt->options = lappend(stmt->options, stmt->options = lappend(stmt->options,
makeDefElem("check_option", makeDefElem("check_option",
(Node *) makeString("cascaded"))); (Node *) makeString("cascaded"), -1));
/* /*
* Check that the view is auto-updatable if WITH CHECK OPTION was * Check that the view is auto-updatable if WITH CHECK OPTION was
......
...@@ -2676,6 +2676,7 @@ _copyDefElem(const DefElem *from) ...@@ -2676,6 +2676,7 @@ _copyDefElem(const DefElem *from)
COPY_STRING_FIELD(defname); COPY_STRING_FIELD(defname);
COPY_NODE_FIELD(arg); COPY_NODE_FIELD(arg);
COPY_SCALAR_FIELD(defaction); COPY_SCALAR_FIELD(defaction);
COPY_LOCATION_FIELD(location);
return newnode; return newnode;
} }
......
...@@ -2424,6 +2424,7 @@ _equalDefElem(const DefElem *a, const DefElem *b) ...@@ -2424,6 +2424,7 @@ _equalDefElem(const DefElem *a, const DefElem *b)
COMPARE_STRING_FIELD(defname); COMPARE_STRING_FIELD(defname);
COMPARE_NODE_FIELD(arg); COMPARE_NODE_FIELD(arg);
COMPARE_SCALAR_FIELD(defaction); COMPARE_SCALAR_FIELD(defaction);
COMPARE_LOCATION_FIELD(location);
return true; return true;
} }
...@@ -2434,6 +2435,7 @@ _equalLockingClause(const LockingClause *a, const LockingClause *b) ...@@ -2434,6 +2435,7 @@ _equalLockingClause(const LockingClause *a, const LockingClause *b)
COMPARE_NODE_FIELD(lockedRels); COMPARE_NODE_FIELD(lockedRels);
COMPARE_SCALAR_FIELD(strength); COMPARE_SCALAR_FIELD(strength);
COMPARE_SCALAR_FIELD(waitPolicy); COMPARE_SCALAR_FIELD(waitPolicy);
COMPARE_LOCATION_FIELD(location);
return true; return true;
} }
......
...@@ -540,7 +540,7 @@ makeFuncExpr(Oid funcid, Oid rettype, List *args, ...@@ -540,7 +540,7 @@ makeFuncExpr(Oid funcid, Oid rettype, List *args,
* and no special action. * and no special action.
*/ */
DefElem * DefElem *
makeDefElem(char *name, Node *arg) makeDefElem(char *name, Node *arg, int location)
{ {
DefElem *res = makeNode(DefElem); DefElem *res = makeNode(DefElem);
...@@ -548,6 +548,7 @@ makeDefElem(char *name, Node *arg) ...@@ -548,6 +548,7 @@ makeDefElem(char *name, Node *arg)
res->defname = name; res->defname = name;
res->arg = arg; res->arg = arg;
res->defaction = DEFELEM_UNSPEC; res->defaction = DEFELEM_UNSPEC;
res->location = location;
return res; return res;
} }
...@@ -558,7 +559,7 @@ makeDefElem(char *name, Node *arg) ...@@ -558,7 +559,7 @@ makeDefElem(char *name, Node *arg)
*/ */
DefElem * DefElem *
makeDefElemExtended(char *nameSpace, char *name, Node *arg, makeDefElemExtended(char *nameSpace, char *name, Node *arg,
DefElemAction defaction) DefElemAction defaction, int location)
{ {
DefElem *res = makeNode(DefElem); DefElem *res = makeNode(DefElem);
...@@ -566,6 +567,7 @@ makeDefElemExtended(char *nameSpace, char *name, Node *arg, ...@@ -566,6 +567,7 @@ makeDefElemExtended(char *nameSpace, char *name, Node *arg,
res->defname = name; res->defname = name;
res->arg = arg; res->arg = arg;
res->defaction = defaction; res->defaction = defaction;
res->location = location;
return res; return res;
} }
......
...@@ -2542,6 +2542,7 @@ _outDefElem(StringInfo str, const DefElem *node) ...@@ -2542,6 +2542,7 @@ _outDefElem(StringInfo str, const DefElem *node)
WRITE_STRING_FIELD(defname); WRITE_STRING_FIELD(defname);
WRITE_NODE_FIELD(arg); WRITE_NODE_FIELD(arg);
WRITE_ENUM_FIELD(defaction, DefElemAction); WRITE_ENUM_FIELD(defaction, DefElemAction);
WRITE_LOCATION_FIELD(location);
} }
static void static void
......
...@@ -1388,6 +1388,7 @@ _readDefElem(void) ...@@ -1388,6 +1388,7 @@ _readDefElem(void)
READ_STRING_FIELD(defname); READ_STRING_FIELD(defname);
READ_NODE_FIELD(arg); READ_NODE_FIELD(arg);
READ_ENUM_FIELD(defaction, DefElemAction); READ_ENUM_FIELD(defaction, DefElemAction);
READ_LOCATION_FIELD(location);
READ_DONE(); READ_DONE();
} }
......
...@@ -928,38 +928,38 @@ AlterOptRoleElem: ...@@ -928,38 +928,38 @@ AlterOptRoleElem:
PASSWORD Sconst PASSWORD Sconst
{ {
$$ = makeDefElem("password", $$ = makeDefElem("password",
(Node *)makeString($2)); (Node *)makeString($2), @1);
} }
| PASSWORD NULL_P | PASSWORD NULL_P
{ {
$$ = makeDefElem("password", NULL); $$ = makeDefElem("password", NULL, @1);
} }
| ENCRYPTED PASSWORD Sconst | ENCRYPTED PASSWORD Sconst
{ {
$$ = makeDefElem("encryptedPassword", $$ = makeDefElem("encryptedPassword",
(Node *)makeString($3)); (Node *)makeString($3), @1);
} }
| UNENCRYPTED PASSWORD Sconst | UNENCRYPTED PASSWORD Sconst
{ {
$$ = makeDefElem("unencryptedPassword", $$ = makeDefElem("unencryptedPassword",
(Node *)makeString($3)); (Node *)makeString($3), @1);
} }
| INHERIT | INHERIT
{ {
$$ = makeDefElem("inherit", (Node *)makeInteger(TRUE)); $$ = makeDefElem("inherit", (Node *)makeInteger(TRUE), @1);
} }
| CONNECTION LIMIT SignedIconst | CONNECTION LIMIT SignedIconst
{ {
$$ = makeDefElem("connectionlimit", (Node *)makeInteger($3)); $$ = makeDefElem("connectionlimit", (Node *)makeInteger($3), @1);
} }
| VALID UNTIL Sconst | VALID UNTIL Sconst
{ {
$$ = makeDefElem("validUntil", (Node *)makeString($3)); $$ = makeDefElem("validUntil", (Node *)makeString($3), @1);
} }
/* Supported but not documented for roles, for use by ALTER GROUP. */ /* Supported but not documented for roles, for use by ALTER GROUP. */
| USER role_list | USER role_list
{ {
$$ = makeDefElem("rolemembers", (Node *)$2); $$ = makeDefElem("rolemembers", (Node *)$2, @1);
} }
| IDENT | IDENT
{ {
...@@ -969,36 +969,36 @@ AlterOptRoleElem: ...@@ -969,36 +969,36 @@ AlterOptRoleElem:
* size of the main parser. * size of the main parser.
*/ */
if (strcmp($1, "superuser") == 0) if (strcmp($1, "superuser") == 0)
$$ = makeDefElem("superuser", (Node *)makeInteger(TRUE)); $$ = makeDefElem("superuser", (Node *)makeInteger(TRUE), @1);
else if (strcmp($1, "nosuperuser") == 0) else if (strcmp($1, "nosuperuser") == 0)
$$ = makeDefElem("superuser", (Node *)makeInteger(FALSE)); $$ = makeDefElem("superuser", (Node *)makeInteger(FALSE), @1);
else if (strcmp($1, "createrole") == 0) else if (strcmp($1, "createrole") == 0)
$$ = makeDefElem("createrole", (Node *)makeInteger(TRUE)); $$ = makeDefElem("createrole", (Node *)makeInteger(TRUE), @1);
else if (strcmp($1, "nocreaterole") == 0) else if (strcmp($1, "nocreaterole") == 0)
$$ = makeDefElem("createrole", (Node *)makeInteger(FALSE)); $$ = makeDefElem("createrole", (Node *)makeInteger(FALSE), @1);
else if (strcmp($1, "replication") == 0) else if (strcmp($1, "replication") == 0)
$$ = makeDefElem("isreplication", (Node *)makeInteger(TRUE)); $$ = makeDefElem("isreplication", (Node *)makeInteger(TRUE), @1);
else if (strcmp($1, "noreplication") == 0) else if (strcmp($1, "noreplication") == 0)
$$ = makeDefElem("isreplication", (Node *)makeInteger(FALSE)); $$ = makeDefElem("isreplication", (Node *)makeInteger(FALSE), @1);
else if (strcmp($1, "createdb") == 0) else if (strcmp($1, "createdb") == 0)
$$ = makeDefElem("createdb", (Node *)makeInteger(TRUE)); $$ = makeDefElem("createdb", (Node *)makeInteger(TRUE), @1);
else if (strcmp($1, "nocreatedb") == 0) else if (strcmp($1, "nocreatedb") == 0)
$$ = makeDefElem("createdb", (Node *)makeInteger(FALSE)); $$ = makeDefElem("createdb", (Node *)makeInteger(FALSE), @1);
else if (strcmp($1, "login") == 0) else if (strcmp($1, "login") == 0)
$$ = makeDefElem("canlogin", (Node *)makeInteger(TRUE)); $$ = makeDefElem("canlogin", (Node *)makeInteger(TRUE), @1);
else if (strcmp($1, "nologin") == 0) else if (strcmp($1, "nologin") == 0)
$$ = makeDefElem("canlogin", (Node *)makeInteger(FALSE)); $$ = makeDefElem("canlogin", (Node *)makeInteger(FALSE), @1);
else if (strcmp($1, "bypassrls") == 0) else if (strcmp($1, "bypassrls") == 0)
$$ = makeDefElem("bypassrls", (Node *)makeInteger(TRUE)); $$ = makeDefElem("bypassrls", (Node *)makeInteger(TRUE), @1);
else if (strcmp($1, "nobypassrls") == 0) else if (strcmp($1, "nobypassrls") == 0)
$$ = makeDefElem("bypassrls", (Node *)makeInteger(FALSE)); $$ = makeDefElem("bypassrls", (Node *)makeInteger(FALSE), @1);
else if (strcmp($1, "noinherit") == 0) else if (strcmp($1, "noinherit") == 0)
{ {
/* /*
* Note that INHERIT is a keyword, so it's handled by main parser, but * Note that INHERIT is a keyword, so it's handled by main parser, but
* NOINHERIT is handled here. * NOINHERIT is handled here.
*/ */
$$ = makeDefElem("inherit", (Node *)makeInteger(FALSE)); $$ = makeDefElem("inherit", (Node *)makeInteger(FALSE), @1);
} }
else else
ereport(ERROR, ereport(ERROR,
...@@ -1013,23 +1013,23 @@ CreateOptRoleElem: ...@@ -1013,23 +1013,23 @@ CreateOptRoleElem:
/* The following are not supported by ALTER ROLE/USER/GROUP */ /* The following are not supported by ALTER ROLE/USER/GROUP */
| SYSID Iconst | SYSID Iconst
{ {
$$ = makeDefElem("sysid", (Node *)makeInteger($2)); $$ = makeDefElem("sysid", (Node *)makeInteger($2), @1);
} }
| ADMIN role_list | ADMIN role_list
{ {
$$ = makeDefElem("adminmembers", (Node *)$2); $$ = makeDefElem("adminmembers", (Node *)$2, @1);
} }
| ROLE role_list | ROLE role_list
{ {
$$ = makeDefElem("rolemembers", (Node *)$2); $$ = makeDefElem("rolemembers", (Node *)$2, @1);
} }
| IN_P ROLE role_list | IN_P ROLE role_list
{ {
$$ = makeDefElem("addroleto", (Node *)$3); $$ = makeDefElem("addroleto", (Node *)$3, @1);
} }
| IN_P GROUP_P role_list | IN_P GROUP_P role_list
{ {
$$ = makeDefElem("addroleto", (Node *)$3); $$ = makeDefElem("addroleto", (Node *)$3, @1);
} }
; ;
...@@ -1206,7 +1206,7 @@ AlterGroupStmt: ...@@ -1206,7 +1206,7 @@ AlterGroupStmt:
n->role = $3; n->role = $3;
n->action = $4; n->action = $4;
n->options = list_make1(makeDefElem("rolemembers", n->options = list_make1(makeDefElem("rolemembers",
(Node *)$6)); (Node *)$6, @6));
$$ = (Node *)n; $$ = (Node *)n;
} }
; ;
...@@ -2446,20 +2446,20 @@ reloption_list: ...@@ -2446,20 +2446,20 @@ reloption_list:
reloption_elem: reloption_elem:
ColLabel '=' def_arg ColLabel '=' def_arg
{ {
$$ = makeDefElem($1, (Node *) $3); $$ = makeDefElem($1, (Node *) $3, @1);
} }
| ColLabel | ColLabel
{ {
$$ = makeDefElem($1, NULL); $$ = makeDefElem($1, NULL, @1);
} }
| ColLabel '.' ColLabel '=' def_arg | ColLabel '.' ColLabel '=' def_arg
{ {
$$ = makeDefElemExtended($1, $3, (Node *) $5, $$ = makeDefElemExtended($1, $3, (Node *) $5,
DEFELEM_UNSPEC); DEFELEM_UNSPEC, @1);
} }
| ColLabel '.' ColLabel | ColLabel '.' ColLabel
{ {
$$ = makeDefElemExtended($1, $3, NULL, DEFELEM_UNSPEC); $$ = makeDefElemExtended($1, $3, NULL, DEFELEM_UNSPEC, @1);
} }
; ;
...@@ -2669,59 +2669,59 @@ copy_opt_list: ...@@ -2669,59 +2669,59 @@ copy_opt_list:
copy_opt_item: copy_opt_item:
BINARY BINARY
{ {
$$ = makeDefElem("format", (Node *)makeString("binary")); $$ = makeDefElem("format", (Node *)makeString("binary"), @1);
} }
| OIDS | OIDS
{ {
$$ = makeDefElem("oids", (Node *)makeInteger(TRUE)); $$ = makeDefElem("oids", (Node *)makeInteger(TRUE), @1);
} }
| FREEZE | FREEZE
{ {
$$ = makeDefElem("freeze", (Node *)makeInteger(TRUE)); $$ = makeDefElem("freeze", (Node *)makeInteger(TRUE), @1);
} }
| DELIMITER opt_as Sconst | DELIMITER opt_as Sconst
{ {
$$ = makeDefElem("delimiter", (Node *)makeString($3)); $$ = makeDefElem("delimiter", (Node *)makeString($3), @1);
} }
| NULL_P opt_as Sconst | NULL_P opt_as Sconst
{ {
$$ = makeDefElem("null", (Node *)makeString($3)); $$ = makeDefElem("null", (Node *)makeString($3), @1);
} }
| CSV | CSV
{ {
$$ = makeDefElem("format", (Node *)makeString("csv")); $$ = makeDefElem("format", (Node *)makeString("csv"), @1);
} }
| HEADER_P | HEADER_P
{ {
$$ = makeDefElem("header", (Node *)makeInteger(TRUE)); $$ = makeDefElem("header", (Node *)makeInteger(TRUE), @1);
} }
| QUOTE opt_as Sconst | QUOTE opt_as Sconst
{ {
$$ = makeDefElem("quote", (Node *)makeString($3)); $$ = makeDefElem("quote", (Node *)makeString($3), @1);
} }
| ESCAPE opt_as Sconst | ESCAPE opt_as Sconst
{ {
$$ = makeDefElem("escape", (Node *)makeString($3)); $$ = makeDefElem("escape", (Node *)makeString($3), @1);
} }
| FORCE QUOTE columnList | FORCE QUOTE columnList
{ {
$$ = makeDefElem("force_quote", (Node *)$3); $$ = makeDefElem("force_quote", (Node *)$3, @1);
} }
| FORCE QUOTE '*' | FORCE QUOTE '*'
{ {
$$ = makeDefElem("force_quote", (Node *)makeNode(A_Star)); $$ = makeDefElem("force_quote", (Node *)makeNode(A_Star), @1);
} }
| FORCE NOT NULL_P columnList | FORCE NOT NULL_P columnList
{ {
$$ = makeDefElem("force_not_null", (Node *)$4); $$ = makeDefElem("force_not_null", (Node *)$4, @1);
} }
| FORCE NULL_P columnList | FORCE NULL_P columnList
{ {
$$ = makeDefElem("force_null", (Node *)$3); $$ = makeDefElem("force_null", (Node *)$3, @1);
} }
| ENCODING Sconst | ENCODING Sconst
{ {
$$ = makeDefElem("encoding", (Node *)makeString($2)); $$ = makeDefElem("encoding", (Node *)makeString($2), @1);
} }
; ;
...@@ -2730,7 +2730,7 @@ copy_opt_item: ...@@ -2730,7 +2730,7 @@ copy_opt_item:
opt_binary: opt_binary:
BINARY BINARY
{ {
$$ = makeDefElem("format", (Node *)makeString("binary")); $$ = makeDefElem("format", (Node *)makeString("binary"), @1);
} }
| /*EMPTY*/ { $$ = NULL; } | /*EMPTY*/ { $$ = NULL; }
; ;
...@@ -2738,7 +2738,7 @@ opt_binary: ...@@ -2738,7 +2738,7 @@ opt_binary:
opt_oids: opt_oids:
WITH OIDS WITH OIDS
{ {
$$ = makeDefElem("oids", (Node *)makeInteger(TRUE)); $$ = makeDefElem("oids", (Node *)makeInteger(TRUE), @1);
} }
| /*EMPTY*/ { $$ = NULL; } | /*EMPTY*/ { $$ = NULL; }
; ;
...@@ -2746,7 +2746,7 @@ opt_oids: ...@@ -2746,7 +2746,7 @@ opt_oids:
copy_delimiter: copy_delimiter:
opt_using DELIMITERS Sconst opt_using DELIMITERS Sconst
{ {
$$ = makeDefElem("delimiter", (Node *)makeString($3)); $$ = makeDefElem("delimiter", (Node *)makeString($3), @2);
} }
| /*EMPTY*/ { $$ = NULL; } | /*EMPTY*/ { $$ = NULL; }
; ;
...@@ -2771,7 +2771,7 @@ copy_generic_opt_list: ...@@ -2771,7 +2771,7 @@ copy_generic_opt_list:
copy_generic_opt_elem: copy_generic_opt_elem:
ColLabel copy_generic_opt_arg ColLabel copy_generic_opt_arg
{ {
$$ = makeDefElem($1, $2); $$ = makeDefElem($1, $2, @1);
} }
; ;
...@@ -3418,8 +3418,8 @@ OptInherit: INHERITS '(' qualified_name_list ')' { $$ = $3; } ...@@ -3418,8 +3418,8 @@ OptInherit: INHERITS '(' qualified_name_list ')' { $$ = $3; }
/* WITH (options) is preferred, WITH OIDS and WITHOUT OIDS are legacy forms */ /* WITH (options) is preferred, WITH OIDS and WITHOUT OIDS are legacy forms */
OptWith: OptWith:
WITH reloptions { $$ = $2; } WITH reloptions { $$ = $2; }
| WITH OIDS { $$ = list_make1(defWithOids(true)); } | WITH OIDS { $$ = list_make1(makeDefElem("oids", (Node *) makeInteger(true), @1)); }
| WITHOUT OIDS { $$ = list_make1(defWithOids(false)); } | WITHOUT OIDS { $$ = list_make1(makeDefElem("oids", (Node *) makeInteger(false), @1)); }
| /*EMPTY*/ { $$ = NIL; } | /*EMPTY*/ { $$ = NIL; }
; ;
...@@ -3636,51 +3636,51 @@ SeqOptList: SeqOptElem { $$ = list_make1($1); } ...@@ -3636,51 +3636,51 @@ SeqOptList: SeqOptElem { $$ = list_make1($1); }
SeqOptElem: CACHE NumericOnly SeqOptElem: CACHE NumericOnly
{ {
$$ = makeDefElem("cache", (Node *)$2); $$ = makeDefElem("cache", (Node *)$2, @1);
} }
| CYCLE | CYCLE
{ {
$$ = makeDefElem("cycle", (Node *)makeInteger(TRUE)); $$ = makeDefElem("cycle", (Node *)makeInteger(TRUE), @1);
} }
| NO CYCLE | NO CYCLE
{ {
$$ = makeDefElem("cycle", (Node *)makeInteger(FALSE)); $$ = makeDefElem("cycle", (Node *)makeInteger(FALSE), @1);
} }
| INCREMENT opt_by NumericOnly | INCREMENT opt_by NumericOnly
{ {
$$ = makeDefElem("increment", (Node *)$3); $$ = makeDefElem("increment", (Node *)$3, @1);
} }
| MAXVALUE NumericOnly | MAXVALUE NumericOnly
{ {
$$ = makeDefElem("maxvalue", (Node *)$2); $$ = makeDefElem("maxvalue", (Node *)$2, @1);
} }
| MINVALUE NumericOnly | MINVALUE NumericOnly
{ {
$$ = makeDefElem("minvalue", (Node *)$2); $$ = makeDefElem("minvalue", (Node *)$2, @1);
} }
| NO MAXVALUE | NO MAXVALUE
{ {
$$ = makeDefElem("maxvalue", NULL); $$ = makeDefElem("maxvalue", NULL, @1);
} }
| NO MINVALUE | NO MINVALUE
{ {
$$ = makeDefElem("minvalue", NULL); $$ = makeDefElem("minvalue", NULL, @1);
} }
| OWNED BY any_name | OWNED BY any_name
{ {
$$ = makeDefElem("owned_by", (Node *)$3); $$ = makeDefElem("owned_by", (Node *)$3, @1);
} }
| START opt_with NumericOnly | START opt_with NumericOnly
{ {
$$ = makeDefElem("start", (Node *)$3); $$ = makeDefElem("start", (Node *)$3, @1);
} }
| RESTART | RESTART
{ {
$$ = makeDefElem("restart", NULL); $$ = makeDefElem("restart", NULL, @1);
} }
| RESTART opt_with NumericOnly | RESTART opt_with NumericOnly
{ {
$$ = makeDefElem("restart", (Node *)$3); $$ = makeDefElem("restart", (Node *)$3, @1);
} }
; ;
...@@ -3879,19 +3879,19 @@ create_extension_opt_list: ...@@ -3879,19 +3879,19 @@ create_extension_opt_list:
create_extension_opt_item: create_extension_opt_item:
SCHEMA name SCHEMA name
{ {
$$ = makeDefElem("schema", (Node *)makeString($2)); $$ = makeDefElem("schema", (Node *)makeString($2), @1);
} }
| VERSION_P NonReservedWord_or_Sconst | VERSION_P NonReservedWord_or_Sconst
{ {
$$ = makeDefElem("new_version", (Node *)makeString($2)); $$ = makeDefElem("new_version", (Node *)makeString($2), @1);
} }
| FROM NonReservedWord_or_Sconst | FROM NonReservedWord_or_Sconst
{ {
$$ = makeDefElem("old_version", (Node *)makeString($2)); $$ = makeDefElem("old_version", (Node *)makeString($2), @1);
} }
| CASCADE | CASCADE
{ {
$$ = makeDefElem("cascade", (Node *)makeInteger(TRUE)); $$ = makeDefElem("cascade", (Node *)makeInteger(TRUE), @1);
} }
; ;
...@@ -3920,7 +3920,7 @@ alter_extension_opt_list: ...@@ -3920,7 +3920,7 @@ alter_extension_opt_list:
alter_extension_opt_item: alter_extension_opt_item:
TO NonReservedWord_or_Sconst TO NonReservedWord_or_Sconst
{ {
$$ = makeDefElem("new_version", (Node *)makeString($2)); $$ = makeDefElem("new_version", (Node *)makeString($2), @1);
} }
; ;
...@@ -4181,10 +4181,10 @@ CreateFdwStmt: CREATE FOREIGN DATA_P WRAPPER name opt_fdw_options create_generic ...@@ -4181,10 +4181,10 @@ CreateFdwStmt: CREATE FOREIGN DATA_P WRAPPER name opt_fdw_options create_generic
; ;
fdw_option: fdw_option:
HANDLER handler_name { $$ = makeDefElem("handler", (Node *)$2); } HANDLER handler_name { $$ = makeDefElem("handler", (Node *)$2, @1); }
| NO HANDLER { $$ = makeDefElem("handler", NULL); } | NO HANDLER { $$ = makeDefElem("handler", NULL, @1); }
| VALIDATOR handler_name { $$ = makeDefElem("validator", (Node *)$2); } | VALIDATOR handler_name { $$ = makeDefElem("validator", (Node *)$2, @1); }
| NO VALIDATOR { $$ = makeDefElem("validator", NULL); } | NO VALIDATOR { $$ = makeDefElem("validator", NULL, @1); }
; ;
fdw_options: fdw_options:
...@@ -4303,14 +4303,14 @@ alter_generic_option_elem: ...@@ -4303,14 +4303,14 @@ alter_generic_option_elem:
} }
| DROP generic_option_name | DROP generic_option_name
{ {
$$ = makeDefElemExtended(NULL, $2, NULL, DEFELEM_DROP); $$ = makeDefElemExtended(NULL, $2, NULL, DEFELEM_DROP, @2);
} }
; ;
generic_option_elem: generic_option_elem:
generic_option_name generic_option_arg generic_option_name generic_option_arg
{ {
$$ = makeDefElem($1, $2); $$ = makeDefElem($1, $2, @1);
} }
; ;
...@@ -4982,7 +4982,7 @@ event_trigger_when_list: ...@@ -4982,7 +4982,7 @@ event_trigger_when_list:
event_trigger_when_item: event_trigger_when_item:
ColId IN_P '(' event_trigger_value_list ')' ColId IN_P '(' event_trigger_value_list ')'
{ $$ = makeDefElem($1, (Node *) $4); } { $$ = makeDefElem($1, (Node *) $4, @1); }
; ;
event_trigger_value_list: event_trigger_value_list:
...@@ -5187,7 +5187,7 @@ DefineStmt: ...@@ -5187,7 +5187,7 @@ DefineStmt:
n->kind = OBJECT_COLLATION; n->kind = OBJECT_COLLATION;
n->args = NIL; n->args = NIL;
n->defnames = $3; n->defnames = $3;
n->definition = list_make1(makeDefElem("from", (Node *) $5)); n->definition = list_make1(makeDefElem("from", (Node *) $5, @5));
$$ = (Node *)n; $$ = (Node *)n;
} }
; ;
...@@ -5201,11 +5201,11 @@ def_list: def_elem { $$ = list_make1($1); } ...@@ -5201,11 +5201,11 @@ def_list: def_elem { $$ = list_make1($1); }
def_elem: ColLabel '=' def_arg def_elem: ColLabel '=' def_arg
{ {
$$ = makeDefElem($1, (Node *) $3); $$ = makeDefElem($1, (Node *) $3, @1);
} }
| ColLabel | ColLabel
{ {
$$ = makeDefElem($1, NULL); $$ = makeDefElem($1, NULL, @1);
} }
; ;
...@@ -5231,7 +5231,7 @@ old_aggr_list: old_aggr_elem { $$ = list_make1($1); } ...@@ -5231,7 +5231,7 @@ old_aggr_list: old_aggr_elem { $$ = list_make1($1); }
*/ */
old_aggr_elem: IDENT '=' def_arg old_aggr_elem: IDENT '=' def_arg
{ {
$$ = makeDefElem($1, (Node *)$3); $$ = makeDefElem($1, (Node *)$3, @1);
} }
; ;
...@@ -6552,15 +6552,15 @@ DefACLOptionList: ...@@ -6552,15 +6552,15 @@ DefACLOptionList:
DefACLOption: DefACLOption:
IN_P SCHEMA name_list IN_P SCHEMA name_list
{ {
$$ = makeDefElem("schemas", (Node *)$3); $$ = makeDefElem("schemas", (Node *)$3, @1);
} }
| FOR ROLE role_list | FOR ROLE role_list
{ {
$$ = makeDefElem("roles", (Node *)$3); $$ = makeDefElem("roles", (Node *)$3, @1);
} }
| FOR USER role_list | FOR USER role_list
{ {
$$ = makeDefElem("roles", (Node *)$3); $$ = makeDefElem("roles", (Node *)$3, @1);
} }
; ;
...@@ -7044,87 +7044,87 @@ createfunc_opt_list: ...@@ -7044,87 +7044,87 @@ createfunc_opt_list:
common_func_opt_item: common_func_opt_item:
CALLED ON NULL_P INPUT_P CALLED ON NULL_P INPUT_P
{ {
$$ = makeDefElem("strict", (Node *)makeInteger(FALSE)); $$ = makeDefElem("strict", (Node *)makeInteger(FALSE), @1);
} }
| RETURNS NULL_P ON NULL_P INPUT_P | RETURNS NULL_P ON NULL_P INPUT_P
{ {
$$ = makeDefElem("strict", (Node *)makeInteger(TRUE)); $$ = makeDefElem("strict", (Node *)makeInteger(TRUE), @1);
} }
| STRICT_P | STRICT_P
{ {
$$ = makeDefElem("strict", (Node *)makeInteger(TRUE)); $$ = makeDefElem("strict", (Node *)makeInteger(TRUE), @1);
} }
| IMMUTABLE | IMMUTABLE
{ {
$$ = makeDefElem("volatility", (Node *)makeString("immutable")); $$ = makeDefElem("volatility", (Node *)makeString("immutable"), @1);
} }
| STABLE | STABLE
{ {
$$ = makeDefElem("volatility", (Node *)makeString("stable")); $$ = makeDefElem("volatility", (Node *)makeString("stable"), @1);
} }
| VOLATILE | VOLATILE
{ {
$$ = makeDefElem("volatility", (Node *)makeString("volatile")); $$ = makeDefElem("volatility", (Node *)makeString("volatile"), @1);
} }
| EXTERNAL SECURITY DEFINER | EXTERNAL SECURITY DEFINER
{ {
$$ = makeDefElem("security", (Node *)makeInteger(TRUE)); $$ = makeDefElem("security", (Node *)makeInteger(TRUE), @1);
} }
| EXTERNAL SECURITY INVOKER | EXTERNAL SECURITY INVOKER
{ {
$$ = makeDefElem("security", (Node *)makeInteger(FALSE)); $$ = makeDefElem("security", (Node *)makeInteger(FALSE), @1);
} }
| SECURITY DEFINER | SECURITY DEFINER
{ {
$$ = makeDefElem("security", (Node *)makeInteger(TRUE)); $$ = makeDefElem("security", (Node *)makeInteger(TRUE), @1);
} }
| SECURITY INVOKER | SECURITY INVOKER
{ {
$$ = makeDefElem("security", (Node *)makeInteger(FALSE)); $$ = makeDefElem("security", (Node *)makeInteger(FALSE), @1);
} }
| LEAKPROOF | LEAKPROOF
{ {
$$ = makeDefElem("leakproof", (Node *)makeInteger(TRUE)); $$ = makeDefElem("leakproof", (Node *)makeInteger(TRUE), @1);
} }
| NOT LEAKPROOF | NOT LEAKPROOF
{ {
$$ = makeDefElem("leakproof", (Node *)makeInteger(FALSE)); $$ = makeDefElem("leakproof", (Node *)makeInteger(FALSE), @1);
} }
| COST NumericOnly | COST NumericOnly
{ {
$$ = makeDefElem("cost", (Node *)$2); $$ = makeDefElem("cost", (Node *)$2, @1);
} }
| ROWS NumericOnly | ROWS NumericOnly
{ {
$$ = makeDefElem("rows", (Node *)$2); $$ = makeDefElem("rows", (Node *)$2, @1);
} }
| FunctionSetResetClause | FunctionSetResetClause
{ {
/* we abuse the normal content of a DefElem here */ /* we abuse the normal content of a DefElem here */
$$ = makeDefElem("set", (Node *)$1); $$ = makeDefElem("set", (Node *)$1, @1);
} }
| PARALLEL ColId | PARALLEL ColId
{ {
$$ = makeDefElem("parallel", (Node *)makeString($2)); $$ = makeDefElem("parallel", (Node *)makeString($2), @1);
} }
; ;
createfunc_opt_item: createfunc_opt_item:
AS func_as AS func_as
{ {
$$ = makeDefElem("as", (Node *)$2); $$ = makeDefElem("as", (Node *)$2, @1);
} }
| LANGUAGE NonReservedWord_or_Sconst | LANGUAGE NonReservedWord_or_Sconst
{ {
$$ = makeDefElem("language", (Node *)makeString($2)); $$ = makeDefElem("language", (Node *)makeString($2), @1);
} }
| TRANSFORM transform_type_list | TRANSFORM transform_type_list
{ {
$$ = makeDefElem("transform", (Node *)$2); $$ = makeDefElem("transform", (Node *)$2, @1);
} }
| WINDOW | WINDOW
{ {
$$ = makeDefElem("window", (Node *)makeInteger(TRUE)); $$ = makeDefElem("window", (Node *)makeInteger(TRUE), @1);
} }
| common_func_opt_item | common_func_opt_item
{ {
...@@ -7336,11 +7336,11 @@ dostmt_opt_list: ...@@ -7336,11 +7336,11 @@ dostmt_opt_list:
dostmt_opt_item: dostmt_opt_item:
Sconst Sconst
{ {
$$ = makeDefElem("as", (Node *)makeString($1)); $$ = makeDefElem("as", (Node *)makeString($1), @1);
} }
| LANGUAGE NonReservedWord_or_Sconst | LANGUAGE NonReservedWord_or_Sconst
{ {
$$ = makeDefElem("language", (Node *)makeString($2)); $$ = makeDefElem("language", (Node *)makeString($2), @1);
} }
; ;
...@@ -8329,9 +8329,9 @@ operator_def_list: operator_def_elem { $$ = list_make1($1); } ...@@ -8329,9 +8329,9 @@ operator_def_list: operator_def_elem { $$ = list_make1($1); }
; ;
operator_def_elem: ColLabel '=' NONE operator_def_elem: ColLabel '=' NONE
{ $$ = makeDefElem($1, NULL); } { $$ = makeDefElem($1, NULL, @1); }
| ColLabel '=' def_arg | ColLabel '=' def_arg
{ $$ = makeDefElem($1, (Node *) $3); } { $$ = makeDefElem($1, (Node *) $3, @1); }
; ;
/***************************************************************************** /*****************************************************************************
...@@ -8697,7 +8697,7 @@ TransactionStmt: ...@@ -8697,7 +8697,7 @@ TransactionStmt:
TransactionStmt *n = makeNode(TransactionStmt); TransactionStmt *n = makeNode(TransactionStmt);
n->kind = TRANS_STMT_SAVEPOINT; n->kind = TRANS_STMT_SAVEPOINT;
n->options = list_make1(makeDefElem("savepoint_name", n->options = list_make1(makeDefElem("savepoint_name",
(Node *)makeString($2))); (Node *)makeString($2), @1));
$$ = (Node *)n; $$ = (Node *)n;
} }
| RELEASE SAVEPOINT ColId | RELEASE SAVEPOINT ColId
...@@ -8705,7 +8705,7 @@ TransactionStmt: ...@@ -8705,7 +8705,7 @@ TransactionStmt:
TransactionStmt *n = makeNode(TransactionStmt); TransactionStmt *n = makeNode(TransactionStmt);
n->kind = TRANS_STMT_RELEASE; n->kind = TRANS_STMT_RELEASE;
n->options = list_make1(makeDefElem("savepoint_name", n->options = list_make1(makeDefElem("savepoint_name",
(Node *)makeString($3))); (Node *)makeString($3), @1));
$$ = (Node *)n; $$ = (Node *)n;
} }
| RELEASE ColId | RELEASE ColId
...@@ -8713,7 +8713,7 @@ TransactionStmt: ...@@ -8713,7 +8713,7 @@ TransactionStmt:
TransactionStmt *n = makeNode(TransactionStmt); TransactionStmt *n = makeNode(TransactionStmt);
n->kind = TRANS_STMT_RELEASE; n->kind = TRANS_STMT_RELEASE;
n->options = list_make1(makeDefElem("savepoint_name", n->options = list_make1(makeDefElem("savepoint_name",
(Node *)makeString($2))); (Node *)makeString($2), @1));
$$ = (Node *)n; $$ = (Node *)n;
} }
| ROLLBACK opt_transaction TO SAVEPOINT ColId | ROLLBACK opt_transaction TO SAVEPOINT ColId
...@@ -8721,7 +8721,7 @@ TransactionStmt: ...@@ -8721,7 +8721,7 @@ TransactionStmt:
TransactionStmt *n = makeNode(TransactionStmt); TransactionStmt *n = makeNode(TransactionStmt);
n->kind = TRANS_STMT_ROLLBACK_TO; n->kind = TRANS_STMT_ROLLBACK_TO;
n->options = list_make1(makeDefElem("savepoint_name", n->options = list_make1(makeDefElem("savepoint_name",
(Node *)makeString($5))); (Node *)makeString($5), @1));
$$ = (Node *)n; $$ = (Node *)n;
} }
| ROLLBACK opt_transaction TO ColId | ROLLBACK opt_transaction TO ColId
...@@ -8729,7 +8729,7 @@ TransactionStmt: ...@@ -8729,7 +8729,7 @@ TransactionStmt:
TransactionStmt *n = makeNode(TransactionStmt); TransactionStmt *n = makeNode(TransactionStmt);
n->kind = TRANS_STMT_ROLLBACK_TO; n->kind = TRANS_STMT_ROLLBACK_TO;
n->options = list_make1(makeDefElem("savepoint_name", n->options = list_make1(makeDefElem("savepoint_name",
(Node *)makeString($4))); (Node *)makeString($4), @1));
$$ = (Node *)n; $$ = (Node *)n;
} }
| PREPARE TRANSACTION Sconst | PREPARE TRANSACTION Sconst
...@@ -8763,19 +8763,19 @@ opt_transaction: WORK {} ...@@ -8763,19 +8763,19 @@ opt_transaction: WORK {}
transaction_mode_item: transaction_mode_item:
ISOLATION LEVEL iso_level ISOLATION LEVEL iso_level
{ $$ = makeDefElem("transaction_isolation", { $$ = makeDefElem("transaction_isolation",
makeStringConst($3, @3)); } makeStringConst($3, @3), @1); }
| READ ONLY | READ ONLY
{ $$ = makeDefElem("transaction_read_only", { $$ = makeDefElem("transaction_read_only",
makeIntConst(TRUE, @1)); } makeIntConst(TRUE, @1), @1); }
| READ WRITE | READ WRITE
{ $$ = makeDefElem("transaction_read_only", { $$ = makeDefElem("transaction_read_only",
makeIntConst(FALSE, @1)); } makeIntConst(FALSE, @1), @1); }
| DEFERRABLE | DEFERRABLE
{ $$ = makeDefElem("transaction_deferrable", { $$ = makeDefElem("transaction_deferrable",
makeIntConst(TRUE, @1)); } makeIntConst(TRUE, @1), @1); }
| NOT DEFERRABLE | NOT DEFERRABLE
{ $$ = makeDefElem("transaction_deferrable", { $$ = makeDefElem("transaction_deferrable",
makeIntConst(FALSE, @1)); } makeIntConst(FALSE, @1), @1); }
; ;
/* Syntax with commas is SQL-spec, without commas is Postgres historical */ /* Syntax with commas is SQL-spec, without commas is Postgres historical */
...@@ -8919,15 +8919,15 @@ createdb_opt_items: ...@@ -8919,15 +8919,15 @@ createdb_opt_items:
createdb_opt_item: createdb_opt_item:
createdb_opt_name opt_equal SignedIconst createdb_opt_name opt_equal SignedIconst
{ {
$$ = makeDefElem($1, (Node *)makeInteger($3)); $$ = makeDefElem($1, (Node *)makeInteger($3), @1);
} }
| createdb_opt_name opt_equal opt_boolean_or_string | createdb_opt_name opt_equal opt_boolean_or_string
{ {
$$ = makeDefElem($1, (Node *)makeString($3)); $$ = makeDefElem($1, (Node *)makeString($3), @1);
} }
| createdb_opt_name opt_equal DEFAULT | createdb_opt_name opt_equal DEFAULT
{ {
$$ = makeDefElem($1, NULL); $$ = makeDefElem($1, NULL, @1);
} }
; ;
...@@ -8987,7 +8987,7 @@ AlterDatabaseStmt: ...@@ -8987,7 +8987,7 @@ AlterDatabaseStmt:
AlterDatabaseStmt *n = makeNode(AlterDatabaseStmt); AlterDatabaseStmt *n = makeNode(AlterDatabaseStmt);
n->dbname = $3; n->dbname = $3;
n->options = list_make1(makeDefElem("tablespace", n->options = list_make1(makeDefElem("tablespace",
(Node *)makeString($6))); (Node *)makeString($6), @6));
$$ = (Node *)n; $$ = (Node *)n;
} }
; ;
...@@ -9451,17 +9451,17 @@ ExplainStmt: ...@@ -9451,17 +9451,17 @@ ExplainStmt:
{ {
ExplainStmt *n = makeNode(ExplainStmt); ExplainStmt *n = makeNode(ExplainStmt);
n->query = $4; n->query = $4;
n->options = list_make1(makeDefElem("analyze", NULL)); n->options = list_make1(makeDefElem("analyze", NULL, @2));
if ($3) if ($3)
n->options = lappend(n->options, n->options = lappend(n->options,
makeDefElem("verbose", NULL)); makeDefElem("verbose", NULL, @3));
$$ = (Node *) n; $$ = (Node *) n;
} }
| EXPLAIN VERBOSE ExplainableStmt | EXPLAIN VERBOSE ExplainableStmt
{ {
ExplainStmt *n = makeNode(ExplainStmt); ExplainStmt *n = makeNode(ExplainStmt);
n->query = $3; n->query = $3;
n->options = list_make1(makeDefElem("verbose", NULL)); n->options = list_make1(makeDefElem("verbose", NULL, @2));
$$ = (Node *) n; $$ = (Node *) n;
} }
| EXPLAIN '(' explain_option_list ')' ExplainableStmt | EXPLAIN '(' explain_option_list ')' ExplainableStmt
...@@ -9499,7 +9499,7 @@ explain_option_list: ...@@ -9499,7 +9499,7 @@ explain_option_list:
explain_option_elem: explain_option_elem:
explain_option_name explain_option_arg explain_option_name explain_option_arg
{ {
$$ = makeDefElem($1, $2); $$ = makeDefElem($1, $2, @1);
} }
; ;
......
...@@ -294,7 +294,8 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString) ...@@ -294,7 +294,8 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString)
* overridden if an inherited table has oids. * overridden if an inherited table has oids.
*/ */
stmt->options = lcons(makeDefElem("oids", stmt->options = lcons(makeDefElem("oids",
(Node *) makeInteger(cxt.hasoids)), stmt->options); (Node *) makeInteger(cxt.hasoids), -1),
stmt->options);
} }
foreach(elements, stmt->tableElts) foreach(elements, stmt->tableElts)
...@@ -482,7 +483,7 @@ transformColumnDefinition(CreateStmtContext *cxt, ColumnDef *column) ...@@ -482,7 +483,7 @@ transformColumnDefinition(CreateStmtContext *cxt, ColumnDef *column)
makeString(cxt->relation->relname), makeString(cxt->relation->relname),
makeString(column->colname)); makeString(column->colname));
altseqstmt->options = list_make1(makeDefElem("owned_by", altseqstmt->options = list_make1(makeDefElem("owned_by",
(Node *) attnamelist)); (Node *) attnamelist, -1));
cxt->alist = lappend(cxt->alist, altseqstmt); cxt->alist = lappend(cxt->alist, altseqstmt);
......
...@@ -225,7 +225,7 @@ pg_logical_slot_get_changes_guts(FunctionCallInfo fcinfo, bool confirm, bool bin ...@@ -225,7 +225,7 @@ pg_logical_slot_get_changes_guts(FunctionCallInfo fcinfo, bool confirm, bool bin
char *name = TextDatumGetCString(datum_opts[i]); char *name = TextDatumGetCString(datum_opts[i]);
char *opt = TextDatumGetCString(datum_opts[i + 1]); char *opt = TextDatumGetCString(datum_opts[i + 1]);
options = lappend(options, makeDefElem(name, (Node *) makeString(opt))); options = lappend(options, makeDefElem(name, (Node *) makeString(opt), -1));
} }
} }
......
...@@ -148,37 +148,37 @@ base_backup_opt: ...@@ -148,37 +148,37 @@ base_backup_opt:
K_LABEL SCONST K_LABEL SCONST
{ {
$$ = makeDefElem("label", $$ = makeDefElem("label",
(Node *)makeString($2)); (Node *)makeString($2), -1);
} }
| K_PROGRESS | K_PROGRESS
{ {
$$ = makeDefElem("progress", $$ = makeDefElem("progress",
(Node *)makeInteger(TRUE)); (Node *)makeInteger(TRUE), -1);
} }
| K_FAST | K_FAST
{ {
$$ = makeDefElem("fast", $$ = makeDefElem("fast",
(Node *)makeInteger(TRUE)); (Node *)makeInteger(TRUE), -1);
} }
| K_WAL | K_WAL
{ {
$$ = makeDefElem("wal", $$ = makeDefElem("wal",
(Node *)makeInteger(TRUE)); (Node *)makeInteger(TRUE), -1);
} }
| K_NOWAIT | K_NOWAIT
{ {
$$ = makeDefElem("nowait", $$ = makeDefElem("nowait",
(Node *)makeInteger(TRUE)); (Node *)makeInteger(TRUE), -1);
} }
| K_MAX_RATE UCONST | K_MAX_RATE UCONST
{ {
$$ = makeDefElem("max_rate", $$ = makeDefElem("max_rate",
(Node *)makeInteger($2)); (Node *)makeInteger($2), -1);
} }
| K_TABLESPACE_MAP | K_TABLESPACE_MAP
{ {
$$ = makeDefElem("tablespace_map", $$ = makeDefElem("tablespace_map",
(Node *)makeInteger(TRUE)); (Node *)makeInteger(TRUE), -1);
} }
; ;
...@@ -315,7 +315,7 @@ plugin_opt_list: ...@@ -315,7 +315,7 @@ plugin_opt_list:
plugin_opt_elem: plugin_opt_elem:
IDENT plugin_opt_arg IDENT plugin_opt_arg
{ {
$$ = makeDefElem($1, $2); $$ = makeDefElem($1, $2, -1);
} }
; ;
......
...@@ -71,7 +71,8 @@ ...@@ -71,7 +71,8 @@
ProcessUtility_hook_type ProcessUtility_hook = NULL; ProcessUtility_hook_type ProcessUtility_hook = NULL;
/* local function declarations */ /* local function declarations */
static void ProcessUtilitySlow(Node *parsetree, static void ProcessUtilitySlow(ParseState *pstate,
Node *parsetree,
const char *queryString, const char *queryString,
ProcessUtilityContext context, ProcessUtilityContext context,
ParamListInfo params, ParamListInfo params,
...@@ -358,12 +359,16 @@ standard_ProcessUtility(Node *parsetree, ...@@ -358,12 +359,16 @@ standard_ProcessUtility(Node *parsetree,
char *completionTag) char *completionTag)
{ {
bool isTopLevel = (context == PROCESS_UTILITY_TOPLEVEL); bool isTopLevel = (context == PROCESS_UTILITY_TOPLEVEL);
ParseState *pstate;
check_xact_readonly(parsetree); check_xact_readonly(parsetree);
if (completionTag) if (completionTag)
completionTag[0] = '\0'; completionTag[0] = '\0';
pstate = make_parsestate(NULL);
pstate->p_sourcetext = queryString;
switch (nodeTag(parsetree)) switch (nodeTag(parsetree))
{ {
/* /*
...@@ -540,7 +545,7 @@ standard_ProcessUtility(Node *parsetree, ...@@ -540,7 +545,7 @@ standard_ProcessUtility(Node *parsetree,
{ {
uint64 processed; uint64 processed;
DoCopy((CopyStmt *) parsetree, queryString, &processed); DoCopy(pstate, (CopyStmt *) parsetree, &processed);
if (completionTag) if (completionTag)
snprintf(completionTag, COMPLETION_TAG_BUFSIZE, snprintf(completionTag, COMPLETION_TAG_BUFSIZE,
"COPY " UINT64_FORMAT, processed); "COPY " UINT64_FORMAT, processed);
...@@ -571,12 +576,12 @@ standard_ProcessUtility(Node *parsetree, ...@@ -571,12 +576,12 @@ standard_ProcessUtility(Node *parsetree,
case T_CreatedbStmt: case T_CreatedbStmt:
/* no event triggers for global objects */ /* no event triggers for global objects */
PreventTransactionChain(isTopLevel, "CREATE DATABASE"); PreventTransactionChain(isTopLevel, "CREATE DATABASE");
createdb((CreatedbStmt *) parsetree); createdb(pstate, (CreatedbStmt *) parsetree);
break; break;
case T_AlterDatabaseStmt: case T_AlterDatabaseStmt:
/* no event triggers for global objects */ /* no event triggers for global objects */
AlterDatabase((AlterDatabaseStmt *) parsetree, isTopLevel); AlterDatabase(pstate, (AlterDatabaseStmt *) parsetree, isTopLevel);
break; break;
case T_AlterDatabaseSetStmt: case T_AlterDatabaseSetStmt:
...@@ -657,7 +662,7 @@ standard_ProcessUtility(Node *parsetree, ...@@ -657,7 +662,7 @@ standard_ProcessUtility(Node *parsetree,
break; break;
case T_ExplainStmt: case T_ExplainStmt:
ExplainQuery((ExplainStmt *) parsetree, queryString, params, dest); ExplainQuery(pstate, (ExplainStmt *) parsetree, queryString, params, dest);
break; break;
case T_AlterSystemStmt: case T_AlterSystemStmt:
...@@ -698,7 +703,7 @@ standard_ProcessUtility(Node *parsetree, ...@@ -698,7 +703,7 @@ standard_ProcessUtility(Node *parsetree,
*/ */
case T_CreateRoleStmt: case T_CreateRoleStmt:
/* no event triggers for global objects */ /* no event triggers for global objects */
CreateRole((CreateRoleStmt *) parsetree); CreateRole(pstate, (CreateRoleStmt *) parsetree);
break; break;
case T_AlterRoleStmt: case T_AlterRoleStmt:
...@@ -803,7 +808,7 @@ standard_ProcessUtility(Node *parsetree, ...@@ -803,7 +808,7 @@ standard_ProcessUtility(Node *parsetree,
GrantStmt *stmt = (GrantStmt *) parsetree; GrantStmt *stmt = (GrantStmt *) parsetree;
if (EventTriggerSupportsGrantObjectType(stmt->objtype)) if (EventTriggerSupportsGrantObjectType(stmt->objtype))
ProcessUtilitySlow(parsetree, queryString, ProcessUtilitySlow(pstate, parsetree, queryString,
context, params, context, params,
dest, completionTag); dest, completionTag);
else else
...@@ -816,7 +821,7 @@ standard_ProcessUtility(Node *parsetree, ...@@ -816,7 +821,7 @@ standard_ProcessUtility(Node *parsetree,
DropStmt *stmt = (DropStmt *) parsetree; DropStmt *stmt = (DropStmt *) parsetree;
if (EventTriggerSupportsObjectType(stmt->removeType)) if (EventTriggerSupportsObjectType(stmt->removeType))
ProcessUtilitySlow(parsetree, queryString, ProcessUtilitySlow(pstate, parsetree, queryString,
context, params, context, params,
dest, completionTag); dest, completionTag);
else else
...@@ -829,7 +834,7 @@ standard_ProcessUtility(Node *parsetree, ...@@ -829,7 +834,7 @@ standard_ProcessUtility(Node *parsetree,
RenameStmt *stmt = (RenameStmt *) parsetree; RenameStmt *stmt = (RenameStmt *) parsetree;
if (EventTriggerSupportsObjectType(stmt->renameType)) if (EventTriggerSupportsObjectType(stmt->renameType))
ProcessUtilitySlow(parsetree, queryString, ProcessUtilitySlow(pstate, parsetree, queryString,
context, params, context, params,
dest, completionTag); dest, completionTag);
else else
...@@ -842,7 +847,7 @@ standard_ProcessUtility(Node *parsetree, ...@@ -842,7 +847,7 @@ standard_ProcessUtility(Node *parsetree,
AlterObjectDependsStmt *stmt = (AlterObjectDependsStmt *) parsetree; AlterObjectDependsStmt *stmt = (AlterObjectDependsStmt *) parsetree;
if (EventTriggerSupportsObjectType(stmt->objectType)) if (EventTriggerSupportsObjectType(stmt->objectType))
ProcessUtilitySlow(parsetree, queryString, ProcessUtilitySlow(pstate, parsetree, queryString,
context, params, context, params,
dest, completionTag); dest, completionTag);
else else
...@@ -855,7 +860,7 @@ standard_ProcessUtility(Node *parsetree, ...@@ -855,7 +860,7 @@ standard_ProcessUtility(Node *parsetree,
AlterObjectSchemaStmt *stmt = (AlterObjectSchemaStmt *) parsetree; AlterObjectSchemaStmt *stmt = (AlterObjectSchemaStmt *) parsetree;
if (EventTriggerSupportsObjectType(stmt->objectType)) if (EventTriggerSupportsObjectType(stmt->objectType))
ProcessUtilitySlow(parsetree, queryString, ProcessUtilitySlow(pstate, parsetree, queryString,
context, params, context, params,
dest, completionTag); dest, completionTag);
else else
...@@ -868,7 +873,7 @@ standard_ProcessUtility(Node *parsetree, ...@@ -868,7 +873,7 @@ standard_ProcessUtility(Node *parsetree,
AlterOwnerStmt *stmt = (AlterOwnerStmt *) parsetree; AlterOwnerStmt *stmt = (AlterOwnerStmt *) parsetree;
if (EventTriggerSupportsObjectType(stmt->objectType)) if (EventTriggerSupportsObjectType(stmt->objectType))
ProcessUtilitySlow(parsetree, queryString, ProcessUtilitySlow(pstate, parsetree, queryString,
context, params, context, params,
dest, completionTag); dest, completionTag);
else else
...@@ -881,7 +886,7 @@ standard_ProcessUtility(Node *parsetree, ...@@ -881,7 +886,7 @@ standard_ProcessUtility(Node *parsetree,
CommentStmt *stmt = (CommentStmt *) parsetree; CommentStmt *stmt = (CommentStmt *) parsetree;
if (EventTriggerSupportsObjectType(stmt->objtype)) if (EventTriggerSupportsObjectType(stmt->objtype))
ProcessUtilitySlow(parsetree, queryString, ProcessUtilitySlow(pstate, parsetree, queryString,
context, params, context, params,
dest, completionTag); dest, completionTag);
else else
...@@ -894,7 +899,7 @@ standard_ProcessUtility(Node *parsetree, ...@@ -894,7 +899,7 @@ standard_ProcessUtility(Node *parsetree,
SecLabelStmt *stmt = (SecLabelStmt *) parsetree; SecLabelStmt *stmt = (SecLabelStmt *) parsetree;
if (EventTriggerSupportsObjectType(stmt->objtype)) if (EventTriggerSupportsObjectType(stmt->objtype))
ProcessUtilitySlow(parsetree, queryString, ProcessUtilitySlow(pstate, parsetree, queryString,
context, params, context, params,
dest, completionTag); dest, completionTag);
else else
...@@ -904,11 +909,13 @@ standard_ProcessUtility(Node *parsetree, ...@@ -904,11 +909,13 @@ standard_ProcessUtility(Node *parsetree,
default: default:
/* All other statement types have event trigger support */ /* All other statement types have event trigger support */
ProcessUtilitySlow(parsetree, queryString, ProcessUtilitySlow(pstate, parsetree, queryString,
context, params, context, params,
dest, completionTag); dest, completionTag);
break; break;
} }
free_parsestate(pstate);
} }
/* /*
...@@ -917,7 +924,8 @@ standard_ProcessUtility(Node *parsetree, ...@@ -917,7 +924,8 @@ standard_ProcessUtility(Node *parsetree,
* perform the trigger support calls if the context allows it. * perform the trigger support calls if the context allows it.
*/ */
static void static void
ProcessUtilitySlow(Node *parsetree, ProcessUtilitySlow(ParseState *pstate,
Node *parsetree,
const char *queryString, const char *queryString,
ProcessUtilityContext context, ProcessUtilityContext context,
ParamListInfo params, ParamListInfo params,
...@@ -1191,9 +1199,9 @@ ProcessUtilitySlow(Node *parsetree, ...@@ -1191,9 +1199,9 @@ ProcessUtilitySlow(Node *parsetree,
{ {
case OBJECT_AGGREGATE: case OBJECT_AGGREGATE:
address = address =
DefineAggregate(stmt->defnames, stmt->args, DefineAggregate(pstate, stmt->defnames, stmt->args,
stmt->oldstyle, stmt->oldstyle,
stmt->definition, queryString); stmt->definition);
break; break;
case OBJECT_OPERATOR: case OBJECT_OPERATOR:
Assert(stmt->args == NIL); Assert(stmt->args == NIL);
...@@ -1202,7 +1210,8 @@ ProcessUtilitySlow(Node *parsetree, ...@@ -1202,7 +1210,8 @@ ProcessUtilitySlow(Node *parsetree,
break; break;
case OBJECT_TYPE: case OBJECT_TYPE:
Assert(stmt->args == NIL); Assert(stmt->args == NIL);
address = DefineType(stmt->defnames, address = DefineType(pstate,
stmt->defnames,
stmt->definition); stmt->definition);
break; break;
case OBJECT_TSPARSER: case OBJECT_TSPARSER:
...@@ -1228,7 +1237,8 @@ ProcessUtilitySlow(Node *parsetree, ...@@ -1228,7 +1237,8 @@ ProcessUtilitySlow(Node *parsetree,
break; break;
case OBJECT_COLLATION: case OBJECT_COLLATION:
Assert(stmt->args == NIL); Assert(stmt->args == NIL);
address = DefineCollation(stmt->defnames, address = DefineCollation(pstate,
stmt->defnames,
stmt->definition); stmt->definition);
break; break;
default: default:
...@@ -1293,11 +1303,11 @@ ProcessUtilitySlow(Node *parsetree, ...@@ -1293,11 +1303,11 @@ ProcessUtilitySlow(Node *parsetree,
break; break;
case T_CreateExtensionStmt: case T_CreateExtensionStmt:
address = CreateExtension((CreateExtensionStmt *) parsetree); address = CreateExtension(pstate, (CreateExtensionStmt *) parsetree);
break; break;
case T_AlterExtensionStmt: case T_AlterExtensionStmt:
address = ExecAlterExtensionStmt((AlterExtensionStmt *) parsetree); address = ExecAlterExtensionStmt(pstate, (AlterExtensionStmt *) parsetree);
break; break;
case T_AlterExtensionContentsStmt: case T_AlterExtensionContentsStmt:
...@@ -1373,11 +1383,11 @@ ProcessUtilitySlow(Node *parsetree, ...@@ -1373,11 +1383,11 @@ ProcessUtilitySlow(Node *parsetree,
break; break;
case T_CreateFunctionStmt: /* CREATE FUNCTION */ case T_CreateFunctionStmt: /* CREATE FUNCTION */
address = CreateFunction((CreateFunctionStmt *) parsetree, queryString); address = CreateFunction(pstate, (CreateFunctionStmt *) parsetree);
break; break;
case T_AlterFunctionStmt: /* ALTER FUNCTION */ case T_AlterFunctionStmt: /* ALTER FUNCTION */
address = AlterFunction((AlterFunctionStmt *) parsetree); address = AlterFunction(pstate, (AlterFunctionStmt *) parsetree);
break; break;
case T_RuleStmt: /* CREATE RULE */ case T_RuleStmt: /* CREATE RULE */
...@@ -1385,11 +1395,11 @@ ProcessUtilitySlow(Node *parsetree, ...@@ -1385,11 +1395,11 @@ ProcessUtilitySlow(Node *parsetree,
break; break;
case T_CreateSeqStmt: case T_CreateSeqStmt:
address = DefineSequence((CreateSeqStmt *) parsetree); address = DefineSequence(pstate, (CreateSeqStmt *) parsetree);
break; break;
case T_AlterSeqStmt: case T_AlterSeqStmt:
address = AlterSequence((AlterSeqStmt *) parsetree); address = AlterSequence(pstate, (AlterSeqStmt *) parsetree);
break; break;
case T_CreateTableAsStmt: case T_CreateTableAsStmt:
...@@ -1523,7 +1533,7 @@ ProcessUtilitySlow(Node *parsetree, ...@@ -1523,7 +1533,7 @@ ProcessUtilitySlow(Node *parsetree,
break; break;
case T_AlterDefaultPrivilegesStmt: case T_AlterDefaultPrivilegesStmt:
ExecAlterDefaultPrivilegesStmt((AlterDefaultPrivilegesStmt *) parsetree); ExecAlterDefaultPrivilegesStmt(pstate, (AlterDefaultPrivilegesStmt *) parsetree);
EventTriggerCollectAlterDefPrivs((AlterDefaultPrivilegesStmt *) parsetree); EventTriggerCollectAlterDefPrivs((AlterDefaultPrivilegesStmt *) parsetree);
commandCollected = true; commandCollected = true;
break; break;
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include "catalog/objectaddress.h" #include "catalog/objectaddress.h"
#include "nodes/parsenodes.h" #include "nodes/parsenodes.h"
extern ObjectAddress DefineCollation(List *names, List *parameters); extern ObjectAddress DefineCollation(ParseState *pstate, List *names, List *parameters);
extern void IsThereCollationInNamespace(const char *collname, Oid nspOid); extern void IsThereCollationInNamespace(const char *collname, Oid nspOid);
#endif /* COLLATIONCMDS_H */ #endif /* COLLATIONCMDS_H */
...@@ -16,16 +16,17 @@ ...@@ -16,16 +16,17 @@
#include "nodes/execnodes.h" #include "nodes/execnodes.h"
#include "nodes/parsenodes.h" #include "nodes/parsenodes.h"
#include "parser/parse_node.h"
#include "tcop/dest.h" #include "tcop/dest.h"
/* CopyStateData is private in commands/copy.c */ /* CopyStateData is private in commands/copy.c */
typedef struct CopyStateData *CopyState; typedef struct CopyStateData *CopyState;
extern Oid DoCopy(const CopyStmt *stmt, const char *queryString, extern Oid DoCopy(ParseState *state, const CopyStmt *stmt,
uint64 *processed); uint64 *processed);
extern void ProcessCopyOptions(CopyState cstate, bool is_from, List *options); extern void ProcessCopyOptions(ParseState *pstate, CopyState cstate, bool is_from, List *options);
extern CopyState BeginCopyFrom(Relation rel, const char *filename, extern CopyState BeginCopyFrom(ParseState *pstate, Relation rel, const char *filename,
bool is_program, List *attnamelist, List *options); bool is_program, List *attnamelist, List *options);
extern void EndCopyFrom(CopyState cstate); extern void EndCopyFrom(CopyState cstate);
extern bool NextCopyFrom(CopyState cstate, ExprContext *econtext, extern bool NextCopyFrom(CopyState cstate, ExprContext *econtext,
......
...@@ -19,10 +19,10 @@ ...@@ -19,10 +19,10 @@
#include "lib/stringinfo.h" #include "lib/stringinfo.h"
#include "nodes/parsenodes.h" #include "nodes/parsenodes.h"
extern Oid createdb(const CreatedbStmt *stmt); extern Oid createdb(ParseState *pstate, const CreatedbStmt *stmt);
extern void dropdb(const char *dbname, bool missing_ok); extern void dropdb(const char *dbname, bool missing_ok);
extern ObjectAddress RenameDatabase(const char *oldname, const char *newname); extern ObjectAddress RenameDatabase(const char *oldname, const char *newname);
extern Oid AlterDatabase(AlterDatabaseStmt *stmt, bool isTopLevel); extern Oid AlterDatabase(ParseState *pstate, AlterDatabaseStmt *stmt, bool isTopLevel);
extern Oid AlterDatabaseSet(AlterDatabaseSetStmt *stmt); extern Oid AlterDatabaseSet(AlterDatabaseSetStmt *stmt);
extern ObjectAddress AlterDatabaseOwner(const char *dbname, Oid newOwnerId); extern ObjectAddress AlterDatabaseOwner(const char *dbname, Oid newOwnerId);
......
...@@ -44,11 +44,11 @@ extern bool CheckIndexCompatible(Oid oldId, ...@@ -44,11 +44,11 @@ extern bool CheckIndexCompatible(Oid oldId,
extern Oid GetDefaultOpClass(Oid type_id, Oid am_id); extern Oid GetDefaultOpClass(Oid type_id, Oid am_id);
/* commands/functioncmds.c */ /* commands/functioncmds.c */
extern ObjectAddress CreateFunction(CreateFunctionStmt *stmt, const char *queryString); extern ObjectAddress CreateFunction(ParseState *pstate, CreateFunctionStmt *stmt);
extern void RemoveFunctionById(Oid funcOid); extern void RemoveFunctionById(Oid funcOid);
extern void SetFunctionReturnType(Oid funcOid, Oid newRetType); extern void SetFunctionReturnType(Oid funcOid, Oid newRetType);
extern void SetFunctionArgType(Oid funcOid, int argIndex, Oid newArgType); extern void SetFunctionArgType(Oid funcOid, int argIndex, Oid newArgType);
extern ObjectAddress AlterFunction(AlterFunctionStmt *stmt); extern ObjectAddress AlterFunction(ParseState *pstate, AlterFunctionStmt *stmt);
extern ObjectAddress CreateCast(CreateCastStmt *stmt); extern ObjectAddress CreateCast(CreateCastStmt *stmt);
extern void DropCastById(Oid castOid); extern void DropCastById(Oid castOid);
extern ObjectAddress CreateTransform(CreateTransformStmt *stmt); extern ObjectAddress CreateTransform(CreateTransformStmt *stmt);
...@@ -58,10 +58,10 @@ extern void IsThereFunctionInNamespace(const char *proname, int pronargs, ...@@ -58,10 +58,10 @@ extern void IsThereFunctionInNamespace(const char *proname, int pronargs,
extern void ExecuteDoStmt(DoStmt *stmt); extern void ExecuteDoStmt(DoStmt *stmt);
extern Oid get_cast_oid(Oid sourcetypeid, Oid targettypeid, bool missing_ok); extern Oid get_cast_oid(Oid sourcetypeid, Oid targettypeid, bool missing_ok);
extern Oid get_transform_oid(Oid type_id, Oid lang_id, bool missing_ok); extern Oid get_transform_oid(Oid type_id, Oid lang_id, bool missing_ok);
extern void interpret_function_parameter_list(List *parameters, extern void interpret_function_parameter_list(ParseState *pstate,
List *parameters,
Oid languageOid, Oid languageOid,
bool is_aggregate, bool is_aggregate,
const char *queryString,
oidvector **parameterTypes, oidvector **parameterTypes,
ArrayType **allParameterTypes, ArrayType **allParameterTypes,
ArrayType **parameterModes, ArrayType **parameterModes,
...@@ -76,8 +76,8 @@ extern void RemoveOperatorById(Oid operOid); ...@@ -76,8 +76,8 @@ extern void RemoveOperatorById(Oid operOid);
extern ObjectAddress AlterOperator(AlterOperatorStmt *stmt); extern ObjectAddress AlterOperator(AlterOperatorStmt *stmt);
/* commands/aggregatecmds.c */ /* commands/aggregatecmds.c */
extern ObjectAddress DefineAggregate(List *name, List *args, bool oldstyle, extern ObjectAddress DefineAggregate(ParseState *pstate, List *name, List *args, bool oldstyle,
List *parameters, const char *queryString); List *parameters);
/* commands/opclasscmds.c */ /* commands/opclasscmds.c */
extern ObjectAddress DefineOpClass(CreateOpClassStmt *stmt); extern ObjectAddress DefineOpClass(CreateOpClassStmt *stmt);
...@@ -152,6 +152,5 @@ extern int64 defGetInt64(DefElem *def); ...@@ -152,6 +152,5 @@ extern int64 defGetInt64(DefElem *def);
extern List *defGetQualifiedName(DefElem *def); extern List *defGetQualifiedName(DefElem *def);
extern TypeName *defGetTypeName(DefElem *def); extern TypeName *defGetTypeName(DefElem *def);
extern int defGetTypeLength(DefElem *def); extern int defGetTypeLength(DefElem *def);
extern DefElem *defWithOids(bool value);
#endif /* DEFREM_H */ #endif /* DEFREM_H */
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "executor/executor.h" #include "executor/executor.h"
#include "lib/stringinfo.h" #include "lib/stringinfo.h"
#include "parser/parse_node.h"
typedef enum ExplainFormat typedef enum ExplainFormat
{ {
...@@ -59,7 +60,7 @@ typedef const char *(*explain_get_index_name_hook_type) (Oid indexId); ...@@ -59,7 +60,7 @@ typedef const char *(*explain_get_index_name_hook_type) (Oid indexId);
extern PGDLLIMPORT explain_get_index_name_hook_type explain_get_index_name_hook; extern PGDLLIMPORT explain_get_index_name_hook_type explain_get_index_name_hook;
extern void ExplainQuery(ExplainStmt *stmt, const char *queryString, extern void ExplainQuery(ParseState *pstate, ExplainStmt *stmt, const char *queryString,
ParamListInfo params, DestReceiver *dest); ParamListInfo params, DestReceiver *dest);
extern ExplainState *NewExplainState(void); extern ExplainState *NewExplainState(void);
......
...@@ -28,7 +28,7 @@ extern PGDLLIMPORT bool creating_extension; ...@@ -28,7 +28,7 @@ extern PGDLLIMPORT bool creating_extension;
extern Oid CurrentExtensionObject; extern Oid CurrentExtensionObject;
extern ObjectAddress CreateExtension(CreateExtensionStmt *stmt); extern ObjectAddress CreateExtension(ParseState *pstate, CreateExtensionStmt *stmt);
extern void RemoveExtensionById(Oid extId); extern void RemoveExtensionById(Oid extId);
...@@ -37,7 +37,7 @@ extern ObjectAddress InsertExtensionTuple(const char *extName, Oid extOwner, ...@@ -37,7 +37,7 @@ extern ObjectAddress InsertExtensionTuple(const char *extName, Oid extOwner,
Datum extConfig, Datum extCondition, Datum extConfig, Datum extCondition,
List *requiredExtensions); List *requiredExtensions);
extern ObjectAddress ExecAlterExtensionStmt(AlterExtensionStmt *stmt); extern ObjectAddress ExecAlterExtensionStmt(ParseState *pstate, AlterExtensionStmt *stmt);
extern ObjectAddress ExecAlterExtensionContentsStmt(AlterExtensionContentsStmt *stmt, extern ObjectAddress ExecAlterExtensionContentsStmt(AlterExtensionContentsStmt *stmt,
ObjectAddress *objAddress); ObjectAddress *objAddress);
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "fmgr.h" #include "fmgr.h"
#include "lib/stringinfo.h" #include "lib/stringinfo.h"
#include "nodes/parsenodes.h" #include "nodes/parsenodes.h"
#include "parser/parse_node.h"
#include "storage/relfilenode.h" #include "storage/relfilenode.h"
...@@ -73,8 +74,8 @@ extern Datum lastval(PG_FUNCTION_ARGS); ...@@ -73,8 +74,8 @@ extern Datum lastval(PG_FUNCTION_ARGS);
extern Datum pg_sequence_parameters(PG_FUNCTION_ARGS); extern Datum pg_sequence_parameters(PG_FUNCTION_ARGS);
extern ObjectAddress DefineSequence(CreateSeqStmt *stmt); extern ObjectAddress DefineSequence(ParseState *pstate, CreateSeqStmt *stmt);
extern ObjectAddress AlterSequence(AlterSeqStmt *stmt); extern ObjectAddress AlterSequence(ParseState *pstate, AlterSeqStmt *stmt);
extern void ResetSequence(Oid seq_relid); extern void ResetSequence(Oid seq_relid);
extern void ResetSequenceCaches(void); extern void ResetSequenceCaches(void);
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#define DEFAULT_TYPDELIM ',' #define DEFAULT_TYPDELIM ','
extern ObjectAddress DefineType(List *names, List *parameters); extern ObjectAddress DefineType(ParseState *pstate, List *names, List *parameters);
extern void RemoveTypeById(Oid typeOid); extern void RemoveTypeById(Oid typeOid);
extern ObjectAddress DefineDomain(CreateDomainStmt *stmt); extern ObjectAddress DefineDomain(CreateDomainStmt *stmt);
extern ObjectAddress DefineEnum(CreateEnumStmt *stmt); extern ObjectAddress DefineEnum(CreateEnumStmt *stmt);
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "catalog/objectaddress.h" #include "catalog/objectaddress.h"
#include "nodes/parsenodes.h" #include "nodes/parsenodes.h"
#include "parser/parse_node.h"
/* Hook to check passwords in CreateRole() and AlterRole() */ /* Hook to check passwords in CreateRole() and AlterRole() */
...@@ -23,7 +24,7 @@ typedef void (*check_password_hook_type) (const char *username, const char *pass ...@@ -23,7 +24,7 @@ typedef void (*check_password_hook_type) (const char *username, const char *pass
extern PGDLLIMPORT check_password_hook_type check_password_hook; extern PGDLLIMPORT check_password_hook_type check_password_hook;
extern Oid CreateRole(CreateRoleStmt *stmt); extern Oid CreateRole(ParseState *pstate, CreateRoleStmt *stmt);
extern Oid AlterRole(AlterRoleStmt *stmt); extern Oid AlterRole(AlterRoleStmt *stmt);
extern Oid AlterRoleSet(AlterRoleSetStmt *stmt); extern Oid AlterRoleSet(AlterRoleSetStmt *stmt);
extern void DropRole(DropRoleStmt *stmt); extern void DropRole(DropRoleStmt *stmt);
......
...@@ -80,9 +80,9 @@ extern FuncExpr *makeFuncExpr(Oid funcid, Oid rettype, List *args, ...@@ -80,9 +80,9 @@ extern FuncExpr *makeFuncExpr(Oid funcid, Oid rettype, List *args,
extern FuncCall *makeFuncCall(List *name, List *args, int location); extern FuncCall *makeFuncCall(List *name, List *args, int location);
extern DefElem *makeDefElem(char *name, Node *arg); extern DefElem *makeDefElem(char *name, Node *arg, int location);
extern DefElem *makeDefElemExtended(char *nameSpace, char *name, Node *arg, extern DefElem *makeDefElemExtended(char *nameSpace, char *name, Node *arg,
DefElemAction defaction); DefElemAction defaction, int location);
extern GroupingSet *makeGroupingSet(GroupingSetKind kind, List *content, int location); extern GroupingSet *makeGroupingSet(GroupingSetKind kind, List *content, int location);
......
...@@ -666,6 +666,7 @@ typedef struct DefElem ...@@ -666,6 +666,7 @@ typedef struct DefElem
char *defname; char *defname;
Node *arg; /* a (Value *) or a (TypeName *) */ Node *arg; /* a (Value *) or a (TypeName *) */
DefElemAction defaction; /* unspecified action, or SET/ADD/DROP */ DefElemAction defaction; /* unspecified action, or SET/ADD/DROP */
int location; /* token location, or -1 if unknown */
} DefElem; } DefElem;
/* /*
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "access/htup.h" #include "access/htup.h"
#include "nodes/parsenodes.h" #include "nodes/parsenodes.h"
#include "parser/parse_node.h"
#include "utils/array.h" #include "utils/array.h"
#include "utils/snapshot.h" #include "utils/snapshot.h"
...@@ -259,7 +260,7 @@ extern Datum aclexplode(PG_FUNCTION_ARGS); ...@@ -259,7 +260,7 @@ extern Datum aclexplode(PG_FUNCTION_ARGS);
* prototypes for functions in aclchk.c * prototypes for functions in aclchk.c
*/ */
extern void ExecuteGrantStmt(GrantStmt *stmt); extern void ExecuteGrantStmt(GrantStmt *stmt);
extern void ExecAlterDefaultPrivilegesStmt(AlterDefaultPrivilegesStmt *stmt); extern void ExecAlterDefaultPrivilegesStmt(ParseState *pstate, AlterDefaultPrivilegesStmt *stmt);
extern void RemoveRoleFromObjectACL(Oid roleid, Oid classid, Oid objid); extern void RemoveRoleFromObjectACL(Oid roleid, Oid classid, Oid objid);
extern void RemoveDefaultACLById(Oid defaclOid); extern void RemoveDefaultACLById(Oid defaclOid);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment