Re: pg_dump --with-* options
Fujii Masao <masao.fujii@gmail.com>
From: Fujii Masao <masao.fujii@gmail.com>
To: Jeff Davis <pgsql@j-davis.com>
Cc: Nathan Bossart <nathandbossart@gmail.com>,
Robert Haas <robertmhaas@gmail.com>, Peter Eisentraut <peter@eisentraut.org>,
pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-08-02T13:58:36Z
Lists: pgsql-hackers
On Sat, Aug 2, 2025 at 4:42 AM Jeff Davis <pgsql@j-davis.com> wrote:
> Patch attached.
>
> * removes --with-data and --with-schema (redundant)
> * renames --with-statistics to just --statistics
>
> I kept --statistics and --no-statistics for both pg_dump and
> pg_restore, because: (a) I think it's good to have consistent options
> between those two programs; and (b) it allows us to potentially change
> the default to include statistics in the future. That leaves some
> redundancy of the options, which some have expressed annoyance over,
> but it doesn't seem like a major point of objection.
I'm OK with this approach. Thanks for the patch! It looks good to me.
While not directly related to your patch, I feel inclined to simplify option
handling in pg_dump, similar to what we've already done in pg_restore.c
and pg_dumpall.c. For example, we could change how statistics_only is handled
like this:
---------------------------------------
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -448,7 +448,7 @@ main(int argc, char **argv)
DataDirSyncMethod sync_method = DATA_DIR_SYNC_METHOD_FSYNC;
bool data_only = false;
bool schema_only = false;
- bool statistics_only = false;
+ static int statistics_only = 0;
bool with_statistics = false;
bool no_data = false;
bool no_schema = false;
@@ -513,7 +513,7 @@ main(int argc, char **argv)
{"serializable-deferrable", no_argument,
&dopt.serializable_deferrable, 1},
{"snapshot", required_argument, NULL, 6},
{"statistics", no_argument, NULL, 22},
- {"statistics-only", no_argument, NULL, 18},
+ {"statistics-only", no_argument, &statistics_only, 1},
{"strict-names", no_argument, &strict_names, 1},
{"use-set-session-authorization", no_argument,
&dopt.use_setsessauth, 1},
{"no-comments", no_argument, &dopt.no_comments, 1},
@@ -777,10 +777,6 @@ main(int argc, char **argv)
optarg);
break;
- case 18:
- statistics_only = true;
- break;
-
case 19:
no_data = true;
break;
---------------------------------------
We could apply the same pattern to others like no_data, no_schema,
no_statistics, and with_statistics to make the code cleaner and more
consistent across tools.
Regards,
--
Fujii Masao
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Simplify options in pg_dump and pg_restore.
- 6a46089e458f 19 (unreleased) landed
- a3e8dc143862 18.0 landed
-
pg_dump: reject combination of "only" and "with"
- 0ed92cf50cc4 19 (unreleased) landed
- 60121890f7f2 18.0 landed
-
Change pg_dump default for statistics export.
- 34eb2a80d5a3 18.0 cited