pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: zoolus . <700671@gmail.com>
Cc: Postgres Bug <pgsql-bugs@postgresql.org>
Subject: Re: weird behavior of ORDER BY
Date: Thu, 26 Apr 2018 09:21:13 -0400
Message-ID: <8451.1524748873@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwbN2T=Xo5jy-s5C6kznqwWs9xSx0WWNUT_sdH2Bi68eEQ@mail.gmail.com>
References: <CAHtc1SN0ygD1TNEg0UkzLJKtSVuKGLwrEY8oofPH4+fbo2Rdjw@mail.gmail.com>
	<CAHtc1SNjd15c-QzG=NqWPkceSyyv0O-YH0YEU6uzJmT0-ZhGJw@mail.gmail.com>
	<CAKFQuwbN2T=Xo5jy-s5C6kznqwWs9xSx0WWNUT_sdH2Bi68eEQ@mail.gmail.com>

"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Thu, Apr 26, 2018 at 2:29 AM, zoolus . <700671@gmail.com> wrote:
>> I think any "ORDER BY" construct can't filter result set.

> ​While a bit surprising I don't really have a problem with it.  I suppose I
> would have expected that set-returning-functions in ORDER BY would be
> prohibited but absent that restriction this result is consistent with other
> behavior: if you had placed the unnest in the select-list and done "ORDER
> BY #" to reference it you would have achieved the same result.

Indeed.  Consider also the case where the SRF in ORDER BY produces more
than one output per input row --- how many result rows do you expect to
get then?  If you don't like reasoning about these cases, don't use a
SRF in ORDER BY.

			regards, tom lane




view thread (3+ messages)

Message-ID: <8451.1524748873@sss.pgh.pa.us>
Permalink:  ../8451.1524748873@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/8451.1524748873@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, david.g.johnston@gmail.com, 700671@gmail.com
  Subject: Re: weird behavior of ORDER BY
  In-Reply-To: <8451.1524748873@sss.pgh.pa.us>
  References: <CAHtc1SN0ygD1TNEg0UkzLJKtSVuKGLwrEY8oofPH4+fbo2Rdjw@mail.gmail.com> <CAHtc1SNjd15c-QzG=NqWPkceSyyv0O-YH0YEU6uzJmT0-ZhGJw@mail.gmail.com> <CAKFQuwbN2T=Xo5jy-s5C6kznqwWs9xSx0WWNUT_sdH2Bi68eEQ@mail.gmail.com> <8451.1524748873@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