Skip to content

Commit 894041e

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 95e389b commit 894041e

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
@@ -338,8 +338,13 @@ currtid_for_view(Relation viewrel, ItemPointer tid)
338338
rte = rt_fetch(var->varno, query->rtable);
339339
if (rte)
340340
{
341+
Datum result;
342+
343+
result = DirectFunctionCall2(currtid_byreloid,
344+
ObjectIdGetDatum(rte->relid),
345+
PointerGetDatum(tid));
341346
table_close(viewrel, AccessShareLock);
342-
return DirectFunctionCall2(currtid_byreloid, ObjectIdGetDatum(rte->relid), PointerGetDatum(tid));
347+
return result;
343348
}
344349
}
345350
}

0 commit comments

Comments
 (0)