aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2020-06-01 14:41:46 +0900
committerMichael Paquier <michael@paquier.xyz>2020-06-01 14:41:46 +0900
commita8c6eb5b4c4cf3470159a0b4b3fd2f2942b7909b (patch)
tree6332caf5e1523420ec98841738c3408e21eacaad
parentbb45c5de2750f8aa5ab501aa327ababafed890d2 (diff)
downloadpostgresql-a8c6eb5b4c4cf3470159a0b4b3fd2f2942b7909b.tar.gz
postgresql-a8c6eb5b4c4cf3470159a0b4b3fd2f2942b7909b.zip
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
-rw-r--r--src/backend/utils/adt/tid.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/backend/utils/adt/tid.c b/src/backend/utils/adt/tid.c
index 5157899c236..c4be647f049 100644
--- a/src/backend/utils/adt/tid.c
+++ b/src/backend/utils/adt/tid.c
@@ -313,8 +313,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;
}
}
}