Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1slpSx-001R8S-7Y for pgsql-admin@arkaria.postgresql.org; Wed, 04 Sep 2024 12:50:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1slpSv-009CVg-Ra for pgsql-admin@arkaria.postgresql.org; Wed, 04 Sep 2024 12:50:30 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1slpSv-009CVK-Eo for pgsql-admin@lists.postgresql.org; Wed, 04 Sep 2024 12:50:29 +0000 Received: from smtp-outbound7.duck.com ([20.67.222.12]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1slpSt-0006yY-0n for pgsql-admin@lists.postgresql.org; Wed, 04 Sep 2024 12:50:28 +0000 MIME-Version: 1.0 Subject: Assign TEXT/NAME variable type to SET SESSION AUTHORIZATION Content-Type: multipart/alternative; boundary="=_46zTf9ks4uMcAWKAP9uQl7_=" X-Rspamd-Bar: - X-Rspamd-Report: DMARC_POLICY_ALLOW(-0.5) R_DKIM_ALLOW(-0.2) MIME_GOOD(-0.1) R_SPF_ALLOW(-0.2) X-Rspamd-Score: -1 X-Rspamd-Action: no action To: pgsql-admin@lists.postgresql.org Received: by smtp-inbound1.duck.com; Wed, 04 Sep 2024 08:50:25 -0400 Message-ID: <9C5DD0F7-B421-488E-BD41-C90287081D6A.1@smtp-inbound1.duck.com> Date: Wed, 04 Sep 2024 08:50:25 -0400 From: keypey@duck.com Feedback-ID: :isSendReply:isDirect:duckcom DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=duck.com; h=Feedback-ID: From: Date: Message-ID: To: Content-Type: Subject: MIME-Version; q=dns/txt; s=postal-KpyQVw; t=1725454225; bh=xK8koyN5ZxZkXStNxgfgafFub8hEtjU4NyglVnVnrIg=; b=B6kAKdSFOOFhVR+VunigwA5k/Z6Zqa88yheC1vhgu4trsPYna+G2sDNhpUlB/oQP4NB/R0KX+ R/AftSimvP+ujnf8qpASiDX9AQy54e9si0tpjGo2UmG8ZmJsyCC8zZzMnwWv+eguL5sSlZ/bgZn l6saB0nRkBs/SprnVyJ2Ups= List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --=_46zTf9ks4uMcAWKAP9uQl7_= Content-Type: text/plain; charset="UTF-8" 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 --=_46zTf9ks4uMcAWKAP9uQl7_= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

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$
declar= e
_username;
begin
if 'reporter' in (select usename from = pg_catalog.pg_user) then
raise notice 'user: reporter' ;
_user :=3D = '"srg"'::name;
else
raise notice 'user: postgres' ;
_user :=3D = '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

<= /div>
--=_46zTf9ks4uMcAWKAP9uQl7_=--