mirror of
https://github.com/postgres/postgres.git
synced 2025-07-15 19:21:59 +03:00
Use consistent format for reporting GetLastError()
Use something like "error code %lu" for reporting GetLastError() values on Windows. Previously, a mix of different wordings and formats were in use.
This commit is contained in:
@ -45,7 +45,7 @@ GetSharedMemName(void)
|
||||
|
||||
bufsize = GetFullPathName(DataDir, 0, NULL, NULL);
|
||||
if (bufsize == 0)
|
||||
elog(FATAL, "could not get size for full pathname of datadir %s: %lu",
|
||||
elog(FATAL, "could not get size for full pathname of datadir %s: error code %lu",
|
||||
DataDir, GetLastError());
|
||||
|
||||
retptr = malloc(bufsize + 18); /* 18 for Global\PostgreSQL: */
|
||||
@ -55,7 +55,7 @@ GetSharedMemName(void)
|
||||
strcpy(retptr, "Global\\PostgreSQL:");
|
||||
r = GetFullPathName(DataDir, bufsize, retptr + 18, NULL);
|
||||
if (r == 0 || r > bufsize)
|
||||
elog(FATAL, "could not generate full pathname for datadir %s: %lu",
|
||||
elog(FATAL, "could not generate full pathname for datadir %s: error code %lu",
|
||||
DataDir, GetLastError());
|
||||
|
||||
/*
|
||||
@ -165,7 +165,7 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port)
|
||||
|
||||
if (!hmap)
|
||||
ereport(FATAL,
|
||||
(errmsg("could not create shared memory segment: %lu", GetLastError()),
|
||||
(errmsg("could not create shared memory segment: error code %lu", GetLastError()),
|
||||
errdetail("Failed system call was CreateFileMapping(size=%lu, name=%s).",
|
||||
(unsigned long) size, szShareMem)));
|
||||
|
||||
@ -200,7 +200,7 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port)
|
||||
*/
|
||||
if (!DuplicateHandle(GetCurrentProcess(), hmap, GetCurrentProcess(), &hmap2, 0, TRUE, DUPLICATE_SAME_ACCESS))
|
||||
ereport(FATAL,
|
||||
(errmsg("could not create shared memory segment: %lu", GetLastError()),
|
||||
(errmsg("could not create shared memory segment: error code %lu", GetLastError()),
|
||||
errdetail("Failed system call was DuplicateHandle.")));
|
||||
|
||||
/*
|
||||
@ -208,7 +208,7 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port)
|
||||
* care.
|
||||
*/
|
||||
if (!CloseHandle(hmap))
|
||||
elog(LOG, "could not close handle to shared memory: %lu", GetLastError());
|
||||
elog(LOG, "could not close handle to shared memory: error code %lu", GetLastError());
|
||||
|
||||
|
||||
/* Register on-exit routine to delete the new segment */
|
||||
@ -221,7 +221,7 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port)
|
||||
memAddress = MapViewOfFileEx(hmap2, FILE_MAP_WRITE | FILE_MAP_READ, 0, 0, 0, NULL);
|
||||
if (!memAddress)
|
||||
ereport(FATAL,
|
||||
(errmsg("could not create shared memory segment: %lu", GetLastError()),
|
||||
(errmsg("could not create shared memory segment: error code %lu", GetLastError()),
|
||||
errdetail("Failed system call was MapViewOfFileEx.")));
|
||||
|
||||
|
||||
@ -272,12 +272,12 @@ PGSharedMemoryReAttach(void)
|
||||
* Release memory region reservation that was made by the postmaster
|
||||
*/
|
||||
if (VirtualFree(UsedShmemSegAddr, 0, MEM_RELEASE) == 0)
|
||||
elog(FATAL, "failed to release reserved memory region (addr=%p): %lu",
|
||||
elog(FATAL, "failed to release reserved memory region (addr=%p): error code %lu",
|
||||
UsedShmemSegAddr, GetLastError());
|
||||
|
||||
hdr = (PGShmemHeader *) MapViewOfFileEx(UsedShmemSegID, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0, UsedShmemSegAddr);
|
||||
if (!hdr)
|
||||
elog(FATAL, "could not reattach to shared memory (key=%p, addr=%p): %lu",
|
||||
elog(FATAL, "could not reattach to shared memory (key=%p, addr=%p): error code %lu",
|
||||
UsedShmemSegID, UsedShmemSegAddr, GetLastError());
|
||||
if (hdr != origUsedShmemSegAddr)
|
||||
elog(FATAL, "reattaching to shared memory returned unexpected address (got %p, expected %p)",
|
||||
@ -302,7 +302,7 @@ PGSharedMemoryDetach(void)
|
||||
if (UsedShmemSegAddr != NULL)
|
||||
{
|
||||
if (!UnmapViewOfFile(UsedShmemSegAddr))
|
||||
elog(LOG, "could not unmap view of shared memory: %lu", GetLastError());
|
||||
elog(LOG, "could not unmap view of shared memory: error code %lu", GetLastError());
|
||||
|
||||
UsedShmemSegAddr = NULL;
|
||||
}
|
||||
@ -318,7 +318,7 @@ pgwin32_SharedMemoryDelete(int status, Datum shmId)
|
||||
{
|
||||
PGSharedMemoryDetach();
|
||||
if (!CloseHandle(DatumGetPointer(shmId)))
|
||||
elog(LOG, "could not close handle to shared memory: %lu", GetLastError());
|
||||
elog(LOG, "could not close handle to shared memory: error code %lu", GetLastError());
|
||||
}
|
||||
|
||||
/*
|
||||
@ -351,7 +351,7 @@ pgwin32_ReserveSharedMemoryRegion(HANDLE hChild)
|
||||
if (address == NULL)
|
||||
{
|
||||
/* Don't use FATAL since we're running in the postmaster */
|
||||
elog(LOG, "could not reserve shared memory region (addr=%p) for child %p: %lu",
|
||||
elog(LOG, "could not reserve shared memory region (addr=%p) for child %p: error code %lu",
|
||||
UsedShmemSegAddr, hChild, GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user