0001-Fix-RangeType-oid-not-found-when-doing-Memoize.patch
application/octet-stream
Filename: 0001-Fix-RangeType-oid-not-found-when-doing-Memoize.patch
Type: application/octet-stream
Part: 1
Patch
Format: format-patch
Series: patch 0001
Subject: Fix RangeType oid not found when doing Memoize.
| File | + | − |
|---|---|---|
| src/backend/executor/nodeMemoize.c | 12 | 8 |
From fe773d211c7da0f97ae764815ad3d87225e0e366 Mon Sep 17 00:00:00 2001
From: "tender.wang" <tender.wang@openpie.com>
Date: Sun, 25 Feb 2024 20:18:04 +0800
Subject: [PATCH] Fix RangeType oid not found when doing Memoize.
After call ResetExprContext(), the data in mstate->proeslot may be freed too,
So we copy the result to probeslot from ExecEvalExpr.
---
src/backend/executor/nodeMemoize.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/src/backend/executor/nodeMemoize.c b/src/backend/executor/nodeMemoize.c
index 18870f10e1..5f1468ad0b 100644
--- a/src/backend/executor/nodeMemoize.c
+++ b/src/backend/executor/nodeMemoize.c
@@ -312,17 +312,21 @@ prepare_probe_slot(MemoizeState *mstate, MemoizeKey *key)
if (key == NULL)
{
ExprContext *econtext = mstate->ss.ps.ps_ExprContext;
- MemoryContext oldcontext;
-
- oldcontext = MemoryContextSwitchTo(econtext->ecxt_per_tuple_memory);
+ Datum value;
+ bool isnull;
+ TupleDesc tup = pslot->tts_tupleDescriptor;
+ Form_pg_attribute att;
/* Set the probeslot's values based on the current parameter values */
for (int i = 0; i < numKeys; i++)
- pslot->tts_values[i] = ExecEvalExpr(mstate->param_exprs[i],
- econtext,
- &pslot->tts_isnull[i]);
-
- MemoryContextSwitchTo(oldcontext);
+ {
+ att = TupleDescAttr(tup, i);
+ value = ExecEvalExprSwitchContext(mstate->param_exprs[i],
+ econtext,
+ &isnull);
+ pslot->tts_values[i] = datumCopy(value, att->attbyval, att->attlen);
+ pslot->tts_isnull[i] = isnull;
+ }
}
else
{
--
2.25.1