1 CREATE FUNCTION chkrolattr()
2 RETURNS TABLE ("role" name, rolekeyword text, canlogin bool, replication bool)
4 SELECT r.rolname, v.keyword, r.rolcanlogin, r.rolreplication
6 JOIN (VALUES(CURRENT_ROLE, 'current_role'),
7 (CURRENT_USER, 'current_user'),
8 (SESSION_USER, 'session_user'),
10 ('current_user', '-'),
11 ('session_user', '-'),
15 ON (r.rolname = v.uname)
19 CREATE FUNCTION chksetconfig()
20 RETURNS TABLE (db name, "role" name, rolkeyword text, setconfig text[])
22 SELECT COALESCE(d.datname, 'ALL'), COALESCE(r.rolname, 'ALL'),
23 COALESCE(v.keyword, '-'), s.setconfig
24 FROM pg_db_role_setting s
25 LEFT JOIN pg_roles r ON (r.oid = s.setrole)
26 LEFT JOIN pg_database d ON (d.oid = s.setdatabase)
27 LEFT JOIN (VALUES(CURRENT_ROLE, 'current_role'),
28 (CURRENT_USER, 'current_user'),
29 (SESSION_USER, 'session_user'))
31 ON (r.rolname = v.uname)
32 WHERE (r.rolname) IN ('Public', 'current_user', 'regress_testrol1', 'regress_testrol2')
36 CREATE FUNCTION chkumapping()
37 RETURNS TABLE (umname name, umserver name, umoptions text[])
39 SELECT r.rolname, s.srvname, m.umoptions
40 FROM pg_user_mapping m
41 LEFT JOIN pg_roles r ON (r.oid = m.umuser)
42 JOIN pg_foreign_server s ON (s.oid = m.umserver)
47 -- We test creation and use of these role names to ensure that the server
48 -- correctly distinguishes role keywords from quoted names that look like
49 -- those keywords. In a test environment, creation of these roles may
50 -- provoke warnings, so hide the warnings by raising client_min_messages.
52 SET client_min_messages = ERROR;
56 CREATE ROLE "current_role";
57 CREATE ROLE "current_user";
58 CREATE ROLE "session_user";
61 RESET client_min_messages;
63 CREATE ROLE current_user; -- error
64 CREATE ROLE current_role; -- error
65 CREATE ROLE session_user; -- error
66 CREATE ROLE user; -- error
67 CREATE ROLE all; -- error
69 CREATE ROLE public; -- error
70 CREATE ROLE "public"; -- error
71 CREATE ROLE none; -- error
72 CREATE ROLE "none"; -- error
74 CREATE ROLE pg_abc; -- error
75 CREATE ROLE "pg_abc"; -- error
76 CREATE ROLE pg_abcdef; -- error
77 CREATE ROLE "pg_abcdef"; -- error
79 CREATE ROLE regress_testrol0 SUPERUSER LOGIN;
80 CREATE ROLE regress_testrolx SUPERUSER LOGIN;
81 CREATE ROLE regress_testrol2 SUPERUSER;
82 CREATE ROLE regress_testrol1 SUPERUSER LOGIN IN ROLE regress_testrol2;
85 SET SESSION AUTHORIZATION regress_testrol1;
86 SET ROLE regress_testrol2;
90 SELECT * FROM chkrolattr();
91 ALTER ROLE CURRENT_ROLE WITH REPLICATION;
92 SELECT * FROM chkrolattr();
93 ALTER ROLE "current_role" WITH REPLICATION;
94 SELECT * FROM chkrolattr();
95 ALTER ROLE CURRENT_ROLE WITH NOREPLICATION;
96 ALTER ROLE CURRENT_USER WITH REPLICATION;
97 SELECT * FROM chkrolattr();
98 ALTER ROLE "current_user" WITH REPLICATION;
99 SELECT * FROM chkrolattr();
100 ALTER ROLE SESSION_USER WITH REPLICATION;
101 SELECT * FROM chkrolattr();
102 ALTER ROLE "session_user" WITH REPLICATION;
103 SELECT * FROM chkrolattr();
104 ALTER USER "Public" WITH REPLICATION;
105 ALTER USER "None" WITH REPLICATION;
106 SELECT * FROM chkrolattr();
107 ALTER USER regress_testrol1 WITH NOREPLICATION;
108 ALTER USER regress_testrol2 WITH NOREPLICATION;
109 SELECT * FROM chkrolattr();
112 ALTER ROLE USER WITH LOGIN; -- error
113 ALTER ROLE ALL WITH REPLICATION; -- error
114 ALTER ROLE SESSION_ROLE WITH NOREPLICATION; -- error
115 ALTER ROLE PUBLIC WITH NOREPLICATION; -- error
116 ALTER ROLE "public" WITH NOREPLICATION; -- error
117 ALTER ROLE NONE WITH NOREPLICATION; -- error
118 ALTER ROLE "none" WITH NOREPLICATION; -- error
119 ALTER ROLE nonexistent WITH NOREPLICATION; -- error
123 SELECT * FROM chkrolattr();
124 ALTER USER CURRENT_ROLE WITH REPLICATION;
125 SELECT * FROM chkrolattr();
126 ALTER USER "current_role" WITH REPLICATION;
127 SELECT * FROM chkrolattr();
128 ALTER USER CURRENT_ROLE WITH NOREPLICATION;
129 ALTER USER CURRENT_USER WITH REPLICATION;
130 SELECT * FROM chkrolattr();
131 ALTER USER "current_user" WITH REPLICATION;
132 SELECT * FROM chkrolattr();
133 ALTER USER SESSION_USER WITH REPLICATION;
134 SELECT * FROM chkrolattr();
135 ALTER USER "session_user" WITH REPLICATION;
136 SELECT * FROM chkrolattr();
137 ALTER USER "Public" WITH REPLICATION;
138 ALTER USER "None" WITH REPLICATION;
139 SELECT * FROM chkrolattr();
140 ALTER USER regress_testrol1 WITH NOREPLICATION;
141 ALTER USER regress_testrol2 WITH NOREPLICATION;
142 SELECT * FROM chkrolattr();
145 ALTER USER USER WITH LOGIN; -- error
146 ALTER USER ALL WITH REPLICATION; -- error
147 ALTER USER SESSION_ROLE WITH NOREPLICATION; -- error
148 ALTER USER PUBLIC WITH NOREPLICATION; -- error
149 ALTER USER "public" WITH NOREPLICATION; -- error
150 ALTER USER NONE WITH NOREPLICATION; -- error
151 ALTER USER "none" WITH NOREPLICATION; -- error
152 ALTER USER nonexistent WITH NOREPLICATION; -- error
154 -- ALTER ROLE SET/RESET
155 SELECT * FROM chksetconfig();
156 ALTER ROLE CURRENT_ROLE SET application_name to 'BAZ';
157 ALTER ROLE CURRENT_USER SET application_name to 'FOO';
158 ALTER ROLE SESSION_USER SET application_name to 'BAR';
159 ALTER ROLE "current_user" SET application_name to 'FOOFOO';
160 ALTER ROLE "Public" SET application_name to 'BARBAR';
161 ALTER ROLE ALL SET application_name to 'SLAP';
162 SELECT * FROM chksetconfig();
163 ALTER ROLE regress_testrol1 SET application_name to 'SLAM';
164 SELECT * FROM chksetconfig();
165 ALTER ROLE CURRENT_ROLE RESET application_name;
166 ALTER ROLE CURRENT_USER RESET application_name;
167 ALTER ROLE SESSION_USER RESET application_name;
168 ALTER ROLE "current_user" RESET application_name;
169 ALTER ROLE "Public" RESET application_name;
170 ALTER ROLE ALL RESET application_name;
171 SELECT * FROM chksetconfig();
174 ALTER ROLE USER SET application_name to 'BOOM'; -- error
175 ALTER ROLE PUBLIC SET application_name to 'BOMB'; -- error
176 ALTER ROLE nonexistent SET application_name to 'BOMB'; -- error
178 -- ALTER USER SET/RESET
179 SELECT * FROM chksetconfig();
180 ALTER USER CURRENT_ROLE SET application_name to 'BAZ';
181 ALTER USER CURRENT_USER SET application_name to 'FOO';
182 ALTER USER SESSION_USER SET application_name to 'BAR';
183 ALTER USER "current_user" SET application_name to 'FOOFOO';
184 ALTER USER "Public" SET application_name to 'BARBAR';
185 ALTER USER ALL SET application_name to 'SLAP';
186 SELECT * FROM chksetconfig();
187 ALTER USER regress_testrol1 SET application_name to 'SLAM';
188 SELECT * FROM chksetconfig();
189 ALTER USER CURRENT_ROLE RESET application_name;
190 ALTER USER CURRENT_USER RESET application_name;
191 ALTER USER SESSION_USER RESET application_name;
192 ALTER USER "current_user" RESET application_name;
193 ALTER USER "Public" RESET application_name;
194 ALTER USER ALL RESET application_name;
195 SELECT * FROM chksetconfig();
198 ALTER USER USER SET application_name to 'BOOM'; -- error
199 ALTER USER PUBLIC SET application_name to 'BOMB'; -- error
200 ALTER USER NONE SET application_name to 'BOMB'; -- error
201 ALTER USER nonexistent SET application_name to 'BOMB'; -- error
204 CREATE SCHEMA newschema1 AUTHORIZATION CURRENT_USER;
205 CREATE SCHEMA newschema2 AUTHORIZATION "current_user";
206 CREATE SCHEMA newschema3 AUTHORIZATION CURRENT_ROLE;
207 CREATE SCHEMA newschema4 AUTHORIZATION SESSION_USER;
208 CREATE SCHEMA newschema5 AUTHORIZATION regress_testrolx;
209 CREATE SCHEMA newschema6 AUTHORIZATION "Public";
211 CREATE SCHEMA newschemax AUTHORIZATION USER; -- error
212 CREATE SCHEMA newschemax AUTHORIZATION PUBLIC; -- error
213 CREATE SCHEMA newschemax AUTHORIZATION "public"; -- error
214 CREATE SCHEMA newschemax AUTHORIZATION NONE; -- error
215 CREATE SCHEMA newschemax AUTHORIZATION nonexistent; -- error
217 SELECT n.nspname, r.rolname FROM pg_namespace n
218 JOIN pg_roles r ON (r.oid = n.nspowner)
219 WHERE n.nspname LIKE 'newschema_' ORDER BY 1;
221 CREATE SCHEMA IF NOT EXISTS newschema1 AUTHORIZATION CURRENT_USER;
222 CREATE SCHEMA IF NOT EXISTS newschema2 AUTHORIZATION "current_user";
223 CREATE SCHEMA IF NOT EXISTS newschema3 AUTHORIZATION CURRENT_ROLE;
224 CREATE SCHEMA IF NOT EXISTS newschema4 AUTHORIZATION SESSION_USER;
225 CREATE SCHEMA IF NOT EXISTS newschema5 AUTHORIZATION regress_testrolx;
226 CREATE SCHEMA IF NOT EXISTS newschema6 AUTHORIZATION "Public";
228 CREATE SCHEMA IF NOT EXISTS newschemax AUTHORIZATION USER; -- error
229 CREATE SCHEMA IF NOT EXISTS newschemax AUTHORIZATION PUBLIC; -- error
230 CREATE SCHEMA IF NOT EXISTS newschemax AUTHORIZATION "public"; -- error
231 CREATE SCHEMA IF NOT EXISTS newschemax AUTHORIZATION NONE; -- error
232 CREATE SCHEMA IF NOT EXISTS newschemax AUTHORIZATION nonexistent; -- error
234 SELECT n.nspname, r.rolname FROM pg_namespace n
235 JOIN pg_roles r ON (r.oid = n.nspowner)
236 WHERE n.nspname LIKE 'newschema_' ORDER BY 1;
238 -- ALTER TABLE OWNER TO
240 SET SESSION AUTHORIZATION regress_testrol0;
241 CREATE TABLE testtab1 (a int);
242 CREATE TABLE testtab2 (a int);
243 CREATE TABLE testtab3 (a int);
244 CREATE TABLE testtab4 (a int);
245 CREATE TABLE testtab5 (a int);
246 CREATE TABLE testtab6 (a int);
247 CREATE TABLE testtab7 (a int);
250 SET SESSION AUTHORIZATION regress_testrol1;
251 SET ROLE regress_testrol2;
253 ALTER TABLE testtab1 OWNER TO CURRENT_USER;
254 ALTER TABLE testtab2 OWNER TO "current_user";
255 ALTER TABLE testtab3 OWNER TO CURRENT_ROLE;
256 ALTER TABLE testtab4 OWNER TO SESSION_USER;
257 ALTER TABLE testtab5 OWNER TO regress_testrolx;
258 ALTER TABLE testtab6 OWNER TO "Public";
260 ALTER TABLE testtab7 OWNER TO USER; --error
261 ALTER TABLE testtab7 OWNER TO PUBLIC; -- error
262 ALTER TABLE testtab7 OWNER TO "public"; -- error
263 ALTER TABLE testtab7 OWNER TO nonexistent; -- error
265 SELECT c.relname, r.rolname
266 FROM pg_class c JOIN pg_roles r ON (r.oid = c.relowner)
267 WHERE relname LIKE 'testtab_'
270 -- ALTER TABLE, VIEW, MATERIALIZED VIEW, FOREIGN TABLE, SEQUENCE are
271 -- changed their owner in the same way.
275 SET SESSION AUTHORIZATION regress_testrol0;
276 CREATE AGGREGATE testagg1(int2) (SFUNC = int2_sum, STYPE = int8);
277 CREATE AGGREGATE testagg2(int2) (SFUNC = int2_sum, STYPE = int8);
278 CREATE AGGREGATE testagg3(int2) (SFUNC = int2_sum, STYPE = int8);
279 CREATE AGGREGATE testagg4(int2) (SFUNC = int2_sum, STYPE = int8);
280 CREATE AGGREGATE testagg5(int2) (SFUNC = int2_sum, STYPE = int8);
281 CREATE AGGREGATE testagg6(int2) (SFUNC = int2_sum, STYPE = int8);
282 CREATE AGGREGATE testagg7(int2) (SFUNC = int2_sum, STYPE = int8);
283 CREATE AGGREGATE testagg8(int2) (SFUNC = int2_sum, STYPE = int8);
284 CREATE AGGREGATE testagg9(int2) (SFUNC = int2_sum, STYPE = int8);
285 CREATE AGGREGATE testagga(int2) (SFUNC = int2_sum, STYPE = int8);
288 SET SESSION AUTHORIZATION regress_testrol1;
289 SET ROLE regress_testrol2;
291 ALTER AGGREGATE testagg1(int2) OWNER TO CURRENT_USER;
292 ALTER AGGREGATE testagg2(int2) OWNER TO "current_user";
293 ALTER AGGREGATE testagg3(int2) OWNER TO CURRENT_ROLE;
294 ALTER AGGREGATE testagg4(int2) OWNER TO SESSION_USER;
295 ALTER AGGREGATE testagg5(int2) OWNER TO regress_testrolx;
296 ALTER AGGREGATE testagg6(int2) OWNER TO "Public";
298 ALTER AGGREGATE testagg6(int2) OWNER TO USER; -- error
299 ALTER AGGREGATE testagg6(int2) OWNER TO PUBLIC; -- error
300 ALTER AGGREGATE testagg6(int2) OWNER TO "public"; -- error
301 ALTER AGGREGATE testagg6(int2) OWNER TO nonexistent; -- error
303 SELECT p.proname, r.rolname
304 FROM pg_proc p JOIN pg_roles r ON (r.oid = p.proowner)
305 WHERE proname LIKE 'testagg_'
308 -- CREATE USER MAPPING
309 CREATE FOREIGN DATA WRAPPER test_wrapper;
310 CREATE SERVER sv1 FOREIGN DATA WRAPPER test_wrapper;
311 CREATE SERVER sv2 FOREIGN DATA WRAPPER test_wrapper;
312 CREATE SERVER sv3 FOREIGN DATA WRAPPER test_wrapper;
313 CREATE SERVER sv4 FOREIGN DATA WRAPPER test_wrapper;
314 CREATE SERVER sv5 FOREIGN DATA WRAPPER test_wrapper;
315 CREATE SERVER sv6 FOREIGN DATA WRAPPER test_wrapper;
316 CREATE SERVER sv7 FOREIGN DATA WRAPPER test_wrapper;
317 CREATE SERVER sv8 FOREIGN DATA WRAPPER test_wrapper;
318 CREATE SERVER sv9 FOREIGN DATA WRAPPER test_wrapper;
319 CREATE SERVER sv10 FOREIGN DATA WRAPPER test_wrapper;
321 CREATE USER MAPPING FOR CURRENT_USER SERVER sv1 OPTIONS (user 'CURRENT_USER');
322 CREATE USER MAPPING FOR "current_user" SERVER sv2 OPTIONS (user '"current_user"');
323 CREATE USER MAPPING FOR CURRENT_ROLE SERVER sv3 OPTIONS (user 'CURRENT_ROLE');
324 CREATE USER MAPPING FOR USER SERVER sv4 OPTIONS (user 'USER');
325 CREATE USER MAPPING FOR "user" SERVER sv5 OPTIONS (user '"USER"');
326 CREATE USER MAPPING FOR SESSION_USER SERVER sv6 OPTIONS (user 'SESSION_USER');
327 CREATE USER MAPPING FOR PUBLIC SERVER sv7 OPTIONS (user 'PUBLIC');
328 CREATE USER MAPPING FOR "Public" SERVER sv8 OPTIONS (user '"Public"');
329 CREATE USER MAPPING FOR regress_testrolx SERVER sv9 OPTIONS (user 'regress_testrolx');
331 CREATE USER MAPPING FOR nonexistent SERVER sv10 OPTIONS (user 'nonexistent'); -- error;
333 SELECT * FROM chkumapping();
335 -- ALTER USER MAPPING
336 ALTER USER MAPPING FOR CURRENT_USER SERVER sv1
337 OPTIONS (SET user 'CURRENT_USER_alt');
338 ALTER USER MAPPING FOR "current_user" SERVER sv2
339 OPTIONS (SET user '"current_user"_alt');
340 ALTER USER MAPPING FOR CURRENT_ROLE SERVER sv3
341 OPTIONS (SET user 'CURRENT_ROLE_alt');
342 ALTER USER MAPPING FOR USER SERVER sv4
343 OPTIONS (SET user 'USER_alt');
344 ALTER USER MAPPING FOR "user" SERVER sv5
345 OPTIONS (SET user '"user"_alt');
346 ALTER USER MAPPING FOR SESSION_USER SERVER sv6
347 OPTIONS (SET user 'SESSION_USER_alt');
348 ALTER USER MAPPING FOR PUBLIC SERVER sv7
349 OPTIONS (SET user 'public_alt');
350 ALTER USER MAPPING FOR "Public" SERVER sv8
351 OPTIONS (SET user '"Public"_alt');
352 ALTER USER MAPPING FOR regress_testrolx SERVER sv9
353 OPTIONS (SET user 'regress_testrolx_alt');
355 ALTER USER MAPPING FOR nonexistent SERVER sv10
356 OPTIONS (SET user 'nonexistent_alt'); -- error
358 SELECT * FROM chkumapping();
361 DROP USER MAPPING FOR CURRENT_USER SERVER sv1;
362 DROP USER MAPPING FOR "current_user" SERVER sv2;
363 DROP USER MAPPING FOR CURRENT_ROLE SERVER sv3;
364 DROP USER MAPPING FOR USER SERVER sv4;
365 DROP USER MAPPING FOR "user" SERVER sv5;
366 DROP USER MAPPING FOR SESSION_USER SERVER sv6;
367 DROP USER MAPPING FOR PUBLIC SERVER sv7;
368 DROP USER MAPPING FOR "Public" SERVER sv8;
369 DROP USER MAPPING FOR regress_testrolx SERVER sv9;
371 DROP USER MAPPING FOR nonexistent SERVER sv10; -- error
372 SELECT * FROM chkumapping();
374 CREATE USER MAPPING FOR CURRENT_USER SERVER sv1 OPTIONS (user 'CURRENT_USER');
375 CREATE USER MAPPING FOR "current_user" SERVER sv2 OPTIONS (user '"current_user"');
376 CREATE USER MAPPING FOR CURRENT_ROLE SERVER sv3 OPTIONS (user 'CURRENT_ROLE');
377 CREATE USER MAPPING FOR USER SERVER sv4 OPTIONS (user 'USER');
378 CREATE USER MAPPING FOR "user" SERVER sv5 OPTIONS (user '"USER"');
379 CREATE USER MAPPING FOR SESSION_USER SERVER sv6 OPTIONS (user 'SESSION_USER');
380 CREATE USER MAPPING FOR PUBLIC SERVER sv7 OPTIONS (user 'PUBLIC');
381 CREATE USER MAPPING FOR "Public" SERVER sv8 OPTIONS (user '"Public"');
382 CREATE USER MAPPING FOR regress_testrolx SERVER sv9 OPTIONS (user 'regress_testrolx');
383 SELECT * FROM chkumapping();
385 -- DROP USER MAPPING IF EXISTS
386 DROP USER MAPPING IF EXISTS FOR CURRENT_USER SERVER sv1;
387 SELECT * FROM chkumapping();
388 DROP USER MAPPING IF EXISTS FOR "current_user" SERVER sv2;
389 SELECT * FROM chkumapping();
390 DROP USER MAPPING IF EXISTS FOR CURRENT_USER SERVER sv3;
391 SELECT * FROM chkumapping();
392 DROP USER MAPPING IF EXISTS FOR USER SERVER sv4;
393 SELECT * FROM chkumapping();
394 DROP USER MAPPING IF EXISTS FOR "user" SERVER sv5;
395 SELECT * FROM chkumapping();
396 DROP USER MAPPING IF EXISTS FOR SESSION_USER SERVER sv6;
397 SELECT * FROM chkumapping();
398 DROP USER MAPPING IF EXISTS FOR PUBLIC SERVER sv7;
399 SELECT * FROM chkumapping();
400 DROP USER MAPPING IF EXISTS FOR "Public" SERVER sv8;
401 SELECT * FROM chkumapping();
402 DROP USER MAPPING IF EXISTS FOR regress_testrolx SERVER sv9;
403 SELECT * FROM chkumapping();
405 DROP USER MAPPING IF EXISTS FOR nonexistent SERVER sv10; -- error
408 GRANT regress_testrol0 TO pg_signal_backend; -- success
410 SET ROLE pg_signal_backend; --success
412 CREATE SCHEMA test_roles_schema AUTHORIZATION pg_signal_backend; --success
413 SET ROLE regress_testrol2;
415 UPDATE pg_proc SET proacl = null WHERE proname LIKE 'testagg_';
416 SELECT proname, proacl FROM pg_proc WHERE proname LIKE 'testagg_';
418 REVOKE ALL PRIVILEGES ON FUNCTION testagg1(int2) FROM PUBLIC;
419 REVOKE ALL PRIVILEGES ON FUNCTION testagg2(int2) FROM PUBLIC;
420 REVOKE ALL PRIVILEGES ON FUNCTION testagg3(int2) FROM PUBLIC;
421 REVOKE ALL PRIVILEGES ON FUNCTION testagg4(int2) FROM PUBLIC;
422 REVOKE ALL PRIVILEGES ON FUNCTION testagg5(int2) FROM PUBLIC;
423 REVOKE ALL PRIVILEGES ON FUNCTION testagg6(int2) FROM PUBLIC;
424 REVOKE ALL PRIVILEGES ON FUNCTION testagg7(int2) FROM PUBLIC;
425 REVOKE ALL PRIVILEGES ON FUNCTION testagg8(int2) FROM PUBLIC;
427 GRANT ALL PRIVILEGES ON FUNCTION testagg1(int2) TO PUBLIC;
428 GRANT ALL PRIVILEGES ON FUNCTION testagg2(int2) TO CURRENT_USER;
429 GRANT ALL PRIVILEGES ON FUNCTION testagg3(int2) TO "current_user";
430 GRANT ALL PRIVILEGES ON FUNCTION testagg4(int2) TO CURRENT_ROLE;
431 GRANT ALL PRIVILEGES ON FUNCTION testagg5(int2) TO SESSION_USER;
432 GRANT ALL PRIVILEGES ON FUNCTION testagg6(int2) TO "Public";
433 GRANT ALL PRIVILEGES ON FUNCTION testagg7(int2) TO regress_testrolx;
434 GRANT ALL PRIVILEGES ON FUNCTION testagg8(int2) TO "public";
435 GRANT ALL PRIVILEGES ON FUNCTION testagg9(int2)
436 TO current_user, public, regress_testrolx;
438 SELECT proname, proacl FROM pg_proc WHERE proname LIKE 'testagg_';
440 GRANT ALL PRIVILEGES ON FUNCTION testagga(int2) TO USER; --error
441 GRANT ALL PRIVILEGES ON FUNCTION testagga(int2) TO NONE; --error
442 GRANT ALL PRIVILEGES ON FUNCTION testagga(int2) TO "none"; --error
444 SELECT proname, proacl FROM pg_proc WHERE proname LIKE 'testagg_';
446 REVOKE ALL PRIVILEGES ON FUNCTION testagg1(int2) FROM PUBLIC;
447 REVOKE ALL PRIVILEGES ON FUNCTION testagg2(int2) FROM CURRENT_USER;
448 REVOKE ALL PRIVILEGES ON FUNCTION testagg3(int2) FROM "current_user";
449 REVOKE ALL PRIVILEGES ON FUNCTION testagg4(int2) FROM CURRENT_ROLE;
450 REVOKE ALL PRIVILEGES ON FUNCTION testagg5(int2) FROM SESSION_USER;
451 REVOKE ALL PRIVILEGES ON FUNCTION testagg6(int2) FROM "Public";
452 REVOKE ALL PRIVILEGES ON FUNCTION testagg7(int2) FROM regress_testrolx;
453 REVOKE ALL PRIVILEGES ON FUNCTION testagg8(int2) FROM "public";
454 REVOKE ALL PRIVILEGES ON FUNCTION testagg9(int2)
455 FROM current_user, public, regress_testrolx;
457 SELECT proname, proacl FROM pg_proc WHERE proname LIKE 'testagg_';
459 REVOKE ALL PRIVILEGES ON FUNCTION testagga(int2) FROM USER; --error
460 REVOKE ALL PRIVILEGES ON FUNCTION testagga(int2) FROM NONE; --error
461 REVOKE ALL PRIVILEGES ON FUNCTION testagga(int2) FROM "none"; --error
463 SELECT proname, proacl FROM pg_proc WHERE proname LIKE 'testagg_';
465 -- DEFAULT MONITORING ROLES
466 CREATE ROLE regress_role_haspriv;
467 CREATE ROLE regress_role_nopriv;
470 GRANT pg_read_all_stats TO regress_role_haspriv;
471 SET SESSION AUTHORIZATION regress_role_haspriv;
472 -- returns true with role member of pg_read_all_stats
473 SELECT COUNT(*) = 0 AS haspriv FROM pg_stat_activity
474 WHERE query = '<insufficient privilege>';
475 SET SESSION AUTHORIZATION regress_role_nopriv;
476 -- returns false with role not member of pg_read_all_stats
477 SELECT COUNT(*) = 0 AS haspriv FROM pg_stat_activity
478 WHERE query = '<insufficient privilege>';
479 RESET SESSION AUTHORIZATION;
480 REVOKE pg_read_all_stats FROM regress_role_haspriv;
482 -- pg_read_all_settings
483 GRANT pg_read_all_settings TO regress_role_haspriv;
485 -- A GUC using GUC_SUPERUSER_ONLY is useful for negative tests.
486 SET LOCAL session_preload_libraries TO 'path-to-preload-libraries';
487 SET SESSION AUTHORIZATION regress_role_haspriv;
488 -- passes with role member of pg_read_all_settings
489 SHOW session_preload_libraries;
490 SET SESSION AUTHORIZATION regress_role_nopriv;
491 -- fails with role not member of pg_read_all_settings
492 SHOW session_preload_libraries;
493 RESET SESSION AUTHORIZATION;
495 REVOKE pg_read_all_settings FROM regress_role_haspriv;
500 DROP SCHEMA test_roles_schema;
501 DROP OWNED BY regress_testrol0, "Public", "current_role", "current_user", regress_testrol1, regress_testrol2, regress_testrolx CASCADE;
502 DROP ROLE regress_testrol0, regress_testrol1, regress_testrol2, regress_testrolx;
503 DROP ROLE "Public", "None", "current_role", "current_user", "session_user", "user";
504 DROP ROLE regress_role_haspriv, regress_role_nopriv;