summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Grittner <kgrittn@postgresql.org>2013-04-30 15:02:43 -0500
committerKevin Grittner <kgrittn@postgresql.org>2013-04-30 15:02:43 -0500
commit200ba1667b3a8d7a9d559d2f05f83d209c9d8267 (patch)
treecb44fabba45e75107ab6e5c69718fbc7f7d6e8d6
parent87d3b35a1ca31a9d947a8f919a6006679216dff0 (diff)
Add regression test for bug fixed by recent refactoring.
Test case by Andres Freund for bug fixed by Tom Lane's refactoring in commit 5194024d72f33fb209e10f9ab0ada7cc67df45b7
-rw-r--r--src/test/regress/expected/matview.out12
-rw-r--r--src/test/regress/sql/matview.sql7
2 files changed, 19 insertions, 0 deletions
diff --git a/src/test/regress/expected/matview.out b/src/test/regress/expected/matview.out
index 5a53f84c5b8..bda4d168aa4 100644
--- a/src/test/regress/expected/matview.out
+++ b/src/test/regress/expected/matview.out
@@ -418,3 +418,15 @@ NOTICE: drop cascades to 3 other objects
DETAIL: drop cascades to view v_test2
drop cascades to materialized view mv_test2
drop cascades to materialized view mv_test3
+-- test a corner case for "with no data" versus a query which yields no rows
+CREATE MATERIALIZED VIEW matview_unit_false AS SELECT false WHERE false WITH NO DATA;
+SELECT * FROM matview_unit_false;
+ERROR: materialized view "matview_unit_false" has not been populated
+HINT: Use the REFRESH MATERIALIZED VIEW command.
+REFRESH MATERIALIZED VIEW matview_unit_false;
+SELECT * FROM matview_unit_false;
+ bool
+------
+(0 rows)
+
+DROP MATERIALIZED VIEW matview_unit_false;
diff --git a/src/test/regress/sql/matview.sql b/src/test/regress/sql/matview.sql
index 08b48188c3c..88c4d220aff 100644
--- a/src/test/regress/sql/matview.sql
+++ b/src/test/regress/sql/matview.sql
@@ -129,3 +129,10 @@ CREATE MATERIALIZED VIEW mv_test3 AS SELECT * FROM mv_test2 WHERE moo = 12345;
SELECT pg_relation_is_scannable('mv_test3'::regclass);
DROP VIEW v_test1 CASCADE;
+
+-- test a corner case for "with no data" versus a query which yields no rows
+CREATE MATERIALIZED VIEW matview_unit_false AS SELECT false WHERE false WITH NO DATA;
+SELECT * FROM matview_unit_false;
+REFRESH MATERIALIZED VIEW matview_unit_false;
+SELECT * FROM matview_unit_false;
+DROP MATERIALIZED VIEW matview_unit_false;