Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ognvo-0001zw-RY for pgsql-docs@arkaria.postgresql.org; Fri, 07 Oct 2022 14:02:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ognvn-0003o0-Mx for pgsql-docs@arkaria.postgresql.org; Fri, 07 Oct 2022 14:02:27 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ognvn-0003nr-FT for pgsql-docs@lists.postgresql.org; Fri, 07 Oct 2022 14:02:27 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ognvk-0008AZ-Ty for pgsql-docs@lists.postgresql.org; Fri, 07 Oct 2022 14:02:27 +0000 Received: from bruce by momjian.us with local (Exim 4.94.2) (envelope-from ) id 1ognvi-005sqC-4b; Fri, 07 Oct 2022 10:02:22 -0400 Date: Fri, 7 Oct 2022 10:02:22 -0400 From: Bruce Momjian To: Erki Eessaar Cc: "pgsql-docs@lists.postgresql.org" , Noah Misch , Peter Eisentraut Subject: Re: SQL-standard function bodies and creating SECURITY DEFINER routines securely Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Oct 7, 2022 at 01:50:14PM +0000, Erki Eessaar wrote: > Hello > > Another example where explicit search path is needed. > > CREATE TABLE public.B(b INTEGER); > CREATE TABLE pg_temp.B(b INTEGER); > > CREATE OR REPLACE FUNCTION f3 () RETURNS VOID > LANGUAGE sql SECURITY DEFINER > BEGIN ATOMIC > INSERT INTO B(b) VALUES (1); > END; > > SELECT f3(); > > SELECT * FROM public.B; > /*Result has 0 rows.*/ > > SELECT * FROM pg_temp.B; > /*Result has 1 row. Function f3 was associated with pg_temp.B because > f3() did not have explicitly set search path.*/ > > I see now that there are multiple reasons why to still use search path. I agree > now that this extra paragaraph is perhaps too confusing and is not needed. Thanks. I learned a few things in this discussion and we can revisit it if we feel there is need of improvement. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com Indecision is a decision. Inaction is an action. Mark Batterson