Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iDu6s-0002f1-2w for pgsql-bugs@arkaria.postgresql.org; Fri, 27 Sep 2019 17:32:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iDu6q-0005bk-Va for pgsql-bugs@arkaria.postgresql.org; Fri, 27 Sep 2019 17:32:48 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iDu6q-0005bd-L6 for pgsql-bugs@lists.postgresql.org; Fri, 27 Sep 2019 17:32:48 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iDu6k-0008Vy-5y for pgsql-bugs@lists.postgresql.org; Fri, 27 Sep 2019 17:32:47 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1iDu6j-0002oT-Bs; Fri, 27 Sep 2019 13:32:41 -0400 Date: Fri, 27 Sep 2019 13:32:41 -0400 From: Bruce Momjian To: alexander.pavlov.rus@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15993: "CREATE OR REPLACE FUNCTION" does not clear search_path Message-ID: <20190927173241.GI31412@momjian.us> References: <15993-a0c0026150beb40a@postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <15993-a0c0026150beb40a@postgresql.org> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Fri, Sep 6, 2019 at 08:42:02PM +0000, PG Bug reporting form wrote: > The following bug has been logged on the website: > > Bug reference: 15993 > Logged by: Alexander Pavlov > Email address: alexander.pavlov.rus@gmail.com > PostgreSQL version: 10.9 > Operating system: Debian > Description: > > -- this will correctly create function with empty search_path > CREATE OR REPLACE FUNCTION MY_FUNC () RETURNS BOOLEAN AS $$ BEGIN RETURN > TRUE;END;$$ LANGUAGE PLPGSQL; > > -- this will correctly update function to have "PUBLIC, MY_SCHEMA" search > path > CREATE OR REPLACE FUNCTION MY_FUNC () RETURNS BOOLEAN AS $$ BEGIN RETURN > TRUE;END;$$ LANGUAGE PLPGSQL SET SEARCH_PATH TO PUBLIC, MY_SCHEMA; > > -- this will correctly update function to have "MY_SCHEMA" search path > CREATE OR REPLACE FUNCTION MY_FUNC () RETURNS BOOLEAN AS $$ BEGIN RETURN > TRUE;END;$$ LANGUAGE PLPGSQL SET SEARCH_PATH TO MY_SCHEMA; > > -- this will NOT update function to have empty search path, search path will > remain "MY_SCHEMA", as at previous "create or replace" call > CREATE OR REPLACE FUNCTION MY_FUNC () RETURNS BOOLEAN AS $$ BEGIN RETURN > TRUE;END;$$ LANGUAGE PLPGSQL; So you are saying that CREATE OR REPLACE FUNCTION should not preserve the SEARCH_PATH. Makes sense to me. Any idea why we coded it this way? It it part of the "OR REPLACE" goal? -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + As you are, so once was I. As I am, so you will be. + + Ancient Roman grave inscription +