pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Josh Berkus <josh@agliodbs.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: Prepare/Execute silently discards prohibited ORDER BY values
Date: Mon, 11 May 2015 20:18:10 -0400
Message-ID: <432.1431389890@sss.pgh.pa.us> (raw)
In-Reply-To: <555143EC.1000808@agliodbs.com>
References: <555143EC.1000808@agliodbs.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Josh Berkus <josh@agliodbs.com> 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



view thread (7+ messages)  latest in thread

Message-ID: <432.1431389890@sss.pgh.pa.us>
Permalink:  ../432.1431389890@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/432.1431389890@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, josh@agliodbs.com
  Subject: Re: Prepare/Execute silently discards prohibited ORDER BY values
  In-Reply-To: <432.1431389890@sss.pgh.pa.us>
  References: <555143EC.1000808@agliodbs.com> <432.1431389890@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox