|
Inside collection_scan.cpp atEndOfRangeInclusive() is used to determine if a recordId is exceeds beyond the end bound. However, there is no check whether a recordId is before the start bound.Consider the following:
Recall RecordIds generated from type ‘objectId’ begin with typebits 78, RecordIds generated from type ‘date’ begin with typebits 64
- Suppose recId0 is generated from a date type (begins with 64)
- maxRecord = 78***, minRecord = 78** (both of type ObjectId)
- Inside CollectionScan::returnIfMatches(), we are not inside at the end of the rangeBound, and there is no filter provided so it passes the filter and returns PlanStage::Advanced
- The caller of returnIfMatches will think there is new work to be done with the document found (recId0)
- This means a result of different type than the bounds may be misinterpreted as within the bounds
Instead of returning PlanStage::Advanced, returnIfMatches should check if the recId found is outside the start bound, and return PlanStage::NEED_TIME if so to prompt another pass
|