From: | Justin Pryzby <pryzby(at)telsasoft(dot)com> |
---|---|
To: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | pg_ftruncate hardcodes length=0 but only under windows |
Date: | 2023-01-06 03:16:53 |
Message-ID: | 20230106031652.GR3109@telsasoft.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
57faaf376 added pg_truncate(const char *path, off_t length), but
"length" is ignored under WIN32 and the file is unconditionally
truncated to 0.
There's no live bug, since the only caller passes 0:
| src/backend/storage/smgr/md.c: ret = pg_truncate(path, 0);
But I guess extension users could be unhappy under win32, so maybe a fix
should be backpatched.
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c
index d4a46f01583..926d000f2ea 100644
--- 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;
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2023-01-06 03:40:36 | Re: Minimal logical decoding on standbys |
Previous Message | Imseih (AWS), Sami | 2023-01-06 03:07:11 | Re: Add index scan progress to pg_stat_progress_vacuum |