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 1oR3E8-0004WG-By for pgsql-general@arkaria.postgresql.org; Thu, 25 Aug 2022 03:08:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oR3E6-0002gH-Rp for pgsql-general@arkaria.postgresql.org; Thu, 25 Aug 2022 03:08:14 +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 1oR3E6-0002g0-Gz for pgsql-general@lists.postgresql.org; Thu, 25 Aug 2022 03:08:14 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oR3E3-0002Gr-9P for pgsql-general@lists.postgresql.org; Thu, 25 Aug 2022 03:08:14 +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 27P37kAe1331175; Wed, 24 Aug 2022 23:07:46 -0400 From: Tom Lane To: gzh cc: pgsql-general@lists.postgresql.org Subject: Re: pg_dump without setting search_path In-reply-to: <4ee8e848.1efe.182d2e88b8c.Coremail.gzhcoder@126.com> References: <4ee8e848.1efe.182d2e88b8c.Coremail.gzhcoder@126.com> Comments: In-reply-to gzh message dated "Thu, 25 Aug 2022 10:50:31 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1331173.1661396866.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 24 Aug 2022 23:07:46 -0400 Message-ID: <1331174.1661396866@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk gzh writes: > When I use pg_dump to export schema from a database, it adds the followi= ng line at the beginning: > SELECT pg_catalog.set_config('search_path', '', false); > Is it possible set an option where pg_dump will not add this line? = No. It's a security precaution. > It is causing issues later when I try to execute other SQL commands, wit= hout the schema qualifier. That probably means you have some user-defined functions that are not sufficiently careful about search_path. You want to either schema-qualify every reference in the function body, or attach a "SET search_path" clause to remove the function's context dependency. (If you're using SQL-language functions in v14 or later, another option is to use the SQL-standard syntax instead of writing the body as a string literal. Then the object references in the function are parsed at definition time.) regards, tom lane