Re: [Proposal] Allow pg_dump to include all child tables with the root table

Gilles Darold <gilles@migops.com>

From: Gilles Darold <gilles@migops.com>
To: pgsql-hackers@lists.postgresql.org
Date: 2023-02-25T18:59:47Z
Lists: pgsql-hackers

Attachments

Le 25/02/2023 à 16:40, Stéphane Tachoires a écrit :
> Hi,
>
> I'm not sure about the "child" -> "partition" change as it also 
> selects childs that are not partitions.
> I'm more dubious about the --with-childs option, I'd rather have 
> --table-with-childs=<PATTERN> and 
> --exclude-table-with-childs=<PATTERN>. That will be clearer about what 
> is what.
>
> I'm working on that, but have a hard time with 
> test pg_dump/002_pg_dump (It's brand new to me)
>
> Stéphane
>
> Le ven. 24 févr. 2023 à 23:50, Cary Huang <cary.huang@highgo.ca> a écrit :
>
>     The following review has been posted through the commitfest
>     application:
>     make installcheck-world:  tested, passed
>     Implements feature:       tested, passed
>     Spec compliant:           not tested
>     Documentation:            not tested
>
>     Hi
>
>     the patch applies fine on current master branch and it works as
>     described. However, I would suggest changing the new option name
>     from "--with-childs" to "--with-partitions" for several reasons.
>
>     "childs" is grammatically incorrect and in the PG community, the
>     term "partitioned table" is normally used to denote a parent
>     table, and the term "partition" is used to denote the child table
>     under the parent table. We should use these terms to stay
>     consistent with the community.
>
>     Also, I would rephrase the documentation as:
>
>     Used in conjunction with
>     <option>-t</option>/<option>--table</option> or
>     <option>-T</option>/<option>--exclude-table</option> options to
>     include or exclude partitions of the specified tables if any.
>
>     thank you
>
>     Cary Huang
>     ================
>     HighGo Software Canada
>     www.highgo.ca <http://www.highgo.ca>
>

Hi,


This is right this patch also works with inherited tables so 
--with-partitions can be confusing this is why --with-childs was chosen. 
But I disagree the use of --table-with-childs and 
--exclude-table-with-childs because we already have the --table and 
--exclude-table, and it will add lot of code where we just need a switch 
to include children tables. Actually my first though was that this 
behavior (dump child tables when the root table is dumped using --table) 
should be the default in pg_dump but the problem is that it could break 
existing scripts using pg_dump so I prefer to implement the 
--with-childs options.


I think we can use --with-partitions, provided that it is clear in the 
documentation that this option also works with inheritance.


Attached is a new patch v2 using the --with-partitions and the 
documentation fix.


-- 
Gilles Darold

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Allow pg_dump to include/exclude child tables automatically.