Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Yrxts-0002fg-9D for pgsql-bugs@arkaria.postgresql.org; Tue, 12 May 2015 00:18:20 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Yrxtr-0004r8-PV for pgsql-bugs@arkaria.postgresql.org; Tue, 12 May 2015 00:18:19 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Yrxtq-0004r0-Pa for pgsql-bugs@postgresql.org; Tue, 12 May 2015 00:18:18 +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) (envelope-from ) id 1Yrxtk-0005ch-46 for pgsql-bugs@postgresql.org; Tue, 12 May 2015 00:18:17 +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 t4C0IAmU000433; Mon, 11 May 2015 20:18:10 -0400 From: Tom Lane To: Josh Berkus cc: pgsql-bugs@postgresql.org Subject: Re: Prepare/Execute silently discards prohibited ORDER BY values In-reply-to: <555143EC.1000808@agliodbs.com> References: <555143EC.1000808@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Mon, 11 May 2015 17:06:04 -0700" Date: Mon, 11 May 2015 20:18:10 -0400 Message-ID: <432.1431389890@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) 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 Josh Berkus writes: > Tested On: 9.4.1, 9.3.6 > Severity: minor > Summary: PREPARE/EXECUTE appears to silently discard ORDER BY parameters. > josh=# prepare foo as select * from test order by $1; > PREPARE I don't see anything wrong with this. Ordering by a provably constant expression is a no-op, not an error. > What appears to be happening is that the prohibited parameter for ORDER > BY is being silently discarded during EXECUTE. At first I thought it > might just be doing ORDER BY 'test' in the background, but that's not it: > josh=# select * from test order by 'test'; > ERROR: non-integer constant in ORDER BY This error is purely a syntactic restriction, not a semantic one. There's nothing that will stop you from ordering by, say, "cos(0)"; and the planner will throw that away too. 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