Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rg3d4-003w4L-RJ for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Mar 2024 14:12:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rg3d3-00DZl2-0w for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Mar 2024 14:12:49 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rg3d1-00DZku-Rt for pgsql-hackers@lists.postgresql.org; Fri, 01 Mar 2024 14:12:49 +0000 Received: from wfhigh6-smtp.messagingengine.com ([64.147.123.157]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rg3cy-002Kly-8e for pgsql-hackers@lists.postgresql.org; Fri, 01 Mar 2024 14:12:47 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfhigh.west.internal (Postfix) with ESMTP id 7C5CF1800081; Fri, 1 Mar 2024 09:12:43 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Fri, 01 Mar 2024 09:12:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eisentraut.org; h=cc:cc:content-transfer-encoding:content-type:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=fm3; t=1709302363; x=1709388763; bh=Pr/R2p8hjqAd7+fndx8HQl7T7Ru0/MLQ +7qUFdcePtM=; b=Il2VQH6HYYAxgNC6JhnvKWN4Xlf5E4H4ptqSg5UnOSZQXeKZ nEDeKzVZiGUXtOY0ANy5W1iDwPFVTpUrICH5hSpoLKVeR8CC3Bc4Gpennws6821w pWn64f+xhHQPI6xnajkZuqf2BVbvnUGQPmkvSG0DOs+cJrOyz22vKAOoZNi8mc/J L5V3POEYBbDAHOghX/1GeE2yfMkAdKDMNuX3y7msdMBrKmQmvhlxOw9/f1hZuAQs skP2gfeY+mWVH9t7wnNRNL6nT2WcOhSH5fPSVv2AijqttlWumajzBB7cxdrrm9Ws I9lHJcfq6aNXJcYTjl0v0FAISU/bVhBn3zeweg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1709302363; x= 1709388763; bh=Pr/R2p8hjqAd7+fndx8HQl7T7Ru0/MLQ+7qUFdcePtM=; b=E aFpVV8+j9AhoC9DU1wjwWwTup7uRL3EpoL/zjMnWaPv/QNvBRixDVMQw54xk1bSq +oOwUm9Ut5+LEewMai+HCQlOlae6LRBHeq/CMkOw5NCOzTGQPl2huV8/24bmdvcl X+ZAsM0ndc7ArFaHK3ougOB3sany0x6f9uRp82jmbnIPdqDeGKaAzV2Ewxd7fYFu q3pwF4m+2+qJgPFAK8NhMUrv7/AUYtoT+u2z5eWW++m7UEuRbM2D2H0m4xSpK+O+ iluCaGgnV6ej1vaDXQnF98qEUT3yNd7/W+/OM88N/lxhGMUrwzdeI2rbQR5gVPGA S+1GTxBEAwL+bH37jjD6w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrhedugdeiudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkffggfgfuvfevfhfhjggtgfesthejredttddvjeenucfhrhhomheprfgvthgv rhcugfhishgvnhhtrhgruhhtuceophgvthgvrhesvghishgvnhhtrhgruhhtrdhorhhgqe enucggtffrrghtthgvrhhnpefgjedthfekfedtuefgieelheetleejgefhueeltdfhueet vdffudekfeejhfegheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehpvghtvghrsegvihhsvghnthhrrghuthdrohhrgh X-ME-Proxy: Feedback-ID: ie0a040ee:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 1 Mar 2024 09:12:42 -0500 (EST) Message-ID: Date: Fri, 1 Mar 2024 15:12:40 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: pread, pwrite, etc return ssize_t not int Content-Language: en-US To: Thomas Munro , Tom Lane Cc: pgsql-hackers@lists.postgresql.org References: <1672202.1703441340@sss.pgh.pa.us> From: Peter Eisentraut In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 27.02.24 12:21, Thomas Munro wrote: > Patches attached. > > PS Correction to my earlier statement about POSIX: the traditional K&R > interfaces were indeed in the original POSIX.1 1988 but it was the > 1990 edition (approximately coinciding with standard C) that adopted > void, size_t, const and invented ssize_t. 0001-Return-ssize_t-in-fd.c-I-O-functions.patch This patch looks correct to me. 0002-Fix-theoretical-overflow-in-Windows-pg_pread-pg_pwri.patch I have two comments on that: For the overflow of the input length (size_t -> DWORD), I don't think we actually need to do anything. The size argument would be truncated, but the callers would just repeat the calls with the remaining size, so in effect they will read the data in chunks of rest + N * DWORD_MAX. The patch just changes this to chunks of N * 1GB + rest. The other issue, the possible overflow of size_t -> ssize_t is not specific to Windows. We could install some protection against that on some other layer, but it's unclear how widespread that issue is or what the appropriate fix is. POSIX says that passing in a size larger than SSIZE_MAX has implementation-defined effect. The FreeBSD man page says that this will result in an EINVAL error. So if we here truncate instead of error, we'd introduce a divergence.