pgsql: Fix REPACK CONCURRENTLY for stored generated columns

From: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix REPACK CONCURRENTLY for stored generated columns
Date: 2026-07-03 10:23:44
Message-ID: E1wfb3g-0019jS-2t@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix REPACK CONCURRENTLY for stored generated columns

In order to replay concurrent changes, REPACK CONCURRENTLY needs the
pg_attrdef tuples for the transient table to be there, in case a tuple
is modified concurrently with REPACK and requires to store the value
from the generated column (which, with the current arrangements, means
all tuples concurrently updated or inserted). Fix by creating a copy of
them from the original table. Add a test that tickles the bug.

Author: Antonin Houska <ah(at)cybertec(dot)at>
Reported-by: Ewan Young <kdbase(dot)hack(at)gmail(dot)com>
Diagnosed-by: Ewan Young <kdbase(dot)hack(at)gmail(dot)com>
Reviewed-by: Ewan Young <kdbase(dot)hack(at)gmail(dot)com>
Backpatch-through: 19
Discussion: https://postgr.es/m/CAON2xHMrELwx9vKg6niSf8fMBA=-MGXmG=MPQU6+vMVhGjF8kQ@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3be823486f2c9f405fc754ac0ece3ce412aee105

Modified Files
--------------
src/backend/commands/repack.c | 103 ++++++++++++++++++++-
.../modules/injection_points/specs/repack.spec | 3 +-
2 files changed, 104 insertions(+), 2 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Heikki Linnakangas 2026-07-03 12:05:58 pgsql: Fix tracing of BackendKeyData and CancelRequest
Previous Message Peter Eisentraut 2026-07-03 10:17:50 pgsql: Prevent dropping the last label from a property graph element