From: Justin Pryzby <pryzby@telsasoft.com>
To: Thomas Munro <thomas.munro@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Subject: pg_ftruncate hardcodes length=0 but only under windows
Date: Thu, 5 Jan 2023 21:16:53 -0600
Message-ID: <20230106031652.GR3109@telsasoft.com> (raw)
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.
inline patch 1: src/backend/storage/file/fd.c (+1/-1 lines) download inline-1.patchdiff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.cindex 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;
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: pryzby@telsasoft.com, thomas.munro@gmail.com
Subject: Re: pg_ftruncate hardcodes length=0 but only under windows
In-Reply-To: <20230106031652.GR3109@telsasoft.com>
References: <20230106031652.GR3109@telsasoft.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox