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