pgsql: Adjust signature of cluster_rel() and its subroutines - Mailing list pgsql-committers

From Álvaro Herrera
Subject pgsql: Adjust signature of cluster_rel() and its subroutines
Date
Msg-id E1tWDuk-000pGa-FX@gemulon.postgresql.org
Whole thread Raw
List 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@cybertec.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(-)


pgsql-committers by date:

Previous
From: David Rowley
Date:
Subject: pgsql: Fix UNION planner datatype issue
Next
From: Andres Freund
Date:
Subject: pgsql: postmaster: Introduce variadic btmask_all_except()