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.94.2) (envelope-from ) id 1t9HH2-008sTX-0V for pgsql-bugs@arkaria.postgresql.org; Fri, 08 Nov 2024 05:11:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1t9HGx-00649J-FR for pgsql-bugs@arkaria.postgresql.org; Fri, 08 Nov 2024 05:11:04 +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.94.2) (envelope-from ) id 1t9HGx-00649A-6z for pgsql-bugs@lists.postgresql.org; Fri, 08 Nov 2024 05:11:03 +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.94.2) (envelope-from ) id 1t9HGt-000nRb-Aj for pgsql-bugs@lists.postgresql.org; Fri, 08 Nov 2024 05:11:02 +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 4A85As863557258; Fri, 8 Nov 2024 00:10:54 -0500 From: Tom Lane To: Alexander Korotkov cc: Tender Wang , nicolas.maus@bertelsmann.de, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18692: Segmentation fault when extending a varchar column with a gist index with custom signal length In-reply-to: References: <18692-72ea398df3ec6712@postgresql.org> <3261639.1730912933@sss.pgh.pa.us> <3534898.1731031548@sss.pgh.pa.us> Comments: In-reply-to Alexander Korotkov message dated "Fri, 08 Nov 2024 04:22:42 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <3557256.1731042654.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Fri, 08 Nov 2024 00:10:54 -0500 Message-ID: <3557257.1731042654@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Alexander Korotkov writes: > On Fri, Nov 8, 2024 at 4:05 AM Tom Lane wrote: >> I think this is nonsense. What about toasted datums, or even >> just short-header ones? > You are correct. I quickly skim trough the sources and didn't find a > function which compares detoasted contents of Datums excluding > headers. Right, there isn't one AFAIK. For context, datumIsEqual() is mainly meant to support cases such as comparison of Const nodes in equal(), where a) false match is unacceptable, but false no-match will at worst cause some performance loss; b) the two inputs have probably come through similar paths (eg, both are fresh from the parser, or both were on-disk), so that any toasting effects will be the same. Also c) for many of the callers, it'd be unsafe to perform disk access to allow accurate comparison of out-of-line values. Problem (a) would be all right for this case, and (c) too, but not so much (b). You can certainly imagine writing a more aggressive routine that can cope with detoasting, but I don't think we've yet found a case where that seemed worth the trouble. Partial solutions such as "cope with short-header but not compressed values" have even narrower possible use-cases. > So, yes, comparison using C-collation seems the most > reasonable option. WFM. But I'm concerned that you couldn't build a test case where the comparison fails. Seems like we need one, in view of this bug having escaped detection for so long. regards, tom lane