Re: Changing a relation's name in parser stage - Mailing list pgsql-novice

From Tom Lane
Subject Re: Changing a relation's name in parser stage
Date
Msg-id 20155.1084232605@sss.pgh.pa.us
Whole thread Raw
In response to Changing a relation's name in parser stage  ("Matthias Lenz" <ml134883@inf.tu-dresden.de>)
List pgsql-novice
"Matthias Lenz" <ml134883@inf.tu-dresden.de> writes:
> List *i;
> i=nth(1, stmt->fromClause);
> ((RangeVar *) lfirst(i))->relname = "s_overall";

nth() is going to give you a list element, not a List*.  So you don't
want the lfirst() call.  I'm also dubious about whether you didn't mean
nth(0, stmt->fromClause) --- nth() counts from zero not one.  Finally,
it seems extremely fragile to assume that fromClause entries are
necessarily RangeVars without checking.  There are other node types that
could be there.

            regards, tom lane

pgsql-novice by date:

Previous
From: David Cruz
Date:
Subject: Question about REF / DREF
Next
From: Ian Pilcher
Date:
Subject: Darn pop singers!