| From: | Nathan Bossart <nathandbossart(at)gmail(dot)com> |
|---|---|
| To: | jian he <jian(dot)universality(at)gmail(dot)com> |
| Cc: | 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-04 18:33:13 |
| Message-ID: | aYOQ6c17UIW9Xsle@nathan |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Wed, Feb 04, 2026 at 04:14:59PM +0800, jian he wrote:
> These global objects dump(roles, tablespaces) are not directly related to
> pg_restore for now, pg_restore does not support options like --roles-only
> or --tablespaces-only.
I'm suggesting adding derivative flags to pg_dumpall, not pg_restore.
> Creating "derivative flags" requires careful
> consideration of their default values, which adds complexity for relatively
> little benefit. Overall we don't need to implement similar logic now, i think.
I'm not following your objection here. If anything, such a change would
reduce complexity. For example, we currently use the following check in
multiple places to decide whether to drop/drump databases:
if (!globals_only && !roles_only && !tablespaces_only)
If we created a derivative flag like this:
shouldDumpDBs = !globals_only && !roles_only && !tablespaces_only;
We could then decide whether to do database things like this:
if (shouldDumpDBs)
dumpDatabases(conn);
This has the added benefit of simplifying future patches that add new -only
options. If/when that happens, we'd just add it to the line that sets
shouldDumpDBs, whereas today we'd need to go through the rest of the code
and update multiple conditions. Not to mention the readability
improvements...
+ /* reject conflicting "-only" options */
+ if (globals_only && with_statistics)
+ pg_fatal("options %s and %s cannot be used together",
+ "-g/--globals-only", "--statistics");
+ if (globals_only && statistics_only)
+ pg_fatal("options %s and %s cannot be used together",
+ "-g/--globals-only", "--statistics-only");
As before, I think we should integrate the new conflicting option handling
into the existing section that does this sort of thing. We should also
make sure the handling is the same. The existing code uses pg_log_error(),
pg_log_error_hint(), and exit_nicely(), while the patch uses pg_fatal().
--
nathan
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Nathan Bossart | 2026-02-04 18:42:28 | Re: [BUG?] macOS (Intel) build warnings: "ranlib: file … has no symbols" for aarch64 objects |
| Previous Message | Tom Lane | 2026-02-04 18:27:43 | Re: [BUG?] macOS (Intel) build warnings: "ranlib: file … has no symbols" for aarch64 objects |