mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +03:00
Avoid potential relcache leak in objectaddress.c.
Nobody using the missing_ok flag yet, but let's speculate that this will be a better interface for future callers. KaiGai Kohei, with some adjustments by me.
This commit is contained in:
@ -639,7 +639,8 @@ get_object_address_relobject(ObjectType objtype, List *objname,
|
|||||||
* Caller is expecting to get back the relation, even though we
|
* Caller is expecting to get back the relation, even though we
|
||||||
* didn't end up using it to find the rule.
|
* didn't end up using it to find the rule.
|
||||||
*/
|
*/
|
||||||
relation = heap_open(reloid, AccessShareLock);
|
if (OidIsValid(address.objectId))
|
||||||
|
relation = heap_open(reloid, AccessShareLock);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -677,6 +678,14 @@ get_object_address_relobject(ObjectType objtype, List *objname,
|
|||||||
address.objectId = InvalidOid;
|
address.objectId = InvalidOid;
|
||||||
address.objectSubId = 0;
|
address.objectSubId = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Avoid relcache leak when object not found. */
|
||||||
|
if (!OidIsValid(address.objectId))
|
||||||
|
{
|
||||||
|
heap_close(relation, AccessShareLock);
|
||||||
|
relation = NULL; /* department of accident prevention */
|
||||||
|
return address;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Done. */
|
/* Done. */
|
||||||
|
Reference in New Issue
Block a user