Re: thinko in basic_archive.c - Mailing list pgsql-hackers

From Nathan Bossart
Subject Re: thinko in basic_archive.c
Date
Msg-id 20221105214651.GC137360@nathanxps13
Whole thread Raw
In response to Re: thinko in basic_archive.c  (Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>)
Responses Re: thinko in basic_archive.c
List pgsql-hackers
On Fri, Oct 21, 2022 at 09:30:16PM +0530, Bharath Rupireddy wrote:
> On Fri, Oct 21, 2022 at 10:43 AM Kyotaro Horiguchi
> <horikyota.ntt@gmail.com> wrote:
>> Thanks, but we don't need to wipe out the all bytes. Just putting \0
>> at the beginning of the buffer is sufficient.
> 
> Nah, that's not a clean way IMO.

Why not?  This is a commonly-used technique.  I see over 80 existing useѕ
in PostgreSQL.  Plus, your shutdown callback only checks for the first
byte, anyway.

+    if (tempfilepath[0] == '\0')
+        return;

As noted upthread [0], I think we should be cautious to only remove the
temporary file if we know we created it.  I still feel that trying to add
this cleanup logic to basic_archive is probably more trouble than it's
worth, but if there is a safe and effective way to do so, I won't object.

[0] https://postgr.es/m/20221015211026.GA1821022%40nathanxps13

-- 
Nathan Bossart
Amazon Web Services: https://aws.amazon.com



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Documentation for building with meson
Next
From: Tom Lane
Date:
Subject: Re: Making Vars outer-join aware