aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/optimizer/util/pathnode.c2
-rw-r--r--src/test/regress/expected/inherit.out23
-rw-r--r--src/test/regress/sql/inherit.sql13
3 files changed, 37 insertions, 1 deletions
diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c
index 8dbf790e893..2e1ec41a541 100644
--- a/src/backend/optimizer/util/pathnode.c
+++ b/src/backend/optimizer/util/pathnode.c
@@ -1470,7 +1470,7 @@ create_merge_append_path(PlannerInfo *root,
root,
pathkeys,
subpath->total_cost,
- subpath->parent->tuples,
+ subpath->rows,
subpath->pathtarget->width,
0.0,
work_mem,
diff --git a/src/test/regress/expected/inherit.out b/src/test/regress/expected/inherit.out
index 56a40d50f90..130a9242288 100644
--- a/src/test/regress/expected/inherit.out
+++ b/src/test/regress/expected/inherit.out
@@ -1716,6 +1716,29 @@ order by t1.b limit 10;
reset enable_nestloop;
drop table matest0 cascade;
NOTICE: drop cascades to table matest1
+-- Test a MergeAppend plan where one child requires a sort
+create table matest0(a int primary key);
+create table matest1() inherits (matest0);
+insert into matest0 select generate_series(1, 400);
+insert into matest1 select generate_series(1, 200);
+analyze matest0;
+analyze matest1;
+explain (costs off)
+select * from matest0 where a < 100 order by a;
+ QUERY PLAN
+---------------------------------------------------------------
+ Merge Append
+ Sort Key: matest0.a
+ -> Index Only Scan using matest0_pkey on matest0 matest0_1
+ Index Cond: (a < 100)
+ -> Sort
+ Sort Key: matest0_2.a
+ -> Seq Scan on matest1 matest0_2
+ Filter: (a < 100)
+(8 rows)
+
+drop table matest0 cascade;
+NOTICE: drop cascades to table matest1
--
-- Test merge-append for UNION ALL append relations
--
diff --git a/src/test/regress/sql/inherit.sql b/src/test/regress/sql/inherit.sql
index 971aac54fda..0ef9a61bc16 100644
--- a/src/test/regress/sql/inherit.sql
+++ b/src/test/regress/sql/inherit.sql
@@ -624,6 +624,19 @@ reset enable_nestloop;
drop table matest0 cascade;
+-- Test a MergeAppend plan where one child requires a sort
+create table matest0(a int primary key);
+create table matest1() inherits (matest0);
+insert into matest0 select generate_series(1, 400);
+insert into matest1 select generate_series(1, 200);
+analyze matest0;
+analyze matest1;
+
+explain (costs off)
+select * from matest0 where a < 100 order by a;
+
+drop table matest0 cascade;
+
--
-- Test merge-append for UNION ALL append relations
--