diff --git a/27a69a5_to_aad2e07.sql b/27a69a5_to_aad2e07.sql new file mode 100644 index 0000000..74250e2 --- /dev/null +++ b/27a69a5_to_aad2e07.sql @@ -0,0 +1,44 @@ +set check_function_bodies = off; + +CREATE OR REPLACE FUNCTION public.unset_acting_usr() + RETURNS void + LANGUAGE plpgsql +AS $function$ +begin + perform set_config('dnim.usr_uid', '', false); +end; +$function$ +; + +CREATE OR REPLACE FUNCTION public.get_acting_usr() + RETURNS usr + LANGUAGE plpgsql +AS $function$ +declare + acting_usr public.usr; +begin + if nullif(current_setting('dnim.usr_uid', true), '') is null then + acting_usr := public.usr_root(); + else + select u.* + from public.usr u + where u.uid = human_uuid.huid_of_string(current_setting('dnim.usr_uid', true)) + into acting_usr; + end if; + + return coalesce(acting_usr, public.usr_root()); +end; +$function$ +; + +CREATE OR REPLACE FUNCTION public.set_acting_usr(uid text) + RETURNS void + LANGUAGE plpgsql +AS $function$ +begin + if uid is not null and uid != '' then + perform set_config('dnim.usr_uid', uid, false); + end if; +end; +$function$ +; diff --git a/885e22c_to_27a69a5.sql b/885e22c_to_27a69a5.sql new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/885e22c_to_27a69a5.sql @@ -0,0 +1 @@ +