Skip to content

Commit 6b8235d

Browse files
committed
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 96bf88d, 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
1 parent 84e3162 commit 6b8235d

File tree

1 file changed

+2
-2
lines changed
  • src/backend/storage/file

1 file changed

+2
-2
lines changed

src/backend/storage/file/fd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,8 +1422,6 @@ PathNameOpenFilePerm(const char *fileName, int fileFlags, mode_t fileMode)
14221422
DO_DB(elog(LOG, "PathNameOpenFile: success %d",
14231423
vfdP->fd));
14241424

1425-
Insert(file);
1426-
14271425
vfdP->fileName = fnamecopy;
14281426
/* Saved flags are adjusted to be OK for re-opening file */
14291427
vfdP->fileFlags = fileFlags & ~(O_CREAT | O_TRUNC | O_EXCL);
@@ -1433,6 +1431,8 @@ PathNameOpenFilePerm(const char *fileName, int fileFlags, mode_t fileMode)
14331431
vfdP->fdstate = 0x0;
14341432
vfdP->resowner = NULL;
14351433

1434+
Insert(file);
1435+
14361436
return file;
14371437
}
14381438

0 commit comments

Comments
 (0)