Don't Insert() a VFD entry until it's fully built.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 17 Nov 2020 01:32:35 +0000 (20:32 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 17 Nov 2020 01:32:55 +0000 (20:32 -0500)
commit2bd49b493a52f0a21bc3fc51c355963f99ac1a4e
treea84319510fe2b16cc70ec8e60e91dabb9175cc81
parentcd9c1b3e197a9b53b840dcc87eb41b04d601a5f9
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