Skip to content

Commit ce1c5b9

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/[email protected] Backpatch-through: 9.5
1 parent e786be5 commit ce1c5b9

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

+6-1
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)