Re: Why pg_dump overwrites dump file?

From: Daniel Gustafsson <daniel(at)yesql(dot)se>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Why pg_dump overwrites dump file?
Date: 2025-10-14 08:44:37
Message-ID: 46AFE2A5-8189-4868-9CF0-E2E58E9DFCC5@yesql.se
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On 14 Oct 2025, at 07:42, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote:

> Behaviors of the two types of pg_dump are inconsistent, I wonder if that’s by design?

It does admittedly seem odd that --file works differently for files and
directories, but at this point it might be behavior that users expect and
changing it might break current usecases? Not sure what the best option is
here.

Another inconsistency is that the documentation states this:

"In this case the directory is created by pg_dump and must not exist
before."

..which isn't true, since it will happily reuse an existing directory as long as
it's empty, the comment in the code makes the intention clear:

/*
* create_or_open_dir
*
* This will create a new directory with the given dirname. If there is
* already an empty directory with that name, then use it.
*/

So regardless it seems we should something like the attached at least.

--
Daniel Gustafsson

Attachment Content-Type Size
pg_dump_emptydir.diff application/octet-stream 724 bytes

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message torikoshia 2025-10-14 09:00:45 Re: Enhancing Memory Context Statistics Reporting
Previous Message Dmitry Dolgov 2025-10-14 08:35:55 Re: Changing shared_buffers without restart