pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jan Wieck <JanWieck@Yahoo.com>
To: Boris Folgmann <boris@folgmann.de>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #6774: FOR IN SELECT LOOP ignores ORDER BY
Date: Mon, 30 Jul 2012 12:21:38 -0400
Message-ID: <5016B492.5030807@Yahoo.com> (raw)
In-Reply-To: <jv5lok$1bmr$1@news.hub.org>
References: <E1Sulxi-0003NK-5i@wrigleys.postgresql.org>
	<20120727160324.GA11439@depesz.com>
	<jv5lok$1bmr$1@news.hub.org>

On 7/30/2012 5:56 AM, Boris Folgmann wrote:
> Hi,
>
> hubert depesz lubaczewski schrieb/wrote:
>> generally - order by datname is understood as "order by *variable
>> datname*". - which is null.
>
> It's clear that it's a shadowing problem. But it's not a "FOR IN EXECUTE"
> where a variable makes sense. I mean why is a "ORDER BY variable" valid in
> "FOR IN"? In SQL you can't use ORDER BY NULL. If the order by clause is not
> correct the whole statement should raise an error.

Note that PL/pgSQL replaces all local variables inside a query with 
$-parameters for the prepared SPI plan. The parser rejects ordering by 
non-integer constants, but it does not reject ordering by $-parameters 
or constant expressions. (maybe it should). You can for example

     SELECT * FROM something ORDER BY 'foo'||'bar';


Jan

-- 
Anyone who trades liberty for security deserves neither
liberty nor security. -- Benjamin Franklin



view thread (5+ messages)  latest in thread

Message-ID: <5016B492.5030807@Yahoo.com>
Permalink:  ../5016B492.5030807@Yahoo.com/
Also on:    postgresql.org/message-id/5016B492.5030807@Yahoo.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: JanWieck@Yahoo.com, boris@folgmann.de
  Subject: Re: BUG #6774: FOR IN SELECT LOOP ignores ORDER BY
  In-Reply-To: <5016B492.5030807@Yahoo.com>
  References: <E1Sulxi-0003NK-5i@wrigleys.postgresql.org> <20120727160324.GA11439@depesz.com> <jv5lok$1bmr$1@news.hub.org> <5016B492.5030807@Yahoo.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