Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement LAST_INSERT_IDS function (#1469)
Summary: This is a multiple-value counterpart of the existing LAST_INSERT_ID function. Its results are returned as a table. - Hardcode the function name LAST_INSERT_IDS into the lexer and the parser due to how MySQL supports table-returning functions, patch the parser for the function. - To keep the autoincrement value set efficiently, implement a data structure that 1) uses delta encoding for consecutive values; 2) special-cases encoding of consecutive delta equal to one values into a single number. - Maintain the last_insert_ids set in THD for the previous and the current statement, similar to existing first_successful_insert_id_in_prev_stmt and first_successful_insert_id_in_cur_stmt fields. - Add a main.last_insert_ids test. - Since MyISAM is an engine that supports composite primary keys with autoincrement suffixes, this scenario is supported as well by allowing the values to be actually non-monotonic by delta encoding writing large deltas that make the value wrap around. For this case add a main.last_insert_ids_myisam test. Pull Request resolved: #1469 Differential Revision: D60675155 fbshipit-source-id: c702048a14763db37140407c40f0d7ca648d5901
- Loading branch information