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 1wDIMN-002pAw-1y for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Apr 2026 08:46:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wDIMM-004zCx-08 for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Apr 2026 08:46:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wDIML-004zCn-2E for pgsql-hackers@lists.postgresql.org; Thu, 16 Apr 2026 08:46:01 +0000 Received: from fhigh-a6-smtp.messagingengine.com ([103.168.172.157]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wDIMJ-00000001NRy-2NQn for pgsql-hackers@postgresql.org; Thu, 16 Apr 2026 08:46:01 +0000 Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfhigh.phl.internal (Postfix) with ESMTP id A370F1400065; Thu, 16 Apr 2026 04:45:57 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Thu, 16 Apr 2026 04:45:57 -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=fm1; t=1776329157; x=1776415557; bh=WFCe98zRLvOj/BS4S/cBDmkEL34vF8Yw iu+jk48LW9U=; b=W8306DliTHFjWWHA8GRFayAkBRlq7bafsrkoWg2Cn1NRYLRr jo5jPGXRBe+ALV9X3aFtxOQYB/exdbTMZRdBPodoVEZNrL9SAMkN1r39rylGUO2x Jurjiiv90hkP30Hs/Zej2+rQAt7OgrR9x0W/STTrA+X1XIOVSnMnMuJBcIL22ixf wbfjaIz2UpmpDSTJsE4onZvNpx8WKLY5zTi8ZLhfZV+E9ufiYHEOPQNfBYiu+5k5 pqoD0YObFE8xF47Q7tOyPu+xJLf7nx+0Arvs0hw6J999vtAsVZTqQeQsqqtTbhxH 8xXawg/poO5r6fUFY9Fj5U8kKOHVJrutmfNf8g== 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=fm2; t=1776329157; x= 1776415557; bh=WFCe98zRLvOj/BS4S/cBDmkEL34vF8Ywiu+jk48LW9U=; b=q 0UvZRCCnM455zxFZ8kopFoQKPAURmW6FC/iagp6Y0brnkEoJIBTOI91ZYADmjd8y txJU5+LJJ3eoVpw3CWfvxL1FL7wzAso7fWj8d/6yO6mMX3IrHx7peVezLUz1gKhs qeLCye8EcL7Yz63R8q7V9wA5qp1e37Bgkwugq1HD8NDcQ6wTq3NDurk4bVkleIoE AF3x5PL0TvIXkE5pOJafrOQO2ugcXZ4vA9Iuq8r2ihBviaMJsyPOmuuVWh4IlBLn DXzW0vhXXC6Z3KZcOwzyT5kOq9TlpEkcaGv+aD7k9JZy4cZ/57mwUCCN58w86X6D 3YVFIHD8MoKuibF///OIw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdegieehiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefkffggfgfuvfevfhfhjggtgfesthejredttddvjeenucfhrhhomheprfgvthgvrhcu gfhishgvnhhtrhgruhhtuceophgvthgvrhesvghishgvnhhtrhgruhhtrdhorhhgqeenuc ggtffrrghtthgvrhhnpefgjedthfekfedtuefgieelheetleejgefhueeltdfhueetvdff udekfeejhfegheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehpvghtvghrsegvihhsvghnthhrrghuthdrohhrghdpnhgspghrtghpthhtohep hedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepthhglhesshhsshdrphhghhdrph grrdhushdprhgtphhtthhopehhlhhinhhnrghkrgesihhkihdrfhhipdhrtghpthhtohep ghgvihgurghvrdhpghesghhmrghilhdrtghomhdprhgtphhtthhopegsohgvkhgvfihurh hmodhpohhsthhgrhgvshesghhmrghilhdrtghomhdprhgtphhtthhopehpghhsqhhlqdhh rggtkhgvrhhssehpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: ie0a040ee:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 16 Apr 2026 04:45:56 -0400 (EDT) Message-ID: <4c1f88d7-5102-45b3-94e3-86d7e4b46b0a@eisentraut.org> Date: Thu, 16 Apr 2026 10:45:55 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Reduce build times of pg_trgm GIN indexes To: Tom Lane Cc: Heikki Linnakangas , David Geier , Matthias van de Meent , pgsql-hackers References: <5d366878-2007-4d31-861e-19294b7a583b@gmail.com> <9ac3931a-180e-4283-a7a8-05eb66099206@iki.fi> <2e11134f-02c3-43da-8c39-fb520a1a251d@iki.fi> <66620ec7-0f81-4813-9cf1-b901a56efcc3@gmail.com> <2a76b5ef-4b12-4023-93a1-eed6e64968f3@gmail.com> <6439c655-e281-409d-b884-6586750d5820@iki.fi> <342012.1776017102@sss.pgh.pa.us> <8f3fab0e-02e1-4948-9683-224fe54e30ae@iki.fi> <77cc23dd-ac53-4bb9-9e90-0019c9ff58df@gmail.com> <195097d6-64cd-4adb-b8a3-1d86ae31c411@iki.fi> <2197023.1776288324@sss.pgh.pa.us> Content-Language: en-US From: Peter Eisentraut In-Reply-To: <2197023.1776288324@sss.pgh.pa.us> 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 15.04.26 23:25, Tom Lane wrote: > Peter Eisentraut writes: >> On 15.04.26 13:06, Heikki Linnakangas wrote: >>> This was briefly discussed when PointerGetDatum() was changed from a >>> macro to a static inline function [1]. On that email, Peter pointed out >>> that the compiler was doing the same deduction that Coverity did now, >>> i.e. that if you pass the Datum returned by PointerGetDatum(&foo) to a >>> function, it cannot change *foo. I'm surprised we dismissed that worry >>> so quickly. If the compiler optimizes based on that assumption, you can >>> get incorrect code. > >> I don't think this is in evidence. AFAICT, it's just Coverity that is >> complaining here, which is its right, but the code is not incorrect. > > Are you sure? This seems like the sort of thing that will bite us on > the rear sometime in the future, as the compiler geeks put in more and > more aggressive optimizations. > > I think we should at least test the theory that changing > PointerGetDatum to remove the const cast would silence Coverity's > complaint. If it does not then we're attributing too much > intelligence to Coverity. But if it does, then we've correctly > identified why it's complaining, and we should take seriously the > idea that they aren't the only ones making this sort of deduction > (or won't be for long). I think it's quite clear to me that Coverity is complaining about this correctly, in its view of the world. Compilers sometimes complain about this, too, although in this case they apparently don't look quite as deeply to do this analysis. What I'm missing here is, essentially where the previous thread stopped: What is the overall message that we want to communicate with the API? If the default assumption is that what pointers converted to Datums point to should not be modified on the other side (where the Datum is converted back to a pointer), then the current declaration of PointerGetDatum() is suitable, and the GIN code can be considered an exception and we make a special API for that. The previous thread proposed NonconstPointerGetDatum(). (If this is the resolution, I also have half a patch somewhere that makes the string input argument for the InputFunctionCall family of functions const, which also seems intuitively sensible.) If, on the other hand, the decision is that there is in fact no such guarantee, that consumers of Datums are free to modify whatever they seem fit, then we should drop the const of PointerGetDatum and fix the fallout up the call stack. The macro proposed by Heikki, I don't know, still doesn't actually answer this question, just (possibly) makes these warnings go away in a slightly mysterious way.