mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +03:00
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 <pavel.stehule@gmail.com>
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user