@@ -1159,8 +1159,14 @@ handle_array(ArrayType *array,
1159
1159
bool elem_byval ;
1160
1160
char elem_align ;
1161
1161
1162
- /* Check if we can work with this strategy */
1163
- if (strategy == 0 )
1162
+ /*
1163
+ * Check if we can work with this strategy
1164
+ * We can work only with BTLessStrategyNumber, BTLessEqualStrategyNumber,
1165
+ * BTEqualStrategyNumber, BTGreaterEqualStrategyNumber and BTGreaterStrategyNumber.
1166
+ * If new search strategies appear in the future, then access optimizations from
1167
+ * this function will not work, and the default behavior (handle_array_return:) will work.
1168
+ */
1169
+ if (strategy == InvalidStrategy || strategy > BTGreaterStrategyNumber )
1164
1170
goto handle_array_return ;
1165
1171
1166
1172
/* Get element's properties */
@@ -1177,8 +1183,12 @@ handle_array(ArrayType *array,
1177
1183
List * ranges ;
1178
1184
int i ;
1179
1185
1180
- /* This is only for paranoia's sake */
1181
- Assert (BTMaxStrategyNumber == 5 && BTEqualStrategyNumber == 3 );
1186
+ /* This is only for paranoia's sake (checking correctness of following take_min calculation) */
1187
+ Assert (BTEqualStrategyNumber == 3
1188
+ && BTLessStrategyNumber < BTEqualStrategyNumber
1189
+ && BTLessEqualStrategyNumber < BTEqualStrategyNumber
1190
+ && BTGreaterEqualStrategyNumber > BTEqualStrategyNumber
1191
+ && BTGreaterStrategyNumber > BTEqualStrategyNumber );
1182
1192
1183
1193
/* Optimizations for <, <=, >=, > */
1184
1194
if (strategy != BTEqualStrategyNumber )
0 commit comments