5
CREATE USER regression_user;
6
CREATE USER regression_user2;
7
CREATE USER regression_user3;
8
CREATE GROUP regression_group;
10
CREATE TABLE deptest (f1 serial primary key, f2 text);
12
GRANT SELECT ON TABLE deptest TO GROUP regression_group;
13
GRANT ALL ON TABLE deptest TO regression_user, regression_user2;
15
-- can't drop neither because they have privileges somewhere
16
DROP USER regression_user;
17
DROP GROUP regression_group;
19
-- if we revoke the privileges we can drop the group
20
REVOKE SELECT ON deptest FROM GROUP regression_group;
21
DROP GROUP regression_group;
23
-- can't drop the user if we revoke the privileges partially
24
REVOKE SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES ON deptest FROM regression_user;
25
DROP USER regression_user;
27
-- now we are OK to drop him
28
REVOKE TRIGGER ON deptest FROM regression_user;
29
DROP USER regression_user;
31
-- we are OK too if we drop the privileges all at once
32
REVOKE ALL ON deptest FROM regression_user2;
33
DROP USER regression_user2;
35
-- can't drop the owner of an object
36
-- the error message detail here would include a pg_toast_nnn name that
37
-- is not constant, so suppress it
39
ALTER TABLE deptest OWNER TO regression_user3;
40
DROP USER regression_user3;
42
\set VERBOSITY default
43
-- if we drop the object, we can drop the user too
45
DROP USER regression_user3;
48
CREATE USER regression_user0;
49
CREATE USER regression_user1;
50
CREATE USER regression_user2;
51
SET SESSION AUTHORIZATION regression_user0;
53
DROP OWNED BY regression_user1;
54
DROP OWNED BY regression_user0, regression_user2;
55
REASSIGN OWNED BY regression_user0 TO regression_user1;
56
REASSIGN OWNED BY regression_user1 TO regression_user0;
57
-- this one is allowed
58
DROP OWNED BY regression_user0;
60
CREATE TABLE deptest1 (f1 int unique);
61
GRANT ALL ON deptest1 TO regression_user1 WITH GRANT OPTION;
63
SET SESSION AUTHORIZATION regression_user1;
64
CREATE TABLE deptest (a serial primary key, b text);
65
GRANT ALL ON deptest1 TO regression_user2;
66
RESET SESSION AUTHORIZATION;
69
DROP OWNED BY regression_user1;
75
-- Test REASSIGN OWNED
76
GRANT ALL ON deptest1 TO regression_user1;
78
SET SESSION AUTHORIZATION regression_user1;
79
CREATE TABLE deptest (a serial primary key, b text);
81
CREATE TABLE deptest2 (f1 int);
82
-- make a serial column the hard way
84
ALTER TABLE deptest2 ALTER f1 SET DEFAULT nextval('ss1');
85
ALTER SEQUENCE ss1 OWNED BY deptest2.f1;
86
RESET SESSION AUTHORIZATION;
88
REASSIGN OWNED BY regression_user1 TO regression_user2;
91
-- doesn't work: grant still exists
92
DROP USER regression_user1;
93
DROP OWNED BY regression_user1;
94
DROP USER regression_user1;
97
DROP USER regression_user2;
98
DROP OWNED BY regression_user2, regression_user0;
99
DROP USER regression_user2;
100
DROP USER regression_user0;