aggfix.patch
text/x-patch
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/backend/executor/execExprInterp.c | 2 | 1 |
| src/backend/executor/nodeAgg.c | 2 | 1 |
| src/backend/executor/nodeWindowAgg.c | 2 | 1 |
| src/backend/jit/llvm/llvmjit_expr.c | 9 | 3 |
diff --git a/src/backend/executor/execExprInterp.c b/src/backend/executor/execExprInterp.c
index 034970648f3..3b5333716d4 100644
--- a/src/backend/executor/execExprInterp.c
+++ b/src/backend/executor/execExprInterp.c
@@ -1743,7 +1743,8 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
* expanded object that is already a child of the aggcontext,
* assume we can adopt that value without copying it.
*/
- if (DatumGetPointer(newVal) != DatumGetPointer(pergroup->transValue))
+ if (DatumGetPointer(newVal) != DatumGetPointer(pergroup->transValue) ||
+ fcinfo->isnull != pergroup->transValueIsNull)
newVal = ExecAggTransReparent(aggstate, pertrans,
newVal, fcinfo->isnull,
pergroup->transValue,
diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c
index 6ee24eab3d2..e848853d6fd 100644
--- a/src/backend/executor/nodeAgg.c
+++ b/src/backend/executor/nodeAgg.c
@@ -628,7 +628,8 @@ advance_transition_function(AggState *aggstate,
* aggcontext, assume we can adopt that value without copying it.
*/
if (!pertrans->transtypeByVal &&
- DatumGetPointer(newVal) != DatumGetPointer(pergroupstate->transValue))
+ (DatumGetPointer(newVal) != DatumGetPointer(pergroupstate->transValue) ||
+ fcinfo->isnull != pergroupstate->transValueIsNull))
{
if (!fcinfo->isnull)
{
diff --git a/src/backend/executor/nodeWindowAgg.c b/src/backend/executor/nodeWindowAgg.c
index f1b9407840d..b165f334c09 100644
--- a/src/backend/executor/nodeWindowAgg.c
+++ b/src/backend/executor/nodeWindowAgg.c
@@ -370,7 +370,8 @@ advance_windowaggregate(WindowAggState *winstate,
* aggcontext, assume we can adopt that value without copying it.
*/
if (!peraggstate->transtypeByVal &&
- DatumGetPointer(newVal) != DatumGetPointer(peraggstate->transValue))
+ (DatumGetPointer(newVal) != DatumGetPointer(peraggstate->transValue) ||
+ fcinfo->isnull != peraggstate->transValueIsNull))
{
if (!fcinfo->isnull)
{
diff --git a/src/backend/jit/llvm/llvmjit_expr.c b/src/backend/jit/llvm/llvmjit_expr.c
index ffd887c71aa..f202f25d1d3 100644
--- a/src/backend/jit/llvm/llvmjit_expr.c
+++ b/src/backend/jit/llvm/llvmjit_expr.c
@@ -2369,13 +2369,19 @@ llvm_compile_expr(ExprState *state)
v_transnull = LLVMBuildLoad(b, v_transnullp, "");
/*
+ * fcinfo->isnull != pergroup->transValueIsNull ||
* DatumGetPointer(newVal) !=
* DatumGetPointer(pergroup->transValue))
*/
LLVMBuildCondBr(b,
- LLVMBuildICmp(b, LLVMIntEQ,
- v_transvalue,
- v_retval, ""),
+ LLVMBuildAnd(b,
+ LLVMBuildICmp(b, LLVMIntEQ,
+ v_transnull,
+ v_fcinfo_isnull, ""),
+ LLVMBuildICmp(b, LLVMIntEQ,
+ v_transvalue,
+ v_retval, ""),
+ ""),
b_nocall, b_call);
/* returned datum not passed datum, reparent */