mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Fix pg_truncate() on Windows.
Commit 57faaf376
added pg_truncate(const char *path, off_t length), but
"length" was ignored under WIN32 and the file was unconditionally
truncated to 0.
There was no live bug, since the only caller passes 0.
Fix, and back-patch to 14 where the function arrived.
Author: Justin Pryzby <pryzby@telsasoft.com>
Discussion: https://postgr.es/m/20230106031652.GR3109%40telsasoft.com
This commit is contained in:
@ -642,7 +642,7 @@ pg_truncate(const char *path, off_t length)
|
|||||||
fd = OpenTransientFile(path, O_RDWR | PG_BINARY);
|
fd = OpenTransientFile(path, O_RDWR | PG_BINARY);
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
{
|
{
|
||||||
ret = ftruncate(fd, 0);
|
ret = ftruncate(fd, length);
|
||||||
save_errno = errno;
|
save_errno = errno;
|
||||||
CloseTransientFile(fd);
|
CloseTransientFile(fd);
|
||||||
errno = save_errno;
|
errno = save_errno;
|
||||||
|
Reference in New Issue
Block a user