Skip to content

Commit 36b18b4

Browse files
committed
test: pgmq functions' owner modification
The change on supabase#1362 modified pgmq functions default owner, which is `supabase_admin`, to `postgres`. This tests function owners of pgmq. Partly addresses supabase#1536.
1 parent ae8cdaf commit 36b18b4

File tree

2 files changed

+67
-5
lines changed

2 files changed

+67
-5
lines changed

nix/tests/expected/pgmq.out

+50-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ select
5151
msg_id,
5252
read_ct,
5353
message
54-
from
54+
from
5555
pgmq.pop('Foo');
5656
msg_id | read_ct | message
5757
--------+---------+---------
@@ -139,3 +139,52 @@ CONTEXT: PL/pgSQL function pgmq.format_table_name(text,text) line 5 at RAISE
139139
PL/pgSQL function pgmq.create_non_partitioned(text) line 3 during statement block local variable initialization
140140
SQL statement "SELECT pgmq.create_non_partitioned(queue_name)"
141141
PL/pgSQL function pgmq."create"(text) line 3 at PERFORM
142+
\echo
143+
144+
-- pgmq schema functions with owners (ownership is modified on ansible/files/postgresql_extension_custom_scripts/pgmq/after-create.sql)
145+
select
146+
n.nspname as schema_name,
147+
p.proname as function_name,
148+
r.rolname as owner
149+
from
150+
pg_proc p
151+
join
152+
pg_namespace n on p.pronamespace = n.oid
153+
join
154+
pg_roles r on p.proowner = r.oid
155+
where
156+
n.nspname = 'pgmq'
157+
order by
158+
p.proname;
159+
schema_name | function_name | owner
160+
-------------+-------------------------------+----------
161+
pgmq | _belongs_to_pgmq | postgres
162+
pgmq | _ensure_pg_partman_installed | postgres
163+
pgmq | _get_partition_col | postgres
164+
pgmq | _get_pg_partman_major_version | postgres
165+
pgmq | _get_pg_partman_schema | postgres
166+
pgmq | archive | postgres
167+
pgmq | archive | postgres
168+
pgmq | convert_archive_partitioned | postgres
169+
pgmq | create | postgres
170+
pgmq | create_non_partitioned | postgres
171+
pgmq | create_partitioned | postgres
172+
pgmq | create_unlogged | postgres
173+
pgmq | delete | postgres
174+
pgmq | delete | postgres
175+
pgmq | detach_archive | postgres
176+
pgmq | drop_queue | postgres
177+
pgmq | format_table_name | postgres
178+
pgmq | list_queues | postgres
179+
pgmq | metrics | postgres
180+
pgmq | metrics_all | postgres
181+
pgmq | pop | postgres
182+
pgmq | purge_queue | postgres
183+
pgmq | read | postgres
184+
pgmq | read_with_poll | postgres
185+
pgmq | send | postgres
186+
pgmq | send_batch | postgres
187+
pgmq | set_vt | postgres
188+
pgmq | validate_queue_name | postgres
189+
(28 rows)
190+

nix/tests/sql/pgmq.sql

+17-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ select
3535
msg_id,
3636
read_ct,
3737
message
38-
from
38+
from
3939
pgmq.pop('Foo');
4040

4141

@@ -84,7 +84,20 @@ select
8484
select pgmq.create('F--oo');
8585
select pgmq.create('F$oo');
8686
select pgmq.create($$F'oo$$);
87+
\echo
8788
88-
89-
90-
89+
-- pgmq schema functions with owners (ownership is modified on ansible/files/postgresql_extension_custom_scripts/pgmq/after-create.sql)
90+
select
91+
n.nspname as schema_name,
92+
p.proname as function_name,
93+
r.rolname as owner
94+
from
95+
pg_proc p
96+
join
97+
pg_namespace n on p.pronamespace = n.oid
98+
join
99+
pg_roles r on p.proowner = r.oid
100+
where
101+
n.nspname = 'pgmq'
102+
order by
103+
p.proname;

0 commit comments

Comments
 (0)