On Fri, Jul 27, 2012 at 02:56:18PM +0000, boris@folgmann.de wrote:
> This is an really interesting one!
> I've trimmed down the problem so you can simply reproduce it by copy &
> paste:
> The only difference of the two functions is that the first one uses a
> variable with the same name of a column.
> This might be a feature and not a bug, but browsing through the
> documentation I could not find any documented restrictions on variable names
> in this context.
and the variable name is the problem.
generally - order by datname is understood as "order by *variable
datname*". - which is null.
change the select to:
select d.* from pg_database d order by d.datname
and now there is no more problem - because you're no longer using
ambiguous identifier.
Also, check this:
http://www.depesz.com/2009/12/16/waiting-for-8-5-plpgsql-variable-resolution/
Best regards,
depesz
--
The best thing about modern society is how easy it is to avoid contact with it.
http://depesz.com/