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.98.2) (envelope-from ) id 1x9SzH-00000002146-2zSz for pgsql-bugs@arkaria.postgresql.org; Wed, 23 Sep 2026 19:50:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1x9SzG-00000007cwz-3hA0 for pgsql-bugs@arkaria.postgresql.org; Wed, 23 Sep 2026 19:50:38 +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.98.2) (envelope-from ) id 1x9SzG-00000007cwq-2dBo for pgsql-bugs@lists.postgresql.org; Wed, 23 Sep 2026 19:50:38 +0000 Received: from mail-dy2-x10.google.com ([2607:f8b0:4864:36::10]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1x9SzE-00000000wBr-1RPd for pgsql-bugs@lists.postgresql.org; Wed, 23 Sep 2026 19:50:38 +0000 Received: by mail-dy2-x10.google.com with SMTP id 5a478bee46e88-33bd6b791eeso129196eec.0 for ; Wed, 23 Sep 2026 12:50:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790193034; x=1790797834; darn=lists.postgresql.org; h=mime-version:content-transfer-encoding:content-type:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=pN90vBgOtiHfU/Tv7s/wLdkuVNxOTpv3luNiMXP5Ut4=; b=kDh+gbA+pm4acBD5VYHTC2/PRfv5/JNNAjn4QXjisLu0ghLO070nF69DzaoLeweUI7 4DspHQPMylZYNFc6iFftxYPgOQGNMpuNeJZAgCb8a2w2dzQYS2Wv6o3orS4hkAt0ruak 6AymS+4A80dPCBH2GDYbk3Fs2HBYdGTUzJCiZ1qmyOgr86kENmPh+zKfq5kACYpdr7W4 YjWsX+Eywf0y8MMnI4XcIOjdN04jeUm6tHRXfQ0T2ANv8PgceD8cqEAZ6wvLAjWzmokj 8umlaccXoeJSgmRJeQH8m3/HgqF6krbkvi2gTwWTnr+sa+YAWsprHkIpQyNpu/PKnNOL YkXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790193034; x=1790797834; h=mime-version:content-transfer-encoding:content-type:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=pN90vBgOtiHfU/Tv7s/wLdkuVNxOTpv3luNiMXP5Ut4=; b=H08tfvEXpntZE1aCQezMUdM65X2zRy/MQEEE+ZfV9v7J5DUIUh5SFklnSb2sawP9aY szUqFG+43JugvPPeybdzUlX6IU/MB1MOY804AKwmMFzNY9hiU/Bd/RfCi4GgLKaUBGaZ sFLFayIqKgsmuZY1rUKIVLH4SviOPGZjkbDinqH1Ha9CCb12jTowNIq4PnivZ269UYLn hdQ/9a7WKFWZa8lpdnufYt1W3wApigYz0w7ogPf7eaXl0P8vF2g5E+hJqzJOQvvdCSE6 zQ7m/xjOJnWKM0oXdJ/WQRLbzACNyW1wFuEx3HJaYHQZyjalT6OTH8/JpUhqE964waC8 +q7A== X-Gm-Message-State: AFuF++l34clICmwx7+GQMyiT0WrBqnqi/B8BVg1bCIj2ZFDNPp17Azet gOy698m4IozXxzxfazi5v7rptOgteSZImmV+IaFVfNPXWFPw7kJp4d0IdC4N5LCyKBQ= X-Gm-Gg: AYBFou0r0QaW01soi9ECsfPLNmEzlzbrQaywUhAYFVQmKgNoVbzxPKGlzDi8tz6tINU RkXHw7IH1Ywb15E4pKvsCVXF3kpolCNc9nU+ehps2S/jDCdJ0r4AOlKZ617ZV9ikpnUVPuFcv48 GqWowXZNQwRQGt+uknQQYgGPGUQ6jM3xfJtsKZ10NB2CbaVM+OJLS6ggFnRwyQPUhINO0rDlwau lzSVeuqeOiHZMVDWqcjqcNDz/G5/vUGZJtrLXFjIgwd7N6MgsZ8/iVzqerMFFWYCOuSBMLRBsqM 18btrULgUKLrR3deuNZ5Yh3qQi88//P5eXqNaWVlHai2ezl205c5yZpW2JPp2zuBEyi3Mcg+Ndx 8PB3aa1ZMSQEbieyIZq8eX9cO9P3I3dWVUp3T0NMkEmnJxOIPqqNIzptRdC5WibeQyaMG8aiX1C TdgHWjIybiVAHj4TG4mgdSqxIB4DsE/wzQxG90JAJXGo55s7y4SGUZSrdRPiSFFe8Z+Ztz7377/ ezLObCM3A2IXWWZHWUzDprUrJs0sya29v4vHHzw666xfgK+8jN40ipD0XwglOGfgF++u5xnvmPw Ci+ZDAgn6pC754WI8bdg7u9OaA== X-Received: by 2002:a05:693c:87d5:20b0:33e:9ec7:45a2 with SMTP id 5a478bee46e88-34001f125edmr312025eec.1.1790193033591; Wed, 23 Sep 2026 12:50:33 -0700 (PDT) Received: from 192.168.1.109 ([2803:3c90:cee:ea00:5c3c:7e70:29e3:7a55]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-33e96e48e3esm8830674eec.26.2026.09.23.12.50.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2026 12:50:33 -0700 (PDT) From: Manu To: pgsql-bugs@lists.postgresql.org Cc: Andrey Rachitskiy , syzhong16@gmail.com Subject: Re: BUG #19641: Unexpected results on an SP-GiST indexed column with a non-deterministic collation Date: Wed, 23 Sep 2026 16:50:31 -0300 Message-ID: <179019303108.297478.2662804185242466018@gmail.com> In-Reply-To: References: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Andrey Rachitskiy wrote: > I have a draft of "A" and "B" ready, but I decided not to publish it > until an agreement on the direction is reached. > > Thoughts? Some data for that choice, all on master (374522aa63a). First, the scope. With the 340-row table from the report, the column under the nondeterministic collation, and the same equality query, each index type against a sequential scan (227 rows): - SP-GiST text_ops: 113 - btree, hash, BRIN, GiST (btree_gist): 227 Every plan used its index, so SP-GiST's text_ops is the only one of them that gets this wrong. It also does so at any size, one row included. Second, what A does to indexes that already exist. The precedent, 281039631, went in before v12's rc1, when no such index could exist yet, while an SP-GiST index under a nondeterministic collation has been accepted since v12. So I built a prototype of A with the same check as the pattern_ops one in index.c, for SP-GiST text_ops, created such an index on an unpatched master cluster, and took it to the prototype: - a pg_dump restored with psql loads the table (340 rows) and skips the index with one ERROR; psql exits with 0, so a restore script that does not stop on errors ends up without the index and says nothing; - pg_upgrade fails, during the schema restore, with the same error. So A cannot be back-patched, and in master it would need a pg_upgrade check that reports these indexes before the upgrade, as pg_upgrade does for other objects it cannot carry over. B has neither problem. If I read your description right, it changes only how the scan uses the tree, not how the tree is built, so an existing index returns correct results after a minor update, without a REINDEX. That seems to me the one that can go to all the branches. Your point that B does not make the index a good accelerator for this equality stands; that seems like something for the documentation to say (a btree index serves it better), rather than a reason to break existing schemas. If you post the B draft, I am happy to test it on the back branches: the existing-index case above, and the other text_ops operators under the same collation. Regards, Manu