Re: Case in Order By Ignored without warning or error - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Case in Order By Ignored without warning or error
Date
Msg-id 19406.1465396372@sss.pgh.pa.us
Whole thread Raw
In response to Re: Case in Order By Ignored without warning or error  (Francisco Olarte <folarte@peoplecall.com>)
List pgsql-bugs
Francisco Olarte <folarte@peoplecall.com> writes:
> On Wed, Jun 8, 2016 at 10:39 AM, Emiel Hermsen <s32191234@gmail.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

pgsql-bugs by date:

Previous
From: Emiel Hermsen
Date:
Subject: Re: Case in Order By Ignored without warning or error
Next
From: Sandro Santilli
Date:
Subject: lower integer bound not supported