WL#6497: Add limited SQL HANDLER support for partitioning
Affects: Server-5.7 — Status: Complete — Priority: Medium
To increase the test coverage of index reads in the partitioning engine, it is helpful to support step by step index reads, by the SQL HANDLER statements. It is not necessary to fully support SQL HANDLER statements for this testing, changed directions of reads (i.e. calling index_prev after index_next or a previous forward index read) does not need to be supported, since that never is done from the optimizer/executor. This means that when HANDLER t READ inx NEXT/PREV will give an error if the current index direction is different (reverse/forward). Also the partitioning engine will use partition pruning also for subsequent HANDLER calls, like CREATE TABLE t (a int, b int, KEY (a, b)) PARTITION BY HASH (b) PARTITIONS 2; HANDLER t READ a = (1, 2); HANDLER t READ a NEXT; ... Will only return records from the partition that matches b == 2 due to dynamic pruning in the index_read_map() function.
Simply remove the restriction for HA_CAN_SQL_HANDLER and fix index_prev() for HA_ERR_KEY_NOT_FOUND. And then issue HA_ERR_WRONG_COMMAND when direction is changed.
See attached patch (based upon the fix for bug#14495351) for the details and tests.
Copyright (c) 2000, 2016, Oracle Corporation and/or its affiliates. All rights reserved.