pg.ddx.io pgsql-hackers@postgresql.org mailing list archive
help / color / mirror / Atom feedpg_dumpall dumps global objects with --statistics-only or --no-schema
3+ messages / 3 participants
[nested] [flat]
Commits from this thread:
2025-07-16 973caf7291 48c2c7b4b4 pg_dumpall: Skip global objects with --statistics-only or --no-schema.
* pg_dumpall dumps global objects with --statistics-only or --no-schema
@ 2025-06-24 15:26 Fujii Masao <masao.fujii@oss.nttdata.com>
0 siblings, 1 reply; 3+ messages in thread
From: Fujii Masao @ 2025-06-24 15:26 UTC (permalink / raw)
To: pgsql-hackers@lists.postgresql.org
Hi,
While testing pg_dumpall in v18, I noticed that it still dumps global objects
such as roles and tablespaces even when --statistics-only or --no-schema is
specified. This seems unexpected.
Since pg_dumpall treats global objects as schema-level content, it currently
includes them with --schema-only but skips them with --data-only. By that logic,
it should also skip them when either --statistics-only or --no-schema is used.
Thought?
Attached is a patch to fix this behavior.
Originally, I planned to work on this after we settled the ongoing discussion
about pg_dump options in [1], but since that may take some time, I wanted to
bring this up now so I don't forget the issue.
Regards,
[1] https://postgr.es/m/7cc52488-f876-4ad3-affd-6e4b0ef0cb09@eisentraut.org
--
Fujii Masao
NTT DATA Japan Corporation
Attachments:
v1-0001-pg_dumpall-Skip-global-objects-with-statistics-on.patch (text/plain, 1.1K) download
From a3cd7c76f456144c62e3652cf3edd77d2d8d3816 Mon Sep 17 00:00:00 2001
From: Fujii Masao <fujii@postgresql.org>
Date: Tue, 24 Jun 2025 23:56:28 +0900
Subject: [PATCH v1] pg_dumpall: Skip global objects with --statistics-only or
--no-schema.
Previously, pg_dumpall would still dump global objects such as roles
and tablespaces even when --statistics-only or --no-schema was specified.
Since these global objects are treated as schema-level data, they should
be skipped in these cases.
This commit fixes the issue by ensuring that global objects are not
dumped when either --statistics-only or --no-schema is used.
---
src/bin/pg_dump/pg_dumpall.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index 3cbcad65c5f..100317b1aa9 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -632,7 +632,7 @@ main(int argc, char *argv[])
fprintf(OPF, "SET escape_string_warning = off;\n");
fprintf(OPF, "\n");
- if (!data_only)
+ if (!data_only && !statistics_only && !no_schema)
{
/*
* If asked to --clean, do that first. We can avoid detailed
--
2.49.0
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: pg_dumpall dumps global objects with --statistics-only or --no-schema
@ 2025-06-30 20:44 Corey Huinker <corey.huinker@gmail.com>
parent: Fujii Masao <masao.fujii@oss.nttdata.com>
0 siblings, 1 reply; 3+ messages in thread
From: Corey Huinker @ 2025-06-30 20:44 UTC (permalink / raw)
To: Fujii Masao <masao.fujii@oss.nttdata.com>; +Cc: pgsql-hackers@lists.postgresql.org
>
>
> Since pg_dumpall treats global objects as schema-level content, it
> currently
> includes them with --schema-only but skips them with --data-only. By that
> logic,
> it should also skip them when either --statistics-only or --no-schema is
> used.
> Thought?
>
>
+1, pending resolution of the defaults issue.
At first glance, this looks like a good candidate for the the same refactor
that we did to pg_dump in 96a81c1be929, where we abandoned using the
schema_only and data_only flags to determine what should be dumped in favor
of dumpSchema, dumpData, and eventually dumpStatistics. This made for a
cleaner interface because each test was described in terms of what was
wanted, not in terms of the opposite being not the case, and all of the
double/triple-negative boolean backflips were concentrated right after the
options conflict resolutions.
However, all prospective do_this_thing branches are used exactly once, so
there is no code savings to be had and no clarity to be gained, so this
patch is fine as is.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: pg_dumpall dumps global objects with --statistics-only or --no-schema
@ 2025-07-16 17:03 Jeff Davis <pgsql@j-davis.com>
parent: Corey Huinker <corey.huinker@gmail.com>
0 siblings, 0 replies; 3+ messages in thread
From: Jeff Davis @ 2025-07-16 17:03 UTC (permalink / raw)
To: Corey Huinker <corey.huinker@gmail.com>; Fujii Masao <masao.fujii@oss.nttdata.com>; +Cc: pgsql-hackers@lists.postgresql.org
On Mon, 2025-06-30 at 16:44 -0400, Corey Huinker wrote:
> >
> > Since pg_dumpall treats global objects as schema-level content, it
> > currently
> > includes them with --schema-only but skips them with --data-only.
> > By that logic,
> > it should also skip them when either --statistics-only or --no-
> > schema is used.
Thank you.
>
> +1, pending resolution of the defaults issue.
I went ahead and committed this as it clearly needs to be fixed. We can
continue the options discussion.
Regards,
Jeff Davis
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2025-07-16 17:03 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-06-24 15:26 pg_dumpall dumps global objects with --statistics-only or --no-schema Fujii Masao <masao.fujii@oss.nttdata.com>
2025-06-30 20:44 ` Corey Huinker <corey.huinker@gmail.com>
2025-07-16 17:03 ` Jeff Davis <pgsql@j-davis.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox