asserts.patch
text/plain
Filename: asserts.patch
Type: text/plain
Part: 4
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/backend/executor/nodeAgg.c | 14 | 0 |
| src/backend/executor/nodeWindowAgg.c | 11 | 0 |
diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c
index 323ae94938..a6428a77c4 100644
--- a/src/backend/executor/nodeAgg.c
+++ b/src/backend/executor/nodeAgg.c
@@ -1108,6 +1108,9 @@ finalize_aggregate(AggState *aggstate,
{
*resultVal = FunctionCallInvoke(fcinfo);
*resultIsNull = fcinfo->isnull;
+ Assert(peragg->resulttypeByVal ||
+ *resultIsNull ||
+ GetMemoryChunkContext(DatumGetPointer(*resultVal)) == CurrentMemoryContext);
}
aggstate->curperagg = NULL;
}
@@ -1116,6 +1119,9 @@ finalize_aggregate(AggState *aggstate,
/* Don't need MakeExpandedObjectReadOnly; datumCopy will copy it */
*resultVal = pergroupstate->transValue;
*resultIsNull = pergroupstate->transValueIsNull;
+ Assert(peragg->resulttypeByVal ||
+ *resultIsNull ||
+ GetMemoryChunkContext(DatumGetPointer(*resultVal)) != CurrentMemoryContext);
}
/*
@@ -1172,6 +1178,10 @@ finalize_partialaggregate(AggState *aggstate,
*resultVal = FunctionCallInvoke(fcinfo);
*resultIsNull = fcinfo->isnull;
+
+ Assert(peragg->resulttypeByVal ||
+ *resultIsNull ||
+ GetMemoryChunkContext(DatumGetPointer(*resultVal)) == CurrentMemoryContext);
}
}
else
@@ -1179,6 +1189,10 @@ finalize_partialaggregate(AggState *aggstate,
/* Don't need MakeExpandedObjectReadOnly; datumCopy will copy it */
*resultVal = pergroupstate->transValue;
*resultIsNull = pergroupstate->transValueIsNull;
+ Assert(peragg->resulttypeByVal ||
+ *resultIsNull ||
+ GetMemoryChunkContext(DatumGetPointer(*resultVal)) != CurrentMemoryContext);
+
}
/* If result is pass-by-ref, make sure it is in the right context. */
diff --git a/src/backend/executor/nodeWindowAgg.c b/src/backend/executor/nodeWindowAgg.c
index 2820044cd0..3e4462b4c4 100644
--- a/src/backend/executor/nodeWindowAgg.c
+++ b/src/backend/executor/nodeWindowAgg.c
@@ -626,6 +626,10 @@ finalize_windowaggregate(WindowAggState *winstate,
*result = FunctionCallInvoke(fcinfo);
winstate->curaggcontext = NULL;
*isnull = fcinfo->isnull;
+
+ Assert(peraggstate->resulttypeByVal ||
+ *isnull ||
+ GetMemoryChunkContext(DatumGetPointer(*result)) == CurrentMemoryContext);
}
}
else
@@ -633,6 +637,9 @@ finalize_windowaggregate(WindowAggState *winstate,
/* Don't need MakeExpandedObjectReadOnly; datumCopy will copy it */
*result = peraggstate->transValue;
*isnull = peraggstate->transValueIsNull;
+ Assert(peraggstate->resulttypeByVal ||
+ *isnull ||
+ GetMemoryChunkContext(DatumGetPointer(*result)) != CurrentMemoryContext);
}
/*
@@ -1060,6 +1067,10 @@ eval_windowfunction(WindowAggState *winstate, WindowStatePerFunc perfuncstate,
*result = FunctionCallInvoke(fcinfo);
*isnull = fcinfo->isnull;
+ Assert(perfuncstate->resulttypeByVal ||
+ *isnull ||
+ GetMemoryChunkContext(DatumGetPointer(*result)) == CurrentMemoryContext);
+
/*
* Make sure pass-by-ref data is allocated in the appropriate context. (We
* need this in case the function returns a pointer into some short-lived