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.96) (envelope-from ) id 1w0H9a-001lmp-09 for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Mar 2026 10:51:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w0H9X-008ZpQ-0c for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Mar 2026 10:50:59 +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.96) (envelope-from ) id 1w0H9W-008ZpI-0b for pgsql-hackers@lists.postgresql.org; Wed, 11 Mar 2026 10:50:59 +0000 Received: from fhigh-a2-smtp.messagingengine.com ([103.168.172.153]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w0H9U-00000001b2T-2muP for pgsql-hackers@postgresql.org; Wed, 11 Mar 2026 10:50:57 +0000 Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfhigh.phl.internal (Postfix) with ESMTP id 66A9E1400181; Wed, 11 Mar 2026 06:50:55 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Wed, 11 Mar 2026 06:50:55 -0400 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=1773226255; x=1773312655; bh=o6AhGrhx/41EXnsCbJ/GS7lDC5AdADkF izLpZIIZlSM=; b=DG10SmnUq/m7B6jJ0lcBkEM5oo2S1G1BLoXH4XmYUDXD7HaN yiAa564jwuJfnprUd1cY61Wj+LvzgekuvqE5SFeEjWnA09CYzpM8HkPAR61B/3DA Kn4bLuxuq7SqxuGh36o8CbaP8YOLYnjQGkqv57PhR5OEp8ZMPoY4M3UMeqDOegH2 hx/LZTjlmDW+CeaeHPKFpEC1YA4A1V6O38/dxDrIzcrUyTt/Iwqs6+iPlHsqw4nm 4MffziouJctqtgIh8+L09PIA3pcIoXaY+JzTgH4XJ0TpnaJ6inGDdhfkY7qC5zHa p1FjvtWfmPkknHGNU56s9tjl6zJr6kWuqxBElQ== 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-sender:x-me-sender:x-sasl-enc; s=fm1; t=1773226255; x= 1773312655; bh=o6AhGrhx/41EXnsCbJ/GS7lDC5AdADkFizLpZIIZlSM=; b=4 PWVtZXjX/OPUWDnR37ruPep/nnn6UbBjdxBuZ7xQDrrI/qEne7ax2Fv6ojtwvwgM MwrlYnvw8b/nkLCOSP0yyEUx4U7BgLI7rjiZ4QJ0uEU5MFZB7HWGp0sfb1Sag/kr 0YIn+j30u/4Smc8zjBCdu/CU8rbVACBMKsSEipWa/aL83ctzcX/c/ZTkU00J47wM iqWfL6sLsMA+AGGmqtcWrXTw+UG/aNQ8TVog3No3ECjz4/4x93SNZrTabt5Dv1Sa 9EtIwwCCeVcTro41PzepWDUfM8tSf/8GnoWz8a+RHvlNoGWKFehgCcDIO9+DHiud 5RoXx+kuPgd0brnUJ8k1g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeefjedtucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtvdejnecuhfhrohhmpefrvghtvghr ucfgihhsvghnthhrrghuthcuoehpvghtvghrsegvihhsvghnthhrrghuthdrohhrgheqne cuggftrfgrthhtvghrnhepgfejtdfhkeeftdeugfeileehteeljeeghfeuledthfeutedv ffdukeefjefhgeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepphgvthgvrhesvghishgvnhhtrhgruhhtrdhorhhgpdhnsggprhgtphhtthho peehpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegrlhgvkhhsrghnuggvrhesth highgvrhgurghtrgdrtghomhdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehp ohhsthhgrhgvshhqlhdrohhrghdprhgtphhtthhopehrvghshhhkvghkihhrihhllhesgh hmrghilhdrtghomhdprhgtphhtthhopegughhrohiflhgvhihmlhesghhmrghilhdrtgho mhdprhgtphhtthhopehtghhlsehsshhsrdhpghhhrdhprgdruhhs X-ME-Proxy: Feedback-ID: ie0a040ee:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 11 Mar 2026 06:50:53 -0400 (EDT) Message-ID: <7f39480a-4b7a-4a51-a9ec-d1189b44432d@eisentraut.org> Date: Wed, 11 Mar 2026 11:50:52 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Define DatumGetInt8 function. To: Aleksander Alekseev , pgsql-hackers Cc: Kirill Reshke , David Rowley , Tom Lane References: <2869012.1767023578@sss.pgh.pa.us> Content-Language: en-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 07.01.26 15:03, Aleksander Alekseev wrote: >> Hmm, v1 looks good and self-contained to me. Like, anyway, making two >> commits (one for signed Int8 and one for unsigned) here is better for >> sake of atomicy? >> Anyway, I can see there are users of UInt8GetDatum, which are [0] and >> forks of Greenplum. So, I am not super-sure removing UInt8* is >> desirable. > > Fair enough. Let it be a separate patch then. I have committed the first patch, which removes Int8GetDatum(). (This is actually used by my extension pguint, but that already needed to provide a replacement for the non-existent DatumGetInt8(), so it's not a bother to provide a replacement for Int8GetDatum() for future PG versions.) About the other patch, two points: 1) The changes in nbtcompare.c look a little messy with respect to signedness and unsignedness of char. I don't know what this code actually does at a higher level, but the low-level details look weird. Like, why does char_decrement() get its input value using DatumGetUInt8() but makes the return value using CharGetDatum()? And your patch changes the UCHAR_MAX to SCHAR_MAX but changes the variable from uint8 to char. First, there is no explanation why this change from unsigned to unclear-sign is correct, and second, if you are using the char type you should then also use the matching symbol CHAR_MAX. I'm tempted to think the correct direction here would be to use uint8 and its associated macros and functions more rigorously, not less. 2) The change in pageinspect looks correct, but then when you look nearby and further around, you will find that there are also a bunch of (if not most) UInt16GetDatum and UInt32GetDatum that are wrong. I think there is some confusion about what the "UIntNN" or "IntNN" in these functions refers to. Some code appears to think that this refers to the input type of that function call, but it's actually more like what SQL data type the value will be used with. (Some maybe it would be more helpful to think of it as "GetDatumForInt32" etc.) There are a lot of opportunities to clean this up, and I suspect that while many of these will work either way in practice because the actual values don't go far enough to hit the signed/unsigned boundary, I think there could a number of little bugs here to be fixed. I don't think it's worth making an isolated fix here for the one use of UInt8GetDatum(), especially if you believe my point 1) and we are not going to be removing this function anyway.