Skip to content

Commit f60acde

Browse files
committed
Fix pg_truncate() on Windows.
Commit 57faaf3 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
1 parent 3706cc9 commit f60acde

File tree

1 file changed

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

1 file changed

+1
-1
lines changed

src/backend/storage/file/fd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ pg_truncate(const char *path, off_t length)
649649
fd = OpenTransientFile(path, O_RDWR | PG_BINARY);
650650
if (fd >= 0)
651651
{
652-
ret = ftruncate(fd, 0);
652+
ret = ftruncate(fd, length);
653653
save_errno = errno;
654654
CloseTransientFile(fd);
655655
errno = save_errno;

0 commit comments

Comments
 (0)