aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_target.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-09-01 20:42:46 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-09-01 20:42:46 +0000
commitb153c0920960a6059b67969469166fb29c0105d7 (patch)
tree4e7100ecdca88746c369ae2a6a43468925f3194d /src/backend/parser/parse_target.c
parent9ac4299163247645c6e391f5f65735c6cb78ccb9 (diff)
downloadpostgresql-b153c0920960a6059b67969469166fb29c0105d7.tar.gz
postgresql-b153c0920960a6059b67969469166fb29c0105d7.zip
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.
Diffstat (limited to 'src/backend/parser/parse_target.c')
-rw-r--r--src/backend/parser/parse_target.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c
index df87f3874cc..20d91a142f5 100644
--- a/src/backend/parser/parse_target.c
+++ b/src/backend/parser/parse_target.c
@@ -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;
+
+ newvar = makeVar(var->varno,
+ i + 1,
+ att->atttypid,
+ att->atttypmod,
+ var->varlevelsup);
+ newvar->location = var->location;
- fieldnode = (Node *) makeVar(var->varno,
- i + 1,
- att->atttypid,
- att->atttypmod,
- var->varlevelsup);
+ 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);