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 1wCJvm-001s1B-2j for pgsql-hackers@arkaria.postgresql.org; Mon, 13 Apr 2026 16:14:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wCJvl-007lsU-0Q for pgsql-hackers@arkaria.postgresql.org; Mon, 13 Apr 2026 16:14:34 +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 1wCJvk-007lsM-2F for pgsql-hackers@lists.postgresql.org; Mon, 13 Apr 2026 16:14:33 +0000 Received: from meesny.iki.fi ([195.140.195.201]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wCJvi-00000000res-3zZt for pgsql-hackers@postgresql.org; Mon, 13 Apr 2026 16:14:33 +0000 Received: from [10.0.2.15] (unknown [130.41.208.1]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: hlinnaka) by meesny.iki.fi (Postfix) with ESMTPSA id 4fvXY11WtdzyQZ; Mon, 13 Apr 2026 19:14:29 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1776096869; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LFWKbxhMX5qzbFO1w94+IS0zohJGIJl7PMrxLOJoKf8=; b=vCHYIZXybvhBAV4tGbxFpmFGfPfF3zGbSX98Pp4yNhOm/iv2YzTRDyHOTf+ePoAMYVkOzP Gx+0VEJRudhG+nrPLr4HE4/d1lq+ridcg2RJBrG41+ogUG9GDiTUbLYiGs4gRnn8PfYyBh qcZzxfK09SRnfg1/irmNI62XRaEjlSU= ARC-Seal: i=1; a=rsa-sha256; d=iki.fi; s=meesny; cv=none; t=1776096869; b=rwnniAhrqcHXSBI7peZzWjDhZ/NKKmUR4cgv7RkcoVNI6oq55ngly+NQsPITZ4dAAIh4sX 14fXftPhuJR/XSRHgmModfex6qI4XXL93wRQvntI2RXOsaUrEg72L698hW81mnrtufdGba f/qqbBJQliiVOL7WvU1o1u6ouVlQFdQ= ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=hlinnaka smtp.mailfrom=hlinnaka@iki.fi ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1776096869; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LFWKbxhMX5qzbFO1w94+IS0zohJGIJl7PMrxLOJoKf8=; b=kGS/8eqgeacAJxbWklMgv7UYxIaeEwhHMlkFYdzKPEUEO+bggfDmASgWKdz4B0ehaVuaxu GuHhNhRvhrVfllaqYF2TSTxzXgANuV77GNX76+IT0qxF77NFOfgRuttrkrefS3pMk3IAyN hNnA0s38Av5vF/RYTJntH0ER7/hHcy4= Message-ID: <8f3fab0e-02e1-4948-9683-224fe54e30ae@iki.fi> Date: Mon, 13 Apr 2026 19:14:23 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Reduce build times of pg_trgm GIN indexes To: Tom Lane Cc: 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> Content-Language: en-US From: Heikki Linnakangas In-Reply-To: <342012.1776017102@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 12/04/2026 21:05, Tom Lane wrote: > Heikki Linnakangas writes: >> Pushed 0001 as commit 6f5ad00ab7. > > This commit has caused Coverity to start complaining that > most of ginExtractEntries() is unreachable: > > *** CID 1691468: Control flow issues (DEADCODE) > /srv/coverity/git/pgsql-git/postgresql/src/backend/access/gin/ginutil.c: 495 in ginExtractEntries() > 489 /* > 490 * Scan the items for any NULLs. All NULLs are considered equal, so we > 491 * just need to check and remember if there are any. We remove them from > 492 * the array here, and after deduplication, put back one NULL entry to > 493 * represent them all. > 494 */ >>>> CID 1691468: Control flow issues (DEADCODE) >>>> Execution cannot reach this statement: "hasNull = false;". > 495 hasNull = false; > 496 if (nullFlags) > 497 { > 498 int32 numNonNulls = 0; > 499 > 500 for (int32 i = 0; i < nentries; i++) > > Evidently, it does not realize that the extractValueFn() can change > nentries from its initial value of zero. I wouldn't be too surprised > if that's related to our casting of the pointer to uintptr_t --- that > may cause it to not see the passed pointer as a potential reference > mechanism. > > I would just write that off as Coverity not being smart enough, except > that I'm worried that some compiler might make a similar deduction and > break the function completely. Was the switch to a local variable > for nentries really a useful win performance-wise? I didn't do it for performance, but because I find the function easier to read that way. We could change it back. It's a pretty scary thought that a compiler might misoptimize that though. In the same function we have 'nullFlags', too, as a local variable, even before this commit. Not sure why Coverity doesn't complain about that. > /* > * PointerGetDatum > * Returns datum representation for a pointer. > */ > static inline Datum > PointerGetDatum(const void *X) > { > return (Datum) (uintptr_t) X; > } Hmm, is that 'const' incorrect? This function doesn't modify *X, but the resulting address will be used to modify it. Maybe changing it to non-const "void *X" would give Coverity a hint. - Heikki