You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: evtrig detection under another extension fmgr_hook
Problem:
Under the following conditions:
- plpgsql_check is enabled (can be any other extension that uses the
fmgr_hook).
+ This means that the `supautils_needs_fmgr_hook` returns true anyway.
- After doing `create extension`, function owners are downgraded
from superuser to non-super.
Supautils event trigger skipping mechanism will wrongly intercept
the downgraded functions and force a noop (internally it's the `version()` function)
causing the extension to misbehave.
The `pgmq` extension is used to test this failure.
Solution:
Ensure we only detect event trigger functions even on the presence of
other extensions fmgr hooks.
errmsg("Skipping event trigger function \"%s\" for user \"%s\"", func_name, current_role_name),
115
-
errdetail("\"%s\" %s and the function \"%s\" is not superuser-owned, it's owned by \"%s\"",
116
-
current_role_name, role_is_super?"is a superuser":"is a reserved role", func_name, GetUserNameFromId(func_owner, false))
117
-
);
99
+
if (is_event_trigger_function(flinfo->fn_oid)){ // recheck the function is an event trigger in case another extension need_fmgr_hook passed our supautils_needs_fmgr_hook
-- downgrade the extension functions owners to non-superuser, to ensure the following function calls are not wrongly skipped by the event trigger mechanism
7
+
do $$
8
+
declare
9
+
extoid oid := (select oid from pg_extension where extname = 'pgmq');
10
+
r record;
11
+
cls pg_class%rowtype;
12
+
begin
13
+
for r in (select * from pg_depend where refobjid = extoid) loop
14
+
if r.classid = 'pg_proc'::regclass then
15
+
execute(format('alter function %s(%s) owner to privileged_role;', r.objid::regproc, pg_get_function_identity_arguments(r.objid)));
-- downgrade the extension functions owners to non-superuser, to ensure the following function calls are not wrongly skipped by the event trigger mechanism
7
+
do $$
8
+
declare
9
+
extoid oid := (selectoidfrom pg_extension where extname ='pgmq');
10
+
r record;
11
+
cls pg_class%rowtype;
12
+
begin
13
+
for r in (select*from pg_depend where refobjid = extoid) loop
14
+
if r.classid='pg_proc'::regclass then
15
+
execute(format('alter function %s(%s) owner to privileged_role;', r.objid::regproc, pg_get_function_identity_arguments(r.objid)));
0 commit comments