Thread: Assign TEXT/NAME variable type to SET SESSION AUTHORIZATION

Assign TEXT/NAME variable type to SET SESSION AUTHORIZATION

From
keypey@duck.com
Date:

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

Re: Assign TEXT/NAME variable type to SET SESSION AUTHORIZATION

From
"David G. Johnston"
Date:
On Wednesday, September 4, 2024, <keypey@duck.com> wrote:


_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. 

Re: Assign TEXT/NAME variable type to SET SESSION AUTHORIZATION

From
keypey@duck.com
Date:

David
Thanks a lot!

--

kp


śr., 4 wrz 2024 o 15:15 David G. Johnston <david.g.johnston_at_gmail.com_keypey@duck.com> napisał(a):
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.
On Wednesday, September 4, 2024, <keypey@duck.com> wrote:


_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. 


--
kp.,