diff options
author | Tomas Vondra | 2017-08-08 10:42:37 +0000 |
---|---|---|
committer | Tomas Vondra | 2017-08-08 10:42:37 +0000 |
commit | 72889323b51d2aa5af954aa74cf8ec51d057f982 (patch) | |
tree | 341b94a5454e502bf99015628db8783a3139e326 /src/backend/executor/nodeModifyTable.c | |
parent | 89ec1d6e1212af9a95a7808ec4a999c0ba4a222c (diff) |
Use sort_pathkeys instead of query_pathkeys in standard_planner
When adding the top-level remote subquery, the code used query_pathkeys,
but that seems to be incorrect as those may be group_pathkeys, as set
by standard_qp_callback().
Consider this query from xc_groupby tests:
select count(*) from xc_groupby_def where a is not null
group by a order by 1;
planned like this
QUERY PLAN
------------------------------------------------------------
Remote Subquery Scan on all
Output: count(*), a
Sort Key: xc_groupby_def.a
-> Sort
Output: (count(*)), a
Sort Key: (count(*))
-> HashAggregate
Output: count(*), a
Group Key: xc_groupby_def.a
-> Seq Scan on public.xc_groupby_def
Output: a, b
Filter: (xc_groupby_def.a IS NOT NULL)
(12 rows)
That's clearly incorrect, because the final sort key should be count(*)
and not xc_groupby_def.a (which is, in fact the group key).
For some reason this did not cause issues on XL 9.5, but apparently the
upper-planner pathification changed the code in a way that affected the
top-level remote subquery.
To fix this, simply use sort_pathkeys instead of query_pathkeys. That
fixes the plans, and also identifies a number of additional plans in
regression tests that were in fact incorrect (but no one noticed).
Several plans stopped producing results with stable ordering, so fix that
by adding an explicit ORDER BY clause.
Diffstat (limited to 'src/backend/executor/nodeModifyTable.c')
0 files changed, 0 insertions, 0 deletions