Re: pg_dumpall --roles-only interact with other options - Mailing list pgsql-hackers

From jian he
Subject Re: pg_dumpall --roles-only interact with other options
Date
Msg-id CACJufxEpPEDsxgppQg41nyPyBQX4+DBRRUnysaBYwRuCqdF48g@mail.gmail.com
Whole thread Raw
In response to Re: pg_dumpall --roles-only interact with other options  (Zsolt Parragi <zsolt.parragi@percona.com>)
List pgsql-hackers
On Fri, Feb 6, 2026 at 4:35 AM Zsolt Parragi <zsolt.parragi@percona.com> wrote:
>
> > The attached patch also addresses the points mentioned by Zsolt Parragi.
>
> old:
>
> - if (!data_only && !statistics_only && !no_schema)
>
> new:
>
> + shouldDumpTablespaces = !roles_only && !no_tablespaces && !data_only
> && !schema_only && !statistics_only;
> + shouldDumpRoles = !tablespaces_only && !data_only && !schema_only &&
> !statistics_only;
>
> This is still a user visible change: no_schema -> schema_only
>
> And I don't think this change is good, roles and tablespaces are part
> of the schema, without them, DDL statements later can fail.
>
hi.
I believe "schema" generally refers to object definitions, excluding
things like roles and tablespaces.
I tend to think that once "only" is specified, the "no" option meaning
is not applied,
thus I'm ok with
pg_dumpall --globals-only --no-schema
is equivalent to
pg_dumpall --globals-only

For all these pg_dumpall combination
--roles-only
--tablespaces-only
--statistics-only
--schema-only
--globals-only
--data-only
--statistics

The only allowed combination is --statistics --statistics-only.
since pg_dump also supports it, and these two option meanings do not contradict.

please check v4, it looks very neat, IMHO.
for example:
+    if (schema_only && (with_statistics || statistics_only))
+    {
+        pg_log_error("options %s and %s cannot be used together",
+                     "-s/--schema-only",
+                     statistics_only ? "--statistics-only" :
+                     "--statistics");
+

src/bin/pg_dump/t/001_basic.pl tests are well aligned with pg_dumpall.c code, so
it's quite easy to review.



--
jian
https://www.enterprisedb.com/

Attachment

pgsql-hackers by date:

Previous
From: Junwang Zhao
Date:
Subject: Re: Emitting JSON to file using COPY TO
Next
From: Michael Paquier
Date:
Subject: Re: Small fixes for incorrect error messages