@@ -1209,9 +1209,6 @@ gen_prune_steps_from_opexps(PartitionScheme part_scheme,
1209
1209
List * opsteps = NIL ;
1210
1210
List * btree_clauses [BTMaxStrategyNumber + 1 ],
1211
1211
* hash_clauses [HTMaxStrategyNumber + 1 ];
1212
- bool need_next_less ,
1213
- need_next_eq ,
1214
- need_next_greater ;
1215
1212
int i ;
1216
1213
1217
1214
memset (btree_clauses , 0 , sizeof (btree_clauses ));
@@ -1222,9 +1219,8 @@ gen_prune_steps_from_opexps(PartitionScheme part_scheme,
1222
1219
bool consider_next_key = true;
1223
1220
1224
1221
/*
1225
- * To be useful for pruning, we must have clauses for a prefix of
1226
- * partition keys in the case of range partitioning. So, ignore
1227
- * clauses for keys after this one.
1222
+ * For range partitioning, if we have no clauses for the current key,
1223
+ * we can't consider any later keys either, so we can stop here.
1228
1224
*/
1229
1225
if (part_scheme -> strategy == PARTITION_STRATEGY_RANGE &&
1230
1226
clauselist == NIL )
@@ -1239,7 +1235,6 @@ gen_prune_steps_from_opexps(PartitionScheme part_scheme,
1239
1235
clauselist == NIL && !bms_is_member (i , nullkeys ))
1240
1236
return NULL ;
1241
1237
1242
- need_next_eq = need_next_less = need_next_greater = true;
1243
1238
foreach (lc , clauselist )
1244
1239
{
1245
1240
PartClauseInfo * pc = (PartClauseInfo * ) lfirst (lc );
@@ -1261,7 +1256,6 @@ gen_prune_steps_from_opexps(PartitionScheme part_scheme,
1261
1256
case PARTITION_STRATEGY_RANGE :
1262
1257
{
1263
1258
PartClauseInfo * last = NULL ;
1264
- bool inclusive = false;
1265
1259
1266
1260
/*
1267
1261
* Add this clause to the list of clauses to be used
@@ -1279,35 +1273,13 @@ gen_prune_steps_from_opexps(PartitionScheme part_scheme,
1279
1273
lappend (btree_clauses [pc -> op_strategy ], pc );
1280
1274
1281
1275
/*
1282
- * We may not need the next clause if they're of
1283
- * certain strategy.
1276
+ * We can't consider subsequent partition keys if the
1277
+ * clause for the current key contains a non-inclusive
1278
+ * operator.
1284
1279
*/
1285
- switch (pc -> op_strategy )
1286
- {
1287
- case BTLessEqualStrategyNumber :
1288
- inclusive = true;
1289
- /* fall through */
1290
- case BTLessStrategyNumber :
1291
- if (!inclusive )
1292
- need_next_eq = need_next_less = false;
1293
- break ;
1294
- case BTEqualStrategyNumber :
1295
- /* always accept clauses for the next key. */
1296
- break ;
1297
- case BTGreaterEqualStrategyNumber :
1298
- inclusive = true;
1299
- /* fall through */
1300
- case BTGreaterStrategyNumber :
1301
- if (!inclusive )
1302
- need_next_eq = need_next_greater = false;
1303
- break ;
1304
- }
1305
-
1306
- /* We may want to change our mind. */
1307
- if (consider_next_key )
1308
- consider_next_key = (need_next_eq ||
1309
- need_next_less ||
1310
- need_next_greater );
1280
+ if (pc -> op_strategy == BTLessStrategyNumber ||
1281
+ pc -> op_strategy == BTGreaterStrategyNumber )
1282
+ consider_next_key = false;
1311
1283
break ;
1312
1284
}
1313
1285
@@ -2847,7 +2819,7 @@ get_matching_range_bounds(PartitionPruneContext *context,
2847
2819
2848
2820
/*
2849
2821
* Look for the greatest bound that is < or <= lookup value and
2850
- * set minoff to its offset.
2822
+ * set maxoff to its offset.
2851
2823
*/
2852
2824
off = partition_range_datum_bsearch (partsupfunc ,
2853
2825
partcollation ,
0 commit comments