pgsql: Make index_concurrently_create_copy more general

From: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Make index_concurrently_create_copy more general
Date: 2026-04-04 19:02:13
Message-ID: E1w96G4-002xGd-1c@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Make index_concurrently_create_copy more general

Also rename it to index_create_copy. Add a 'boolean concurrent' option,
and make it work for both cases: in concurrent mode, just create the
catalog entries; caller is responsible for the actual building later.
In non-concurrent mode, the index is built right away.

This allows it to be reused for other purposes -- specifically, for
concurrent REPACK.

(With the CONCURRENTLY option, REPACK cannot simply swap the heap file and
rebuild its indexes. Instead, it needs to build a separate set of
indexes, including their system catalog entries, *before* the actual
swap, to reduce the time AccessExclusiveLock needs to be held for. This
approach is different from what CREATE INDEX CONCURRENTLY does.)

Per a suggestion from Mihail Nikalayeu.

Author: Antonin Houska <ah(at)cybertec(dot)at>
Reviewed-by: Mihail Nikalayeu <mihailnikalayeu(at)gmail(dot)com>
Reviewed-by: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
Discussion: https://postgr.es/m/41104.1754922120@localhost

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/33bf7318f94ce730563eb5ed95ad6c61d6e6f7a6

Modified Files
--------------
src/backend/catalog/index.c | 41 +++++++++++++++++++++++++++-------------
src/backend/commands/indexcmds.c | 9 +++++----
src/include/catalog/index.h | 7 +++----
3 files changed, 36 insertions(+), 21 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Álvaro Herrera 2026-04-04 22:22:57 pgsql: Modernize struct declarations in snapbuild.h
Previous Message Peter Geoghegan 2026-04-04 17:50:29 pgsql: heapam: Keep buffer pins across index scan resets.