mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
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.
This commit is contained in:
@ -2276,3 +2276,44 @@ SELECT like_escape( name::text, ''::citext ) = like_escape( name::text, '' ) AS
|
||||
t
|
||||
(5 rows)
|
||||
|
||||
-- Ensure correct behavior for citext with materialized views.
|
||||
CREATE TABLE citext_table (
|
||||
id serial primary key,
|
||||
name citext
|
||||
);
|
||||
INSERT INTO citext_table (name)
|
||||
VALUES ('one'), ('two'), ('three'), (NULL), (NULL);
|
||||
CREATE MATERIALIZED VIEW citext_matview AS
|
||||
SELECT * FROM citext_table;
|
||||
CREATE UNIQUE INDEX citext_matview_id
|
||||
ON citext_matview (id);
|
||||
SELECT *
|
||||
FROM citext_matview m
|
||||
FULL JOIN citext_table t ON (t.id = m.id AND t *= m)
|
||||
WHERE t.id IS NULL OR m.id IS NULL;
|
||||
id | name | id | name
|
||||
----+------+----+------
|
||||
(0 rows)
|
||||
|
||||
UPDATE citext_table SET name = 'Two' WHERE name = 'TWO';
|
||||
SELECT *
|
||||
FROM citext_matview m
|
||||
FULL JOIN citext_table t ON (t.id = m.id AND t *= m)
|
||||
WHERE t.id IS NULL OR m.id IS NULL;
|
||||
id | name | id | name
|
||||
----+------+----+------
|
||||
| | 2 | Two
|
||||
2 | two | |
|
||||
(2 rows)
|
||||
|
||||
REFRESH MATERIALIZED VIEW CONCURRENTLY citext_matview;
|
||||
SELECT * FROM citext_matview ORDER BY id;
|
||||
id | name
|
||||
----+-------
|
||||
1 | one
|
||||
2 | Two
|
||||
3 | three
|
||||
4 |
|
||||
5 |
|
||||
(5 rows)
|
||||
|
||||
|
@ -2276,3 +2276,44 @@ SELECT like_escape( name::text, ''::citext ) = like_escape( name::text, '' ) AS
|
||||
t
|
||||
(5 rows)
|
||||
|
||||
-- Ensure correct behavior for citext with materialized views.
|
||||
CREATE TABLE citext_table (
|
||||
id serial primary key,
|
||||
name citext
|
||||
);
|
||||
INSERT INTO citext_table (name)
|
||||
VALUES ('one'), ('two'), ('three'), (NULL), (NULL);
|
||||
CREATE MATERIALIZED VIEW citext_matview AS
|
||||
SELECT * FROM citext_table;
|
||||
CREATE UNIQUE INDEX citext_matview_id
|
||||
ON citext_matview (id);
|
||||
SELECT *
|
||||
FROM citext_matview m
|
||||
FULL JOIN citext_table t ON (t.id = m.id AND t *= m)
|
||||
WHERE t.id IS NULL OR m.id IS NULL;
|
||||
id | name | id | name
|
||||
----+------+----+------
|
||||
(0 rows)
|
||||
|
||||
UPDATE citext_table SET name = 'Two' WHERE name = 'TWO';
|
||||
SELECT *
|
||||
FROM citext_matview m
|
||||
FULL JOIN citext_table t ON (t.id = m.id AND t *= m)
|
||||
WHERE t.id IS NULL OR m.id IS NULL;
|
||||
id | name | id | name
|
||||
----+------+----+------
|
||||
| | 2 | Two
|
||||
2 | two | |
|
||||
(2 rows)
|
||||
|
||||
REFRESH MATERIALIZED VIEW CONCURRENTLY citext_matview;
|
||||
SELECT * FROM citext_matview ORDER BY id;
|
||||
id | name
|
||||
----+-------
|
||||
1 | one
|
||||
2 | Two
|
||||
3 | three
|
||||
4 |
|
||||
5 |
|
||||
(5 rows)
|
||||
|
||||
|
@ -711,3 +711,26 @@ SELECT COUNT(*) = 19::bigint AS t FROM try;
|
||||
|
||||
SELECT like_escape( name, '' ) = like_escape( name::text, '' ) AS t FROM srt;
|
||||
SELECT like_escape( name::text, ''::citext ) = like_escape( name::text, '' ) AS t FROM srt;
|
||||
|
||||
-- Ensure correct behavior for citext with materialized views.
|
||||
CREATE TABLE citext_table (
|
||||
id serial primary key,
|
||||
name citext
|
||||
);
|
||||
INSERT INTO citext_table (name)
|
||||
VALUES ('one'), ('two'), ('three'), (NULL), (NULL);
|
||||
CREATE MATERIALIZED VIEW citext_matview AS
|
||||
SELECT * FROM citext_table;
|
||||
CREATE UNIQUE INDEX citext_matview_id
|
||||
ON citext_matview (id);
|
||||
SELECT *
|
||||
FROM citext_matview m
|
||||
FULL JOIN citext_table t ON (t.id = m.id AND t *= m)
|
||||
WHERE t.id IS NULL OR m.id IS NULL;
|
||||
UPDATE citext_table SET name = 'Two' WHERE name = 'TWO';
|
||||
SELECT *
|
||||
FROM citext_matview m
|
||||
FULL JOIN citext_table t ON (t.id = m.id AND t *= m)
|
||||
WHERE t.id IS NULL OR m.id IS NULL;
|
||||
REFRESH MATERIALIZED VIEW CONCURRENTLY citext_matview;
|
||||
SELECT * FROM citext_matview ORDER BY id;
|
||||
|
Reference in New Issue
Block a user