aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_utilcmd.c
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2015-03-18 14:48:02 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2015-03-18 14:48:02 -0300
commitb8d226b4f9691c7afb986dbaaf3f6ff7b203d1b5 (patch)
tree22edcc6d4eb91685d02d0bdb8421523ecd85cb99 /src/backend/parser/parse_utilcmd.c
parent0d831389749a3baaced7b984205b9894a82444b9 (diff)
downloadpostgresql-b8d226b4f9691c7afb986dbaaf3f6ff7b203d1b5.tar.gz
postgresql-b8d226b4f9691c7afb986dbaaf3f6ff7b203d1b5.zip
Setup cursor position for schema-qualified elements
This makes any errors thrown while looking up such schemas report the position of the error. Author: Ryan Kelly Reviewed by: Jeevan Chalke, Tom Lane
Diffstat (limited to 'src/backend/parser/parse_utilcmd.c')
-rw-r--r--src/backend/parser/parse_utilcmd.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c
index 1e6da9cc40e..1bbed9582c9 100644
--- a/src/backend/parser/parse_utilcmd.c
+++ b/src/backend/parser/parse_utilcmd.c
@@ -149,6 +149,7 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString)
ListCell *elements;
Oid namespaceid;
Oid existing_relid;
+ ParseCallbackState pcbstate;
/*
* We must not scribble on the passed-in CreateStmt, so copy it. (This is
@@ -156,15 +157,22 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString)
*/
stmt = (CreateStmt *) copyObject(stmt);
+ /* Set up pstate */
+ pstate = make_parsestate(NULL);
+ pstate->p_sourcetext = queryString;
+
/*
* Look up the creation namespace. This also checks permissions on the
* target namespace, locks it against concurrent drops, checks for a
* preexisting relation in that namespace with the same name, and updates
* stmt->relation->relpersistence if the selected namespace is temporary.
*/
+ setup_parser_errposition_callback(&pcbstate, pstate,
+ stmt->relation->location);
namespaceid =
RangeVarGetAndCheckCreationNamespace(stmt->relation, NoLock,
&existing_relid);
+ cancel_parser_errposition_callback(&pcbstate);
/*
* If the relation already exists and the user specified "IF NOT EXISTS",
@@ -190,10 +198,7 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString)
&& stmt->relation->relpersistence != RELPERSISTENCE_TEMP)
stmt->relation->schemaname = get_namespace_name(namespaceid);
- /* Set up pstate and CreateStmtContext */
- pstate = make_parsestate(NULL);
- pstate->p_sourcetext = queryString;
-
+ /* Set up CreateStmtContext */
cxt.pstate = pstate;
if (IsA(stmt, CreateForeignTableStmt))
{