Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dJOA8-0001LY-I4 for pgsql-bugs@arkaria.postgresql.org; Fri, 09 Jun 2017 17:57:32 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dJOA7-0007th-2j for pgsql-bugs@arkaria.postgresql.org; Fri, 09 Jun 2017 17:57:31 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dJO9Q-0006g4-Ba for pgsql-bugs@postgresql.org; Fri, 09 Jun 2017 17:56:48 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dJO9N-00022n-L4 for pgsql-bugs@postgresql.org; Fri, 09 Jun 2017 17:56:47 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v59HuhLF005618; Fri, 9 Jun 2017 13:56:43 -0400 From: Tom Lane To: psuderevsky@gmail.com cc: pgsql-bugs@postgresql.org Subject: Re: BUG #14700: pg_restore doesn't declare schema in 'create function' statements In-reply-to: <20170609163144.26508.40598@wrigleys.postgresql.org> References: <20170609163144.26508.40598@wrigleys.postgresql.org> Comments: In-reply-to psuderevsky@gmail.com message dated "Fri, 09 Jun 2017 16:31:44 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <5616.1497031003.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 09 Jun 2017 13:56:43 -0400 Message-ID: <5617.1497031003@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org psuderevsky@gmail.com writes: > When restoring only particular schema from dump with "pg_restore -n" it d= oes > the following: > 1. SET search_path =3D yourschema, pg_catalog > 2. CREATE FUNCTION yourfunction() Yes, that's intentional. > As a result, if you had forgotten creating yourschema before restoring th= en > no objects will be restored except your functions, they will be restored = in > pg_catalog schema. > These statements must be performed with direct schema reference: CREATE > FUNCTION yourschema.yourfunction(). We're not doing that because it breaks other useful use-cases; in particular, editing a dump to move things into another schema becomes a lot harder. Even if we wanted to change pg_dump that way, it wouldn't make things any safer for existing dump files. There was a long discussion of whether to change anything in this area a few years ago: https://www.postgresql.org/message-id/flat/8c4600a6f10e7dd823a157eff9985068= .squirrel%40webmail.xs4all.nl That trailed off without any real consensus about what to do. Personally I still like the idea of refusing to allow creates if the first schema listed in search_path doesn't exist, but I was having a hard time selling that plan :-( regards, tom lane --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs