Don't add bailout adjustment for non-strict deserialize calls.
authorAndrew Gierth <[email protected]>
Thu, 28 Jan 2021 10:53:10 +0000 (10:53 +0000)
committerAndrew Gierth <[email protected]>
Thu, 28 Jan 2021 10:53:10 +0000 (10:53 +0000)
When building aggregate expression steps, strict checks need a bailout
jump for when a null value is encountered, so there is a list of steps
that require later adjustment. Adding entries to that list for steps
that aren't actually strict would be harmless, except that there is an
Assert which catches them. This leads to spurious errors on asserts
builds, for data sets that trigger parallel aggregation of an
aggregate with a non-strict deserialization function (no such
aggregates exist in the core system).

Repair by not adding the adjustment entry when it's not needed.

Backpatch back to 11 where the code was introduced.

Per a report from Darafei (Komzpa) of the PostGIS project; analysis
and patch by me.

Discussion: https://postgr.es/m/[email protected]

src/backend/executor/execExpr.c

index 8fc2a2666bd807e9b3e52c2fcf5417ec547566ba..2e463f5499052a87799d40b5204cfd8e195669a9 100644 (file)
@@ -3067,8 +3067,10 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase,
                scratch.resnull = &trans_fcinfo->args[argno + 1].isnull;
 
                ExprEvalPushStep(state, &scratch);
-               adjust_bailout = lappend_int(adjust_bailout,
-                                            state->steps_len - 1);
+               /* don't add an adjustment unless the function is strict */
+               if (pertrans->deserialfn.fn_strict)
+                   adjust_bailout = lappend_int(adjust_bailout,
+                                                state->steps_len - 1);
 
                /* restore normal settings of scratch fields */
                scratch.resvalue = &state->resvalue;