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 1s9nGI-005BmS-Db for pgsql-general@arkaria.postgresql.org; Wed, 22 May 2024 14:48:16 +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 1s9nGI-000A4b-FH for pgsql-general@arkaria.postgresql.org; Wed, 22 May 2024 14:48:14 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s9nGG-0009zb-Vb for pgsql-general@lists.postgresql.org; Wed, 22 May 2024 14:48:14 +0000 Received: from wfhigh7-smtp.messagingengine.com ([64.147.123.158]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s9nGC-000DSD-KD for pgsql-general@postgresql.org; Wed, 22 May 2024 14:48:12 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfhigh.west.internal (Postfix) with ESMTP id 6BCFF18000DA; Wed, 22 May 2024 10:48:06 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Wed, 22 May 2024 10:48:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1716389286; x=1716475686; bh=6ooRF6re8AtiSSPGBVX2TNtdAyBHWd5I2vW+TVffnN0=; b= m+LbAvEzqCriRmcSmAuxCAxK8apfW35CkzHhYckzihdf7zmgOlLyltdo9IULkJk+ 0frYFTxeAvC86FmRXdPxAWOt/A9wNm0SUy4+RmQQCdAUmhswAxKpRlYnGSYORiFs zT48irVMQRSfwyN+QOgENnP+xANBy1G9iioTbFJ4arSQwurgAicFq6MtrT0G+OaS 7cKB6OGEqYLBlXtOxWUZ/ATvwYEKttK+ovwYLmj4mGIX67hwhwq7DW/jMXHKlJxx deW/hC739k3dXlMp7wZeUZ5t9s2lcc0SQZfRUuN+z99y7VlWLKnlhSCav+yG3ABD XdzvVBfhkPbPyzyW6RC/Qg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1716389286; x= 1716475686; bh=6ooRF6re8AtiSSPGBVX2TNtdAyBHWd5I2vW+TVffnN0=; b=O epoN4fkUxwBkwk5Tgc/0Am1YgHpZ8VfJEZpjqASxUeFWX/2kf4AUUIEd6JcNmIxY XaAreruatlCDVPvlVL24deY/ZoJMCufLzyfYQo5bFs1MkZGf7FxYdk8Bk7RfKsFZ +NbSWvem6iZb6wyu1qWK4tK/PrTL3tKBbcb2p97DcwBMMdd0/CN/Xr/mJ7G+IjY/ AloNCyIu9KpyztAvZQpn7ZHz4XXbD/hE34zQcq3J+CSt7hKUCo7AF4KZ+YFV1vvr cvT6KLCHzn1AMhhGlCw5JjLAPr5s2B7ObWUGIxtMWvBezxP2GXFjPP9gnjixiLsV KSbPc7WhJR3Pgpk796UPQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdeigedgvddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefkffggfgfuvfhfhfgjtgfgsehtke ertddtvdejnecuhfhrohhmpeetughrihgrnhcumfhlrghvvghruceorggurhhirghnrdhk lhgrvhgvrhesrghklhgrvhgvrhdrtghomheqnecuggftrfgrthhtvghrnhepleegveekke ekueeigfdtveeileeuhfefudefteekjeffkeejueejheegheegkedtnecuffhomhgrihhn pehpohhsthhgrhgvshhqlhdrohhrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgt ohhm X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 22 May 2024 10:48:05 -0400 (EDT) Message-ID: <42db74b1-69a7-452b-9e27-d9d421aae8db@aklaver.com> Date: Wed, 22 May 2024 07:48:04 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: search_path and SET ROLE To: Ron Johnson , pgsql-general References: Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 5/22/24 07:27, Ron Johnson wrote: > PG 9.6.24 (Soon, I swear!) > > It seems that the search_path of the role that you SET ROLE to does not > become the new search_path. > > Am I missing something, or is that PG's behavior? > > AS USER postgres > ================ > > $ psql -h 10.143.170.52 -Xac "CREATE ROLE dbagrp SUPERUSER INHERIT NOLOGIN;" > CREATE ROLE dbagrp SUPERUSER INHERIT NOLOGIN; > CREATE ROLE > > $ psql -h 10.143.170.52 -Xac "CREATE USER rjohnson IN GROUP dbagrp INHERIT;" > CREATE USER rjohnson IN GROUP dbagrp INHERIT; > CREATE ROLE > > [postgres@FISPMONDB001 ~]$ psql -h 10.143.170.52 -Xac "CREATE USER > \"11026270\" IN GROUP dbagrp INHERIT PASSWORD '${NewPass}' VALID UNTIL > '2024-06-30 23:59:59';" > CREATE USER "11026270" IN GROUP dbagrp INHERIT PASSWORD 'linenoise' > VALID UNTIL '2024-06-30 23:59:59'; > CREATE ROLE > > $ psql -h 10.143.170.52 -Xac "ALTER ROLE dbagrp set search_path = > dbagrp, public, dba, cds, tms;" > ALTER ROLE dbagrp set search_path = dbagrp, public, dba, cds, tms; > ALTER ROLE > > AS USER rjohnson > ================ > > [rjohnson@fpslbxcdsdbppg1 ~]$ psql -dCDSLBXW > psql (9.6.24) > Type "help" for help. > > CDSLBXW=> SET ROLE dbagrp; > SET > CDSLBXW=# > CDSLBXW=# SHOW SEARCH_PATH; >    search_path > ----------------- >  "$user", public > (1 row) > > > Back to user postgres > ================= > > $ psql -h 10.143.170.52 -Xac "ALTER ROLE rjohnson set search_path = > dbagrp, public, dba, cds, tms;" > ALTER ROLE rjohnson set search_path = dbagrp, public, dba, cds, tms; > ALTER ROLE > > Back to user rjohnson > ================= > > [rjohnson@fpslbxcdsdbppg1 ~]$ psql -dCDSLBXW > psql (9.6.24) > Type "help" for help. > > CDSLBXW=> > CDSLBXW=> SET ROLE dbagrp; > SET > > CDSLBXW=# SHOW SEARCH_PATH; >           search_path > ------------------------------- >  dbagrp, public, dba, cds, tms > (1 row) https://www.postgresql.org/docs/current/sql-alterrole.html Whenever the role subsequently starts a new session, the specified value becomes the session default, overriding whatever setting is present in postgresql.conf or has been received from the postgres command line. This only happens at login time; executing SET ROLE or SET SESSION AUTHORIZATION does not cause new configuration values to be set. Settings set for all databases are overridden by database-specific settings attached to a role. Settings for specific databases or specific roles override settings for all roles. -- Adrian Klaver adrian.klaver@aklaver.com