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:
parent
ad30d36642
commit
393e828e31
|
@ -639,6 +639,7 @@ get_object_address_relobject(ObjectType objtype, List *objname,
|
|||
* Caller is expecting to get back the relation, even though we
|
||||
* didn't end up using it to find the rule.
|
||||
*/
|
||||
if (OidIsValid(address.objectId))
|
||||
relation = heap_open(reloid, AccessShareLock);
|
||||
}
|
||||
else
|
||||
|
@ -677,6 +678,14 @@ get_object_address_relobject(ObjectType objtype, List *objname,
|
|||
address.objectId = InvalidOid;
|
||||
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. */
|
||||
|
|
Loading…
Reference in New Issue