git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f2857af)
Fix pg_truncate() on Windows.
Fri, 6 Jan 2023 03:38:46 +0000 (16:38 +1300)
Fri, 6 Jan 2023 03:42:47 +0000 (16:42 +1300)
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


diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c
index d4a46f01583d6933f52b59ef54016138149d8b7c..926d000f2ead6d0ad44e67f029cd4edf0f5d2d6d 100644 (file)
--- a/src/backend/storage/file/fd.c
+++ b/src/backend/storage/file/fd.c
@@ -638,7 +638,7 @@ pg_truncate(const char *path, off_t length)
fd = OpenTransientFile(path, O_RDWR | PG_BINARY);
if (fd >= 0)
{
- ret = ftruncate(fd, 0);
+ ret = ftruncate(fd, length);
save_errno = errno;
CloseTransientFile(fd);
errno = save_errno;
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /