The SE API doesn't have a direct equivalent of read_range_first/next for doing reverse scans.
Instead, the QUICK_SELECT_DESC does this:
1. Inform the SE about the other end of the range.
2. Call ha_rocksdb->ha_index_read_map(..., find_flag=HA_READ_BEFORE_KEY)
Step #2 is implemented in different ways in MariaDB and in the Upstream.
The upstream' QUICK_SELECT_DESC::get_next does it as follows:
file->set_end_range(&min_range, handler::RANGE_SCAN_DESC);
|
min_range here has
{key= SQL "NULL", flag = HA_READ_AFTER_KEY}
MariaDB's QUICK_SELECT_DESC::get_next uses a different API call:
result= file->prepare_range_scan((last_range->flag & NO_MIN_RANGE) ? NULL : &start_key,
|
(last_range->flag & NO_MAX_RANGE) ? NULL : &end_key);
|
(gdb) x/4x start_key.key
|
0x7fff78343f48: 0x01 0x00 0x00 0x00 // HA_READ_AFTER_KEY
|
(gdb) x/4x end_key.key
|
0x7fff78343f50: 0x00 0x49 0xc5 0x0f // HA_READ_BEFORE_KEY
|
Thanks for the report and test case. Reproducible as described.
Same workflow with InnoDB or MyISAM works all right.