Re: pg_dumpall --exclude-database option

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_dumpall --exclude-database option
Date: 2018-10-13 14:07:03
Message-ID: alpine.DEB.2.21.1810131525000.12620@lancre
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


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.

--
Fabien.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jung, Jinho 2018-10-13 16:12:03 Regarding query minimizer (simplifier)
Previous Message Andrew Dunstan 2018-10-13 14:00:25 Re: pgsql: Add TAP tests for pg_verify_checksums