postgres.git / summary / log / commit / refs
commit a36f216209b818a28d7597966032cc3dce6acfa2
Author: Michael Paquier <michael@paquier.xyz>
Date: Mon Jun 01 05:41:37 2020 +0000
First released in: 13.0, 9.5.23, 9.6.19, 10.14, 11.9, 12.4
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
src/backend/utils/adt/tid.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/backend/utils/adt/tid.c b/src/backend/utils/adt/tid.c
index 8453b65e78a..75d04280ee9 100644
--- a/src/backend/utils/adt/tid.c
+++ b/src/backend/utils/adt/tid.c
@@ -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;
}
}
}
[parent: cb9795eb2e17]