Adjust comments of CheckRelationTableSpaceMove() and SetRelationTableSpace()

4c9c359, that introduced those two functions, has been overoptimistic on
the point that only ShareUpdateExclusiveLock would be required when
moving a relation to a new tablespace.  AccessExclusiveLock is a
requirement, but ShareUpdateExclusiveLock may be used under specific
conditions like REINDEX CONCURRENTLY where waits on past transactions
make the operation safe even with a lower-level lock.  The current code
does only the former, so update the existing comments to reflect that.

Once a REINDEX (TABLESPACE) is introduced, those comments would require
an extra refresh to mention their new use case.

While on it, fix an incorrect variable name.

Per discussion with Álvaro Herrera.

Discussion: https://postgr.es/m/20210127140741.GA14174@alvherre.pgsql
This commit is contained in:
Michael Paquier 2021-01-29 13:59:18 +09:00
parent 5c6d184213
commit 24843297a9
1 changed files with 6 additions and 7 deletions

View File

@ -3041,11 +3041,11 @@ SetRelationHasSubclass(Oid relationId, bool relhassubclass)
* CheckRelationTableSpaceMove
* Check if relation can be moved to new tablespace.
*
* NOTE: Caller must be holding an appropriate lock on the relation.
* ShareUpdateExclusiveLock is sufficient.
* NOTE: The caller must hold AccessExclusiveLock on the relation.
*
* Returns true if the relation can be moved to the new tablespace;
* false otherwise.
* Returns true if the relation can be moved to the new tablespace; raises
* an error if it is not possible to do the move; returns false if the move
* would have no effect.
*/
bool
CheckRelationTableSpaceMove(Relation rel, Oid newTableSpaceId)
@ -3094,11 +3094,10 @@ CheckRelationTableSpaceMove(Relation rel, Oid newTableSpaceId)
* Set new reltablespace and relfilenode in pg_class entry.
*
* newTableSpaceId is the new tablespace for the relation, and
* newRelFileNode its new filenode. If newrelfilenode is InvalidOid,
* newRelFileNode its new filenode. If newRelFileNode is InvalidOid,
* this field is not updated.
*
* NOTE: Caller must be holding an appropriate lock on the relation.
* ShareUpdateExclusiveLock is sufficient.
* NOTE: The caller must hold AccessExclusiveLock on the relation.
*
* The caller of this routine had better check if a relation can be
* moved to this new tablespace by calling CheckRelationTableSpaceMove()