Skip to content

Commit 8bc7449

Browse files
committed
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
1 parent f4f4d64 commit 8bc7449

File tree

1 file changed

+6
-1
lines changed
  • src/backend/utils/adt

1 file changed

+6
-1
lines changed

src/backend/utils/adt/tid.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,13 @@ currtid_for_view(Relation viewrel, ItemPointer tid)
309309
rte = rt_fetch(var->varno, query->rtable);
310310
if (rte)
311311
{
312+
Datum result;
313+
314+
result = DirectFunctionCall2(currtid_byreloid,
315+
ObjectIdGetDatum(rte->relid),
316+
PointerGetDatum(tid));
312317
heap_close(viewrel, AccessShareLock);
313-
return DirectFunctionCall2(currtid_byreloid, ObjectIdGetDatum(rte->relid), PointerGetDatum(tid));
318+
return result;
314319
}
315320
}
316321
}

0 commit comments

Comments
 (0)