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 1wzsY3-004JQP-0q for pgsql-bugs@arkaria.postgresql.org; Fri, 28 Aug 2026 09:06:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wzsY1-006wGB-2n for pgsql-bugs@arkaria.postgresql.org; Fri, 28 Aug 2026 09:06:53 +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 1wznvp-005gBQ-20 for pgsql-bugs@lists.postgresql.org; Fri, 28 Aug 2026 04:11:09 +0000 Received: from mahout.postgresql.org ([2001:4800:3e1:1::227]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wznvm-00000001fAE-1cRJ for pgsql-bugs@lists.postgresql.org; Fri, 28 Aug 2026 04:11:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Message-ID:Date:Reply-To:Cc:From:To:Subject: Content-Transfer-Encoding:MIME-Version:Content-Type:Sender:Content-ID: Content-Description:In-Reply-To:References; bh=BKjy66RwI7UIo9kAByk/Q1/cfUGPjta6uQbkCBVbk5Y=; b=sYiOTp5eLF5Mg2yFc/S+Oeq8Aw JdMO8yECBcoyUlhG9biFhiCTKgj7s7S4biy8R8O2JONTFFFea5OXaiN7GSCtkiNRPLYLLZSRqo16x oItQkuOZ5T+pK5KVJxLCtPzlafuryP77ay1RIM/jaBg0741/Hf1Q1v4W0G5SUPK6xBJoIm0Fun1+2 mDGfa5tmHRZ4c51YV6c8nccAPDGOm27t6Jl5DzL79cxNFouiFJ+UZosUamGxhboWDS7CVsFnLGim4 oL1XCq/ggN2h+qoORxSmYKHrnlXR3oxTD1k9wPzQUIVjeiqPoQIPRqYZthuSZUvkXxGCLwxophxQ6 yh/B4LlQ==; Received: from wrigleys.postgresql.org ([2a02:16a8:dc51::60]) by mahout.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wznvk-008RmR-1v for pgsql-bugs@lists.postgresql.org; Fri, 28 Aug 2026 04:11:04 +0000 Received: from localhost ([127.0.0.1] helo=wrigleys.postgresql.org) by wrigleys.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1wznvj-000000059Ph-0njY for pgsql-bugs@lists.postgresql.org; Fri, 28 Aug 2026 04:11:03 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19641: Unexpected results on an SP-GiST indexed column with a non-deterministic collation To: pgsql-bugs@lists.postgresql.org From: PG Bug reporting form Cc: syzhong16@gmail.com Reply-To: syzhong16@gmail.com, pgsql-bugs@lists.postgresql.org Date: Fri, 28 Aug 2026 04:10:09 +0000 Message-ID: <19641-fbd0937eac4bf27e@postgresql.org> X-Auto-Response-Suppress: All Auto-Submitted: auto-generated List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk The following bug has been logged on the website: Bug reference: 19641 Logged by: Suyang Zhong Email address: syzhong16@gmail.com PostgreSQL version: 19beta3 Operating system: Ubuntu 22.04 Description: =20 Hi, Consider the following test case: CREATE COLLATION nd (provider =3D icu, locale =3D 'und-u-ks-level2', deterministic =3D false); CREATE TABLE t0(c1 text); INSERT INTO t0 VALUES ('ALPHA'); CREATE INDEX ON t0 USING spgist (c1 COLLATE nd); SELECT c1, c1 COLLATE nd =3D 'alpha' AS p FROM t0; -- ALPHA | t SET enable_seqscan =3D off; SELECT count(*) FROM t0 WHERE c1 COLLATE nd =3D 'alpha'; -- Expected: 1, Actual: 0 RESET enable_seqscan; SELECT count(*) FROM t0 WHERE c1 COLLATE nd =3D 'alpha'; -- 1 The predicate evaluates to true for the row, so filtering on the same predicate should return it. The original test case, where the planner chooses the index by itself: CREATE TABLE t1(c1 text); INSERT INTO t1 SELECT CASE WHEN i % 3 =3D 0 THEN 'alpha' WHEN i % 3 =3D 1 THEN 'ALPHA' ELSE 'beta' END FROM generate_series(1, 340) AS i; CREATE INDEX ON t1 USING spgist (c1 COLLATE nd); SELECT count(*) FROM t1 WHERE c1 COLLATE nd =3D 'alpha'; -- Expected: 227, Actual: 113 With the v2 patch from #19633 applied, this case is still unchanged. Reproduced on 20devel, 19beta3 and 18.6.