Re: Case in Order By Ignored without warning or error

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Francisco Olarte <folarte(at)peoplecall(dot)com>
Cc: Emiel Hermsen <s32191234(at)gmail(dot)com>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Case in Order By Ignored without warning or error
Date: 2016-06-08 14:32:52
Message-ID: 19406.1465396372@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Francisco Olarte <folarte(at)peoplecall(dot)com> writes:
> On Wed, Jun 8, 2016 at 10:39 AM, Emiel Hermsen <s32191234(at)gmail(dot)com> wrote:
>> The second option, again just my opinion, would be to change the behavior
>> where the ORDER BY clause refuses any contained content other than numbers
>> and column names combined with the ASC and DESC keywords.

> I *strongly* disagree with that.

Yeah, there is very little chance we'd change the behavior here. Some
context might help: the behavior whereby ORDER BY's arguments are names
or numbers of output columns was mandated in SQL92. SQL99, and more
recent iterations of the standard, redefined ORDER BY's arguments as
being arbitrary expressions over the input columns. Postgres attempts
to be compatible with both of those interpretations. There's no way that
we would drop the SQL99 behavior, because that's required by current
spec. Dropping the SQL92 behavior is also unpleasant to contemplate,
because it would break a lot of legacy code, and frankly "ORDER BY 1"
is just too convenient a shorthand to give up easily. So we live with
the fact that the behavior is a bit ambiguous.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Sandro Santilli 2016-06-08 16:08:00 lower integer bound not supported
Previous Message Tom Lane 2016-06-08 14:04:51 Re: [BUGS] Routine analyze of single column prevents standard autoanalyze from running at all