pg_ivm/expected/create_immv.out

50 lines
1.5 KiB
Text
Raw Normal View History

CREATE TABLE t (i int PRIMARY KEY);
INSERT INTO t SELECT generate_series(1, 100);
SELECT create_immv('mv', 'SELECT * FROM t');
NOTICE: created index "mv_index" on immv "mv"
create_immv
-------------
100
(1 row)
SELECT 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 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, get_immv_def(immvrelid) FROM 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)
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, get_immv_def(immvrelid) FROM 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, get_immv_def(immvrelid) FROM pg_ivm_immv ORDER BY 1;
immvrelid | get_immv_def
-----------+--------------
(0 rows)
DROP TABLE t;