Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d8oFF-0006aa-KL for pgsql-hackers@arkaria.postgresql.org; Thu, 11 May 2017 13:35:05 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1d8oFF-000452-5R for pgsql-hackers@arkaria.postgresql.org; Thu, 11 May 2017 13:35:05 +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 1d8oDj-0001DM-Lq for pgsql-hackers@postgresql.org; Thu, 11 May 2017 13:33:31 +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 1d8oDh-0000Rq-8C for pgsql-hackers@postgresql.org; Thu, 11 May 2017 13:33:30 +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 v4BDXRpD003929; Thu, 11 May 2017 09:33:27 -0400 From: Tom Lane To: Robert Haas cc: Jeevan Ladhe , Ashutosh Bapat , amul sul , PostgreSQL-development Subject: Re: Bug in pg_dump --table and --exclude-table for declarative partition table handling. In-reply-to: References: <14125.1494452121@sss.pgh.pa.us> <31399.1494507762@sss.pgh.pa.us> Comments: In-reply-to Robert Haas message dated "Thu, 11 May 2017 09:13:56 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3927.1494509607.1@sss.pgh.pa.us> Date: Thu, 11 May 2017 09:33:27 -0400 Message-ID: <3928.1494509607@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-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Robert Haas writes: > On Thu, May 11, 2017 at 9:02 AM, Tom Lane wrote: >> You could argue that it would be better for pg_dump to emit something >> like >> >> CREATE TABLE c (...); >> ALTER TABLE c INHERIT p; >> >> so that if p isn't around, at least c gets created. And I think it >> *would* be better, probably. But if that isn't a new feature then >> I don't know what is. And partitioning really ought to track the >> behavior of inheritance here. > Hmm, I think that'd actually be worse, because it would break the use > case where you want to restore the old contents of one particular > inheritance child. So you drop that child (but not the parent or any > other children) and then do a selective restore of that one child. > Right now that works fine, but it'll fail with an error if we try to > create the already-extant parent. Uh ... what in that is creating the already-extant parent? What I'm envisioning is simply that the TOC entry for the child table contains those two statements rather than "CREATE TABLE c (...) INHERITS (p)". The equivalent thing for the partitioned case is to use a separate ATTACH PARTITION command rather than naming the parent immediately in the child's CREATE TABLE. This is independent of the question of how --table and friends ought to behave. > I think one answer to the original complaint might be to add a new > flag to pg_dump, something like --recursive-selection, maybe -r for > short, which makes --table, --exclude-table, and --exclude-table-data > cascade to inheritance descendents. Yeah, you could do it like that. Another way to do it would be to create variants of all the selection switches, along the lines of "--table-all=foo" meaning "foo plus its children". Then you could have some switches recursing and others not within the same command. But maybe that's more flexibility than needed ... and I'm having a hard time coming up with nice switch names, anyway. Anyway, I'm still of the opinion that it's fine to leave this as a future feature. If we've gotten away without it this long for inherited tables, it's unlikely to be critical for partitioned tables. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers