Previously, pg_upgrade failed due to the permission denied because the pg_ivm_immv catalog was in the pg_catalog catalog (Issue #79). To fix this, all objects created by pg_ivm are moved to theschema pgivm, which is also created by pg_ivm. pg_ivm is still not relocatable and this must be installed to the pgivm schema because the catalog and some internal functions are referred to unqualified by the schema name from the pg_ivm module. In future, this might be able to relocatable during installation, though. This commit affects compatibility with previous releases. To allow to access objects like create_immv function as previous, you need to qualify them with the schema name or setup search_path properly.
118 lines
2 KiB
Text
118 lines
2 KiB
Text
CREATE TABLE t (i int PRIMARY KEY);
|
|
INSERT INTO t SELECT generate_series(1, 5);
|
|
SELECT pgivm.create_immv('mv', 'SELECT * FROM t');
|
|
NOTICE: created index "mv_index" on immv "mv"
|
|
create_immv
|
|
-------------
|
|
5
|
|
(1 row)
|
|
|
|
SELECT immvrelid, ispopulated FROM pgivm.pg_ivm_immv ORDER BY 1;
|
|
immvrelid | ispopulated
|
|
-----------+-------------
|
|
mv | t
|
|
(1 row)
|
|
|
|
-- Refresh IMMV with data
|
|
SELECT pgivm.refresh_immv('mv', true);
|
|
refresh_immv
|
|
--------------
|
|
5
|
|
(1 row)
|
|
|
|
SELECT immvrelid, ispopulated FROM pgivm.pg_ivm_immv ORDER BY 1;
|
|
immvrelid | ispopulated
|
|
-----------+-------------
|
|
mv | t
|
|
(1 row)
|
|
|
|
INSERT INTO t VALUES(6);
|
|
SELECT i FROM mv ORDER BY 1;
|
|
i
|
|
---
|
|
1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
(6 rows)
|
|
|
|
-- Make IMMV unpopulated
|
|
SELECT pgivm.refresh_immv('mv', false);
|
|
refresh_immv
|
|
--------------
|
|
0
|
|
(1 row)
|
|
|
|
SELECT immvrelid, ispopulated FROM pgivm.pg_ivm_immv ORDER BY 1;
|
|
immvrelid | ispopulated
|
|
-----------+-------------
|
|
mv | f
|
|
(1 row)
|
|
|
|
SELECT i FROM mv ORDER BY 1;
|
|
i
|
|
---
|
|
(0 rows)
|
|
|
|
-- Immediate maintenance is disabled. IMMV can be scannable and is empty.
|
|
INSERT INTO t VALUES(7);
|
|
SELECT i FROM mv ORDER BY 1;
|
|
i
|
|
---
|
|
(0 rows)
|
|
|
|
-- Refresh the IMMV and make it populated.
|
|
SELECT pgivm.refresh_immv('mv', true);
|
|
refresh_immv
|
|
--------------
|
|
7
|
|
(1 row)
|
|
|
|
SELECT immvrelid, ispopulated FROM pgivm.pg_ivm_immv ORDER BY 1;
|
|
immvrelid | ispopulated
|
|
-----------+-------------
|
|
mv | t
|
|
(1 row)
|
|
|
|
SELECT i FROM mv ORDER BY 1;
|
|
i
|
|
---
|
|
1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
7
|
|
(7 rows)
|
|
|
|
-- Immediate maintenance is enabled.
|
|
INSERT INTO t VALUES(8);
|
|
SELECT i FROM mv ORDER BY 1;
|
|
i
|
|
---
|
|
1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
7
|
|
8
|
|
(8 rows)
|
|
|
|
-- Use qualified name
|
|
SELECT pgivm.refresh_immv('public.mv', true);
|
|
refresh_immv
|
|
--------------
|
|
8
|
|
(1 row)
|
|
|
|
-- Use not existing IMMV
|
|
SELECT pgivm.refresh_immv('mv_not_existing', true);
|
|
ERROR: relation "mv_not_existing" does not exist
|
|
-- Try to refresh a normal table -- error
|
|
SELECT pgivm.refresh_immv('t', true);
|
|
ERROR: "t" is not an IMMV
|