aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-01-02 21:43:36 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-01-02 21:43:36 +0000
commit09d09b988df4fba7c800445da73cb09a915f940c (patch)
tree74f9a99a5544bc4ae9db6eaaecabc419d5f99be4
parentcac2d912d97321bf43b2d6c50fa67154763ce5c5 (diff)
downloadpostgresql-09d09b988df4fba7c800445da73cb09a915f940c.tar.gz
postgresql-09d09b988df4fba7c800445da73cb09a915f940c.zip
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.
-rw-r--r--src/test/regress/input/tablespace.source11
-rw-r--r--src/test/regress/output/tablespace.source15
2 files changed, 26 insertions, 0 deletions
diff --git a/src/test/regress/input/tablespace.source b/src/test/regress/input/tablespace.source
index 9e2c3580947..df5479d5893 100644
--- a/src/test/regress/input/tablespace.source
+++ b/src/test/regress/input/tablespace.source
@@ -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
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
CREATE TABLESPACE badspace LOCATION '/no/such/location';
diff --git a/src/test/regress/output/tablespace.source b/src/test/regress/output/tablespace.source
index d75493fb0b6..8ab6b68f124 100644
--- a/src/test/regress/output/tablespace.source
+++ b/src/test/regress/output/tablespace.source
@@ -41,6 +41,20 @@ SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c
foo_idx | testspace
(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
CREATE TABLESPACE badspace LOCATION '/no/such/location';
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;
ERROR: tablespace "testspace" is not empty
DROP SCHEMA testschema CASCADE;
+NOTICE: drop cascades to table testschema.atable
NOTICE: drop cascades to table testschema.asexecute
NOTICE: drop cascades to table testschema.asselect
NOTICE: drop cascades to table testschema.foo