public inbox for [email protected]
help / color / mirror / Atom feedFrom: Tom Lane <[email protected]>
To: David G. Johnston <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re: Is this example regarding aggregates sourced by subquery correct?
Date: Sat, 21 May 2016 13:02:43 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAKFQuwbsUgMVnWXObyjvZsY46pkzVF3Wm2Z7j678eA8vNJHbaQ@mail.gmail.com>
References: <CAKFQuwbAX=iO9QbpN7_jr+BnUWm9FYX8WbEPUvG0p+nZhp6TZg@mail.gmail.com>
<[email protected]>
<CAKFQuwbsUgMVnWXObyjvZsY46pkzVF3Wm2Z7j678eA8vNJHbaQ@mail.gmail.com>
List-Unsubscribe: <mailto:[email protected]?body=unsub%20pgsql-docs>
"David G. Johnston" <[email protected]> writes:
> Based upon what you've said I would soften it a bit. Given my own
> experience I'd probably point out what is now obvious to me - that the
> allowance of the ORDER BY clause is implementation specific. But I'd be
> fine chalking that up to an anomalous reading.
> Something like:
> "But permitting the sub-query's ORDER BY was only upgraded to optional in
> SQL:2008 and thus this syntax poses a portability hazard."
After further thought I realized that this gripe applies just as much
to the alternative we're comparing this to, ie, putting ORDER BY into
the aggregate call. (I've not looked up whether the two features were
introduced in exactly the same SQL version, but I am pretty sure they
are both post-SQL99.) So we might as well just take it out. What we
could usefully do instead is explain exactly what's dangerous about
using a subquery ORDER BY in this way. So I changed it to
Beware that this approach can fail if the outer query level contains
additional processing, such as a join, because that might cause the
subquery's output to be reordered before the aggregate is computed.
regards, tom lane
--
Sent via pgsql-docs mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs
view thread (5+ messages) latest in thread
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 using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: Is this example regarding aggregates sourced by subquery correct?
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox