Debian Codegraph @

contrib/test_decoding/expected/permissions.out

raw
1 -- predictability
2 SET synchronous_commit = on;
3 -- setup
4 CREATE ROLE regress_lr_normal;
5 CREATE ROLE regress_lr_superuser SUPERUSER;
6 CREATE ROLE regress_lr_replication REPLICATION;
7 CREATE TABLE lr_test(data text);
8 -- superuser can control replication
9 SET ROLE regress_lr_superuser;
10 SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding');
11 ?column?
12 ----------
13 init
14 (1 row)
15
16 INSERT INTO lr_test VALUES('lr_superuser_init');
17 SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
18 data
19 --------------------------------------------------------------
20 BEGIN
21 table public.lr_test: INSERT: data[text]:'lr_superuser_init'
22 COMMIT
23 (3 rows)
24
25 SELECT pg_drop_replication_slot('regression_slot');
26 pg_drop_replication_slot
27 --------------------------
28
29 (1 row)
30
31 RESET ROLE;
32 -- no users can load an untrusted plugin
33 SET output_plugin_libraries = pgoutput;
34 SET ROLE regress_lr_replication;
35 SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding');
36 ERROR: library "test_decoding" may not be used as an output plugin
37 HINT: If it is safe for all REPLICATION users to use this library as an output plugin, add it to "output_plugin_libraries" and reload the server configuration.
38 RESET ROLE;
39 SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding');
40 ERROR: library "test_decoding" may not be used as an output plugin
41 HINT: If it is safe for all REPLICATION users to use this library as an output plugin, add it to "output_plugin_libraries" and reload the server configuration.
42 RESET output_plugin_libraries;
43 -- replication user can control replication
44 SET ROLE regress_lr_replication;
45 SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding');
46 ?column?
47 ----------
48 init
49 (1 row)
50
51 INSERT INTO lr_test VALUES('lr_superuser_init');
52 ERROR: permission denied for table lr_test
53 SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
54 data
55 ------
56 (0 rows)
57
58 SELECT pg_drop_replication_slot('regression_slot');
59 pg_drop_replication_slot
60 --------------------------
61
62 (1 row)
63
64 RESET ROLE;
65 -- plain user *can't* can control replication
66 SET ROLE regress_lr_normal;
67 SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding');
68 ERROR: permission denied to use replication slots
69 DETAIL: Only roles with the REPLICATION attribute may use replication slots.
70 INSERT INTO lr_test VALUES('lr_superuser_init');
71 ERROR: permission denied for table lr_test
72 SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
73 ERROR: permission denied to use replication slots
74 DETAIL: Only roles with the REPLICATION attribute may use replication slots.
75 SELECT pg_drop_replication_slot('regression_slot');
76 ERROR: permission denied to use replication slots
77 DETAIL: Only roles with the REPLICATION attribute may use replication slots.
78 SELECT pg_sync_replication_slots();
79 ERROR: permission denied to use replication slots
80 DETAIL: Only roles with the REPLICATION attribute may use replication slots.
81 RESET ROLE;
82 -- replication users can drop superuser created slots
83 SET ROLE regress_lr_superuser;
84 SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding');
85 ?column?
86 ----------
87 init
88 (1 row)
89
90 RESET ROLE;
91 SET ROLE regress_lr_replication;
92 SELECT pg_drop_replication_slot('regression_slot');
93 pg_drop_replication_slot
94 --------------------------
95
96 (1 row)
97
98 RESET ROLE;
99 -- normal users can't drop existing slots
100 SET ROLE regress_lr_superuser;
101 SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding');
102 ?column?
103 ----------
104 init
105 (1 row)
106
107 RESET ROLE;
108 SET ROLE regress_lr_normal;
109 SELECT pg_drop_replication_slot('regression_slot');
110 ERROR: permission denied to use replication slots
111 DETAIL: Only roles with the REPLICATION attribute may use replication slots.
112 RESET ROLE;
113 -- all users can see existing slots
114 SET ROLE regress_lr_superuser;
115 SELECT slot_name, plugin FROM pg_replication_slots;
116 slot_name | plugin
117 -----------------+---------------
118 regression_slot | test_decoding
119 (1 row)
120
121 RESET ROLE;
122 SET ROLE regress_lr_replication;
123 SELECT slot_name, plugin FROM pg_replication_slots;
124 slot_name | plugin
125 -----------------+---------------
126 regression_slot | test_decoding
127 (1 row)
128
129 RESET ROLE;
130 SET ROLE regress_lr_normal;
131 SELECT slot_name, plugin FROM pg_replication_slots;
132 slot_name | plugin
133 -----------------+---------------
134 regression_slot | test_decoding
135 (1 row)
136
137 RESET ROLE;
138 -- cleanup
139 SELECT pg_drop_replication_slot('regression_slot');
140 pg_drop_replication_slot
141 --------------------------
142
143 (1 row)
144
145 DROP ROLE regress_lr_normal;
146 DROP ROLE regress_lr_superuser;
147 DROP ROLE regress_lr_replication;
148 DROP TABLE lr_test;