Prevent generating EEOP_AGG_STRICT_INPUT_CHECK operations when nargs == 0.
authorAndres Freund <[email protected]>
Sat, 3 Nov 2018 22:55:23 +0000 (15:55 -0700)
committerAndres Freund <[email protected]>
Sat, 3 Nov 2018 22:55:23 +0000 (15:55 -0700)
This only became a problem with 4c640f4f38, which didn't synchronize
the value agg_strict_input_check.nargs is set to, with the guard
condition for emitting the operation.

Besides such instructions being unnecessary overhead, currently the
LLVM JIT provider doesn't support them. It seems more sensible to
avoid generating such instruction than supporting them. Add assertions
to make it easier to debug a potential further occurance.

Discussion: https://postgr.es/m/2a505161-2727-2473-7c46-591ed108ac52@email.cz
Back: 11-, like 4c640f4f38.

src/backend/executor/execExpr.c
src/backend/jit/llvm/llvmjit_expr.c

index 5397de4e05012fdc8f41caef8360b69d96c4dbec..4b44a4a4ead6d4b457c8c2c8a21e251c4a238b6f 100644 (file)
@@ -3023,7 +3023,7 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase,
         * just keep the prior transValue. This is true for both plain and
         * sorted/distinct aggregates.
         */
-       if (trans_fcinfo->flinfo->fn_strict && numInputs > 0)
+       if (trans_fcinfo->flinfo->fn_strict && pertrans->numTransInputs > 0)
        {
            scratch.opcode = EEOP_AGG_STRICT_INPUT_CHECK;
            scratch.d.agg_strict_input_check.nulls = strictnulls;
index e5fe116acbc8cb1f3be7a3a688145f2e5f814a19..42258774783f31db2b4deae2c07c4e857b50c49c 100644 (file)
@@ -2124,6 +2124,8 @@ llvm_compile_expr(ExprState *state)
                    LLVMValueRef v_nullp;
                    LLVMBasicBlockRef *b_checknulls;
 
+                   Assert(nargs > 0);
+
                    jumpnull = op->d.agg_strict_input_check.jumpnull;
                    v_nullp = l_ptr_const(nulls, l_ptr(TypeStorageBool));