Don't Insert() a VFD entry until it's fully built.
authorTom Lane <[email protected]>
Tue, 17 Nov 2020 01:32:35 +0000 (20:32 -0500)
committerTom Lane <[email protected]>
Tue, 17 Nov 2020 01:32:35 +0000 (20:32 -0500)
commitd02dbbadb7cc7a3c70803c3b77a448b355ecb85b
treed019adcdcfa4672bf237d2fa36feac3e827660a0
parenta39de0c415fa6f0e215c97e4d587aaa6482174ca
Don't Insert() a VFD entry until it's fully built.

Otherwise, if FDDEBUG is enabled, the debugging output fails because
it tries to read the fileName, which isn't set up yet (and should in
fact always be NULL).

AFAICT, this has been wrong since Berkeley.  Before 96bf88d52,
it would accidentally fail to crash on platforms where snprintf()
is forgiving about being passed a NULL pointer for %s; but the
file name intended to be included in the debug output wouldn't
ever have shown up.

Report and fix by Greg Nancarrow.  Although this is only visibly
broken in custom-made builds, it still seems worth back-patching
to all supported branches, as the FDDEBUG code is pretty useless
as it stands.

Discussion: https://postgr.es/m/CAJcOf-cUDgm9qYtC_B6XrC6MktMPNRby2p61EtSGZKnfotMArw@mail.gmail.com
src/backend/storage/file/fd.c