Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit09d09b9

Browse files
committed
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.
1 parentcac2d91 commit09d09b9

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

‎src/test/regress/input/tablespace.source

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ CREATE INDEX foo_idx on testschema.foo(i) TABLESPACE testspace;
2828
SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c
2929
where c.reltablespace = t.oid AND c.relname = 'foo_idx';
3030

31+
-- let's try moving a table from one place to another
32+
CREATE TABLE testschema.atable AS VALUES (1), (2);
33+
CREATE UNIQUE INDEX anindex ON testschema.atable(column1);
34+
35+
ALTER TABLE testschema.atable SET TABLESPACE testspace;
36+
ALTER INDEX testschema.anindex SET TABLESPACE testspace;
37+
38+
INSERT INTO testschema.atable VALUES(3);-- ok
39+
INSERT INTO testschema.atable VALUES(1);-- fail (checks index)
40+
SELECT COUNT(*) FROM testschema.atable;-- checks heap
41+
3142
-- Will fail with bad path
3243
CREATE TABLESPACE badspace LOCATION '/no/such/location';
3344

‎src/test/regress/output/tablespace.source

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,20 @@ SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c
4141
foo_idx | testspace
4242
(1 row)
4343

44+
-- let's try moving a table from one place to another
45+
CREATE TABLE testschema.atable AS VALUES (1), (2);
46+
CREATE UNIQUE INDEX anindex ON testschema.atable(column1);
47+
ALTER TABLE testschema.atable SET TABLESPACE testspace;
48+
ALTER INDEX testschema.anindex SET TABLESPACE testspace;
49+
INSERT INTO testschema.atable VALUES(3);-- ok
50+
INSERT INTO testschema.atable VALUES(1);-- fail (checks index)
51+
ERROR: duplicate key violates unique constraint "anindex"
52+
SELECT COUNT(*) FROM testschema.atable;-- checks heap
53+
count
54+
-------
55+
3
56+
(1 row)
57+
4458
-- Will fail with bad path
4559
CREATE TABLESPACE badspace LOCATION '/no/such/location';
4660
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
5165
DROP TABLESPACE testspace;
5266
ERROR: tablespace "testspace" is not empty
5367
DROP SCHEMA testschema CASCADE;
68+
NOTICE: drop cascades to table testschema.atable
5469
NOTICE: drop cascades to table testschema.asexecute
5570
NOTICE: drop cascades to table testschema.asselect
5671
NOTICE: drop cascades to table testschema.foo

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp