Re: Why pg_dump overwrites dump file?

From: Daniel Gustafsson <daniel(at)yesql(dot)se>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Why pg_dump overwrites dump file?
Date: 2025-10-29 20:12:02
Message-ID: 955DA44F-1034-4813-A8DF-2483133CF84A@yesql.se
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On 29 Oct 2025, at 20:47, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
>
> On Tue, Oct 14, 2025 at 10:44:37AM +0200, Daniel Gustafsson wrote:
>> 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
>>
>
>> diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml
>> index fd4ecf01a0a..5ac3f3e8510 100644
>> --- a/doc/src/sgml/ref/pg_dump.sgml
>> +++ b/doc/src/sgml/ref/pg_dump.sgml
>> @@ -297,8 +297,8 @@ PostgreSQL documentation
>> file based output formats, in which case the standard output is used.
>> It must be given for the directory output format however, where it
>> specifies the target directory instead of a file. In this case the
>> - directory is created by <command>pg_dump</command> and must not exist
>> - before.
>> + directory is created by <command>pg_dump</command> unless the directory
>> + exist and is empty.
>> </para>
>> </listitem>
>> </varlistentry>
>
> Uh, Daniel, are you going to make this change?

Yes, I had left it in my TODO for after my vacation (ie next week) to leave time for the OP (or someone else) to propose something different.

./daniel

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Davis 2025-10-29 20:14:21 Re: C11: should we use char32_t for unicode code points?
Previous Message Tom Lane 2025-10-29 19:51:46 Re: Use BumpContext contexts for TupleHashTables' tablecxt