Skip to content

Commit aa3299f

Browse files
committed
Avoid retaining multiple relation locks in RangeVarGetRelid.
If it turns out we've locked the wrong OID, release the old lock. In most cases, it's pretty harmless to retain the extra lock, but this seems tidier and avoids using lock table slots unnecessarily. Per discussion with Tom Lane.
1 parent a6ce8ba commit aa3299f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/backend/catalog/namespace.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,18 @@ RangeVarGetRelid(const RangeVar *relation, LOCKMODE lockmode, bool missing_ok,
322322
* If, upon retry, we get back the same OID we did last time, then
323323
* the invalidation messages we processed did not change the final
324324
* answer. So we're done.
325+
*
326+
* If we got a different OID, we've locked the relation that used to
327+
* have this name rather than the one that does now. So release
328+
* the lock.
325329
*/
326-
if (retry && relId == oldRelId)
327-
break;
330+
if (retry)
331+
{
332+
if (relId == oldRelId)
333+
break;
334+
if (OidIsValid(oldRelId))
335+
UnlockRelationOid(oldRelId, lockmode);
336+
}
328337

329338
/*
330339
* Lock relation. This will also accept any pending invalidation

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy