diff options
author | Kevin Grittner <kgrittn@postgresql.org> | 2013-10-09 14:26:09 -0500 |
---|---|---|
committer | Kevin Grittner <kgrittn@postgresql.org> | 2013-10-09 14:26:09 -0500 |
commit | f566515192461acd8d9c232f48ddac3fc965cfd8 (patch) | |
tree | d8609adb64a67bcaadbd1142bd074911aa158d87 /src/backend/commands/matview.c | |
parent | 1cccce50f374cfc6081850aedce8eb0f8b274bc5 (diff) | |
download | postgresql-f566515192461acd8d9c232f48ddac3fc965cfd8.tar.gz postgresql-f566515192461acd8d9c232f48ddac3fc965cfd8.zip |
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/backend/commands/matview.c')
-rw-r--r-- | src/backend/commands/matview.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/backend/commands/matview.c b/src/backend/commands/matview.c index 238ccc72f52..fcfc678813d 100644 --- a/src/backend/commands/matview.c +++ b/src/backend/commands/matview.c @@ -562,7 +562,7 @@ refresh_by_match_merge(Oid matviewOid, Oid tempOid) "SELECT newdata FROM %s newdata " "WHERE newdata IS NOT NULL AND EXISTS " "(SELECT * FROM %s newdata2 WHERE newdata2 IS NOT NULL " - "AND newdata2 OPERATOR(pg_catalog.=) newdata " + "AND newdata2 OPERATOR(pg_catalog.*=) newdata " "AND newdata2.ctid OPERATOR(pg_catalog.<>) " "newdata.ctid) LIMIT 1", tempname, tempname); @@ -645,9 +645,6 @@ refresh_by_match_merge(Oid matviewOid, Oid tempOid) /* * Only include the column once regardless of how many times * it shows up in how many indexes. - * - * This is also useful later to omit columns which can not - * have changed from the SET clause of the UPDATE statement. */ if (usedForQual[attnum - 1]) continue; @@ -682,8 +679,9 @@ refresh_by_match_merge(Oid matviewOid, Oid tempOid) errhint("Create a UNIQUE index with no WHERE clause on one or more columns of the materialized view."))); appendStringInfoString(&querybuf, - " AND newdata = mv) WHERE newdata IS NULL OR mv IS NULL" - " ORDER BY tid"); + " AND newdata OPERATOR(pg_catalog.*=) mv) " + "WHERE newdata IS NULL OR mv IS NULL " + "ORDER BY tid"); /* Create the temporary "diff" table. */ if (SPI_exec(querybuf.data, 0) != SPI_OK_UTILITY) |