Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bAeYG-0007Hf-1u for pgsql-bugs@arkaria.postgresql.org; Wed, 08 Jun 2016 14:33:48 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bAeYF-0001n6-Kp for pgsql-bugs@arkaria.postgresql.org; Wed, 08 Jun 2016 14:33:47 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bAeXc-00015p-G0 for pgsql-bugs@postgresql.org; Wed, 08 Jun 2016 14:33:08 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bAeXV-00037C-5H for pgsql-bugs@postgresql.org; Wed, 08 Jun 2016 14:33:07 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u58EWqL9019407; Wed, 8 Jun 2016 10:32:52 -0400 From: Tom Lane To: Francisco Olarte cc: Emiel Hermsen , "David G. Johnston" , "pgsql-bugs@postgresql.org" Subject: Re: Case in Order By Ignored without warning or error In-reply-to: References: Comments: In-reply-to Francisco Olarte message dated "Wed, 08 Jun 2016 12:37:16 +0200" Date: Wed, 08 Jun 2016 10:32:52 -0400 Message-ID: <19406.1465396372@sss.pgh.pa.us> X-Pg-Spam-Score: -3.3 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Francisco Olarte writes: > On Wed, Jun 8, 2016 at 10:39 AM, Emiel Hermsen 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 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs