aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/expected/union.out30
-rw-r--r--src/test/regress/sql/union.sql13
2 files changed, 43 insertions, 0 deletions
diff --git a/src/test/regress/expected/union.out b/src/test/regress/expected/union.out
index d22db69c7d3..4d697bada72 100644
--- a/src/test/regress/expected/union.out
+++ b/src/test/regress/expected/union.out
@@ -720,3 +720,33 @@ select * from
drop table t3;
drop function expensivefunc(int);
+-- Test handling of appendrel quals that const-simplify into an AND
+explain (costs off)
+select * from
+ (select *, 0 as x from int8_tbl a
+ union all
+ select *, 1 as x from int8_tbl b) ss
+where (x = 0) or (q1 >= q2 and q1 <= q2);
+ QUERY PLAN
+---------------------------------------------
+ Append
+ -> Seq Scan on int8_tbl a
+ -> Seq Scan on int8_tbl b
+ Filter: ((q1 >= q2) AND (q1 <= q2))
+(4 rows)
+
+select * from
+ (select *, 0 as x from int8_tbl a
+ union all
+ select *, 1 as x from int8_tbl b) ss
+where (x = 0) or (q1 >= q2 and q1 <= q2);
+ q1 | q2 | x
+------------------+-------------------+---
+ 123 | 456 | 0
+ 123 | 4567890123456789 | 0
+ 4567890123456789 | 123 | 0
+ 4567890123456789 | 4567890123456789 | 0
+ 4567890123456789 | -4567890123456789 | 0
+ 4567890123456789 | 4567890123456789 | 1
+(6 rows)
+
diff --git a/src/test/regress/sql/union.sql b/src/test/regress/sql/union.sql
index debd99ed51b..48e6850798e 100644
--- a/src/test/regress/sql/union.sql
+++ b/src/test/regress/sql/union.sql
@@ -322,3 +322,16 @@ select * from
drop table t3;
drop function expensivefunc(int);
+
+-- Test handling of appendrel quals that const-simplify into an AND
+explain (costs off)
+select * from
+ (select *, 0 as x from int8_tbl a
+ union all
+ select *, 1 as x from int8_tbl b) ss
+where (x = 0) or (q1 >= q2 and q1 <= q2);
+select * from
+ (select *, 0 as x from int8_tbl a
+ union all
+ select *, 1 as x from int8_tbl b) ss
+where (x = 0) or (q1 >= q2 and q1 <= q2);