1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-30 06:01:21 +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:
Peter Eisentraut
2016-09-06 12:00:00 -04:00
parent 975768f8ea
commit 49eb0fd097
38 changed files with 438 additions and 347 deletions

View File

@@ -2676,6 +2676,7 @@ _copyDefElem(const DefElem *from)
COPY_STRING_FIELD(defname);
COPY_NODE_FIELD(arg);
COPY_SCALAR_FIELD(defaction);
COPY_LOCATION_FIELD(location);
return newnode;
}

View File

@@ -2424,6 +2424,7 @@ _equalDefElem(const DefElem *a, const DefElem *b)
COMPARE_STRING_FIELD(defname);
COMPARE_NODE_FIELD(arg);
COMPARE_SCALAR_FIELD(defaction);
COMPARE_LOCATION_FIELD(location);
return true;
}
@@ -2434,6 +2435,7 @@ _equalLockingClause(const LockingClause *a, const LockingClause *b)
COMPARE_NODE_FIELD(lockedRels);
COMPARE_SCALAR_FIELD(strength);
COMPARE_SCALAR_FIELD(waitPolicy);
COMPARE_LOCATION_FIELD(location);
return true;
}

View File

@@ -540,7 +540,7 @@ makeFuncExpr(Oid funcid, Oid rettype, List *args,
* and no special action.
*/
DefElem *
makeDefElem(char *name, Node *arg)
makeDefElem(char *name, Node *arg, int location)
{
DefElem *res = makeNode(DefElem);
@@ -548,6 +548,7 @@ makeDefElem(char *name, Node *arg)
res->defname = name;
res->arg = arg;
res->defaction = DEFELEM_UNSPEC;
res->location = location;
return res;
}
@@ -558,7 +559,7 @@ makeDefElem(char *name, Node *arg)
*/
DefElem *
makeDefElemExtended(char *nameSpace, char *name, Node *arg,
DefElemAction defaction)
DefElemAction defaction, int location)
{
DefElem *res = makeNode(DefElem);
@@ -566,6 +567,7 @@ makeDefElemExtended(char *nameSpace, char *name, Node *arg,
res->defname = name;
res->arg = arg;
res->defaction = defaction;
res->location = location;
return res;
}

View File

@@ -2542,6 +2542,7 @@ _outDefElem(StringInfo str, const DefElem *node)
WRITE_STRING_FIELD(defname);
WRITE_NODE_FIELD(arg);
WRITE_ENUM_FIELD(defaction, DefElemAction);
WRITE_LOCATION_FIELD(location);
}
static void

View File

@@ -1388,6 +1388,7 @@ _readDefElem(void)
READ_STRING_FIELD(defname);
READ_NODE_FIELD(arg);
READ_ENUM_FIELD(defaction, DefElemAction);
READ_LOCATION_FIELD(location);
READ_DONE();
}