mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-27 08:39:28 +08:00
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.
This commit is contained in:
parent
a6ce8ba2f3
commit
aa3299f256
@ -322,9 +322,18 @@ RangeVarGetRelid(const RangeVar *relation, LOCKMODE lockmode, bool missing_ok,
|
|||||||
* If, upon retry, we get back the same OID we did last time, then
|
* If, upon retry, we get back the same OID we did last time, then
|
||||||
* the invalidation messages we processed did not change the final
|
* the invalidation messages we processed did not change the final
|
||||||
* answer. So we're done.
|
* answer. So we're done.
|
||||||
|
*
|
||||||
|
* If we got a different OID, we've locked the relation that used to
|
||||||
|
* have this name rather than the one that does now. So release
|
||||||
|
* the lock.
|
||||||
*/
|
*/
|
||||||
if (retry && relId == oldRelId)
|
if (retry)
|
||||||
|
{
|
||||||
|
if (relId == oldRelId)
|
||||||
break;
|
break;
|
||||||
|
if (OidIsValid(oldRelId))
|
||||||
|
UnlockRelationOid(oldRelId, lockmode);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lock relation. This will also accept any pending invalidation
|
* Lock relation. This will also accept any pending invalidation
|
||||||
|
Loading…
Reference in New Issue
Block a user