Stabilize plan changes and ordering in xc_groupby test
authorTomas Vondra <tomas@2ndquadrant.com>
Thu, 13 Jul 2017 17:14:16 +0000 (19:14 +0200)
committerTomas Vondra <tomas@2ndquadrant.com>
Thu, 13 Jul 2017 17:14:16 +0000 (19:14 +0200)
commit4c6a467a01b129f5bbb3ce900c1a9af41c0e4ec8
tree1db7b0ae2a96dccf602985520ed857ceb670a4d2
parentde0c3732928cc408ee7d822e975969dfba31567f
Stabilize plan changes and ordering in xc_groupby test

The regression test was failing because many queries started producing
results with unstable ordering, so fix that by adding ORDER BY clause
to many of them.

This of course affects the plans that were part of the test too, so
instead of running query with ORDER BY clause and then checking plan
for a query without it, check plans for both query versions. This makes
the test somewhat bigger, but it seems to be worth it and the impact on
test duration is negligible.

Multiple query plans changed in a non-trivial ways, too. This commit
accepts changes that are clearly inherited from the upstream, which was
verified by running the query on PostgreSQL 10 and accepting simple
changes (essentially adding "Remote Subquery" to reasonable places in
the plan or "Remote Fast Query Execution" at the top).

More complicated plan changes (e.g. switching from Group Aggregate to
Hash Aggregate or back, join algorithms etc.) are left unaccepted for
additional analysis.

The SQL script also generates multiple query plans that are not included
in the expected output. This is intentional, as the generated plans are
incorrect and produce incorrect ordering of results. The bug is that
queries like

    SELECT sum(a) FROM t GROUP BY 1

end up producing results sorted by 'a' and not 'sum(a)'.
src/test/regress/expected/xc_groupby.out
src/test/regress/sql/xc_groupby.sql