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 1wDNw0-002uek-1Q for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Apr 2026 14:43:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wDNvz-005vCR-23 for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Apr 2026 14:43:11 +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 1wDNvy-005vCA-2g for pgsql-hackers@lists.postgresql.org; Thu, 16 Apr 2026 14:43:11 +0000 Received: from fout-a7-smtp.messagingengine.com ([103.168.172.150]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wDNvw-00000001Q0w-0j5v for pgsql-hackers@lists.postgresql.org; Thu, 16 Apr 2026 14:43:10 +0000 Received: from phl-compute-08.internal (phl-compute-08.internal [10.202.2.48]) by mailfout.phl.internal (Postfix) with ESMTP id BDFABEC0198; Thu, 16 Apr 2026 10:43:06 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-08.internal (MEProxy); Thu, 16 Apr 2026 10:43:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; 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=fm2; t=1776350586; x=1776436986; bh=dBkipQP5lYNIZLGtZCMdO7RKRkW9pPVEIUG8bOCBG50=; b= RsdXYJJ4xZWV2diH8Sf/qKX7iuW3rJ5Rl0w/ZA+ETL7hh54stX7ZRaK3Qg00GDRS If/wMUnTDXNhclQo/hFWYlV31dAllAfuFgEFyGEkm0UdjeVKylNT2CJ5RyVIJPhq kh20VqWbSQfaitRFJU1UVGowoijfDWC9kZJim1516VgmTpFL/lGsWbE33xBUMu5v Kg+3ycQvRCYAHUwoZ+z2n18BK5W5oOz6RMJVVIxGH7kyo6kZM6VVrz2JML+mgAhI /z/uRWNzyHxmZ9D67Rcpw1FXXcrnEd0K37r0t1cxBDDuJIJdS+VgYumyGgkMTzbm aQTpULe/EVi4WeWkmqtoIA== 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=1776350586; x= 1776436986; bh=dBkipQP5lYNIZLGtZCMdO7RKRkW9pPVEIUG8bOCBG50=; b=t gy1d9XS08OViASg4oi+j7Y6aLkpgaTe9Ag2Ei94gjfzSpgiCwReyds/RpQZeMCj2 GI+J/6Js91TWNm0xwj14hLG0FSTxV+SO+BFua/7szqP0S27KGqkDOaSJgD9pfa7c WZAK0cw4OieFh3uSUcKptJlegLYehgrkUl4xmQzbxwoWy0l36/uGfurw4mbvVLGW 0WYL/S0OukSmhKGKq5kKKMg9V71H5GgW+ae4BEHdsoOH4w2bq1z6WlKXE1G3IcpF /RtIpjz8QyhAkyBzM/DrBDdQm/d8J10bIlqwrUDOktawHBp6iaFKAGoDCvTuV+aB fNRS8lwgdYRi4SpbJigGw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdegjedvjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpeffhffvvefufggjfhfkgggtgfesthhqmhdttderjeenucfhrhhomheptehnughrvghs ucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrfgrth htvghrnhephffgkeehtedtgeevvedttdfhleeuheejvdetveffhffgjeduieegjeegkeei tdffnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hnughrvghssegrnhgrrhgriigvlhdruggvpdhnsggprhgtphhtthhopeejpdhmohguvgep shhmthhpohhuthdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehlihhsthhsrd hpohhsthhgrhgvshhqlhdrohhrghdprhgtphhtthhopehpvghtvghrsegvihhsvghnthhr rghuthdrohhrghdprhgtphhtthhopehtghhlsehsshhsrdhpghhhrdhprgdruhhspdhrtg hpthhtohephhhlihhnnhgrkhgrsehikhhirdhfihdprhgtphhtthhopehgvghiuggrvhdr phhgsehgmhgrihhlrdgtohhmpdhrtghpthhtohepsghovghkvgifuhhrmhdophhoshhtgh hrvghssehgmhgrihhlrdgtohhmpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrshes phhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 16 Apr 2026 10:43:05 -0400 (EDT) Date: Thu, 16 Apr 2026 10:43:04 -0400 From: Andres Freund To: pgsql-hackers@lists.postgresql.org, Peter Eisentraut , Tom Lane CC: Heikki Linnakangas , David Geier , Matthias van de Meent , pgsql-hackers Subject: Re: Reduce build times of pg_trgm GIN indexes User-Agent: K-9 Mail for Android In-Reply-To: <4c1f88d7-5102-45b3-94e3-86d7e4b46b0a@eisentraut.org> 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> <4c1f88d7-5102-45b3-94e3-86d7e4b46b0a@eisentraut.org> Message-ID: <3038C8A0-6C5F-45B2-ACB2-329DABB4A1E1@anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi,=20 On April 16, 2026 4:45:55 AM EDT, Peter Eisentraut wrote: >On 15=2E04=2E26 23:25, Tom Lane wrote: >> Peter Eisentraut writes: >>> On 15=2E04=2E26 13:06, Heikki Linnakangas wrote: >>>> This was briefly discussed when PointerGetDatum() was changed from a >>>> macro to a static inline function [1]=2E On that email, Peter pointed= out >>>> that the compiler was doing the same deduction that Coverity did now, >>>> i=2Ee=2E that if you pass the Datum returned by PointerGetDatum(&foo)= to a >>>> function, it cannot change *foo=2E I'm surprised we dismissed that wo= rry >>>> so quickly=2E If the compiler optimizes based on that assumption, you= can >>>> get incorrect code=2E >>=20 >>> I don't think this is in evidence=2E AFAICT, it's just Coverity that = is >>> complaining here, which is its right, but the code is not incorrect=2E >>=20 >> 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=2E >>=20 >> I think we should at least test the theory that changing >> PointerGetDatum to remove the const cast would silence Coverity's >> complaint=2E If it does not then we're attributing too much >> intelligence to Coverity=2E 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)=2E > >I think it's quite clear to me that Coverity is complaining about this co= rrectly, in its view of the world=2E Compilers sometimes complain about th= is, too, although in this case they apparently don't look quite as deeply t= o do this analysis=2E > >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 su= itable, and the GIN code can be considered an exception and we make a speci= al API for that=2E The previous thread proposed NonconstPointerGetDatum()= =2E To me it seems way way way to dangerous to just redefine what PointerGetDa= tum() means for all existing callers, without doing an exhaustive verificat= ion of all the callers=2E Separately from that, it doesn't seem defensible to take a const pointer a= nd return a non const one=2E Why is that sane?=20 Greetings,=20 Andres --=20 Sent from my Android device with K-9 Mail=2E Please excuse my brevity=2E