diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2016-09-06 12:00:00 -0400 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2016-09-06 12:00:00 -0400 |
commit | 49eb0fd0972d14014dd3533b1f1bf8c94c899883 (patch) | |
tree | bcbfa5cf8f49c1b73066a5c4eaf80f33fc4ecc53 /src/backend/commands/extension.c | |
parent | 975768f8eae2581b89ceafe8b16a77ff375207fe (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 <pavel.stehule@gmail.com>
Diffstat (limited to 'src/backend/commands/extension.c')
-rw-r--r-- | src/backend/commands/extension.c | 25 |
1 files changed, 15 insertions, 10 deletions
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 |