mirror of
https://github.com/postgres/postgres.git
synced 2025-04-25 21:42:33 +03:00
Add regression tests for ALTER MATERIALIZED VIEW with tablespaces
The clauses SET TABLESPACE and ALL IN TABLESPACE are supported in ALTER MATERIALIZED VIEW for a long time, and they behave mostly like ALTER TABLE by reusing the same code paths, but there were zero tests for them. This commit closes the gap with new tests in tablespace.sql. Author: Yugo Nagata Discussion: https://postgr.es/m/20220316133337.5dc9740abfa24c25ec9f67f5@sraoss.co.jp
This commit is contained in:
parent
9616da3ddb
commit
ade2159bcd
@ -905,6 +905,16 @@ SELECT COUNT(*) FROM testschema.atable; -- checks heap
|
|||||||
3
|
3
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
-- let's try moving a materialized view from one place to another
|
||||||
|
CREATE MATERIALIZED VIEW testschema.amv AS SELECT * FROM testschema.atable;
|
||||||
|
ALTER MATERIALIZED VIEW testschema.amv SET TABLESPACE regress_tblspace;
|
||||||
|
REFRESH MATERIALIZED VIEW testschema.amv;
|
||||||
|
SELECT COUNT(*) FROM testschema.amv;
|
||||||
|
count
|
||||||
|
-------
|
||||||
|
3
|
||||||
|
(1 row)
|
||||||
|
|
||||||
-- Will fail with bad path
|
-- Will fail with bad path
|
||||||
CREATE TABLESPACE regress_badspace LOCATION '/no/such/location';
|
CREATE TABLESPACE regress_badspace LOCATION '/no/such/location';
|
||||||
ERROR: directory "/no/such/location" does not exist
|
ERROR: directory "/no/such/location" does not exist
|
||||||
@ -939,18 +949,22 @@ RESET ROLE;
|
|||||||
ALTER TABLESPACE regress_tblspace RENAME TO regress_tblspace_renamed;
|
ALTER TABLESPACE regress_tblspace RENAME TO regress_tblspace_renamed;
|
||||||
ALTER TABLE ALL IN TABLESPACE regress_tblspace_renamed SET TABLESPACE pg_default;
|
ALTER TABLE ALL IN TABLESPACE regress_tblspace_renamed SET TABLESPACE pg_default;
|
||||||
ALTER INDEX ALL IN TABLESPACE regress_tblspace_renamed SET TABLESPACE pg_default;
|
ALTER INDEX ALL IN TABLESPACE regress_tblspace_renamed SET TABLESPACE pg_default;
|
||||||
|
ALTER MATERIALIZED VIEW ALL IN TABLESPACE regress_tblspace_renamed SET TABLESPACE pg_default;
|
||||||
-- Should show notice that nothing was done
|
-- Should show notice that nothing was done
|
||||||
ALTER TABLE ALL IN TABLESPACE regress_tblspace_renamed SET TABLESPACE pg_default;
|
ALTER TABLE ALL IN TABLESPACE regress_tblspace_renamed SET TABLESPACE pg_default;
|
||||||
NOTICE: no matching relations in tablespace "regress_tblspace_renamed" found
|
NOTICE: no matching relations in tablespace "regress_tblspace_renamed" found
|
||||||
|
ALTER MATERIALIZED VIEW ALL IN TABLESPACE regress_tblspace_renamed SET TABLESPACE pg_default;
|
||||||
|
NOTICE: no matching relations in tablespace "regress_tblspace_renamed" found
|
||||||
-- Should succeed
|
-- Should succeed
|
||||||
DROP TABLESPACE regress_tblspace_renamed;
|
DROP TABLESPACE regress_tblspace_renamed;
|
||||||
DROP SCHEMA testschema CASCADE;
|
DROP SCHEMA testschema CASCADE;
|
||||||
NOTICE: drop cascades to 6 other objects
|
NOTICE: drop cascades to 7 other objects
|
||||||
DETAIL: drop cascades to table testschema.foo
|
DETAIL: drop cascades to table testschema.foo
|
||||||
drop cascades to table testschema.asselect
|
drop cascades to table testschema.asselect
|
||||||
drop cascades to table testschema.asexecute
|
drop cascades to table testschema.asexecute
|
||||||
drop cascades to table testschema.part
|
drop cascades to table testschema.part
|
||||||
drop cascades to table testschema.atable
|
drop cascades to table testschema.atable
|
||||||
|
drop cascades to materialized view testschema.amv
|
||||||
drop cascades to table testschema.tablespace_acl
|
drop cascades to table testschema.tablespace_acl
|
||||||
DROP ROLE regress_tablespace_user1;
|
DROP ROLE regress_tablespace_user1;
|
||||||
DROP ROLE regress_tablespace_user2;
|
DROP ROLE regress_tablespace_user2;
|
||||||
|
@ -380,6 +380,12 @@ INSERT INTO testschema.atable VALUES(3); -- ok
|
|||||||
INSERT INTO testschema.atable VALUES(1); -- fail (checks index)
|
INSERT INTO testschema.atable VALUES(1); -- fail (checks index)
|
||||||
SELECT COUNT(*) FROM testschema.atable; -- checks heap
|
SELECT COUNT(*) FROM testschema.atable; -- checks heap
|
||||||
|
|
||||||
|
-- let's try moving a materialized view from one place to another
|
||||||
|
CREATE MATERIALIZED VIEW testschema.amv AS SELECT * FROM testschema.atable;
|
||||||
|
ALTER MATERIALIZED VIEW testschema.amv SET TABLESPACE regress_tblspace;
|
||||||
|
REFRESH MATERIALIZED VIEW testschema.amv;
|
||||||
|
SELECT COUNT(*) FROM testschema.amv;
|
||||||
|
|
||||||
-- Will fail with bad path
|
-- Will fail with bad path
|
||||||
CREATE TABLESPACE regress_badspace LOCATION '/no/such/location';
|
CREATE TABLESPACE regress_badspace LOCATION '/no/such/location';
|
||||||
|
|
||||||
@ -414,9 +420,11 @@ ALTER TABLESPACE regress_tblspace RENAME TO regress_tblspace_renamed;
|
|||||||
|
|
||||||
ALTER TABLE ALL IN TABLESPACE regress_tblspace_renamed SET TABLESPACE pg_default;
|
ALTER TABLE ALL IN TABLESPACE regress_tblspace_renamed SET TABLESPACE pg_default;
|
||||||
ALTER INDEX ALL IN TABLESPACE regress_tblspace_renamed SET TABLESPACE pg_default;
|
ALTER INDEX ALL IN TABLESPACE regress_tblspace_renamed SET TABLESPACE pg_default;
|
||||||
|
ALTER MATERIALIZED VIEW ALL IN TABLESPACE regress_tblspace_renamed SET TABLESPACE pg_default;
|
||||||
|
|
||||||
-- Should show notice that nothing was done
|
-- Should show notice that nothing was done
|
||||||
ALTER TABLE ALL IN TABLESPACE regress_tblspace_renamed SET TABLESPACE pg_default;
|
ALTER TABLE ALL IN TABLESPACE regress_tblspace_renamed SET TABLESPACE pg_default;
|
||||||
|
ALTER MATERIALIZED VIEW ALL IN TABLESPACE regress_tblspace_renamed SET TABLESPACE pg_default;
|
||||||
|
|
||||||
-- Should succeed
|
-- Should succeed
|
||||||
DROP TABLESPACE regress_tblspace_renamed;
|
DROP TABLESPACE regress_tblspace_renamed;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user