Re: pg_dumpall --exclude-database option

From: Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>
To: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_dumpall --exclude-database option
Date: 2018-10-31 14:16:49
Message-ID: 110d6eb1-9695-24fd-5ae3-f4670fa8fcd0@2ndQuadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 10/13/2018 10:07 AM, Fabien COELHO wrote:
>
> Hello Andrew,
>
>>> A question: would it makes sense to have a symmetrical
>>> --include-database=PATTERN option as well?
>>
>> I don't think so. If you only want a few databases, just use pg_dump.
>> The premise of pg_dumpall is that you want all of them and this
>> switch provides for exceptions to that.
>
> Ok, sounds reasonable.
>
>>> Somehow the option does not make much sense when under -g/-r/-t...
>>> maybe it should complain, like it does when the others are used
>>> together?
>>
>> Added an error check.
>
> Ok.
>
>>> ISTM that it would have been better to issue just one query with an
>>> OR list, but that would require to extend "processSQLNamePattern" a
>>> little bit. Not sure whether it is worth it.
>>
>> I don't think it is. This uses the same pattern that is used in
>> pg_dump.c for similar switches.
>
> Ok.
>
>> revised patch attached.
>
> Patch applies cleanly, compiles, make check ok, pg_dump tap tests ok,
> doc build ok.
>
> Very minor comments:
>
> Missing space after comma:
>
>  + {"exclude-database",required_argument, NULL, 5},
>
> Now that C99 is okay, ISTM that both for loops in
> expand_dbname_patterns could benefit from using loop-local variables:
>
>   for (SimpleStringListCell *cell = ...
>   for (int i = ...
>
> About the documentation:
>
>    "When using wildcards, be careful to quote the pattern if needed to
> prevent
>     the shell from expanding the wildcards."
>
> I'd suggest to consider simplifying the end, maybe "to prevent shell
> wildcard expansion".
>
> The feature is not tested per se. Maybe one existing tap test could be
> extended with minimal fuss to use it, eg --exclude-database='[a-z]*'
> should be close to only keeping the global stuff? I noticed an
> "exclude table" test already exists.
>

This patch addresses all these concerns.

cheers

andrew

--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment Content-Type Size
pg_dumpall-exclude-v4.patch text/x-patch 9.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2018-10-31 14:21:44 Re: WIP Patch: Add a function that returns binary JSONB as a bytea
Previous Message Stephen Frost 2018-10-31 13:30:56 Re: WIP Patch: Add a function that returns binary JSONB as a bytea