summaryrefslogtreecommitdiff
path: root/src/test/regress/expected/select_distinct.out
diff options
context:
space:
mode:
authorTom Lane2016-05-26 18:52:24 +0000
committerTom Lane2016-05-26 18:52:30 +0000
commitaeb9ae6457865c8949641d71a9523374d843a418 (patch)
tree099574b47620bae45704e7d8c725561bc411ba14 /src/test/regress/expected/select_distinct.out
parentd7ef3572a8a17cd6c495d7593ea94a2cf2c076e3 (diff)
Disable physical tlist if any Var would need multiple sortgroupref labels.
As part of upper planner pathification (commit 3fc6e2d7f5b652b4) I redid createplan.c's approach to the physical-tlist optimization, in which scan nodes are allowed to return exactly the underlying table's columns so as to save doing a projection step at runtime. The logic was intentionally more aggressive than before about applying the optimization, which is generally a good thing, but Andres Freund found a case in which it got too aggressive. Namely, if any column is referenced more than once in the parent plan node's sorting or grouping column list, we can't optimize because then that column would need to have more than one ressortgroupref label, and we only have space for one. Add logic to detect this situation in use_physical_tlist(), and also add some error checking in apply_pathtarget_labeling_to_tlist(), which this example proves was being overly cavalier about whether what it was doing made any sense. The added test case exposes the problem only because we do not eliminate duplicate grouping keys. That might be something to fix someday, but it doesn't seem like appropriate post-beta work. Report: <[email protected]>
Diffstat (limited to 'src/test/regress/expected/select_distinct.out')
-rw-r--r--src/test/regress/expected/select_distinct.out24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/test/regress/expected/select_distinct.out b/src/test/regress/expected/select_distinct.out
index 38107a04133..f3696c6d1de 100644
--- a/src/test/regress/expected/select_distinct.out
+++ b/src/test/regress/expected/select_distinct.out
@@ -125,6 +125,30 @@ SELECT DISTINCT p.age FROM person* p ORDER BY age using >;
(20 rows)
--
+-- Check mentioning same column more than once
+--
+EXPLAIN (VERBOSE, COSTS OFF)
+SELECT count(*) FROM
+ (SELECT DISTINCT two, four, two FROM tenk1) ss;
+ QUERY PLAN
+--------------------------------------------------------
+ Aggregate
+ Output: count(*)
+ -> HashAggregate
+ Output: tenk1.two, tenk1.four, tenk1.two
+ Group Key: tenk1.two, tenk1.four, tenk1.two
+ -> Seq Scan on public.tenk1
+ Output: tenk1.two, tenk1.four, tenk1.two
+(7 rows)
+
+SELECT count(*) FROM
+ (SELECT DISTINCT two, four, two FROM tenk1) ss;
+ count
+-------
+ 4
+(1 row)
+
+--
-- Also, some tests of IS DISTINCT FROM, which doesn't quite deserve its
-- very own regression file.
--