Re: bug: pg_dumpall with --data-only and --clean options is giving an error after some dump

From: Srinath Reddy Sadipiralla <srinath2133(at)gmail(dot)com>
To: Mahendra Singh Thalor <mahi6run(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: bug: pg_dumpall with --data-only and --clean options is giving an error after some dump
Date: 2026-03-15 06:14:50
Message-ID: CAFC+b6pOQ3HZMVQu43jZo-pA7+Y+ndPprKa5jV6CQoug3xcs1Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

On Sun, Mar 15, 2026 at 12:49 AM Mahendra Singh Thalor <mahi6run(at)gmail(dot)com>
wrote:

> Hi all,
>
> I was doing some tests with pg_dump, pg_dumpall and pg_restore tools. With
> "pg_dumpall --data-only --clean", we are reporting an error after dumping
> some data.
>
> Please see the example below.
>
> ./pg_dumpall --data-only --clean
>> --
>> -- PostgreSQL database cluster dump
>> --
>>
>> \restrict ZQDDv56JBW8CVfkLsRDeyRpBvDGYUeqhZbJkDccKbXG8q6PI4RB69Dd8KaqcWMY
>>
>> SET default_transaction_read_only = off;
>>
>> SET client_encoding = 'UTF8';
>> SET standard_conforming_strings = on;
>>
>> \unrestrict
>> ZQDDv56JBW8CVfkLsRDeyRpBvDGYUeqhZbJkDccKbXG8q6PI4RB69Dd8KaqcWMY
>>
>> --
>> -- Databases
>> --
>>
>> --
>> -- Database "template1" dump
>> --
>>
>> pg_dump: error: options -c/--clean and -a/--data-only cannot be used
>> together
>> pg_dumpall: error: pg_dump failed on database "template1", exiting
>>
>>
> Error is coming from pg_dump but it should come from pg_dumpall without
> any dump.
>
> Here, I am attaching a patch to fix this problem. Please review this.
>

+1 for the fix , as it immediately throws an error in pg_dumpall itself,
instead of going through all the way until pg_dump and then finding
out it's not a correct combination of options.

I have reviewed,tested the patch , except these it LGTM.
1) maybe match the pg_dumpall comment with the pg_dump comment.
2) please fix the indentation using pgindent

diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index 47a062d0160..b47e683e1d4 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -455,9 +455,9 @@ main(int argc, char *argv[])
schema_only,
"-s/--schema-only",
tablespaces_only,
"-t/--tablespaces-only");

- /* --clean and --data-only are incompatible */
+ /* --clean is incompatible with --data-only */
check_mut_excl_opts(output_clean, "-c/--clean",
- data_only, "-a/--data-only");
+ data_only,
"-a/--data-only");

if (if_exists && !output_clean)
pg_fatal("option %s requires option %s",

--
Thanks,
Srinath Reddy Sadipiralla
EDB: https://www.enterprisedb.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Zsolt Parragi 2026-03-15 07:40:38 Re: Proposal: common explicit lists for installed headers
Previous Message Marcos Magueta 2026-03-15 04:25:22 Re: WIP - xmlvalidate implementation from TODO list