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;
} }
......
This diff is collapsed.
...@@ -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();
} }
......
This diff is collapsed.
...@@ -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