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 1wD7ju-002dD2-2R for pgsql-hackers@arkaria.postgresql.org; Wed, 15 Apr 2026 21:25:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wD7js-002EZn-2k for pgsql-hackers@arkaria.postgresql.org; Wed, 15 Apr 2026 21:25:36 +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 1wD7js-002EZe-1o for pgsql-hackers@lists.postgresql.org; Wed, 15 Apr 2026 21:25:36 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wD7jq-00000001IB0-1ruR for pgsql-hackers@postgresql.org; Wed, 15 Apr 2026 21:25:36 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 63FLPOQa2197024; Wed, 15 Apr 2026 17:25:24 -0400 From: Tom Lane To: Peter Eisentraut cc: Heikki Linnakangas , David Geier , Matthias van de Meent , pgsql-hackers Subject: Re: Reduce build times of pg_trgm GIN indexes In-reply-to: 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> Comments: In-reply-to Peter Eisentraut message dated "Wed, 15 Apr 2026 21:12:51 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2197022.1776288324.1@sss.pgh.pa.us> Date: Wed, 15 Apr 2026 17:25:24 -0400 Message-ID: <2197023.1776288324@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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). regards, tom lane