Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pDdE9-0007EZ-96 for pgsql-hackers@arkaria.postgresql.org; Fri, 06 Jan 2023 03:17:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pDdE7-0001dr-9w for pgsql-hackers@arkaria.postgresql.org; Fri, 06 Jan 2023 03:17:03 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pDdE6-0001dh-TG for pgsql-hackers@lists.postgresql.org; Fri, 06 Jan 2023 03:17:03 +0000 Received: from mail-qt1-x82a.google.com ([2607:f8b0:4864:20::82a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pDdDz-00044o-Ia for pgsql-hackers@lists.postgresql.org; Fri, 06 Jan 2023 03:17:01 +0000 Received: by mail-qt1-x82a.google.com with SMTP id a16so1111651qtw.10 for ; Thu, 05 Jan 2023 19:16:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=user-agent:content-disposition:mime-version:message-id:subject:cc :to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Gg0UvdsayunVlrzhOBQJL7RizXW56YkO6fZmorrtsmk=; b=TSON5dRZzd44ZxeK2Xn64YA86n6GOMUnQL//yrYLio06F4rNDTz7NuieOIvIqc5gdK KZscI7qCXAMXkvNjJYn+MPTA6yXEVw7XbPqTs1Xrog/fpkiImuSusILzkWtzlnPBwDi8 qfcejVjmTJ+2cEDorCGcTVfIrhJ7IT02f3eUEJQdP3fsvwwf57JFtw3mBx3p32VV1Y40 cUEixAyTSbeVREywQIzyJTkXQ6RkA9+aMZboI02VvZ7h6HS1ovkJcn4evF1YAL4ZGn34 XJVN/I5fGEoeBIsrQklSCFXJnxxaOZpU331iItvtsgWV6qruv5dzFjGOGA45TxihUIrB I1Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=user-agent:content-disposition:mime-version:message-id:subject:cc :to:from:date:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Gg0UvdsayunVlrzhOBQJL7RizXW56YkO6fZmorrtsmk=; b=1125uSm7wdW2bxk08xVb4M7KXqtLSGnznAWua5uRwatG4S+6XoDVfY/BCkw0X3J9un WC/xu7SFSz+5HDdr+zVMqsRjgSZaxi1Lrvqxc+fodx5/KNVs5o/Alj4lR3uTdVMEL+dD Foa7odL4Urvh45rCYLRgGJHqqKwzQHtlSVCHb3P7gaKotXWUeANDeml9uHFFIPqCG7Ik 6Co5bszRMzdHwUZh6nRw8aj58B1xQpjwD+H0NkNiTydJsHG1hxRho9lZsTY7pZRYnesS xP9ieZGiz7K/AXRjZTOBd1R1spc7/C6s87CjLGMtztLv69zJJcrZxUADCQQOdwy5bRZA ueFQ== X-Gm-Message-State: AFqh2kqc8g3ZERVDawtPdSdqv3lIUlI7x9sRe9wBNwI3+llj8ocAqCTc kboSi4wLVlntrc/BZcaw0XwEzw== X-Google-Smtp-Source: AMrXdXtDoOfmVCnrCMwZoBT/hk4zT17EnOkaCbfRzQL0AKpzkm8Ja5/jVA3j7xA4DAsl3FLe+e+7xg== X-Received: by 2002:ac8:7588:0:b0:3a7:e570:8275 with SMTP id s8-20020ac87588000000b003a7e5708275mr68795379qtq.27.1672975014535; Thu, 05 Jan 2023 19:16:54 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id ga27-20020a05622a591b00b0039cd4d87aacsm22557043qtb.15.2023.01.05.19.16.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 19:16:54 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 306C4800827; Thu, 5 Jan 2023 21:16:53 -0600 (CST) Date: Thu, 5 Jan 2023 21:16:53 -0600 From: Justin Pryzby To: Thomas Munro Cc: pgsql-hackers@lists.postgresql.org Subject: pg_ftruncate hardcodes length=0 but only under windows Message-ID: <20230106031652.GR3109@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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;