@@ -486,7 +486,10 @@ get_matching_partitions(PartitionPruneContext *context, List *pruning_steps)
486
486
487
487
/* If there are no pruning steps then all partitions match. */
488
488
if (num_steps == 0 )
489
+ {
490
+ Assert (context -> nparts > 0 );
489
491
return bms_add_range (NULL , 0 , context -> nparts - 1 );
492
+ }
490
493
491
494
/*
492
495
* Allocate space for individual pruning steps to store its result. Each
@@ -2048,8 +2051,12 @@ get_matching_hash_bounds(PartitionPruneContext *context,
2048
2051
bms_make_singleton (rowHash % greatest_modulus );
2049
2052
}
2050
2053
else
2054
+ {
2055
+ /* Getting here means at least one hash partition exists. */
2056
+ Assert (boundinfo -> ndatums > 0 );
2051
2057
result -> bound_offsets = bms_add_range (NULL , 0 ,
2052
2058
boundinfo -> ndatums - 1 );
2059
+ }
2053
2060
2054
2061
/*
2055
2062
* There is neither a special hash null partition or the default hash
@@ -2128,6 +2135,7 @@ get_matching_list_bounds(PartitionPruneContext *context,
2128
2135
*/
2129
2136
if (nvalues == 0 )
2130
2137
{
2138
+ Assert (boundinfo -> ndatums > 0 );
2131
2139
result -> bound_offsets = bms_add_range (NULL , 0 ,
2132
2140
boundinfo -> ndatums - 1 );
2133
2141
result -> scan_default = partition_bound_has_default (boundinfo );
@@ -2140,6 +2148,7 @@ get_matching_list_bounds(PartitionPruneContext *context,
2140
2148
/*
2141
2149
* First match to all bounds. We'll remove any matching datums below.
2142
2150
*/
2151
+ Assert (boundinfo -> ndatums > 0 );
2143
2152
result -> bound_offsets = bms_add_range (NULL , 0 ,
2144
2153
boundinfo -> ndatums - 1 );
2145
2154
@@ -2250,6 +2259,7 @@ get_matching_list_bounds(PartitionPruneContext *context,
2250
2259
break ;
2251
2260
}
2252
2261
2262
+ Assert (minoff >= 0 && maxoff >= 0 );
2253
2263
result -> bound_offsets = bms_add_range (NULL , minoff , maxoff );
2254
2264
return result ;
2255
2265
}
@@ -2327,6 +2337,7 @@ get_matching_range_bounds(PartitionPruneContext *context,
2327
2337
maxoff -- ;
2328
2338
2329
2339
result -> scan_default = partition_bound_has_default (boundinfo );
2340
+ Assert (minoff >= 0 && maxoff >= 0 );
2330
2341
result -> bound_offsets = bms_add_range (NULL , minoff , maxoff );
2331
2342
2332
2343
return result ;
0 commit comments