Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 2484329

Browse files
committed
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
1 parent 5c6d184 commit 2484329

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/backend/commands/tablecmds.c

+6-7
Original file line numberDiff line numberDiff line change
@@ -3041,11 +3041,11 @@ SetRelationHasSubclass(Oid relationId, bool relhassubclass)
30413041
* CheckRelationTableSpaceMove
30423042
* Check if relation can be moved to new tablespace.
30433043
*
3044-
* NOTE: Caller must be holding an appropriate lock on the relation.
3045-
* ShareUpdateExclusiveLock is sufficient.
3044+
* NOTE: The caller must hold AccessExclusiveLock on the relation.
30463045
*
3047-
* Returns true if the relation can be moved to the new tablespace;
3048-
* false otherwise.
3046+
* Returns true if the relation can be moved to the new tablespace; raises
3047+
* an error if it is not possible to do the move; returns false if the move
3048+
* would have no effect.
30493049
*/
30503050
bool
30513051
CheckRelationTableSpaceMove(Relation rel, Oid newTableSpaceId)
@@ -3094,11 +3094,10 @@ CheckRelationTableSpaceMove(Relation rel, Oid newTableSpaceId)
30943094
* Set new reltablespace and relfilenode in pg_class entry.
30953095
*
30963096
* newTableSpaceId is the new tablespace for the relation, and
3097-
* newRelFileNode its new filenode. If newrelfilenode is InvalidOid,
3097+
* newRelFileNode its new filenode. If newRelFileNode is InvalidOid,
30983098
* this field is not updated.
30993099
*
3100-
* NOTE: Caller must be holding an appropriate lock on the relation.
3101-
* ShareUpdateExclusiveLock is sufficient.
3100+
* NOTE: The caller must hold AccessExclusiveLock on the relation.
31023101
*
31033102
* The caller of this routine had better check if a relation can be
31043103
* moved to this new tablespace by calling CheckRelationTableSpaceMove()

0 commit comments

Comments
 (0)