When building different range and index-merge trees the range optimizer
could build an index-merge tree with an index scan containing less ranges
then needed. This index-merge could be chosen as the best. Following this
index-merge the executioner missed some rows in the result set.
The invalid index scan was built due to an inconsistency in the code
back-ported from mysql into 5.3 that fixed mysql bug #11765831:
the code added to key_or() could change shared keys of the second
ored tree. Partially the problem was fixed in the patch for mariadb
bug #823301, but it turned out that only partially.
- Change the default flag value to ON.
- Update the testcases to be run extended_keys=ON:
= trivial test result updates
= If extended_keys setting makes a difference for a testcase, run the testcase
with extended_keys=off. There were only a few such cases
- Update to vcol_select_innodb looks like a worse plan but it will be gone in 10.0.
If, when executing a query with ORDER BY col LIMIT n, the optimizer chose
an index-merge scan to access the table containing col while there existed
an index defined over col then optimizer did not consider the possibility
of using an alternative range scan by this index to avoid filesort. This
could cause a performance degradation if the optimizer flag index_merge was
set up to 'on'.
Due to this bug the function SEL_IMERGE::or_sel_tree_with_checks()
could build an inconsistent merge tree if one of the SEL_TREEs in the
resulting index merge happened to contain a full key range.
This could trigger an assertion failure.
The function key_and() erroneously called SEL_ARG::increment_use_count()
when SEL_ARG::incr_refs() should had been called. This could lead to
wrong values of use_count for some SEL_ARG trees.
A bug in the code of the function key_or could lead to a situation
when performing of an OR operation for one index changes the result
the operation for another index. This bug is fixed with this patch.
Also corrected the specification and the code of the function
or_sel_tree_with_checks.
Also:
Changed the value of TIME_FOR_COMPARE_ROWID to make it the same as for MWL 21.
Changed some queries in range_vs_index_merge.test to make them generate
the same plans as earlier.
When ORing two AND-OR formulas the range optimizer could miss
a conjunct in one of AND-OR formulas in the result. If the
index merge union plan to access a table is formed by this
formula that, in general, is not inferred from the original
where/on condition,the query could return an incorrect result set.
A crash may happenin the cases when the range optimizer tried to OR
two index merge such that the second one contained less range trees
than the first one.
The bug was introduced by the patch of MWL#24:
"index_merge: fair choice between index_merge union and range access".
A crash may happenin the cases when the range optimizer tried to OR
two index merge such that the second one contained less range trees
than the first one.
The bug was introduced by the patch of MWL#24:
"index_merge: fair choice between index_merge union and range access".
that blocked building index merge plans for the queries with where
conditions of the form
(key1|2_p1=c AND range(key1_p2)) OR (key1|2_p1=c AND range(key2_p2)).
The problem was discovered by Sergey Petrunia when he reviewed the patch
for WL#24.
Added new test cases. One of them failed to produce an index merge plan
before the patch was applied.
"index_merge: fair choice between index_merge union and range access"
mysql-test/include/world.inc:
A new include file to upload the world database.
mysql-test/include/world_schema.inc:
A new include file to create tables of the world database.
mysql-test/r/index_merge_myisam.result:
The results for test cases testing the optimizations added in WL#24 for MyISAM.
mysql-test/r/range_vs_index_merge.result:
The results for test cases testing the optimizations added in WL#24 for InnoDB.
mysql-test/t/range_vs_index_merge.test:
Test cases to test the optimizations added in WL#24 for MyISAM.
mysql-test/t/range_vs_index_merge_innodb.test:
Test cases to test the optimizations added in WL#24 for InnoDB.
sql/sql_list.h:
Fixed a bug that did not allow adding a non-empty list to an empty list.