diff --git a/src/backend/partitioning/partprune.c b/src/backend/partitioning/partprune.c index 5e1329a5e4..fb0de1d47a 100644 --- a/src/backend/partitioning/partprune.c +++ b/src/backend/partitioning/partprune.c @@ -3404,6 +3404,12 @@ partkey_datum_from_expr(PartitionPruneContext *context, } else { + /* + * We should never see a non-Const in a step unless we're running in + * the executor + */ + Assert(context->planstate != NULL); + /* * When called from the executor we'll have a valid planstate so we * may be able to evaluate an expression which could not be folded to @@ -3412,9 +3418,7 @@ partkey_datum_from_expr(PartitionPruneContext *context, * must be careful here to evaluate expressions containing PARAM_EXEC * Params only when told it's OK. */ - if (context->planstate && - (context->evalexecparams || - !context->exprhasexecparam[stateidx])) + if (context->evalexecparams || !context->exprhasexecparam[stateidx]) { ExprState *exprstate; ExprContext *ectx;