Re: pg_dumpall --roles-only interact with other options

From: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: Nathan Bossart <nathandbossart(at)gmail(dot)com>, wangpeng <215722532(at)qq(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_dumpall --roles-only interact with other options
Date: 2026-02-05 20:35:04
Message-ID: CAN4CZFPaUtO6eaF_7QEqSPmqfJsH7yQGFF6VUAGdd3uq1RA56g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> 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.

The variables also should use under_score names, not camelCase.

And these two produce empty dumps, maybe they could result in errors instead:

pg_dumpall --globals-only --schema-only
pg_dumpall --globals-only --data-only

These produce an empty dump with a pg_dump error message, as pg_dump
blocks them, so they could use early errors:

pg_dumpall --data-only --statistics-only
pg_dumpall --schema-only --statistics-only
pg_dumpall --data-only --schema-only

I also wonder if it would be better to use a simple static array with
a helper struct to describe the blocked pairs, iterating it with a
simple for loop and generating error messages dynamically, instead of
manual copy-paste and editing. This if list is already getting quite
long, and it doesn't contain all combinations that should be blocked
yet.

E.g.

incompatible_options[] = { { &globals_only, &roles_only,
"-g/--globals-only", "-r/--roles-only" }, ... }

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Sami Imseih 2026-02-05 20:43:38 Re: Fix pg_stat_get_backend_wait_event() for aux processes
Previous Message Andres Freund 2026-02-05 20:34:24 Re: pg_upgrade: transfer pg_largeobject_metadata's files when possible