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 1vuoh5-007ysp-2v for pgsql-bugs@arkaria.postgresql.org; Tue, 24 Feb 2026 09:27:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vuoh4-000Lnv-1Y for pgsql-bugs@arkaria.postgresql.org; Tue, 24 Feb 2026 09:27:02 +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 1vuoh4-000Lnm-0Z for pgsql-bugs@lists.postgresql.org; Tue, 24 Feb 2026 09:27:02 +0000 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vuoh0-000000010hy-2si8 for pgsql-bugs@lists.postgresql.org; Tue, 24 Feb 2026 09:27:01 +0000 Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-65c20dc9577so9828967a12.2 for ; Tue, 24 Feb 2026 01:26:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1771925218; cv=none; d=google.com; s=arc-20240605; b=XWkbSBuGP2dKxH10JjPr/DjNWEpe+FuamFtGijWcZQsSqVeS9PVbjtJLUxkGxpb325 2LtZKB8d2TWS8HJctbFMBt6LqaM0aMdczYukzBRL2UwHfIwra136rn/CJTEeyjJhELBp AUCG6rub4aS5F4a+1Upwbs7JzynvIZYBF4ed1XbsMHzbLN8wcYtMu+vAKrkCbYlv4y37 nuXLGvg+Zk9uY6BVeAhkkJWaWxQhW/Hg43hvlrL0oSXh65uqFj+WDYcNl9U24JX9fXHN tF0gbjzY3i7TJx/BXN31mKZxaNYWtOd6bfPpn/KOY3DXea77rYxoUnjPj5nAwj6xTjxd 8t/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=/wH9q37kU8oyK90gz5L0ggbMWoA+tW0HjumaVLXU4J4=; fh=tSFFKPZSDef871jAUBjs/e/m/XibkJhlFRe6t833qKw=; b=VqzMcqPLr/w0NlZfE2/VN2c5p7agKa0r1StInAZgvxRJTBUJZACPBrzozRVUg6bDMw U/c4vFhK0Sy375gpFWCZPqE3f60YnxHC39mENBfhuJ8pORkXqnU99ZWCK/NlKUccR4/L Q+UQfiQTOoFogGcVGFogGh4EPdU+XLCA5K9VwHmg2MwtWkhMMEDe/pgphSTrIUn4tbVe 2SZcrWDOKaGXzMv7VSvc6oUS4Y3zIPRkZ8Y4wvgMUlatltec7xthUP0CtZrFUVwwCZOm JtpAf9AcTwhdAtxPO9TmnXH3sAraZ08qwSc9ZgPJIkN4q6A5WJqGv0TPyMsAtfoO+ycR kmPw==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771925218; x=1772530018; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=/wH9q37kU8oyK90gz5L0ggbMWoA+tW0HjumaVLXU4J4=; b=LLzpCdlH6OrRkTFLtL2j6Ug0bkVHE7eevjQxxIZ+pqFswp42lhnd9+NJVlqe8d0fqV lzJQ/Si1wM9KLNX61UOKbqR+YMSD4rkcNmTo1EL+I8Qe413ABuCYN6spAzMnTEv5H4UV EVSBxuj2kOr+Eod07WiQVklau1y6x2cRKf+69GLRDJon90S8yLPx1rcesfoEXjPpfh8w e4CHi+sbyEVX8ZF7N2v8tIhNVN0U0T1R27UDa6SQ9YvVKO5yqlbysByBLl4Gu4rOCu2X v8xGGpj29tAXgpHbO2pF8bOiR5SKKrh39xLwKgUF+AA6/baB1MDH7HgCCcoDz/JQMsfz q8CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771925218; x=1772530018; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=/wH9q37kU8oyK90gz5L0ggbMWoA+tW0HjumaVLXU4J4=; b=Mr56AxhL/atxtBupctIy0Mw1LQV4gXz+feCZggUMkXE2ogoywmax08YNiPluSPUCUV fF8LenslQFNmeNPKS9y6pA85coT7rUW3/g0qfgWiPQ0VTkF84mQsMO8nmXmsymc7Yjgo N4v8JssI4hxY/A7itHUtskgmbjKsZXZILwdc6jyJahw3QSo3gk27evLo+PzOwEpow+9m piePKSHwAxye8ctANcP2IcR66JXC1Px8tlA8BnJ7hynFaTvyjXQJcgUmVLFIHq/sgAv6 04bX4X3H785n5ujtrEEp6c9w6sMT6z98z42psbxgRgStHliKOSBeApbY6DfMKRxyejHj ajEA== X-Gm-Message-State: AOJu0YwB+sXyhLVFssNL5zQZlKQ+mRoUKq0jbG4bbfWlTRwgGsLFalzq /i1oq3JN5hMBYBqUsCOAjWewFJY/yZGfsKedTtoBCq3gG1ZTPbE3wqxNqd7N8Hv50w529VaYJ2x 9p3g4LX+4wantvNbhGt5DkbymX2eZduc= X-Gm-Gg: ATEYQzyD/rfzIAuJS8ij1uM88luAI1QmAKnRnvSQ5z8oc7byXZ6847a9dMCAMTwZGRp nJsfoNEJJvdHp68d/Yq7gHRQ0NHISY8ofO+RngLkqrvYOm2ft/05OLmY6Ov6QjTcweBN0HScClM W3YtWPMOO5gD1O5dd+xgJW3fBi3xnuYhBRB5zF/Be1It9TWr5szmkMh0zs5ncUy8I/NTSC06O/Q sD9T8DK9EJYchiV4b6FggqvNC9PwxeltEHpsFu/3wo9NNTQZadxHFeXSNbzlLICcvH50Q6sfS4j ityj6Q== X-Received: by 2002:a05:6402:f18:b0:659:4b76:74f4 with SMTP id 4fb4d7f45d1cf-65ea4f1a583mr4979713a12.16.1771925217894; Tue, 24 Feb 2026 01:26:57 -0800 (PST) MIME-Version: 1.0 References: <19414-add8251d7863a802@postgresql.org> <202602232020.e2fyql4ip6hd@alvherre.pgsql> In-Reply-To: <202602232020.e2fyql4ip6hd@alvherre.pgsql> From: =?UTF-8?Q?Jos=C3=A9_Antonio_Morcillo_Valenciano?= Date: Tue, 24 Feb 2026 10:26:45 +0100 X-Gm-Features: AaiRm52CH3Mit98aiBSBeIXB0-Hpsp-gE0M-r_WsMsEvqoJS_L4EBRYclT9s0VU Message-ID: Subject: Re: BUG #19414: Wrong rows returned by index scan on HASH-partitioned table with PRIMARY KEY (PostgreSQL 16.9) To: =?UTF-8?Q?=C3=81lvaro_Herrera?= Cc: pgsql-bugs@lists.postgresql.org Content-Type: multipart/alternative; boundary="0000000000002e6341064b8e7dfc" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000002e6341064b8e7dfc Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi! After upgrading we reindex all our databases, so I don't see it clear. The difficulty here is finding a test case to work with. El lun, 23 feb 2026 a las 21:27, =C3=81lvaro Herrera () escribi=C3=B3: > On 2026-Feb-19, PG Bug reporting form wrote: > > > CREATE TABLE r_has_stock ( > > site_public_id varchar(10) NOT NULL, > [...] > > ) PARTITION BY HASH (site_public_id); > [...] > > Additional notes > > =E2=80=A2 Database collation: en_US.UTF-8 > > =E2=80=A2 Server encoding: UTF8 > > =E2=80=A2 Explicit casts and COLLATE tests did not change > behaviour. > > =E2=80=A2 Issue appears only when index scan is used. > > =E2=80=A2 Table and indexes originate from a cluster init= ially > running > > PostgreSQL 14.12 and later upgraded to 16.9. > > =E2=80=A2 After reindex the issue was resolved. > > > > > > Question > > > > Could this be related to HASH partitioning combined with PRIMARY KEY / > > UNIQUE indexes, or to data created in older PostgreSQL versions and lat= er > > upgraded? > > I would be pretty certain that the problem is related to collation > changes, since the partition key is varchar and you said the problem > disappeared after the reindex. > > The solution is exactly that: reindex any indexes potentially affected > by collation changes as part of a platform upgrade. > > -- > =C3=81lvaro Herrera PostgreSQL Developer =E2=80=94 > https://www.EnterpriseDB.com/ > "No hay hombre que no aspire a la plenitud, es decir, > la suma de experiencias de que un hombre es capaz" > > > --0000000000002e6341064b8e7dfc Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi!

After upgrading we= reindex all our databases, so I don't see it clear.
The diff= iculty here is finding a test case to work with.

<= br>

El lun, 23 feb 2026 a las 21:27, =C3=81lvaro= Herrera (<alvherre@kurilemu.de<= /a>>) escribi=C3=B3:
On 2026-Feb-19, PG Bug reporting form wrote:

> CREATE TABLE r_has_stock (
>=C2=A0 =C2=A0 =C2=A0site_public_id varchar(10) NOT NULL,
[...]
> ) PARTITION BY HASH (site_public_id);
[...]
> Additional notes
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=E2=80=A2=C2=A0 =C2=A0 =C2=A0 =C2=A0D= atabase collation: en_US.UTF-8
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=E2=80=A2=C2=A0 =C2=A0 =C2=A0 =C2=A0S= erver encoding: UTF8
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=E2=80=A2=C2=A0 =C2=A0 =C2=A0 =C2=A0E= xplicit casts and COLLATE tests did not change behaviour.
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=E2=80=A2=C2=A0 =C2=A0 =C2=A0 =C2=A0I= ssue appears only when index scan is used.
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=E2=80=A2=C2=A0 =C2=A0 =C2=A0 =C2=A0T= able and indexes originate from a cluster initially running
> PostgreSQL 14.12 and later upgraded to 16.9.
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=E2=80=A2=C2=A0 =C2=A0 =C2=A0 =C2=A0A= fter reindex the issue was resolved.
>
>
> Question
>
> Could this be related to HASH partitioning combined with PRIMARY KEY /=
> UNIQUE indexes, or to data created in older PostgreSQL versions and la= ter
> upgraded?

I would be pretty certain that the problem is related to collation
changes, since the partition key is varchar and you said the problem
disappeared after the reindex.

The solution is exactly that: reindex any indexes potentially affected
by collation changes as part of a platform upgrade.

--
=C3=81lvaro Herrera=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0PostgreSQL Developer= =C2=A0 =E2=80=94=C2=A0
https://www.EnterpriseDB.com/
"No hay hombre que no aspire a la plenitud, es decir,
la suma de experiencias de que un hombre es capaz"


--0000000000002e6341064b8e7dfc--