summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorKevin Grittner2013-10-09 19:26:09 +0000
committerKevin Grittner2013-10-09 19:26:09 +0000
commitf566515192461acd8d9c232f48ddac3fc965cfd8 (patch)
treed8609adb64a67bcaadbd1142bd074911aa158d87 /src/test
parent1cccce50f374cfc6081850aedce8eb0f8b274bc5 (diff)
Add record_image_ops opclass for matview concurrent refresh.
REFRESH MATERIALIZED VIEW CONCURRENTLY was broken for any matview containing a column of a type without a default btree operator class. It also did not produce results consistent with a non- concurrent REFRESH or a normal view if any column was of a type which allowed user-visible differences between values which compared as equal according to the type's default btree opclass. Concurrent matview refresh was modified to use the new operators to solve these problems. Documentation was added for record comparison, both for the default btree operator class for record, and the newly added operators. Regression tests now check for proper behavior both for a matview with a box column and a matview containing a citext column. Reviewed by Steve Singer, who suggested some of the doc language.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/expected/matview.out22
-rw-r--r--src/test/regress/expected/opr_sanity.out7
-rw-r--r--src/test/regress/sql/matview.sql15
3 files changed, 41 insertions, 3 deletions
diff --git a/src/test/regress/expected/matview.out b/src/test/regress/expected/matview.out
index ddaa6460953..c2bb9b0c5ef 100644
--- a/src/test/regress/expected/matview.out
+++ b/src/test/regress/expected/matview.out
@@ -412,7 +412,7 @@ ERROR: new data for "mv" contains duplicate rows without any NULL columns
DETAIL: Row: (1,10)
DROP TABLE foo CASCADE;
NOTICE: drop cascades to materialized view mv
--- make sure that all indexes covered by unique indexes works
+-- make sure that all columns covered by unique indexes works
CREATE TABLE foo(a, b, c) AS VALUES(1, 2, 3);
CREATE MATERIALIZED VIEW mv AS SELECT * FROM foo;
CREATE UNIQUE INDEX ON mv (a);
@@ -424,3 +424,23 @@ REFRESH MATERIALIZED VIEW mv;
REFRESH MATERIALIZED VIEW CONCURRENTLY mv;
DROP TABLE foo CASCADE;
NOTICE: drop cascades to materialized view mv
+-- make sure that types with unusual equality tests work
+CREATE TABLE boxes (id serial primary key, b box);
+INSERT INTO boxes (b) VALUES
+ ('(32,32),(31,31)'),
+ ('(2.0000004,2.0000004),(1,1)'),
+ ('(1.9999996,1.9999996),(1,1)');
+CREATE MATERIALIZED VIEW boxmv AS SELECT * FROM boxes;
+CREATE UNIQUE INDEX boxmv_id ON boxmv (id);
+UPDATE boxes SET b = '(2,2),(1,1)' WHERE id = 2;
+REFRESH MATERIALIZED VIEW CONCURRENTLY boxmv;
+SELECT * FROM boxmv ORDER BY id;
+ id | b
+----+-----------------------------
+ 1 | (32,32),(31,31)
+ 2 | (2,2),(1,1)
+ 3 | (1.9999996,1.9999996),(1,1)
+(3 rows)
+
+DROP TABLE boxes CASCADE;
+NOTICE: drop cascades to materialized view boxmv
diff --git a/src/test/regress/expected/opr_sanity.out b/src/test/regress/expected/opr_sanity.out
index 515cd9daaa8..57d614f6517 100644
--- a/src/test/regress/expected/opr_sanity.out
+++ b/src/test/regress/expected/opr_sanity.out
@@ -1036,13 +1036,18 @@ FROM pg_amop p1 LEFT JOIN pg_operator p2 ON amopopr = p2.oid
ORDER BY 1, 2, 3;
amopmethod | amopstrategy | oprname
------------+--------------+---------
+ 403 | 1 | *<
403 | 1 | <
403 | 1 | ~<~
+ 403 | 2 | *<=
403 | 2 | <=
403 | 2 | ~<=~
+ 403 | 3 | *=
403 | 3 | =
+ 403 | 4 | *>=
403 | 4 | >=
403 | 4 | ~>=~
+ 403 | 5 | *>
403 | 5 | >
403 | 5 | ~>~
405 | 1 | =
@@ -1098,7 +1103,7 @@ ORDER BY 1, 2, 3;
4000 | 15 | >
4000 | 16 | @>
4000 | 18 | =
-(62 rows)
+(67 rows)
-- Check that all opclass search operators have selectivity estimators.
-- This is not absolutely required, but it seems a reasonable thing
diff --git a/src/test/regress/sql/matview.sql b/src/test/regress/sql/matview.sql
index 620cbaca151..3ba6109d0b0 100644
--- a/src/test/regress/sql/matview.sql
+++ b/src/test/regress/sql/matview.sql
@@ -143,7 +143,7 @@ REFRESH MATERIALIZED VIEW mv;
REFRESH MATERIALIZED VIEW CONCURRENTLY mv;
DROP TABLE foo CASCADE;
--- make sure that all indexes covered by unique indexes works
+-- make sure that all columns covered by unique indexes works
CREATE TABLE foo(a, b, c) AS VALUES(1, 2, 3);
CREATE MATERIALIZED VIEW mv AS SELECT * FROM foo;
CREATE UNIQUE INDEX ON mv (a);
@@ -154,3 +154,16 @@ INSERT INTO foo VALUES(3, 4, 5);
REFRESH MATERIALIZED VIEW mv;
REFRESH MATERIALIZED VIEW CONCURRENTLY mv;
DROP TABLE foo CASCADE;
+
+-- make sure that types with unusual equality tests work
+CREATE TABLE boxes (id serial primary key, b box);
+INSERT INTO boxes (b) VALUES
+ ('(32,32),(31,31)'),
+ ('(2.0000004,2.0000004),(1,1)'),
+ ('(1.9999996,1.9999996),(1,1)');
+CREATE MATERIALIZED VIEW boxmv AS SELECT * FROM boxes;
+CREATE UNIQUE INDEX boxmv_id ON boxmv (id);
+UPDATE boxes SET b = '(2,2),(1,1)' WHERE id = 2;
+REFRESH MATERIALIZED VIEW CONCURRENTLY boxmv;
+SELECT * FROM boxmv ORDER BY id;
+DROP TABLE boxes CASCADE;