diff --git a/src/backend/partitioning/partprune.c b/src/backend/partitioning/partprune.c
index cdc61a8..5de28cf 100644
--- a/src/backend/partitioning/partprune.c
+++ b/src/backend/partitioning/partprune.c
@@ -854,27 +854,22 @@ gen_partprune_steps_internal(GeneratePruningStepsContext *context,
 	}
 
 	/*
-	 * If generate_opsteps is set to false it means no OpExprs were directly
-	 * present in the input list.
+	 * Generate one prune step for the information derived from IS NULL,
+	 * if any.  To prune hash partitions, we must have found IS NULL
+	 * clauses for all partition keys.
 	 */
-	if (!generate_opsteps)
+	if (!bms_is_empty(nullkeys) &&
+		(part_scheme->strategy != PARTITION_STRATEGY_HASH ||
+		 bms_num_members(nullkeys) == part_scheme->partnatts))
 	{
-		/*
-		 * Generate one prune step for the information derived from IS NULL,
-		 * if any.  To prune hash partitions, we must have found IS NULL
-		 * clauses for all partition keys.
-		 */
-		if (!bms_is_empty(nullkeys) &&
-			(part_scheme->strategy != PARTITION_STRATEGY_HASH ||
-			 bms_num_members(nullkeys) == part_scheme->partnatts))
-		{
-			PartitionPruneStep *step;
-
-			step = gen_prune_step_op(context, InvalidStrategy,
-									 false, NIL, NIL, nullkeys);
-			result = lappend(result, step);
-		}
+		PartitionPruneStep *step;
 
+		step = gen_prune_step_op(context, InvalidStrategy,
+								 false, NIL, NIL, nullkeys);
+		result = lappend(result, step);
+	}
+	else if (!generate_opsteps)
+	{
 		/*
 		 * Note that for IS NOT NULL clauses, simply having step suffices;
 		 * there is no need to propagate the exact details of which keys are
