summaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorTom Lane2016-05-21 16:55:31 +0000
committerTom Lane2016-05-21 16:55:31 +0000
commit82eafabeaaf12231a85ed67bbf4eae698aacb1c9 (patch)
treec339385837d7becaea12df5180dda4cb55013f19 /doc/src
parent50e5315a58554735096f7530cb766fae2dd3b0c7 (diff)
Improve docs about using ORDER BY to control aggregate input order.
David Johnston pointed out that the original text here had been obsoleted by SQL:2008, which allowed ORDER BY in subqueries. We could weaken the text to describe ORDER-BY-in-subqueries as an optional SQL feature that's possibly unportable; but then the exact same statements would apply to the alternative it's being compared to (ORDER-BY-in-aggregate-calls). So really that would be pretty useless; let's just take out the sentence entirely. Instead, point out the hazard that any extra processing in the upper query might cause the subquery output order to be destroyed. Discussion: <CAKFQuwbAX=iO9QbpN7_jr+BnUWm9FYX8WbEPUvG0p+nZhp6TZg@mail.gmail.com>
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/func.sgml5
1 files changed, 3 insertions, 2 deletions
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 3f627dc885f..ff7545de156 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -13102,8 +13102,9 @@ SELECT count(*) FROM sometable;
SELECT xmlagg(x) FROM (SELECT x FROM test ORDER BY y DESC) AS tab;
]]></screen>
- But this syntax is not allowed in the SQL standard, and is
- not portable to other database systems.
+ 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.
</para>
<para>