1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-14 18:42:34 +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:
Tom Lane
2008-09-01 20:42:46 +00:00
parent 9ac4299163
commit b153c09209
103 changed files with 1877 additions and 485 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/parse_target.c,v 1.163 2008/08/30 01:39:14 tgl Exp $
* $PostgreSQL: pgsql/src/backend/parser/parse_target.c,v 1.164 2008/09/01 20:42:44 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -45,7 +45,7 @@ static Node *transformAssignmentIndirection(ParseState *pstate,
int location);
static List *ExpandColumnRefStar(ParseState *pstate, ColumnRef *cref,
bool targetlist);
static List *ExpandAllTables(ParseState *pstate);
static List *ExpandAllTables(ParseState *pstate, int location);
static List *ExpandIndirectionStar(ParseState *pstate, A_Indirection *ind,
bool targetlist);
static int FigureColnameInternal(Node *node, char **name);
@ -836,7 +836,7 @@ ExpandColumnRefStar(ParseState *pstate, ColumnRef *cref,
* need not handle the targetlist==false case here.
*/
Assert(targetlist);
return ExpandAllTables(pstate);
return ExpandAllTables(pstate, cref->location);
}
else
{
@ -889,11 +889,12 @@ ExpandColumnRefStar(ParseState *pstate, ColumnRef *cref,
break;
}
rte = refnameRangeTblEntry(pstate, schemaname, relname,
rte = refnameRangeTblEntry(pstate, schemaname, relname, cref->location,
&sublevels_up);
if (rte == NULL)
rte = addImplicitRTE(pstate, makeRangeVar(schemaname, relname),
cref->location);
rte = addImplicitRTE(pstate,
makeRangeVar(schemaname, relname,
cref->location));
/* Require read access --- see comments in setTargetTable() */
rte->requiredPerms |= ACL_SELECT;
@ -901,12 +902,13 @@ ExpandColumnRefStar(ParseState *pstate, ColumnRef *cref,
rtindex = RTERangeTablePosn(pstate, rte, &sublevels_up);
if (targetlist)
return expandRelAttrs(pstate, rte, rtindex, sublevels_up);
return expandRelAttrs(pstate, rte, rtindex, sublevels_up,
cref->location);
else
{
List *vars;
expandRTE(rte, rtindex, sublevels_up, false,
expandRTE(rte, rtindex, sublevels_up, cref->location, false,
NULL, &vars);
return vars;
}
@ -923,7 +925,7 @@ ExpandColumnRefStar(ParseState *pstate, ColumnRef *cref,
* etc.
*/
static List *
ExpandAllTables(ParseState *pstate)
ExpandAllTables(ParseState *pstate, int location)
{
List *target = NIL;
ListCell *l;
@ -932,7 +934,8 @@ ExpandAllTables(ParseState *pstate)
if (!pstate->p_varnamespace)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("SELECT * with no tables specified is not valid")));
errmsg("SELECT * with no tables specified is not valid"),
parser_errposition(pstate, location)));
foreach(l, pstate->p_varnamespace)
{
@ -943,7 +946,8 @@ ExpandAllTables(ParseState *pstate)
rte->requiredPerms |= ACL_SELECT;
target = list_concat(target,
expandRelAttrs(pstate, rte, rtindex, 0));
expandRelAttrs(pstate, rte, rtindex, 0,
location));
}
return target;
@ -1014,12 +1018,16 @@ ExpandIndirectionStar(ParseState *pstate, A_Indirection *ind,
((Var *) expr)->varattno == InvalidAttrNumber)
{
Var *var = (Var *) expr;
Var *newvar;
fieldnode = (Node *) makeVar(var->varno,
i + 1,
att->atttypid,
att->atttypmod,
var->varlevelsup);
newvar = makeVar(var->varno,
i + 1,
att->atttypid,
att->atttypmod,
var->varlevelsup);
newvar->location = var->location;
fieldnode = (Node *) newvar;
}
else
{
@ -1088,7 +1096,7 @@ expandRecordVariable(ParseState *pstate, Var *var, int levelsup)
*lvar;
int i;
expandRTE(rte, var->varno, 0, false,
expandRTE(rte, var->varno, 0, var->location, false,
&names, &vars);
tupleDesc = CreateTemplateTupleDesc(list_length(vars), false);