Re: BUG #19664: nbtree: Assertion failure when a custom index AM reuses bthandler

From: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
To: mrdrivingduck(at)gmail(dot)com, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #19664: nbtree: Assertion failure when a custom index AM reuses bthandler
Date: 2026-09-09 09:59:14
Message-ID: 508C89D3-DDCB-411D-BF07-A5FB98859684@yandex-team.ru
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

> On 7 Sep 2026, at 16:51, PG Bug reporting form <noreply(at)postgresql(dot)org> wrote:
>
> CREATE ACCESS METHOD hx_orph_ix TYPE INDEX HANDLER bthandler;

I've toyed with reusing B-tree code in another index AM. It is possible,
but this Assert is far from the only assumption that the code is dealing
with the built-in B-tree AM. A grep finds 32 BTREE_AM_OID references in
19 files under src/, including nbtree, tuplesort, the planner, catalog and
DDL code, typcache, and RI triggers. B-tree has grown into the core, and
that is not necessarily a problem.

I once made a working btree-fork extension by copying nbtree and fixing the
relevant assumptions [0]. So the implementation can be detached, but
that is quite different from registering the in-core bthandler under
another AM OID. I don't think that use is documented or promised.

The gist2 regression case is a test hack, not a documented interface. I
therefore don't think removing this one Assert would make this usage
valid. The assertion failure could perhaps be replaced with a regular
error instead.

Best regards, Andrey Borodin.

[0] https://github.com/x4m/postgres_g/commit/58ced18d8901d9cf58c6aa8d82cc20e426e9517d

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Rui Zhao 2026-09-09 16:29:00 Re: BUG #19483: pg_upgrade fails with orphan records in pg_init_priv catalog table
Previous Message Luguoqing 2026-09-09 07:27:06 Re: table_rewrite event trigger can corrupt rows by inserting into the table being rewritten (20devel)