Skip to content

Commit b921a26

Browse files
Regression tests for ALTER TABLESPACE RENAME,OWNER
Hari Babu Kommi reviewed by David Rowley
1 parent b5e0a2a commit b921a26

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

src/test/regress/input/tablespace.source

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,22 @@ CREATE TABLE bar (i int) TABLESPACE nosuchspace;
5454
-- Fail, not empty
5555
DROP TABLESPACE testspace;
5656

57+
CREATE ROLE tablespace_testuser1 login;
58+
CREATE ROLE tablespace_testuser2 login;
59+
60+
ALTER TABLESPACE testspace OWNER TO tablespace_testuser1;
61+
62+
SET SESSION ROLE tablespace_testuser2;
63+
CREATE TABLE tablespace_table (i int) TABLESPACE testspace; -- fail
64+
65+
\c -
66+
67+
ALTER TABLESPACE testspace RENAME TO testspace_renamed;
68+
5769
DROP SCHEMA testschema CASCADE;
5870

5971
-- Should succeed
60-
DROP TABLESPACE testspace;
72+
DROP TABLESPACE testspace_renamed;
73+
74+
DROP ROLE tablespace_testuser1;
75+
DROP ROLE tablespace_testuser2;

src/test/regress/output/tablespace.source

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,21 @@ ERROR: tablespace "nosuchspace" does not exist
7272
-- Fail, not empty
7373
DROP TABLESPACE testspace;
7474
ERROR: tablespace "testspace" is not empty
75+
CREATE ROLE tablespace_testuser1 login;
76+
CREATE ROLE tablespace_testuser2 login;
77+
ALTER TABLESPACE testspace OWNER TO tablespace_testuser1;
78+
SET SESSION ROLE tablespace_testuser2;
79+
CREATE TABLE tablespace_table (i int) TABLESPACE testspace; -- fail
80+
ERROR: permission denied for tablespace testspace
81+
\c -
82+
ALTER TABLESPACE testspace RENAME TO testspace_renamed;
7583
DROP SCHEMA testschema CASCADE;
7684
NOTICE: drop cascades to 4 other objects
7785
DETAIL: drop cascades to table testschema.foo
7886
drop cascades to table testschema.asselect
7987
drop cascades to table testschema.asexecute
8088
drop cascades to table testschema.atable
8189
-- Should succeed
82-
DROP TABLESPACE testspace;
90+
DROP TABLESPACE testspace_renamed;
91+
DROP ROLE tablespace_testuser1;
92+
DROP ROLE tablespace_testuser2;

0 commit comments

Comments
 (0)