Add a regression test for ALTER SET TABLESPACE; this is a whole separate
code path in tablecmds.c that wasn't exercised at all before.
This commit is contained in:
parent
cac2d912d9
commit
09d09b988d
@ -28,6 +28,17 @@ CREATE INDEX foo_idx on testschema.foo(i) TABLESPACE testspace;
|
|||||||
SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c
|
SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c
|
||||||
where c.reltablespace = t.oid AND c.relname = 'foo_idx';
|
where c.reltablespace = t.oid AND c.relname = 'foo_idx';
|
||||||
|
|
||||||
|
-- let's try moving a table from one place to another
|
||||||
|
CREATE TABLE testschema.atable AS VALUES (1), (2);
|
||||||
|
CREATE UNIQUE INDEX anindex ON testschema.atable(column1);
|
||||||
|
|
||||||
|
ALTER TABLE testschema.atable SET TABLESPACE testspace;
|
||||||
|
ALTER INDEX testschema.anindex SET TABLESPACE testspace;
|
||||||
|
|
||||||
|
INSERT INTO testschema.atable VALUES(3); -- ok
|
||||||
|
INSERT INTO testschema.atable VALUES(1); -- fail (checks index)
|
||||||
|
SELECT COUNT(*) FROM testschema.atable; -- checks heap
|
||||||
|
|
||||||
-- Will fail with bad path
|
-- Will fail with bad path
|
||||||
CREATE TABLESPACE badspace LOCATION '/no/such/location';
|
CREATE TABLESPACE badspace LOCATION '/no/such/location';
|
||||||
|
|
||||||
|
@ -41,6 +41,20 @@ SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c
|
|||||||
foo_idx | testspace
|
foo_idx | testspace
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
-- let's try moving a table from one place to another
|
||||||
|
CREATE TABLE testschema.atable AS VALUES (1), (2);
|
||||||
|
CREATE UNIQUE INDEX anindex ON testschema.atable(column1);
|
||||||
|
ALTER TABLE testschema.atable SET TABLESPACE testspace;
|
||||||
|
ALTER INDEX testschema.anindex SET TABLESPACE testspace;
|
||||||
|
INSERT INTO testschema.atable VALUES(3); -- ok
|
||||||
|
INSERT INTO testschema.atable VALUES(1); -- fail (checks index)
|
||||||
|
ERROR: duplicate key violates unique constraint "anindex"
|
||||||
|
SELECT COUNT(*) FROM testschema.atable; -- checks heap
|
||||||
|
count
|
||||||
|
-------
|
||||||
|
3
|
||||||
|
(1 row)
|
||||||
|
|
||||||
-- Will fail with bad path
|
-- Will fail with bad path
|
||||||
CREATE TABLESPACE badspace LOCATION '/no/such/location';
|
CREATE TABLESPACE badspace LOCATION '/no/such/location';
|
||||||
ERROR: could not set permissions on directory "/no/such/location": No such file or directory
|
ERROR: could not set permissions on directory "/no/such/location": No such file or directory
|
||||||
@ -51,6 +65,7 @@ ERROR: tablespace "nosuchspace" does not exist
|
|||||||
DROP TABLESPACE testspace;
|
DROP TABLESPACE testspace;
|
||||||
ERROR: tablespace "testspace" is not empty
|
ERROR: tablespace "testspace" is not empty
|
||||||
DROP SCHEMA testschema CASCADE;
|
DROP SCHEMA testschema CASCADE;
|
||||||
|
NOTICE: drop cascades to table testschema.atable
|
||||||
NOTICE: drop cascades to table testschema.asexecute
|
NOTICE: drop cascades to table testschema.asexecute
|
||||||
NOTICE: drop cascades to table testschema.asselect
|
NOTICE: drop cascades to table testschema.asselect
|
||||||
NOTICE: drop cascades to table testschema.foo
|
NOTICE: drop cascades to table testschema.foo
|
||||||
|
Loading…
x
Reference in New Issue
Block a user