@@ -1071,7 +1071,6 @@ ts_chunk_column_stats_get_chunk_ids_by_scan(DimensionRestrictInfo *dri)
1071
1071
ScanIterator it ;
1072
1072
List * chunkids = NIL ;
1073
1073
DimensionRestrictInfoOpen * open ;
1074
- bool check_both = false;
1075
1074
1076
1075
Assert (dri && dri -> dimension -> type == DIMENSION_TYPE_STATS );
1077
1076
@@ -1082,25 +1081,6 @@ ts_chunk_column_stats_get_chunk_ids_by_scan(DimensionRestrictInfo *dri)
1082
1081
1083
1082
open = (DimensionRestrictInfoOpen * ) dri ;
1084
1083
1085
- /*
1086
- * Since we need to find chunks with overlapping ranges. We use checks on both the
1087
- * lower_bound and the upper_bound.
1088
- */
1089
- if (open -> upper_strategy != InvalidStrategy && open -> lower_strategy != InvalidStrategy )
1090
- check_both = true;
1091
-
1092
- if (open -> upper_strategy == InvalidStrategy )
1093
- {
1094
- open -> upper_strategy = open -> lower_strategy ;
1095
- open -> upper_bound = open -> lower_bound ;
1096
- }
1097
-
1098
- if (open -> lower_strategy == InvalidStrategy )
1099
- {
1100
- open -> lower_strategy = open -> upper_strategy ;
1101
- open -> lower_bound = open -> upper_bound ;
1102
- }
1103
-
1104
1084
/*
1105
1085
* We need to get all chunks matching the hypertable ID and the column name.
1106
1086
*/
@@ -1143,18 +1123,6 @@ ts_chunk_column_stats_get_chunk_ids_by_scan(DimensionRestrictInfo *dri)
1143
1123
goto done ;
1144
1124
}
1145
1125
1146
- /*
1147
- * If both upper and lower bounds have been specified then we need to check
1148
- * if that range overlaps (subset, superset, intersect) with the current fd entry
1149
- * values
1150
- */
1151
- if (check_both )
1152
- {
1153
- /* range is before or after our fd range_start/range_end values */
1154
- if (open -> upper_bound < fd -> range_start || open -> lower_bound > fd -> range_end )
1155
- goto done ;
1156
- }
1157
-
1158
1126
/*
1159
1127
* All data is in int8 format so we do regular comparisons. Also, it's an OR
1160
1128
* check so prepare to short circuit if one evaluates to true.
@@ -1166,78 +1134,37 @@ ts_chunk_column_stats_get_chunk_ids_by_scan(DimensionRestrictInfo *dri)
1166
1134
{
1167
1135
case BTLessEqualStrategyNumber : /* e.g: id <= 90 */
1168
1136
{
1169
- /* range_end is exclusive, so check accordingly */
1170
- if ((fd -> range_end - 1 ) <= open -> upper_bound )
1171
- matched = check_both ? false : true;
1137
+ matched = fd -> range_start <= open -> upper_bound ;
1172
1138
}
1173
1139
break ;
1174
1140
case BTLessStrategyNumber : /* e.g: id < 90 */
1175
1141
{
1176
- /* range_end is exclusive, so check accordingly */
1177
- if ((fd -> range_end - 1 ) < open -> upper_bound )
1178
- matched = check_both ? false : true;
1179
- }
1180
- break ;
1181
- case BTGreaterEqualStrategyNumber : /* e.g: id >= 90 */
1182
- {
1183
- /* range_end is exclusive, so check accordingly */
1184
- if ((fd -> range_end - 1 ) >= open -> upper_bound )
1185
- matched = check_both ? false : true;
1186
- }
1187
- break ;
1188
- case BTGreaterStrategyNumber : /* e.g: id > 9 */
1189
- {
1190
- /* range_end is exclusive, so check accordingly */
1191
- if ((fd -> range_end - 1 ) > open -> upper_bound )
1192
- matched = check_both ? false : true;
1193
- }
1194
- break ;
1195
- case BTEqualStrategyNumber : /* e.g: id == 9 */
1196
- {
1197
- /* need to check for both range_start and range_end */
1198
- if (fd -> range_start <= open -> lower_bound &&
1199
- (fd -> range_end - 1 ) >= open -> upper_bound )
1200
- matched = true;
1142
+ matched = fd -> range_start < open -> upper_bound ;
1201
1143
}
1202
1144
break ;
1203
1145
default :
1204
- /* unsupported strategy */
1146
+ open -> upper_strategy = InvalidStrategy ;
1205
1147
break ;
1206
1148
}
1207
1149
1208
- if (matched )
1150
+ if (open -> upper_strategy != InvalidStrategy && ! matched )
1209
1151
goto done ;
1210
1152
1211
1153
/* range_end checks didn't match, check for range_start now */
1212
1154
switch (open -> lower_strategy )
1213
1155
{
1214
- case BTLessEqualStrategyNumber :
1215
- {
1216
- if (fd -> range_start <= open -> lower_bound )
1217
- matched = true;
1218
- }
1219
- break ;
1220
- case BTLessStrategyNumber :
1221
- {
1222
- if (fd -> range_start < open -> lower_bound )
1223
- matched = true;
1224
- }
1225
- break ;
1226
1156
case BTGreaterEqualStrategyNumber :
1227
1157
{
1228
- if ( fd -> range_start >= open -> lower_bound )
1229
- matched = true ;
1158
+ /* range_end is exclusive */
1159
+ matched = ( fd -> range_end - 1 ) >= open -> lower_bound ;
1230
1160
}
1231
1161
break ;
1232
1162
case BTGreaterStrategyNumber :
1233
1163
{
1234
- /* range_start is inclusive */
1235
- if (fd -> range_start >= open -> lower_bound )
1236
- matched = true;
1164
+ /* range_end is exclusive */
1165
+ matched = (fd -> range_end - 1 ) > open -> lower_bound ;
1237
1166
}
1238
1167
break ;
1239
- case BTEqualStrategyNumber :
1240
- /* already handled above with upper_strategy */
1241
1168
default :
1242
1169
/* unsupported strategy */
1243
1170
break ;
0 commit comments