When doing a SELECT...FOR [SHARE|UPDATE] with a WHERE condition specifying a range, we were locking "one row too much". This patch fixes locking behaviour in several (hopefuly) most common cases, so that we only lock rows and gaps which intersect the searched range.
- Added MTR to demonstrate current locking policy for end of range - Got rid of goto - Extracted logic of determining relation between range and row to separate function - Extracted reoccuring patterns of modifications of search_tuple so it is easier to add same for stop_tuple - Added prebuilt->m_stop_tuple and made sure it is in sync with prebuilt->m_mysql_handler->end_range for during read_range_first() and read_range_next() - Added row_can_be_in_range field - Do not lock the row (just the gap) if the row is same length and after the stop_tuple - Do not lock the row (just the gap) if the row is same length and equal to stop_tuple and strict inequality was used for end of range - Do not lock the row (just the gap) if the row is longer than stop_tuple and its prefix is after the stop_tuple - Do not lock the row (just the gap) if the row is longer than stop_tuple and its prefixis equal to stop_tuple and strict inequality was used for end of range - Do not lock the row nor gap if we already saw a row same length and equal to stop_tuple in previous iteration