[Proposal] Allow pg_dump to include all child tables with the root table - Mailing list pgsql-hackers

From Gilles Darold
Subject [Proposal] Allow pg_dump to include all child tables with the root table
Date
Msg-id 5aa393b5-5f67-8447-b83e-544516990ee2@migops.com
Whole thread Raw
Responses Re: [Proposal] Allow pg_dump to include all child tables with the root table
List pgsql-hackers
Hi all,


I would like to propose a new pg_dump option called --with-child to 
include or exclude from a dump all child and partition tables when a 
parent table is specified using option -t/--table or -T/--exclude-table. 
The whole tree is dumped with the root table.


To include all partitions or child tables with inheritance in a table 
dump we usually use the wildcard, for example:


     pg_dump -d mydb -t "root_tbname*" > out.sql


This suppose that all child/partition tables use the prefix root_tbname 
in their object name. This is often the case but, if you are as lucky as 
me, the partitions could have a total different name. No need to say 
that for inheritance this is rarely the case. The other problem is that 
with the wildcard you can also dump relations that are not concerned at 
all by what you want to dump. Using the --with-child option will allow 
to just specify the root relation and all child/partition definitions 
and/or data will be parts of dump.


     pg_dump -d mydb --table "root_tbname" --with-childs > out.sql


To exclude a whole inheritance tree from a dump:


     pg_dump -d mydb --exclude-table "root_tbname" --with-childs > out.sql


Here in attachment the patch that adds this feature to pg_dump.


Is there is any interest for this feature?


Best regards,

-- 
Gilles Darold
https://www.migops.com/

Attachment

pgsql-hackers by date:

Previous
From: vignesh C
Date:
Subject: Re: mprove tab completion for ALTER EXTENSION ADD/DROP
Next
From: Andrey Borodin
Date:
Subject: Re: MultiXact\SLRU buffers configuration