Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eeYyy-0007PJ-Ej for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Jan 2018 04:17:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eeYyx-0006GP-Vb for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Jan 2018 04:17:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eeYyx-0006GF-PC for pgsql-hackers@lists.postgresql.org; Thu, 25 Jan 2018 04:17:47 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eeYyq-0002Ju-To for pgsql-hackers@lists.postgresql.org; Thu, 25 Jan 2018 04:17: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 w0P4HcAJ004859; Wed, 24 Jan 2018 23:17:38 -0500 From: Tom Lane To: "David G. Johnston" cc: "pgsql-hackers@lists.postgresql.org" Subject: Re: Further cleanup of pg_dump/pg_restore item selection code In-reply-to: References: <32668.1516848577@sss.pgh.pa.us> Comments: In-reply-to "David G. Johnston" message dated "Wed, 24 Jan 2018 20:36:05 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4857.1516853858.1@sss.pgh.pa.us> Date: Wed, 24 Jan 2018 23:17:38 -0500 Message-ID: <4858.1516853858@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk "David G. Johnston" writes: > On Wednesday, January 24, 2018, Tom Lane wrote: >> The same behaviors occur if you do e.g. >> pg_dump -Fc -t sometable somedb | pg_restore --create >> which is another undocumented misbehavior: the docs for pg_restore do not >> suggest that --create might fail if the source archive was selective. > pg_restore -t: > "When -t is specified, pg_restore makes no attempt to restore any other > database objects that the selected table(s) might depend upon. Therefore, > there is no guarantee that a specific-table restore into a clean database > will succeed." I think you might be missing one of the main points here, which is that --create is specified as causing both a CREATE DATABASE and a reconnect to that database. If it silently becomes a no-op, which is what happens today, the restore is likely to go into the wrong database entirely (or at least not the DB the user expected). I won't deny the possibility that some people are depending on the existing wrong behavior, but that's a hazard with any bug fix. regards, tom lane