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 1xMgsh-000000029Tt-2opC for pgsql-bugs@arkaria.postgresql.org; Fri, 30 Oct 2026 07:18:32 +0000 Received: from localhost ([127.0.0.1]:51180 helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xMgsf-00000008qJl-1uXZ for pgsql-bugs@arkaria.postgresql.org; Fri, 30 Oct 2026 07:18:29 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]:60304) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xMJbQ-00000002wFK-0dPI for pgsql-bugs@lists.postgresql.org; Thu, 29 Oct 2026 06:27:08 +0000 Received: from mahout.postgresql.org ([2001:4800:3e1:1::227]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xMJbN-00000001U8X-3aER for pgsql-bugs@lists.postgresql.org; Thu, 29 Oct 2026 06:27:07 +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=uFpbncO3LIQXNxO8cn2rmNAX4AImMZ1xwzeR5JYbIKg=; b=qMSGJLLNbkazFeURUelsPSRl7k 78w2kVvQ9ihXhr11tXT70ktfIZ3qN6/AO1F+RQljsnzlWoYXzf3W9wERILmKExMzQsUzuFm0QyBhp TbbZI9wo6iKfYoKlkxM61pLd/VT1gwNt5Y3xmFTROGKT+XNmwC391oPx9Kllw3YFjFEUnv5aK4lAv 19ZJ18qbK1FOeMBIf3fCWYT5gmCCQOaq+dqzCc5EhkOl331A4pxhTjW/D6VUrqGkIUCTtL35mmRP8 ZaElNi78rJ2Kvg57iywiHvJnxTblKae91LwWGb8YQtsJZJV1/XE69T48oWGut/c2yIw1Z/Vgdmv84 +9Hy3Fpg==; 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.98.2) (envelope-from ) id 1xMJbN-00000004HTC-0j5x for pgsql-bugs@lists.postgresql.org; Thu, 29 Oct 2026 06:27:05 +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 1xMJbK-00000005bQy-3zVE for pgsql-bugs@lists.postgresql.org; Thu, 29 Oct 2026 06:27:03 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19809: oidvector index dedup still returns wrong results on 18.6; CTAS persists the corrupted rows To: pgsql-bugs@lists.postgresql.org From: PG Bug reporting form Cc: 303677365@qq.com Reply-To: 303677365@qq.com, pgsql-bugs@lists.postgresql.org Date: Thu, 29 Oct 2026 06:26:24 +0000 Message-ID: <19809-c48ecb1edfc5f2d8@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: 19809 Logged by: chunling qin Email address: 303677365@qq.com PostgreSQL version: 18.6 Operating system: Linux x86_64 Description: =20 Commit 882fd41 (2026-10-06, "Rescind unsafe deduplication support", fixes bug #19749) removed nbtree deduplication for bpchar but deliberately left oidvector_ops deduplication enabled on branches 14 through 18, to avoid making pg_amcheck report a corrupt metapage for pg_proc_proname_args_nsp_index. Its commit message reasons that "a user can only hit it by indexing an oidvector column that stores the output of a function like trim_array(). It seems very unlikely that any user would ever do that." This is a short report to (1) provide a minimal deterministic reproduction on the official 18.6 docker image, and (2) show that the damage is not limited to query-time wrong results: CREATE TABLE AS persists the corrupted index images into a new table, where a later REINDEX of the original index cannot fix them. Background: oidvector equality intentionally ignores the array lower-bound field, so trim_array('1 2 3 4'::oidvector, 1) (lower bound 1) and '1 2 3'::oidvector (lower bound 0) compare equal but have different byte images. A posting-list split can attach a TID to the "equal but not identical" key, and index-only scans then return the wrong image. Minimal reproduction (self-contained): CREATE TABLE ov_repro(id int, a oidvector); INSERT INTO ov_repro SELECT g, trim_array('1 2 3 4'::oidvector, 1) FROM generate_series(1,60) g; -- fillfactor 10 keeps everything on one leaf page (a single posting list) CREATE INDEX ov_repro_i ON ov_repro(a) WITH (fillfactor =3D 10); VACUUM ov_repro; -- free ctids in the middle, so later inserts reuse them DELETE FROM ov_repro WHERE id BETWEEN 20 AND 30; VACUUM ov_repro; -- 5 rows storing the other image; they reuse the freed ctids INSERT INTO ov_repro SELECT 1000 + g, '1 2 3'::oidvector FROM generate_series(1,5) g; VACUUM ANALYZE ov_repro; -- symmetry breaker: remove the image-A rows again; the heap is now all image B DELETE FROM ov_repro WHERE id > 1000; VACUUM ANALYZE ov_repro; -- heap truth: all 49 surviving rows are image B (a[1] =3D 1) SET enable_indexonlyscan =3D off; SET enable_indexscan =3D off; SET enable_bitmapscan =3D off; SELECT a[1], count(*) FROM ov_repro WHERE a =3D '1 2 3'::oidvector GROUP BY= 1; -> 1 | 49 -- the same rows through an index-only scan SET enable_seqscan =3D off; SET enable_indexonlyscan =3D on; SET enable_indexscan =3D on; SELECT a[1], count(*) FROM ov_repro WHERE a =3D '1 2 3'::oidvector GROUP BY= 1; -> 1 | 44 2 | 5 <- wrong image for 5 rows; the heap stores no such row SELECT count(*) FROM ov_repro WHERE a =3D '1 2 3'::oidvector AND a[1] =3D 2; -> 5 <- must be 0: no surviving heap row satisfies this This also reproduces with fully default settings at a larger scale (20000-row table, plain CREATE INDEX, ordinary DELETE/INSERT/VACUUM churn): 10000 surviving rows, heap all image B, index-only scan reports 2498 rows with the wrong image. Persistence beyond the query: a CREATE TABLE AS over such a table copies the index-provided values, so the wrong images become permanent data. REINDEX on the original index afterwards repairs the index, but the copied table keeps the corrupted rows (verified end-to-end with array_lower(a,1) as the discriminator: source table 0 rows with lower bound 0 after REINDEX, the CTAS copy still has them). Given that the exposure is silent wrong results plus permanently corrupted data via CTAS, it may be worth revisiting the tradeoff made in 882fd41 - e.g. a backpatchable fix that does not trip pg_amcheck's metapage check, or at least documenting the hazard for users who index oidvector columns.