Re: bad variable subst after "AS" - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: bad variable subst after "AS"
Date
Msg-id 1284649877-sup-6411@alvh.no-ip.org
Whole thread Raw
In response to bad variable subst after "AS"  (Darren Duncan <darren@darrenduncan.net>)
Responses Re: bad variable subst after "AS"
List pgsql-hackers
Excerpts from Darren Duncan's message of jue sep 16 02:33:37 -0400 2010:

> My impression of this is that Pg is treating the "a1" after the "AS" like it was
> a variable reference and so substituted it for $1.

Yes.

> Now that just seems wrong to me.  I can understand either "a0" or "rv" getting a
> substitution, but something following an "AS" being substituted is just wrong.
> 
> Is that a bug and if not then what is the rationale for working that way, and
> can it be changed?

Fixed in 9.0.

> Meanwhile, what is the best way to write f to work around this misbehavior?

Give the column a different alias, one not colliding with a variable name.

-- 
Álvaro Herrera <alvherre@commandprompt.com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: autonomous transactions
Next
From: Magnus Hagander
Date:
Subject: Re: [BUGS] BUG #5305: Postgres service stops when closing Windows session