summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Paquier2020-06-01 05:41:18 +0000
committerMichael Paquier2020-06-01 05:41:18 +0000
commitce1c5b9ae87b6153d3f40a4f7806f2effef12363 (patch)
tree4b9bdb98be64ff9894dbbc98c4452d1f04104712
parente786be5fcb257a09b05bd8e509c8d1b82e626352 (diff)
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
-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 cc699ee2f4..509a0fdffc 100644
--- a/src/backend/utils/adt/tid.c
+++ b/src/backend/utils/adt/tid.c
@@ -338,8 +338,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));
table_close(viewrel, AccessShareLock);
- return DirectFunctionCall2(currtid_byreloid, ObjectIdGetDatum(rte->relid), PointerGetDatum(tid));
+ return result;
}
}
}