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 1lDF6K-00063N-3U for pgsql-general@arkaria.postgresql.org; Fri, 19 Feb 2021 23:22:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lDF6I-00012b-Pa for pgsql-general@arkaria.postgresql.org; Fri, 19 Feb 2021 23:22:18 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lDF6I-00012U-Hf for pgsql-general@lists.postgresql.org; Fri, 19 Feb 2021 23:22:18 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lDF6C-0006t0-9v for pgsql-general@lists.postgresql.org; Fri, 19 Feb 2021 23:22:17 +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 11JNMAxg3123725; Fri, 19 Feb 2021 18:22:10 -0500 From: Tom Lane To: Ken Tanzer cc: Rob Sargent , "pgsql-generallists.postgresql.org" Subject: Re: Error with pg_dump (of data), with --role In-reply-to: References: <296ae0e1-8f2c-fc11-d184-f98dba3d0cd5@gmail.com> <2996155.1613709876@sss.pgh.pa.us> Comments: In-reply-to Ken Tanzer message dated "Fri, 19 Feb 2021 10:53:49 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3123723.1613776930.1@sss.pgh.pa.us> Date: Fri, 19 Feb 2021 18:22:10 -0500 Message-ID: <3123724.1613776930@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Ken Tanzer writes: > On Thu, Feb 18, 2021 at 8:44 PM Tom Lane wrote: >> There was a security change to pg_dump a few years ago to make it >> put "set search_path = pg_catalog" into the dump script. This >> basically means that any user-defined function in indexes, check >> constraints, etc is on its own to be sure that it schema-qualifies >> non-system names, or has a "SET search_path" clause to do that >> for it. > Thank you Tom for that explanation. To follow on, I tried adding: > SET search_path = public; > to the functions, but that prevents my function from working at all: No, the way to do it is with a SET function property, like create or replace function myfunc(...) returns ... language ... as $$body here$$ SET search_path = whatever ... other function properties ... ; That takes care of restoring the old value on the way out of the function, so it's okay to use in an immutable function. I think you can plaster this property onto an existing function with ALTER FUNCTION, which should be less error-prone than repeating the whole CREATE. regards, tom lane