-
Ajo Robert authored
WRONG QUERY RESULTS Analysis ======== When using index_merge for InnoDB tables with a primary key, the server does not set read_set correctly for index scan after optimization. This does not cause a problem in other cases because InnoDB does create templates during first call to index_read(). Innodb uses sql_stat_start to decide initializing templates in index_read(). sql_stat_start is set to false at handler creation and set to true during first call to index_read(). In case of sub-query, during optimization we scan the index and reset it for index read for execution. Further call to index_read() does uses the templates created at reset as inited is set to true during optimize phase. This leads to InnoDB not reading primary key of the rows and furthur leads to mismatch during index merge. Fix ==== Provide correct read_set for each index during index_reset to innodb for creating the right column template for reading.
Ajo Robert authoredWRONG QUERY RESULTS Analysis ======== When using index_merge for InnoDB tables with a primary key, the server does not set read_set correctly for index scan after optimization. This does not cause a problem in other cases because InnoDB does create templates during first call to index_read(). Innodb uses sql_stat_start to decide initializing templates in index_read(). sql_stat_start is set to false at handler creation and set to true during first call to index_read(). In case of sub-query, during optimization we scan the index and reset it for index read for execution. Further call to index_read() does uses the templates created at reset as inited is set to true during optimize phase. This leads to InnoDB not reading primary key of the rows and furthur leads to mismatch during index merge. Fix ==== Provide correct read_set for each index during index_reset to innodb for creating the right column template for reading.
Loading