Re: Fix REPACK with WITHOUT OVERLAPS replica identity indexes

Álvaro Herrera <alvherre@kurilemu.de>

From: Álvaro Herrera <alvherre@kurilemu.de>
To: Chao Li <li.evan.chao@gmail.com>
Cc: Kirill Reshke <reshkekirill@gmail.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2026-05-09T22:38:08Z
Lists: pgsql-hackers
On 2026-May-09, Chao Li wrote:

> > On May 9, 2026, at 01:47, Kirill Reshke <reshkekirill@gmail.com> wrote:
> > 
> > On Fri, 8 May 2026 at 09:22, Chao Li <li.evan.chao@gmail.com> wrote:

> >> While testing UPDATE FOR PORTION OF, I started wondering whether
> >> REPACK supports temporal tables. In theory, it should, because
> >> temporal WITHOUT OVERLAPS indexes can be used as replica identity
> >> indexes. So I created a test script, repack_temporal.spec, which is
> >> included in the attached patch, and it failed.

Nice find, thanks for testing.

> >> I found that REPACK hard-codes BTEqualStrategyNumber when calling
> >> get_opfamily_member(). That seems wrong, because
> >> build_replindex_scan_key() uses IndexAmTranslateCompareType() to
> >> get the equality strategy for COMPARE_EQ.

Makes sense.

I think it would be a good idea to make identity_key_equal() not deform
all attributes, but instead only up to the last one it needs for the key
comparisons.

-- 
Álvaro Herrera         PostgreSQL Developer  —  https://www.EnterpriseDB.com/