Thread: Assign TEXT/NAME variable type to SET SESSION AUTHORIZATION
Hello everyone!
----
I need to change the session user in the script, depending on whether it is defined.
I'm trying to do it this way:
---
```
down
$body$
declare
_username;
begin
if 'reporter' in (select usename from pg_catalog.pg_user) then
raise notice 'user: reporter' ;
_user := '"srg"'::name;
else
raise notice 'user: postgres' ;
_user := 'postgres'::name;
end if;
SET SESSION AUTHORIZATION _user::name;
end;
$body$
;
```
---
Unfortunately, I don't know how to convert it so that SET SESSION AUTHORIZATION works properly.
I am asking for support.
--
Regards,
keypey
_user := 'postgres'::name;
end if;
SET SESSION AUTHORIZATION _user::name;
end;
$body$
;
```
---
Unfortunately, I don't know how to convert it so that SET SESSION AUTHORIZATION works properly.
David
Thanks a lot!
--
kp
On Wednesday, September 4, 2024, <keypey@duck.com> wrote:On Wednesday, September 4, 2024, wrote: _user := 'postgres'::name;end if; SET SESSION AUTHORIZATION _user::name;end;$body$;```---Unfortunately, I don't know how to convert it so that
DuckDuckGo did not detect any trackers.
_user := 'postgres'::name;
end if;
SET SESSION AUTHORIZATION _user::name;
end;
$body$
;
```
---
Unfortunately, I don't know how to convert it so that SET SESSION AUTHORIZATION works properly.Dynamic SQL, I.e., the execute statement.David J.