summaryrefslogtreecommitdiff
path: root/src/backend/commands
diff options
context:
space:
mode:
authorPeter Eisentraut2016-09-06 16:00:00 +0000
committerPeter Eisentraut2016-09-06 16:00:00 +0000
commit49eb0fd0972d14014dd3533b1f1bf8c94c899883 (patch)
treebcbfa5cf8f49c1b73066a5c4eaf80f33fc4ecc53 /src/backend/commands
parent975768f8eae2581b89ceafe8b16a77ff375207fe (diff)
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: Pavel Stehule <[email protected]>
Diffstat (limited to 'src/backend/commands')
-rw-r--r--src/backend/commands/aggregatecmds.c7
-rw-r--r--src/backend/commands/collationcmds.c5
-rw-r--r--src/backend/commands/copy.c93
-rw-r--r--src/backend/commands/dbcommands.c61
-rw-r--r--src/backend/commands/define.c9
-rw-r--r--src/backend/commands/explain.c8
-rw-r--r--src/backend/commands/extension.c25
-rw-r--r--src/backend/commands/functioncmds.c57
-rw-r--r--src/backend/commands/sequence.c36
-rw-r--r--src/backend/commands/tsearchcmds.c8
-rw-r--r--src/backend/commands/typecmds.c8
-rw-r--r--src/backend/commands/user.c41
-rw-r--r--src/backend/commands/view.c4
13 files changed, 213 insertions, 149 deletions
diff --git a/src/backend/commands/aggregatecmds.c b/src/backend/commands/aggregatecmds.c
index d34c82c5baf..b36f09eb7b9 100644
--- a/src/backend/commands/aggregatecmds.c
+++ b/src/backend/commands/aggregatecmds.c
@@ -52,8 +52,7 @@
* "parameters" is a list of DefElem representing the agg's definition clauses.
*/
ObjectAddress
-DefineAggregate(List *name, List *args, bool oldstyle, List *parameters,
- const char *queryString)
+DefineAggregate(ParseState *pstate, List *name, List *args, bool oldstyle, List *parameters)
{
char *aggName;
Oid aggNamespace;
@@ -287,10 +286,10 @@ DefineAggregate(List *name, List *args, bool oldstyle, List *parameters,
errmsg("basetype is redundant with aggregate input type specification")));
numArgs = list_length(args);
- interpret_function_parameter_list(args,
+ interpret_function_parameter_list(pstate,
+ args,
InvalidOid,
true, /* is an aggregate */
- queryString,
&parameterTypes,
&allParameterTypes,
&parameterModes,
diff --git a/src/backend/commands/collationcmds.c b/src/backend/commands/collationcmds.c
index e4ebb654a6e..0c75d16f369 100644
--- a/src/backend/commands/collationcmds.c
+++ b/src/backend/commands/collationcmds.c
@@ -38,7 +38,7 @@
* CREATE COLLATION
*/
ObjectAddress
-DefineCollation(List *names, List *parameters)
+DefineCollation(ParseState *pstate, List *names, List *parameters)
{
char *collName;
Oid collNamespace;
@@ -78,7 +78,8 @@ DefineCollation(List *names, List *parameters)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("collation attribute \"%s\" not recognized",
- defel->defname)));
+ defel->defname),
+ parser_errposition(pstate, defel->location)));
break;
}
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index 5947e720934..e393c0b39ea 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -279,12 +279,12 @@ static const char BinarySignature[11] = "PGCOPY\n\377\r\n\0";
/* non-export function prototypes */
-static CopyState BeginCopy(bool is_from, Relation rel, Node *raw_query,
- const char *queryString, const Oid queryRelId, List *attnamelist,
+static CopyState BeginCopy(ParseState *pstate, bool is_from, Relation rel, Node *raw_query,
+ const Oid queryRelId, List *attnamelist,
List *options);
static void EndCopy(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,
List *attnamelist, List *options);
static void EndCopyTo(CopyState cstate);
@@ -787,7 +787,7 @@ CopyLoadRawBuf(CopyState cstate)
* the table or the specifically requested columns.
*/
Oid
-DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed)
+DoCopy(ParseState *pstate, const CopyStmt *stmt, uint64 *processed)
{
CopyState cstate;
bool is_from = stmt->is_from;
@@ -936,7 +936,7 @@ DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed)
PreventCommandIfReadOnly("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);
cstate->range_table = range_table;
*processed = CopyFrom(cstate); /* copy from file to database */
@@ -944,7 +944,7 @@ DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed)
}
else
{
- cstate = BeginCopyTo(rel, query, queryString, relid,
+ cstate = BeginCopyTo(pstate, rel, query, relid,
stmt->filename, stmt->is_program,
stmt->attlist, stmt->options);
*processed = DoCopyTo(cstate); /* copy from database to file */
@@ -980,7 +980,8 @@ DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed)
* self-consistency of the options list.
*/
void
-ProcessCopyOptions(CopyState cstate,
+ProcessCopyOptions(ParseState *pstate,
+ CopyState cstate,
bool is_from,
List *options)
{
@@ -1005,7 +1006,8 @@ ProcessCopyOptions(CopyState cstate,
if (format_specified)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
format_specified = true;
if (strcmp(fmt, "text") == 0)
/* default format */ ;
@@ -1016,14 +1018,16 @@ ProcessCopyOptions(CopyState cstate,
else
ereport(ERROR,
(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)
{
if (cstate->oids)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
cstate->oids = defGetBoolean(defel);
}
else if (strcmp(defel->defname, "freeze") == 0)
@@ -1031,7 +1035,8 @@ ProcessCopyOptions(CopyState cstate,
if (cstate->freeze)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
cstate->freeze = defGetBoolean(defel);
}
else if (strcmp(defel->defname, "delimiter") == 0)
@@ -1039,7 +1044,8 @@ ProcessCopyOptions(CopyState cstate,
if (cstate->delim)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
cstate->delim = defGetString(defel);
}
else if (strcmp(defel->defname, "null") == 0)
@@ -1047,7 +1053,8 @@ ProcessCopyOptions(CopyState cstate,
if (cstate->null_print)
ereport(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);
}
else if (strcmp(defel->defname, "header") == 0)
@@ -1055,7 +1062,8 @@ ProcessCopyOptions(CopyState cstate,
if (cstate->header_line)
ereport(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);
}
else if (strcmp(defel->defname, "quote") == 0)
@@ -1063,7 +1071,8 @@ ProcessCopyOptions(CopyState cstate,
if (cstate->quote)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
cstate->quote = defGetString(defel);
}
else if (strcmp(defel->defname, "escape") == 0)
@@ -1071,7 +1080,8 @@ ProcessCopyOptions(CopyState cstate,
if (cstate->escape)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
cstate->escape = defGetString(defel);
}
else if (strcmp(defel->defname, "force_quote") == 0)
@@ -1079,7 +1089,8 @@ ProcessCopyOptions(CopyState cstate,
if (cstate->force_quote || cstate->force_quote_all)
ereport(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))
cstate->force_quote_all = true;
else if (defel->arg && IsA(defel->arg, List))
@@ -1088,21 +1099,24 @@ ProcessCopyOptions(CopyState cstate,
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
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)
{
if (cstate->force_notnull)
ereport(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))
cstate->force_notnull = (List *) defel->arg;
else
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
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)
{
@@ -1116,7 +1130,8 @@ ProcessCopyOptions(CopyState cstate,
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
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)
{
@@ -1128,7 +1143,8 @@ ProcessCopyOptions(CopyState cstate,
if (cstate->convert_selectively)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
cstate->convert_selectively = true;
if (defel->arg == NULL || IsA(defel->arg, List))
cstate->convert_select = (List *) defel->arg;
@@ -1136,26 +1152,30 @@ ProcessCopyOptions(CopyState cstate,
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
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)
{
if (cstate->file_encoding >= 0)
ereport(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));
if (cstate->file_encoding < 0)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("argument to option \"%s\" must be a valid encoding name",
- defel->defname)));
+ defel->defname),
+ parser_errposition(pstate, defel->location)));
}
else
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("option \"%s\" not recognized",
- defel->defname)));
+ defel->defname),
+ parser_errposition(pstate, defel->location)));
}
/*
@@ -1318,10 +1338,10 @@ ProcessCopyOptions(CopyState cstate,
* NULL values as <null_print>.
*/
static CopyState
-BeginCopy(bool is_from,
+BeginCopy(ParseState *pstate,
+ bool is_from,
Relation rel,
Node *raw_query,
- const char *queryString,
const Oid queryRelId,
List *attnamelist,
List *options)
@@ -1345,7 +1365,7 @@ BeginCopy(bool is_from,
oldcontext = MemoryContextSwitchTo(cstate->copycontext);
/* 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 */
if (rel)
@@ -1390,7 +1410,7 @@ BeginCopy(bool is_from,
* DECLARE CURSOR and PREPARE.) XXX FIXME someday.
*/
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 */
if (rewritten == NIL)
@@ -1490,7 +1510,7 @@ BeginCopy(bool is_from,
((DR_copy *) dest)->cstate = cstate;
/* Create a QueryDesc requesting no output */
- cstate->queryDesc = CreateQueryDesc(plan, queryString,
+ cstate->queryDesc = CreateQueryDesc(plan, pstate->p_sourcetext,
GetActiveSnapshot(),
InvalidSnapshot,
dest, NULL, 0);
@@ -1678,9 +1698,9 @@ EndCopy(CopyState cstate)
* Setup CopyState to read tuples from a table or a query for COPY TO.
*/
static CopyState
-BeginCopyTo(Relation rel,
+BeginCopyTo(ParseState *pstate,
+ Relation rel,
Node *query,
- const char *queryString,
const Oid queryRelId,
const char *filename,
bool is_program,
@@ -1723,7 +1743,7 @@ BeginCopyTo(Relation rel,
RelationGetRelationName(rel))));
}
- cstate = BeginCopy(false, rel, query, queryString, queryRelId, attnamelist,
+ cstate = BeginCopy(pstate, false, rel, query, queryRelId, attnamelist,
options);
oldcontext = MemoryContextSwitchTo(cstate->copycontext);
@@ -2645,7 +2665,8 @@ CopyFromInsertBatch(CopyState cstate, EState *estate, CommandId mycid,
* Returns a CopyState, to be passed to NextCopyFrom and related functions.
*/
CopyState
-BeginCopyFrom(Relation rel,
+BeginCopyFrom(ParseState *pstate,
+ Relation rel,
const char *filename,
bool is_program,
List *attnamelist,
@@ -2666,7 +2687,7 @@ BeginCopyFrom(Relation rel,
MemoryContext oldcontext;
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);
/* Initialize state variables */
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index c1c0223770e..ef486593c00 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -96,7 +96,7 @@ static int errdetail_busy_db(int notherbackends, int npreparedxacts);
* CREATE DATABASE
*/
Oid
-createdb(const CreatedbStmt *stmt)
+createdb(ParseState *pstate, const CreatedbStmt *stmt)
{
HeapScanDesc scan;
Relation rel;
@@ -152,7 +152,8 @@ createdb(const CreatedbStmt *stmt)
if (dtablespacename)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
dtablespacename = defel;
}
else if (strcmp(defel->defname, "owner") == 0)
@@ -160,7 +161,8 @@ createdb(const CreatedbStmt *stmt)
if (downer)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
downer = defel;
}
else if (strcmp(defel->defname, "template") == 0)
@@ -168,7 +170,8 @@ createdb(const CreatedbStmt *stmt)
if (dtemplate)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
dtemplate = defel;
}
else if (strcmp(defel->defname, "encoding") == 0)
@@ -176,7 +179,8 @@ createdb(const CreatedbStmt *stmt)
if (dencoding)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
dencoding = defel;
}
else if (strcmp(defel->defname, "lc_collate") == 0)
@@ -184,7 +188,8 @@ createdb(const CreatedbStmt *stmt)
if (dcollate)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
dcollate = defel;
}
else if (strcmp(defel->defname, "lc_ctype") == 0)
@@ -192,7 +197,8 @@ createdb(const CreatedbStmt *stmt)
if (dctype)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
dctype = defel;
}
else if (strcmp(defel->defname, "is_template") == 0)
@@ -200,7 +206,8 @@ createdb(const CreatedbStmt *stmt)
if (distemplate)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
distemplate = defel;
}
else if (strcmp(defel->defname, "allow_connections") == 0)
@@ -208,7 +215,8 @@ createdb(const CreatedbStmt *stmt)
if (dallowconnections)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
dallowconnections = defel;
}
else if (strcmp(defel->defname, "connection_limit") == 0)
@@ -216,7 +224,8 @@ createdb(const CreatedbStmt *stmt)
if (dconnlimit)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
dconnlimit = defel;
}
else if (strcmp(defel->defname, "location") == 0)
@@ -224,12 +233,14 @@ createdb(const CreatedbStmt *stmt)
ereport(WARNING,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("LOCATION is not supported anymore"),
- errhint("Consider using tablespaces instead.")));
+ errhint("Consider using tablespaces instead."),
+ parser_errposition(pstate, defel->location)));
}
else
ereport(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)
@@ -249,7 +260,8 @@ createdb(const CreatedbStmt *stmt)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("%d is not a valid encoding code",
- encoding)));
+ encoding),
+ parser_errposition(pstate, dencoding->location)));
}
else
{
@@ -259,7 +271,8 @@ createdb(const CreatedbStmt *stmt)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("%s is not a valid encoding name",
- encoding_name)));
+ encoding_name),
+ parser_errposition(pstate, dencoding->location)));
}
}
if (dcollate && dcollate->arg)
@@ -1364,7 +1377,7 @@ movedb_failure_callback(int code, Datum arg)
* ALTER DATABASE name ...
*/
Oid
-AlterDatabase(AlterDatabaseStmt *stmt, bool isTopLevel)
+AlterDatabase(ParseState *pstate, AlterDatabaseStmt *stmt, bool isTopLevel)
{
Relation rel;
Oid dboid;
@@ -1394,7 +1407,8 @@ AlterDatabase(AlterDatabaseStmt *stmt, bool isTopLevel)
if (distemplate)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
distemplate = defel;
}
else if (strcmp(defel->defname, "allow_connections") == 0)
@@ -1402,7 +1416,8 @@ AlterDatabase(AlterDatabaseStmt *stmt, bool isTopLevel)
if (dallowconnections)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
dallowconnections = defel;
}
else if (strcmp(defel->defname, "connection_limit") == 0)
@@ -1410,7 +1425,8 @@ AlterDatabase(AlterDatabaseStmt *stmt, bool isTopLevel)
if (dconnlimit)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
dconnlimit = defel;
}
else if (strcmp(defel->defname, "tablespace") == 0)
@@ -1418,13 +1434,15 @@ AlterDatabase(AlterDatabaseStmt *stmt, bool isTopLevel)
if (dtablespace)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
dtablespace = defel;
}
else
ereport(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)
@@ -1438,7 +1456,8 @@ AlterDatabase(AlterDatabaseStmt *stmt, bool isTopLevel)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
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 */
PreventTransactionChain(isTopLevel, "ALTER DATABASE SET TABLESPACE");
movedb(stmt->dbname, defGetString(dtablespace));
diff --git a/src/backend/commands/define.c b/src/backend/commands/define.c
index ece803ec4bf..533926693af 100644
--- a/src/backend/commands/define.c
+++ b/src/backend/commands/define.c
@@ -319,12 +319,3 @@ defGetTypeLength(DefElem *def)
def->defname, defGetString(def))));
return 0; /* keep compiler quiet */
}
-
-/*
- * Create a DefElem setting "oids" to the specified value.
- */
-DefElem *
-defWithOids(bool value)
-{
- return makeDefElem("oids", (Node *) makeInteger(value));
-}
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
index 82ba58ef713..124743318d8 100644
--- a/src/backend/commands/explain.c
+++ b/src/backend/commands/explain.c
@@ -140,7 +140,7 @@ static void escape_yaml(StringInfo buf, const char *str);
* execute an EXPLAIN command
*/
void
-ExplainQuery(ExplainStmt *stmt, const char *queryString,
+ExplainQuery(ParseState *pstate, ExplainStmt *stmt, const char *queryString,
ParamListInfo params, DestReceiver *dest)
{
ExplainState *es = NewExplainState();
@@ -183,13 +183,15 @@ ExplainQuery(ExplainStmt *stmt, const char *queryString,
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("unrecognized value for EXPLAIN option \"%s\": \"%s\"",
- opt->defname, p)));
+ opt->defname, p),
+ parser_errposition(pstate, opt->location)));
}
else
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("unrecognized EXPLAIN option \"%s\"",
- opt->defname)));
+ opt->defname),
+ parser_errposition(pstate, opt->location)));
}
if (es->buffers && !es->analyze)
diff --git a/src/backend/commands/extension.c b/src/backend/commands/extension.c
index fa861e670b7..df49a78e2fa 100644
--- a/src/backend/commands/extension.c
+++ b/src/backend/commands/extension.c
@@ -1175,7 +1175,7 @@ find_update_path(List *evi_list,
* installed, allowing us to error out if we recurse to one of those.
*/
static ObjectAddress
-CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents)
+CreateExtensionInternal(ParseState *pstate, CreateExtensionStmt *stmt, List *parents)
{
DefElem *d_schema = NULL;
DefElem *d_new_version = NULL;
@@ -1215,7 +1215,8 @@ CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents)
if (d_schema)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
d_schema = defel;
}
else if (strcmp(defel->defname, "new_version") == 0)
@@ -1223,7 +1224,8 @@ CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents)
if (d_new_version)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
d_new_version = defel;
}
else if (strcmp(defel->defname, "old_version") == 0)
@@ -1231,7 +1233,8 @@ CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents)
if (d_old_version)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
d_old_version = defel;
}
else if (strcmp(defel->defname, "cascade") == 0)
@@ -1239,7 +1242,8 @@ CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents)
if (d_cascade)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
d_cascade = defel;
cascade = defGetBoolean(d_cascade);
}
@@ -1458,7 +1462,7 @@ CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents)
lappend(list_copy(parents), stmt->extname);
/* Create the required extension. */
- addr = CreateExtensionInternal(ces, cascade_parents);
+ addr = CreateExtensionInternal(pstate, ces, cascade_parents);
/* Get its newly-assigned OID. */
reqext = addr.objectId;
@@ -1515,7 +1519,7 @@ CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents)
* CREATE EXTENSION
*/
ObjectAddress
-CreateExtension(CreateExtensionStmt *stmt)
+CreateExtension(ParseState *pstate, CreateExtensionStmt *stmt)
{
/* Check extension name validity before any filesystem access */
check_valid_extension_name(stmt->extname);
@@ -1553,7 +1557,7 @@ CreateExtension(CreateExtensionStmt *stmt)
errmsg("nested CREATE EXTENSION is not supported")));
/* 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)
* Execute ALTER EXTENSION UPDATE
*/
ObjectAddress
-ExecAlterExtensionStmt(AlterExtensionStmt *stmt)
+ExecAlterExtensionStmt(ParseState *pstate, AlterExtensionStmt *stmt)
{
DefElem *d_new_version = NULL;
char *versionName;
@@ -2757,7 +2761,8 @@ ExecAlterExtensionStmt(AlterExtensionStmt *stmt)
if (d_new_version)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
d_new_version = defel;
}
else
diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c
index 748c8f75d48..becafc3045a 100644
--- a/src/backend/commands/functioncmds.c
+++ b/src/backend/commands/functioncmds.c
@@ -167,7 +167,6 @@ compute_return_type(TypeName *returnType, Oid languageOid,
* parameters: list of FunctionParameter structs
* languageOid: OID of function language (InvalidOid if it's CREATE AGGREGATE)
* is_aggregate: needed only to determine error handling
- * queryString: likewise, needed only for error handling
*
* Results are stored into output parameters. parameterTypes must always
* be created, but the other arrays are set to NULL if not needed.
@@ -177,10 +176,10 @@ compute_return_type(TypeName *returnType, Oid languageOid,
* else it is set to the OID of the implied result type.
*/
void
-interpret_function_parameter_list(List *parameters,
+interpret_function_parameter_list(ParseState *pstate,
+ List *parameters,
Oid languageOid,
bool is_aggregate,
- const char *queryString,
oidvector **parameterTypes,
ArrayType **allParameterTypes,
ArrayType **parameterModes,
@@ -201,7 +200,6 @@ interpret_function_parameter_list(List *parameters,
bool have_defaults = false;
ListCell *x;
int i;
- ParseState *pstate;
*variadicArgType = InvalidOid; /* default result */
*requiredResultType = InvalidOid; /* default result */
@@ -212,10 +210,6 @@ interpret_function_parameter_list(List *parameters,
paramNames = (Datum *) palloc0(parameterCount * sizeof(Datum));
*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 */
i = 0;
foreach(x, parameters)
@@ -413,8 +407,6 @@ interpret_function_parameter_list(List *parameters,
i++;
}
- free_parsestate(pstate);
-
/* Now construct the proper outputs as needed */
*parameterTypes = buildoidvector(inTypes, inCount);
@@ -458,7 +450,8 @@ interpret_function_parameter_list(List *parameters,
* SET parameters though --- if you're redundant, the last one wins.)
*/
static bool
-compute_common_attribute(DefElem *defel,
+compute_common_attribute(ParseState *pstate,
+ DefElem *defel,
DefElem **volatility_item,
DefElem **strict_item,
DefElem **security_item,
@@ -530,7 +523,8 @@ compute_common_attribute(DefElem *defel,
duplicate_error:
ereport(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 */
}
@@ -609,7 +603,8 @@ update_proconfig_value(ArrayType *a, List *set_items)
* attributes.
*/
static void
-compute_attributes_sql_style(List *options,
+compute_attributes_sql_style(ParseState *pstate,
+ List *options,
List **as,
char **language,
Node **transform,
@@ -646,7 +641,8 @@ compute_attributes_sql_style(List *options,
if (as_item)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
as_item = defel;
}
else if (strcmp(defel->defname, "language") == 0)
@@ -654,7 +650,8 @@ compute_attributes_sql_style(List *options,
if (language_item)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
language_item = defel;
}
else if (strcmp(defel->defname, "transform") == 0)
@@ -662,7 +659,8 @@ compute_attributes_sql_style(List *options,
if (transform_item)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
transform_item = defel;
}
else if (strcmp(defel->defname, "window") == 0)
@@ -670,10 +668,12 @@ compute_attributes_sql_style(List *options,
if (windowfunc_item)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
windowfunc_item = defel;
}
- else if (compute_common_attribute(defel,
+ else if (compute_common_attribute(pstate,
+ defel,
&volatility_item,
&strict_item,
&security_item,
@@ -763,7 +763,7 @@ compute_attributes_sql_style(List *options,
*------------
*/
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;
@@ -783,7 +783,8 @@ compute_attributes_with_style(List *parameters, bool *isStrict_p, char *volatili
ereport(WARNING,
(errcode(ERRCODE_SYNTAX_ERROR),
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,
* Execute a CREATE FUNCTION utility statement.
*/
ObjectAddress
-CreateFunction(CreateFunctionStmt *stmt, const char *queryString)
+CreateFunction(ParseState *pstate, CreateFunctionStmt *stmt)
{
char *probin_str;
char *prosrc_str;
@@ -915,7 +916,8 @@ CreateFunction(CreateFunctionStmt *stmt, const char *queryString)
parallel = PROPARALLEL_UNSAFE;
/* override attributes from explicit list */
- compute_attributes_sql_style(stmt->options,
+ compute_attributes_sql_style(pstate,
+ stmt->options,
&as_clause, &language, &transformDefElem,
&isWindowFunc, &volatility,
&isStrict, &security, &isLeakProof,
@@ -987,10 +989,10 @@ CreateFunction(CreateFunctionStmt *stmt, const char *queryString)
* Convert remaining parameters of CREATE to form wanted by
* ProcedureCreate.
*/
- interpret_function_parameter_list(stmt->parameters,
+ interpret_function_parameter_list(pstate,
+ stmt->parameters,
languageOid,
false, /* not an aggregate */
- queryString,
&parameterTypes,
&allParameterTypes,
&parameterModes,
@@ -1045,7 +1047,7 @@ CreateFunction(CreateFunctionStmt *stmt, const char *queryString)
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,
&prosrc_str, &probin_str);
@@ -1163,7 +1165,7 @@ RemoveFunctionById(Oid funcOid)
* ALTER framework).
*/
ObjectAddress
-AlterFunction(AlterFunctionStmt *stmt)
+AlterFunction(ParseState *pstate, AlterFunctionStmt *stmt)
{
HeapTuple tup;
Oid funcOid;
@@ -1208,7 +1210,8 @@ AlterFunction(AlterFunctionStmt *stmt)
{
DefElem *defel = (DefElem *) lfirst(l);
- if (compute_common_attribute(defel,
+ if (compute_common_attribute(pstate,
+ defel,
&volatility_item,
&strict_item,
&security_def_item,
diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c
index c98f9811119..fc3a8eebce3 100644
--- a/src/backend/commands/sequence.c
+++ b/src/backend/commands/sequence.c
@@ -94,7 +94,7 @@ static void create_seq_hashtable(void);
static void init_sequence(Oid relid, SeqTable *p_elm, Relation *p_rel);
static Form_pg_sequence read_seq_tuple(SeqTable elm, Relation rel,
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);
static void do_setval(Oid relid, int64 next, bool iscalled);
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
*/
ObjectAddress
-DefineSequence(CreateSeqStmt *seq)
+DefineSequence(ParseState *pstate, CreateSeqStmt *seq)
{
FormData_pg_sequence new;
List *owned_by;
@@ -145,7 +145,7 @@ DefineSequence(CreateSeqStmt *seq)
}
/* 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)
@@ -404,7 +404,7 @@ fill_seq_with_data(Relation rel, HeapTuple tuple)
* Modify the definition of a sequence relation
*/
ObjectAddress
-AlterSequence(AlterSeqStmt *stmt)
+AlterSequence(ParseState *pstate, AlterSeqStmt *stmt)
{
Oid relid;
SeqTable elm;
@@ -440,7 +440,7 @@ AlterSequence(AlterSeqStmt *stmt)
memcpy(&new, seq, sizeof(FormData_pg_sequence));
/* 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 */
/* Note that we do not change the currval() state */
@@ -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.
*/
static void
-init_params(List *options, bool isInit,
+init_params(ParseState *pstate, List *options, bool isInit,
Form_pg_sequence new, List **owned_by)
{
DefElem *start_value = NULL;
@@ -1186,7 +1186,8 @@ init_params(List *options, bool isInit,
if (increment_by)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
increment_by = defel;
}
else if (strcmp(defel->defname, "start") == 0)
@@ -1194,7 +1195,8 @@ init_params(List *options, bool isInit,
if (start_value)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
start_value = defel;
}
else if (strcmp(defel->defname, "restart") == 0)
@@ -1202,7 +1204,8 @@ init_params(List *options, bool isInit,
if (restart_value)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
restart_value = defel;
}
else if (strcmp(defel->defname, "maxvalue") == 0)
@@ -1210,7 +1213,8 @@ init_params(List *options, bool isInit,
if (max_value)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
max_value = defel;
}
else if (strcmp(defel->defname, "minvalue") == 0)
@@ -1218,7 +1222,8 @@ init_params(List *options, bool isInit,
if (min_value)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
min_value = defel;
}
else if (strcmp(defel->defname, "cache") == 0)
@@ -1226,7 +1231,8 @@ init_params(List *options, bool isInit,
if (cache_value)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
cache_value = defel;
}
else if (strcmp(defel->defname, "cycle") == 0)
@@ -1234,7 +1240,8 @@ init_params(List *options, bool isInit,
if (is_cycled)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
is_cycled = defel;
}
else if (strcmp(defel->defname, "owned_by") == 0)
@@ -1242,7 +1249,8 @@ init_params(List *options, bool isInit,
if (*owned_by)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
*owned_by = defGetQualifiedName(defel);
}
else
diff --git a/src/backend/commands/tsearchcmds.c b/src/backend/commands/tsearchcmds.c
index 69c038c52b1..b24011371c7 100644
--- a/src/backend/commands/tsearchcmds.c
+++ b/src/backend/commands/tsearchcmds.c
@@ -1700,7 +1700,7 @@ deserialize_deflist(Datum txt)
*wsptr++ = '\0';
result = lappend(result,
makeDefElem(pstrdup(workspace),
- (Node *) makeString(pstrdup(startvalue))));
+ (Node *) makeString(pstrdup(startvalue)), -1));
state = CS_WAITKEY;
}
}
@@ -1732,7 +1732,7 @@ deserialize_deflist(Datum txt)
*wsptr++ = '\0';
result = lappend(result,
makeDefElem(pstrdup(workspace),
- (Node *) makeString(pstrdup(startvalue))));
+ (Node *) makeString(pstrdup(startvalue)), -1));
state = CS_WAITKEY;
}
}
@@ -1747,7 +1747,7 @@ deserialize_deflist(Datum txt)
*wsptr++ = '\0';
result = lappend(result,
makeDefElem(pstrdup(workspace),
- (Node *) makeString(pstrdup(startvalue))));
+ (Node *) makeString(pstrdup(startvalue)), -1));
state = CS_WAITKEY;
}
else
@@ -1766,7 +1766,7 @@ deserialize_deflist(Datum txt)
*wsptr++ = '\0';
result = lappend(result,
makeDefElem(pstrdup(workspace),
- (Node *) makeString(pstrdup(startvalue))));
+ (Node *) makeString(pstrdup(startvalue)), -1));
}
else if (state != CS_WAITKEY)
ereport(ERROR,
diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c
index 8e7be78f651..6cc7106467d 100644
--- a/src/backend/commands/typecmds.c
+++ b/src/backend/commands/typecmds.c
@@ -111,7 +111,7 @@ static char *domainAddConstraint(Oid domainOid, Oid domainNamespace,
* Registers a new base type.
*/
ObjectAddress
-DefineType(List *names, List *parameters)
+DefineType(ParseState *pstate, List *names, List *parameters)
{
char *typeName;
Oid typeNamespace;
@@ -286,13 +286,15 @@ DefineType(List *names, List *parameters)
ereport(WARNING,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("type attribute \"%s\" not recognized",
- defel->defname)));
+ defel->defname),
+ parser_errposition(pstate, defel->location)));
continue;
}
if (*defelp != NULL)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
*defelp = defel;
}
diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c
index 821dce3ce7b..4027c89b143 100644
--- a/src/backend/commands/user.c
+++ b/src/backend/commands/user.c
@@ -69,7 +69,7 @@ have_createrole_privilege(void)
* CREATE ROLE
*/
Oid
-CreateRole(CreateRoleStmt *stmt)
+CreateRole(ParseState *pstate, CreateRoleStmt *stmt)
{
Relation pg_authid_rel;
TupleDesc pg_authid_dsc;
@@ -136,7 +136,8 @@ CreateRole(CreateRoleStmt *stmt)
if (dpassword)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
dpassword = defel;
if (strcmp(defel->defname, "encryptedPassword") == 0)
encrypt_password = true;
@@ -153,7 +154,8 @@ CreateRole(CreateRoleStmt *stmt)
if (dissuper)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
dissuper = defel;
}
else if (strcmp(defel->defname, "inherit") == 0)
@@ -161,7 +163,8 @@ CreateRole(CreateRoleStmt *stmt)
if (dinherit)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
dinherit = defel;
}
else if (strcmp(defel->defname, "createrole") == 0)
@@ -169,7 +172,8 @@ CreateRole(CreateRoleStmt *stmt)
if (dcreaterole)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
dcreaterole = defel;
}
else if (strcmp(defel->defname, "createdb") == 0)
@@ -177,7 +181,8 @@ CreateRole(CreateRoleStmt *stmt)
if (dcreatedb)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
dcreatedb = defel;
}
else if (strcmp(defel->defname, "canlogin") == 0)
@@ -185,7 +190,8 @@ CreateRole(CreateRoleStmt *stmt)
if (dcanlogin)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
dcanlogin = defel;
}
else if (strcmp(defel->defname, "isreplication") == 0)
@@ -193,7 +199,8 @@ CreateRole(CreateRoleStmt *stmt)
if (disreplication)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
disreplication = defel;
}
else if (strcmp(defel->defname, "connectionlimit") == 0)
@@ -201,7 +208,8 @@ CreateRole(CreateRoleStmt *stmt)
if (dconnlimit)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
dconnlimit = defel;
}
else if (strcmp(defel->defname, "addroleto") == 0)
@@ -209,7 +217,8 @@ CreateRole(CreateRoleStmt *stmt)
if (daddroleto)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
daddroleto = defel;
}
else if (strcmp(defel->defname, "rolemembers") == 0)
@@ -217,7 +226,8 @@ CreateRole(CreateRoleStmt *stmt)
if (drolemembers)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
drolemembers = defel;
}
else if (strcmp(defel->defname, "adminmembers") == 0)
@@ -225,7 +235,8 @@ CreateRole(CreateRoleStmt *stmt)
if (dadminmembers)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
dadminmembers = defel;
}
else if (strcmp(defel->defname, "validUntil") == 0)
@@ -233,7 +244,8 @@ CreateRole(CreateRoleStmt *stmt)
if (dvalidUntil)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
dvalidUntil = defel;
}
else if (strcmp(defel->defname, "bypassrls") == 0)
@@ -241,7 +253,8 @@ CreateRole(CreateRoleStmt *stmt)
if (dbypassRLS)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
dbypassRLS = defel;
}
else
diff --git a/src/backend/commands/view.c b/src/backend/commands/view.c
index 085bf323205..325a81096fb 100644
--- a/src/backend/commands/view.c
+++ b/src/backend/commands/view.c
@@ -434,11 +434,11 @@ DefineView(ViewStmt *stmt, const char *queryString)
if (stmt->withCheckOption == LOCAL_CHECK_OPTION)
stmt->options = lappend(stmt->options,
makeDefElem("check_option",
- (Node *) makeString("local")));
+ (Node *) makeString("local"), -1));
else if (stmt->withCheckOption == CASCADED_CHECK_OPTION)
stmt->options = lappend(stmt->options,
makeDefElem("check_option",
- (Node *) makeString("cascaded")));
+ (Node *) makeString("cascaded"), -1));
/*
* Check that the view is auto-updatable if WITH CHECK OPTION was