Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 35AE416AF4E5 for ; Mon, 30 Jul 2012 13:36:33 -0300 (ADT) Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SvsxM-0001Vr-5N for pgsql-bugs@postgresql.org; Mon, 30 Jul 2012 16:36:32 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id q6UGaDFK001187; Mon, 30 Jul 2012 12:36:13 -0400 (EDT) From: Tom Lane To: Jan Wieck cc: Boris Folgmann , pgsql-bugs@postgresql.org Subject: Re: BUG #6774: FOR IN SELECT LOOP ignores ORDER BY In-reply-to: <5016B492.5030807@Yahoo.com> References: <20120727160324.GA11439@depesz.com> <5016B492.5030807@Yahoo.com> Comments: In-reply-to Jan Wieck message dated "Mon, 30 Jul 2012 12:21:38 -0400" Date: Mon, 30 Jul 2012 12:36:13 -0400 Message-ID: <1186.1343666173@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201207/235 X-Sequence-Number: 33711 Jan Wieck writes: > 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). The only real reason it complains about simple constants is that otherwise people might think "ORDER BY 1" means something different than what it does mean according to SQL92. Otherwise, if you want to sort by a constant, who are we to stop you? regards, tom lane