Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f836c2e

Browse files
committed
Add some debug logging code to AllocateFile's failure path to log the
specific Windows error code (GetLastError). This is a hopefully temporary hack to try to diagnose rare failures. Magnus Hagander
1 parent 6935652 commit f836c2e

File tree

1 file changed

+15
-1
lines changed
  • src/backend/storage/file

1 file changed

+15
-1
lines changed

src/backend/storage/file/fd.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/storage/file/fd.c,v 1.128 2006/05/30 13:04:59 momjian Exp $
10+
* $PostgreSQL: pgsql/src/backend/storage/file/fd.c,v 1.129 2006/08/24 03:15:43 tgl Exp $
1111
*
1212
* NOTES:
1313
*
@@ -1278,6 +1278,20 @@ AllocateFile(const char *name, const char *mode)
12781278
errno = save_errno;
12791279
}
12801280

1281+
/*
1282+
* TEMPORARY hack to log the Windows error code on fopen failures,
1283+
* in hopes of diagnosing some hard-to-reproduce problems.
1284+
*/
1285+
#ifdef WIN32
1286+
{
1287+
int save_errno = errno;
1288+
1289+
elog(LOG, "Windows fopen(\"%s\",\"%s\") failed: code %lu, errno %d",
1290+
name, mode, GetLastError(), save_errno);
1291+
errno = save_errno;
1292+
}
1293+
#endif
1294+
12811295
return NULL;
12821296
}
12831297

0 commit comments

Comments
 (0)