I've been running some aggregation queries in PostgreSQL 9.6.6 for some time, but the same query under 10.1 throws errors and produces results in a different order.
demo=# select id, grouping (id), sum(qty) from tags group by rollup(id); id | grouping | sum -----+----------+----- | 1 | 60 A01 | 0 | 10 A03 | 0 | 30 A02 | 0 | 20 (4 rows)
demo=# select unnest(tags), grouping (unnest(tags)), sum(qty) from tags group by rollup(unnest(tags)); ERROR: aggregate function calls cannot contain set-returning function calls LINE 1: select unnest(tags), grouping (unnest(tags)), sum(qty) from ... ^ HINT: You might be able to move the set-returning function into a LATERAL FROM item. demo=#
Question 1: Was the ordering of the aggregate rows always undefined? Under 9.6.6 it was always at the end of the base rows, under 10.1 it seems to be usually at the beginning of the corresponding block of base rows.
Question 2: Is the error regarding aggregate function calls under 10.1 as planned or is it a bug?