diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/regress/expected/predicate.out | 48 | ||||
-rw-r--r-- | src/test/regress/sql/predicate.sql | 27 |
2 files changed, 75 insertions, 0 deletions
diff --git a/src/test/regress/expected/predicate.out b/src/test/regress/expected/predicate.out index 60bf3e37aa6..6f1cc0d54cd 100644 --- a/src/test/regress/expected/predicate.out +++ b/src/test/regress/expected/predicate.out @@ -242,3 +242,51 @@ SELECT * FROM pred_tab t1 (9 rows) DROP TABLE pred_tab; +-- Validate we handle IS NULL and IS NOT NULL quals correctly with inheritance +-- parents. +CREATE TABLE pred_parent (a int); +CREATE TABLE pred_child () INHERITS (pred_parent); +ALTER TABLE ONLY pred_parent ALTER a SET NOT NULL; +-- Ensure that the scan on pred_child contains the IS NOT NULL qual. +EXPLAIN (COSTS OFF) +SELECT * FROM pred_parent WHERE a IS NOT NULL; + QUERY PLAN +--------------------------------------------- + Append + -> Seq Scan on pred_parent pred_parent_1 + -> Seq Scan on pred_child pred_parent_2 + Filter: (a IS NOT NULL) +(4 rows) + +-- Ensure we only scan pred_child and not pred_parent +EXPLAIN (COSTS OFF) +SELECT * FROM pred_parent WHERE a IS NULL; + QUERY PLAN +------------------------------------ + Seq Scan on pred_child pred_parent + Filter: (a IS NULL) +(2 rows) + +ALTER TABLE pred_parent ALTER a DROP NOT NULL; +ALTER TABLE pred_child ALTER a SET NOT NULL; +-- Ensure the IS NOT NULL qual is removed from the pred_child scan. +EXPLAIN (COSTS OFF) +SELECT * FROM pred_parent WHERE a IS NOT NULL; + QUERY PLAN +--------------------------------------------- + Append + -> Seq Scan on pred_parent pred_parent_1 + Filter: (a IS NOT NULL) + -> Seq Scan on pred_child pred_parent_2 +(4 rows) + +-- Ensure we only scan pred_parent and not pred_child +EXPLAIN (COSTS OFF) +SELECT * FROM pred_parent WHERE a IS NULL; + QUERY PLAN +------------------------- + Seq Scan on pred_parent + Filter: (a IS NULL) +(2 rows) + +DROP TABLE pred_parent, pred_child; diff --git a/src/test/regress/sql/predicate.sql b/src/test/regress/sql/predicate.sql index 563e395fdea..63f6a7786f3 100644 --- a/src/test/regress/sql/predicate.sql +++ b/src/test/regress/sql/predicate.sql @@ -120,3 +120,30 @@ SELECT * FROM pred_tab t1 LEFT JOIN pred_tab t3 ON t2.a IS NULL OR t2.c IS NULL; DROP TABLE pred_tab; + +-- Validate we handle IS NULL and IS NOT NULL quals correctly with inheritance +-- parents. +CREATE TABLE pred_parent (a int); +CREATE TABLE pred_child () INHERITS (pred_parent); +ALTER TABLE ONLY pred_parent ALTER a SET NOT NULL; + +-- Ensure that the scan on pred_child contains the IS NOT NULL qual. +EXPLAIN (COSTS OFF) +SELECT * FROM pred_parent WHERE a IS NOT NULL; + +-- Ensure we only scan pred_child and not pred_parent +EXPLAIN (COSTS OFF) +SELECT * FROM pred_parent WHERE a IS NULL; + +ALTER TABLE pred_parent ALTER a DROP NOT NULL; +ALTER TABLE pred_child ALTER a SET NOT NULL; + +-- Ensure the IS NOT NULL qual is removed from the pred_child scan. +EXPLAIN (COSTS OFF) +SELECT * FROM pred_parent WHERE a IS NOT NULL; + +-- Ensure we only scan pred_parent and not pred_child +EXPLAIN (COSTS OFF) +SELECT * FROM pred_parent WHERE a IS NULL; + +DROP TABLE pred_parent, pred_child; |