@@ -1159,8 +1159,14 @@ handle_array(ArrayType *array,
11591159bool elem_byval ;
11601160char elem_align ;
11611161
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 )
11641170gotohandle_array_return ;
11651171
11661172/* Get element's properties */
@@ -1177,8 +1183,12 @@ handle_array(ArrayType *array,
11771183List * ranges ;
11781184int i ;
11791185
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 );
11821192
11831193/* Optimizations for <, <=, >=, > */
11841194if (strategy != BTEqualStrategyNumber )