pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: hubert depesz lubaczewski <depesz@depesz.com>
To: boris@folgmann.de
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #6774: FOR IN SELECT LOOP ignores ORDER BY
Date: Fri, 27 Jul 2012 18:03:24 +0200
Message-ID: <20120727160324.GA11439@depesz.com> (raw)
In-Reply-To: <E1Sulxi-0003NK-5i@wrigleys.postgresql.org>
References: <E1Sulxi-0003NK-5i@wrigleys.postgresql.org>

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/



view thread (5+ messages)  latest in thread

Message-ID: <20120727160324.GA11439@depesz.com>
Permalink:  ../20120727160324.GA11439@depesz.com/
Also on:    postgresql.org/message-id/20120727160324.GA11439@depesz.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: depesz@depesz.com, boris@folgmann.de
  Subject: Re: BUG #6774: FOR IN SELECT LOOP ignores ORDER BY
  In-Reply-To: <20120727160324.GA11439@depesz.com>
  References: <E1Sulxi-0003NK-5i@wrigleys.postgresql.org> <20120727160324.GA11439@depesz.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox