Debian Codegraph @

src/test/modules/unsafe_tests/expected/alter_system_table.out

raw
1 --
2 -- Tests for things affected by allow_system_table_mods
3 --
4 -- We run the same set of commands once with allow_system_table_mods
5 -- off and then again with on.
6 --
7 -- The "on" tests should where possible be wrapped in BEGIN/ROLLBACK
8 -- blocks so as to not leave a mess around.
9 CREATE USER regress_user_ast;
10 SET allow_system_table_mods = off;
11 -- create new table in pg_catalog
12 CREATE TABLE pg_catalog.test (a int);
13 ERROR: permission denied to create "pg_catalog.test"
14 DETAIL: System catalog modifications are currently disallowed.
15 -- anyarray column
16 CREATE TABLE t1x (a int, b anyarray);
17 ERROR: column "b" has pseudo-type anyarray
18 -- index on system catalog
19 ALTER TABLE pg_namespace ADD CONSTRAINT foo UNIQUE USING INDEX pg_namespace_nspname_index;
20 ERROR: permission denied: "pg_namespace" is a system catalog
21 -- write to system catalog table as superuser
22 -- (allowed even without allow_system_table_mods)
23 INSERT INTO pg_description (objoid, classoid, objsubid, description) VALUES (0, 0, 0, 'foo');
24 -- write to system catalog table as normal user
25 GRANT INSERT ON pg_description TO regress_user_ast;
26 SET ROLE regress_user_ast;
27 INSERT INTO pg_description (objoid, classoid, objsubid, description) VALUES (0, 0, 1, 'foo');
28 ERROR: permission denied for table pg_description
29 RESET ROLE;
30 -- policy on system catalog
31 CREATE POLICY foo ON pg_description FOR SELECT USING (description NOT LIKE 'secret%');
32 ERROR: permission denied: "pg_description" is a system catalog
33 -- reserved schema name
34 CREATE SCHEMA pg_foo;
35 ERROR: unacceptable schema name "pg_foo"
36 DETAIL: The prefix "pg_" is reserved for system schemas.
37 -- drop system table
38 DROP TABLE pg_description;
39 ERROR: permission denied: "pg_description" is a system catalog
40 -- truncate of system table
41 TRUNCATE pg_description;
42 ERROR: permission denied: "pg_description" is a system catalog
43 -- rename column of system table
44 ALTER TABLE pg_description RENAME COLUMN description TO comment;
45 ERROR: permission denied: "pg_description" is a system catalog
46 -- ATSimplePermissions()
47 ALTER TABLE pg_description ALTER COLUMN description SET NOT NULL;
48 ERROR: permission denied: "pg_description" is a system catalog
49 -- SET STATISTICS
50 ALTER TABLE pg_description ALTER COLUMN description SET STATISTICS -1;
51 ERROR: permission denied: "pg_description" is a system catalog
52 -- foreign key referencing catalog
53 CREATE TABLE foo (a oid, b oid, c int, FOREIGN KEY (a, b, c) REFERENCES pg_description);
54 ERROR: permission denied: "pg_description" is a system catalog
55 -- RangeVarCallbackOwnsRelation()
56 CREATE INDEX pg_description_test_index ON pg_description (description);
57 ERROR: permission denied: "pg_description" is a system catalog
58 -- RangeVarCallbackForAlterRelation()
59 ALTER TABLE pg_description RENAME TO pg_comment;
60 ERROR: permission denied: "pg_description" is a system catalog
61 ALTER TABLE pg_description SET SCHEMA public;
62 ERROR: permission denied: "pg_description" is a system catalog
63 -- reserved tablespace name
64 CREATE TABLESPACE pg_foo LOCATION '/no/such/location';
65 ERROR: unacceptable tablespace name "pg_foo"
66 DETAIL: The prefix "pg_" is reserved for system tablespaces.
67 -- triggers
68 CREATE FUNCTION tf1() RETURNS trigger
69 LANGUAGE plpgsql
70 AS $$
71 BEGIN
72 RETURN NULL;
73 END $$;
74 CREATE TRIGGER t1 BEFORE INSERT ON pg_description EXECUTE FUNCTION tf1();
75 ERROR: permission denied: "pg_description" is a system catalog
76 ALTER TRIGGER t1 ON pg_description RENAME TO t2;
77 ERROR: permission denied: "pg_description" is a system catalog
78 --DROP TRIGGER t2 ON pg_description;
79 -- rules
80 CREATE RULE r1 AS ON INSERT TO pg_description DO INSTEAD NOTHING;
81 ERROR: permission denied: "pg_description" is a system catalog
82 ALTER RULE r1 ON pg_description RENAME TO r2;
83 ERROR: permission denied: "pg_description" is a system catalog
84 -- now make one to test dropping:
85 SET allow_system_table_mods TO on;
86 CREATE RULE r2 AS ON INSERT TO pg_description DO INSTEAD NOTHING;
87 RESET allow_system_table_mods;
88 DROP RULE r2 ON pg_description;
89 ERROR: permission denied: "pg_description" is a system catalog
90 -- cleanup:
91 SET allow_system_table_mods TO on;
92 DROP RULE r2 ON pg_description;
93 RESET allow_system_table_mods;
94 -- Reloptions on TOAST tables
95 ALTER TABLE pg_toast.pg_toast_2615 SET (fillfactor = '90');
96 ERROR: permission denied: "pg_toast_2615" is a system catalog
97 SET allow_system_table_mods = on;
98 -- create new table in pg_catalog
99 BEGIN;
100 CREATE TABLE pg_catalog.test (a int);
101 ROLLBACK;
102 -- anyarray column
103 BEGIN;
104 CREATE TABLE t1 (a int, b anyarray);
105 ROLLBACK;
106 -- index on system catalog
107 BEGIN;
108 ALTER TABLE pg_namespace ADD CONSTRAINT foo UNIQUE USING INDEX pg_namespace_nspname_index;
109 NOTICE: ALTER TABLE / ADD CONSTRAINT USING INDEX will rename index "pg_namespace_nspname_index" to "foo"
110 ROLLBACK;
111 -- write to system catalog table as superuser
112 BEGIN;
113 INSERT INTO pg_description (objoid, classoid, objsubid, description) VALUES (0, 0, 2, 'foo');
114 ROLLBACK;
115 -- write to system catalog table as normal user
116 -- (not allowed)
117 SET ROLE regress_user_ast;
118 INSERT INTO pg_description (objoid, classoid, objsubid, description) VALUES (0, 0, 3, 'foo');
119 ERROR: permission denied for table pg_description
120 RESET ROLE;
121 -- policy on system catalog
122 BEGIN;
123 CREATE POLICY foo ON pg_description FOR SELECT USING (description NOT LIKE 'secret%');
124 ROLLBACK;
125 -- reserved schema name
126 BEGIN;
127 CREATE SCHEMA pg_foo;
128 ROLLBACK;
129 -- drop system table
130 -- (This will fail anyway because it's pinned.)
131 BEGIN;
132 DROP TABLE pg_description;
133 ERROR: cannot drop table pg_description because it is required by the database system
134 ROLLBACK;
135 -- truncate of system table
136 BEGIN;
137 TRUNCATE pg_description;
138 ROLLBACK;
139 -- rename column of system table
140 BEGIN;
141 ALTER TABLE pg_description RENAME COLUMN description TO comment;
142 ROLLBACK;
143 -- ATSimplePermissions()
144 BEGIN;
145 ALTER TABLE pg_description ALTER COLUMN description SET NOT NULL;
146 ROLLBACK;
147 -- SET STATISTICS
148 BEGIN;
149 ALTER TABLE pg_description ALTER COLUMN description SET STATISTICS -1;
150 ROLLBACK;
151 -- foreign key referencing catalog
152 BEGIN;
153 CREATE TABLE foo (a oid, b oid, c int, FOREIGN KEY (a, b, c) REFERENCES pg_description);
154 ROLLBACK;
155 -- RangeVarCallbackOwnsRelation()
156 BEGIN;
157 CREATE INDEX pg_description_test_index ON pg_description (description);
158 ROLLBACK;
159 -- RangeVarCallbackForAlterRelation()
160 BEGIN;
161 ALTER TABLE pg_description RENAME TO pg_comment;
162 ROLLBACK;
163 BEGIN;
164 ALTER TABLE pg_description SET SCHEMA public;
165 ROLLBACK;
166 -- reserved tablespace name
167 SET client_min_messages = error; -- disable ENFORCE_REGRESSION_TEST_NAME_RESTRICTIONS warning
168 CREATE TABLESPACE pg_foo LOCATION '/no/such/location';
169 ERROR: directory "/no/such/location" does not exist
170 RESET client_min_messages;
171 -- triggers
172 CREATE TRIGGER t1 BEFORE INSERT ON pg_description EXECUTE FUNCTION tf1();
173 ALTER TRIGGER t1 ON pg_description RENAME TO t2;
174 DROP TRIGGER t2 ON pg_description;
175 -- rules
176 CREATE RULE r1 AS ON INSERT TO pg_description DO INSTEAD NOTHING;
177 ALTER RULE r1 ON pg_description RENAME TO r2;
178 DROP RULE r2 ON pg_description;
179 -- Reloptions on TOAST tables
180 ALTER TABLE pg_toast.pg_toast_2615 SET (fillfactor = '90');
181 ERROR: ALTER action SET cannot be performed on relation "pg_toast_2615"
182 DETAIL: This operation is not supported for TOAST tables.
183 -- cleanup
184 REVOKE ALL ON pg_description FROM regress_user_ast;
185 DROP USER regress_user_ast;
186 DROP FUNCTION tf1;