From b0c451e145be23211dce0718cc63e632959591e8 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 5 Aug 2010 18:21:19 +0000 Subject: Remove the single-argument form of string_agg(). It added nothing much in functionality, while creating an ambiguity in usage with ORDER BY that at least two people have already gotten seriously confused by. Also, add an opr_sanity test to check that we don't in future violate the newly minted policy of not having built-in aggregates with the same name and different numbers of parameters. Per discussion of a complaint from Thom Brown. --- doc/src/sgml/func.sgml | 12 ++++++------ doc/src/sgml/syntax.sgml | 11 ++++++----- 2 files changed, 12 insertions(+), 11 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 07ff132cbb5..b981ca7f920 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -1,4 +1,4 @@ - + Functions and Operators @@ -9782,7 +9782,7 @@ SELECT NULLIF(value, '(none)') ... Function - Argument Type + Argument Type(s) Return Type Description @@ -9952,17 +9952,17 @@ SELECT NULLIF(value, '(none)') ... string_agg - string_agg(expression - [, delimiter ] ) + string_agg(expression, + delimiter) - text + text, text text - input values concatenated into a string, optionally with delimiters + input values concatenated into a string, separated by delimiter diff --git a/doc/src/sgml/syntax.sgml b/doc/src/sgml/syntax.sgml index 16aa89f497f..ee2c5214aa9 100644 --- a/doc/src/sgml/syntax.sgml +++ b/doc/src/sgml/syntax.sgml @@ -1,4 +1,4 @@ - + SQL Syntax @@ -1583,16 +1583,17 @@ SELECT array_agg(a ORDER BY b DESC) FROM table; When dealing with multiple-argument aggregate functions, note that the ORDER BY clause goes after all the aggregate arguments. - For example, this: + For example, write this: SELECT string_agg(a, ',' ORDER BY a) FROM table; not this: -SELECT string_agg(a ORDER BY a, ',') FROM table; -- not what you want +SELECT string_agg(a ORDER BY a, ',') FROM table; -- incorrect - The latter syntax will be accepted, but ',' will be - treated as a (useless) sort key. + The latter is syntactically valid, but it represents a call of a + single-argument aggregate function with two ORDER BY keys + (the second one being rather useless since it's a constant). -- cgit v1.2.3