Adjust signature of cluster_rel() and its subroutines
authorÁlvaro Herrera <alvherre@alvh.no-ip.org>
Fri, 10 Jan 2025 12:09:38 +0000 (13:09 +0100)
committerÁlvaro Herrera <alvherre@alvh.no-ip.org>
Fri, 10 Jan 2025 12:09:38 +0000 (13:09 +0100)
commitcc811f92bac5c80253c8a22e43409722cab4c05b
treef6d617d86d46415071b24ad013535b96dc0d5e49
parent23100645104f63bf7c35304f36f8a7d91f5ddd73
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
src/backend/commands/cluster.c
src/backend/commands/matview.c
src/backend/commands/vacuum.c
src/include/commands/cluster.h