Fix use-after-release mistake in currtid() and currtid2() for views

This issue has been present since the introduction of this code as of
a3519a2 from 2002, and has been found by buildfarm member prion that
uses RELCACHE_FORCE_RELEASE via the tests introduced recently in
e786be5.

Discussion: https://postgr.es/m/20200601022055.GB4121@paquier.xyz
Backpatch-through: 9.5
This commit is contained in:
Michael Paquier 2020-06-01 14:41:32 +09:00
parent f4f4d64eaf
commit 8bc74490df
1 changed files with 6 additions and 1 deletions

View File

@ -309,8 +309,13 @@ currtid_for_view(Relation viewrel, ItemPointer tid)
rte = rt_fetch(var->varno, query->rtable);
if (rte)
{
Datum result;
result = DirectFunctionCall2(currtid_byreloid,
ObjectIdGetDatum(rte->relid),
PointerGetDatum(tid));
heap_close(viewrel, AccessShareLock);
return DirectFunctionCall2(currtid_byreloid, ObjectIdGetDatum(rte->relid), PointerGetDatum(tid));
return result;
}
}
}