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 1s9pTt-005OPi-2N for pgsql-general@arkaria.postgresql.org; Wed, 22 May 2024 17:10:26 +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 1s9pTs-001Yk9-5s for pgsql-general@arkaria.postgresql.org; Wed, 22 May 2024 17:10:24 +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 1s9pTr-001Yk1-LV for pgsql-general@lists.postgresql.org; Wed, 22 May 2024 17:10:23 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s9pTp-001TzM-79 for pgsql-general@postgresql.org; Wed, 22 May 2024 17:10:22 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 44MHAJ854165842; Wed, 22 May 2024 13:10:19 -0400 From: Tom Lane To: Ron Johnson cc: pgsql-general Subject: Re: search_path and SET ROLE In-reply-to: References: Comments: In-reply-to Ron Johnson message dated "Wed, 22 May 2024 10:27:41 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4165840.1716397819.1@sss.pgh.pa.us> Date: Wed, 22 May 2024 13:10:19 -0400 Message-ID: <4165841.1716397819@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Ron Johnson writes: > It seems that the search_path of the role that you SET ROLE to does not > become the new search_path. It does for me: regression=# create role r1; CREATE ROLE regression=# create schema r1 authorization r1; CREATE SCHEMA regression=# select current_schemas(true), current_user; current_schemas | current_user ---------------------+-------------- {pg_catalog,public} | postgres (1 row) regression=# set role r1; SET regression=> select current_schemas(true), current_user; current_schemas | current_user ------------------------+-------------- {pg_catalog,r1,public} | r1 (1 row) regression=> show search_path ; search_path ----------------- "$user", public (1 row) The fine manual says that $user tracks the result of CURRENT_USER, and at least in this example it's doing that. (I hasten to add that I would not swear there are no bugs in this area.) > Am I missing something, or is that PG's behavior? I bet what you missed is granting (at least) USAGE on the schema to that role. PG will silently ignore unreadable schemas when computing the effective search path. regards, tom lane