mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Add a bunch of new error location reports to parse-analysis error messages.
There are still some weak spots around JOIN USING and relation alias lists, but most errors reported within backend/parser/ now have locations.
This commit is contained in:
@ -15,7 +15,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.403 2008/08/30 01:39:13 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.404 2008/09/01 20:42:44 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -722,6 +722,7 @@ _copyRangeVar(RangeVar *from)
|
||||
COPY_SCALAR_FIELD(inhOpt);
|
||||
COPY_SCALAR_FIELD(istemp);
|
||||
COPY_NODE_FIELD(alias);
|
||||
COPY_LOCATION_FIELD(location);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
@ -1773,10 +1774,11 @@ _copySortBy(SortBy *from)
|
||||
{
|
||||
SortBy *newnode = makeNode(SortBy);
|
||||
|
||||
COPY_NODE_FIELD(node);
|
||||
COPY_SCALAR_FIELD(sortby_dir);
|
||||
COPY_SCALAR_FIELD(sortby_nulls);
|
||||
COPY_NODE_FIELD(useOp);
|
||||
COPY_NODE_FIELD(node);
|
||||
COPY_LOCATION_FIELD(location);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
@ -2406,7 +2408,7 @@ _copyNotifyStmt(NotifyStmt *from)
|
||||
{
|
||||
NotifyStmt *newnode = makeNode(NotifyStmt);
|
||||
|
||||
COPY_NODE_FIELD(relation);
|
||||
COPY_STRING_FIELD(conditionname);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
@ -2416,7 +2418,7 @@ _copyListenStmt(ListenStmt *from)
|
||||
{
|
||||
ListenStmt *newnode = makeNode(ListenStmt);
|
||||
|
||||
COPY_NODE_FIELD(relation);
|
||||
COPY_STRING_FIELD(conditionname);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
@ -2426,7 +2428,7 @@ _copyUnlistenStmt(UnlistenStmt *from)
|
||||
{
|
||||
UnlistenStmt *newnode = makeNode(UnlistenStmt);
|
||||
|
||||
COPY_NODE_FIELD(relation);
|
||||
COPY_STRING_FIELD(conditionname);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.330 2008/08/30 01:39:13 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.331 2008/09/01 20:42:44 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -106,6 +106,7 @@ _equalRangeVar(RangeVar *a, RangeVar *b)
|
||||
COMPARE_SCALAR_FIELD(inhOpt);
|
||||
COMPARE_SCALAR_FIELD(istemp);
|
||||
COMPARE_NODE_FIELD(alias);
|
||||
COMPARE_LOCATION_FIELD(location);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1230,7 +1231,7 @@ _equalRuleStmt(RuleStmt *a, RuleStmt *b)
|
||||
static bool
|
||||
_equalNotifyStmt(NotifyStmt *a, NotifyStmt *b)
|
||||
{
|
||||
COMPARE_NODE_FIELD(relation);
|
||||
COMPARE_STRING_FIELD(conditionname);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1238,7 +1239,7 @@ _equalNotifyStmt(NotifyStmt *a, NotifyStmt *b)
|
||||
static bool
|
||||
_equalListenStmt(ListenStmt *a, ListenStmt *b)
|
||||
{
|
||||
COMPARE_NODE_FIELD(relation);
|
||||
COMPARE_STRING_FIELD(conditionname);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1246,7 +1247,7 @@ _equalListenStmt(ListenStmt *a, ListenStmt *b)
|
||||
static bool
|
||||
_equalUnlistenStmt(UnlistenStmt *a, UnlistenStmt *b)
|
||||
{
|
||||
COMPARE_NODE_FIELD(relation);
|
||||
COMPARE_STRING_FIELD(conditionname);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1837,10 +1838,11 @@ _equalTypeCast(TypeCast *a, TypeCast *b)
|
||||
static bool
|
||||
_equalSortBy(SortBy *a, SortBy *b)
|
||||
{
|
||||
COMPARE_NODE_FIELD(node);
|
||||
COMPARE_SCALAR_FIELD(sortby_dir);
|
||||
COMPARE_SCALAR_FIELD(sortby_nulls);
|
||||
COMPARE_NODE_FIELD(useOp);
|
||||
COMPARE_NODE_FIELD(node);
|
||||
COMPARE_LOCATION_FIELD(location);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/makefuncs.c,v 1.59 2008/08/28 23:09:46 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/makefuncs.c,v 1.60 2008/09/01 20:42:44 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -266,7 +266,7 @@ makeRelabelType(Expr *arg, Oid rtype, int32 rtypmod, CoercionForm rformat)
|
||||
* creates a RangeVar node (rather oversimplified case)
|
||||
*/
|
||||
RangeVar *
|
||||
makeRangeVar(char *schemaname, char *relname)
|
||||
makeRangeVar(char *schemaname, char *relname, int location)
|
||||
{
|
||||
RangeVar *r = makeNode(RangeVar);
|
||||
|
||||
@ -276,6 +276,7 @@ makeRangeVar(char *schemaname, char *relname)
|
||||
r->inhOpt = INH_DEFAULT;
|
||||
r->istemp = false;
|
||||
r->alias = NULL;
|
||||
r->location = location;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/nodeFuncs.c,v 1.31 2008/08/28 23:09:46 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/nodeFuncs.c,v 1.32 2008/09/01 20:42:44 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -613,6 +613,9 @@ exprLocation(Node *expr)
|
||||
return -1;
|
||||
switch (nodeTag(expr))
|
||||
{
|
||||
case T_RangeVar:
|
||||
loc = ((RangeVar *) expr)->location;
|
||||
break;
|
||||
case T_Var:
|
||||
loc = ((Var *) expr)->location;
|
||||
break;
|
||||
@ -789,6 +792,10 @@ exprLocation(Node *expr)
|
||||
/* just use argument's location */
|
||||
loc = exprLocation((Node *) ((TargetEntry *) expr)->expr);
|
||||
break;
|
||||
case T_IntoClause:
|
||||
/* use the contained RangeVar's location --- close enough */
|
||||
loc = exprLocation((Node *) ((IntoClause *) expr)->rel);
|
||||
break;
|
||||
case T_List:
|
||||
{
|
||||
/* report location of first list member that has a location */
|
||||
@ -852,6 +859,10 @@ exprLocation(Node *expr)
|
||||
loc = leftmostLoc(loc, tc->location);
|
||||
}
|
||||
break;
|
||||
case T_SortBy:
|
||||
/* just use argument's location (ignore operator, if any) */
|
||||
loc = exprLocation(((SortBy *) expr)->node);
|
||||
break;
|
||||
case T_TypeName:
|
||||
loc = ((TypeName *) expr)->location;
|
||||
break;
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.337 2008/08/30 01:39:14 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.338 2008/09/01 20:42:44 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Every node type that can appear in stored rules' parsetrees *must*
|
||||
@ -667,6 +667,7 @@ _outRangeVar(StringInfo str, RangeVar *node)
|
||||
WRITE_ENUM_FIELD(inhOpt, InhOption);
|
||||
WRITE_BOOL_FIELD(istemp);
|
||||
WRITE_NODE_FIELD(alias);
|
||||
WRITE_LOCATION_FIELD(location);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1609,7 +1610,7 @@ _outNotifyStmt(StringInfo str, NotifyStmt *node)
|
||||
{
|
||||
WRITE_NODE_TYPE("NOTIFY");
|
||||
|
||||
WRITE_NODE_FIELD(relation);
|
||||
WRITE_STRING_FIELD(conditionname);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -2038,10 +2039,11 @@ _outSortBy(StringInfo str, SortBy *node)
|
||||
{
|
||||
WRITE_NODE_TYPE("SORTBY");
|
||||
|
||||
WRITE_NODE_FIELD(node);
|
||||
WRITE_ENUM_FIELD(sortby_dir, SortByDir);
|
||||
WRITE_ENUM_FIELD(sortby_nulls, SortByNulls);
|
||||
WRITE_NODE_FIELD(useOp);
|
||||
WRITE_NODE_FIELD(node);
|
||||
WRITE_LOCATION_FIELD(location);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/readfuncs.c,v 1.213 2008/08/28 23:09:46 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/readfuncs.c,v 1.214 2008/09/01 20:42:44 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Path and Plan nodes do not have any readfuncs support, because we
|
||||
@ -179,7 +179,7 @@ _readNotifyStmt(void)
|
||||
{
|
||||
READ_LOCALS(NotifyStmt);
|
||||
|
||||
READ_NODE_FIELD(relation);
|
||||
READ_STRING_FIELD(conditionname);
|
||||
|
||||
READ_DONE();
|
||||
}
|
||||
@ -278,6 +278,7 @@ _readRangeVar(void)
|
||||
READ_ENUM_FIELD(inhOpt, InhOption);
|
||||
READ_BOOL_FIELD(istemp);
|
||||
READ_NODE_FIELD(alias);
|
||||
READ_LOCATION_FIELD(location);
|
||||
|
||||
READ_DONE();
|
||||
}
|
||||
|
Reference in New Issue
Block a user