pg_ivm/expected/create_immv.out
Yugo Nagata 417c291454
Change the schema from pg_catalog to pgivm (#116)
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.
2025-02-17 12:07:21 +09:00

65 lines
2.5 KiB
Text

CREATE TABLE t (i int PRIMARY KEY);
INSERT INTO t SELECT generate_series(1, 100);
SELECT pgivm.create_immv('mv', 'SELECT * FROM t');
NOTICE: created index "mv_index" on immv "mv"
create_immv
-------------
100
(1 row)
SELECT pgivm.create_immv(' mv2 ( x ) ', 'SELECT * FROM t WHERE i%2 = 0');
NOTICE: created index "mv2_index" on immv "mv2"
create_immv
-------------
50
(1 row)
SELECT pgivm.create_immv('mv3', 'WITH d AS (DELETE FROM t RETURNING NULL) SELECT * FROM t');
ERROR: materialized views must not use data-modifying statements in WITH
SELECT immvrelid, pgivm.get_immv_def(immvrelid) FROM pgivm.pg_ivm_immv ORDER BY 1;
immvrelid | get_immv_def
-----------+-----------------------
mv | SELECT i +
| FROM t
mv2 | SELECT i AS x +
| FROM t +
| WHERE ((i % 2) = 0)
(2 rows)
-- contain immv
SELECT pgivm.create_immv('mv_in_immv01', 'SELECT i FROM mv');
ERROR: including IMMV in definition is not supported on incrementally maintainable materialized view
SELECT pgivm.create_immv('mv_in_immv02', 'SELECT t.i FROM t INNER JOIN mv2 ON t.i = mv2.x');
ERROR: including IMMV in definition is not supported on incrementally maintainable materialized view
-- SQL other than SELECT
SELECT pgivm.create_immv('mv_in_create', 'CREATE TABLE in_create(i int)');
ERROR: view definition must specify SELECT statement
SELECT pgivm.create_immv('mv_in_insert', 'INSERT INTO t VALUES(10)');
ERROR: view definition must specify SELECT statement
SELECT pgivm.create_immv('mv_in_update', 'UPDATE t SET i = 10');
ERROR: view definition must specify SELECT statement
SELECT pgivm.create_immv('mv_in_delete', 'DELETE FROM t');
ERROR: view definition must specify SELECT statement
SELECT pgivm.create_immv('mv_in_drop', 'DROP TABLE t');
ERROR: view definition must specify SELECT statement
DROP TABLE t;
ERROR: cannot drop table t because other objects depend on it
DETAIL: table mv depends on table t
table mv2 depends on table t
HINT: Use DROP ... CASCADE to drop the dependent objects too.
DROP TABLE mv;
SELECT immvrelid, pgivm.get_immv_def(immvrelid) FROM pgivm.pg_ivm_immv ORDER BY 1;
immvrelid | get_immv_def
-----------+-----------------------
mv2 | SELECT i AS x +
| FROM t +
| WHERE ((i % 2) = 0)
(1 row)
DROP TABLE mv2;
SELECT immvrelid, pgivm.get_immv_def(immvrelid) FROM pgivm.pg_ivm_immv ORDER BY 1;
immvrelid | get_immv_def
-----------+--------------
(0 rows)
DROP TABLE t;