Skip to content

Commit 1339fcc

Browse files
committed
Clarify comment about assignment and reset of temp namespace ID in MyProc
The new wording comes from Álvaro, which I modified a bit. Reported-by: Andres Freund, Álvaro Herrera Author: Álvaro Herrera, Michael Paquier Discussion: https://postgr.es/m/20180809165047.GK13638@paquier.xyz Backpatch-through: 11
1 parent f3efef4 commit 1339fcc

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/backend/catalog/namespace.c

+16-10
Original file line numberDiff line numberDiff line change
@@ -3938,8 +3938,10 @@ InitTempTableNamespace(void)
39383938
* decide if a temporary namespace is in use or not. We assume that
39393939
* assignment of namespaceId is an atomic operation. Even if it is not,
39403940
* the temporary relation which resulted in the creation of this temporary
3941-
* namespace is still locked until the current transaction commits, so it
3942-
* would not be accessible yet, acting as a barrier.
3941+
* namespace is still locked until the current transaction commits, and
3942+
* its pg_namespace row is not visible yet. However it does not matter:
3943+
* this flag makes the namespace as being in use, so no objects created on
3944+
* it would be removed concurrently.
39433945
*/
39443946
MyProc->tempNamespaceId = namespaceId;
39453947

@@ -3976,10 +3978,12 @@ AtEOXact_Namespace(bool isCommit, bool parallel)
39763978

39773979
/*
39783980
* Reset the temporary namespace flag in MyProc. We assume that
3979-
* this operation is atomic. Even if it is not, the temporary
3980-
* table which created this namespace is still locked until this
3981-
* transaction aborts so it would not be visible yet, acting as a
3982-
* barrier.
3981+
* this operation is atomic.
3982+
*
3983+
* Because this transaction is aborting, the pg_namespace row is
3984+
* not visible to anyone else anyway, but that doesn't matter:
3985+
* it's not a problem if objects contained in this namespace are
3986+
* removed concurrently.
39833987
*/
39843988
MyProc->tempNamespaceId = InvalidOid;
39853989
}
@@ -4037,10 +4041,12 @@ AtEOSubXact_Namespace(bool isCommit, SubTransactionId mySubid,
40374041

40384042
/*
40394043
* Reset the temporary namespace flag in MyProc. We assume that
4040-
* this operation is atomic. Even if it is not, the temporary
4041-
* table which created this namespace is still locked until this
4042-
* transaction aborts so it would not be visible yet, acting as a
4043-
* barrier.
4044+
* this operation is atomic.
4045+
*
4046+
* Because this subtransaction is aborting, the pg_namespace row
4047+
* is not visible to anyone else anyway, but that doesn't matter:
4048+
* it's not a problem if objects contained in this namespace are
4049+
* removed concurrently.
40444050
*/
40454051
MyProc->tempNamespaceId = InvalidOid;
40464052
}

0 commit comments

Comments
 (0)