pgsql: Adjust signature of cluster_rel() and its subroutines

From: Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Adjust signature of cluster_rel() and its subroutines
Date: 2025-01-10 12:14:58
Message-ID: E1tWDuk-000pGa-FX@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Adjust signature of cluster_rel() and its subroutines

cluster_rel() receives the OID of the relation to process, which it
opens and locks; but then its subroutine copy_table_data() also receives
the relation OID and opens it by itself. This is a bit wasteful. It's
better to have cluster_rel() receive the relation already open, and pass
it down to its subroutines as necessary; then cluster_rel closes the rel
before returning. This simplifies things.

But a better motivation to make this change is that a future command to
do logical-decoding-based "concurrent VACUUM FULL" will need to release
all locks on the relation (and possibly on the clustering index) at some
point. Since it makes little sense to keep the relation reference
without the lock, the cluster_rel() function will also close it (and
the index). With this arrangement, neither the function nor its
subroutines need open extra references, which, again, makes things simpler.

Author: Antonin Houska <ah(at)cybertec(dot)at>
Discussion: https://postgr.es/m/82651.1720540558@antos

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/cc811f92bac5c80253c8a22e43409722cab4c05b

Modified Files
--------------
src/backend/commands/cluster.c | 135 +++++++++++++++++++++--------------------
src/backend/commands/matview.c | 2 +-
src/backend/commands/vacuum.c | 9 ++-
src/include/commands/cluster.h | 2 +-
4 files changed, 75 insertions(+), 73 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2025-01-10 16:44:53 pgsql: postmaster: Make btmask_add() variadic
Previous Message David Rowley 2025-01-10 01:31:48 pgsql: Fix UNION planner datatype issue