MDEV-31237 Assertion `!(tab->select && tab->select->quick)' failed in make_join_readinfo
The problem was a wrong assert. I changed it to match the code in
best_access_path().
The given test case was a bit tricky for the optimizer, which first
decided on using a index scan (because of force index), but then
test_if_skip_sort_order() decided to use range anyway to handle
distinct.
MDEV-31258 Assertion `cond_selectivity <= 1.000000001' upon range query
This was caused of two minor issues:
- get_quick_record_count() returned the number of rows for range with
least cost, when it should have returned the minum number of rows
for any range.
- When changing REF to RANGE, we also changed records_out, which
should not be done (number of records in the result will not
change).
The above change can cause a small change in row estimates where the
optimizer chooses a clustered key with more rows than a range one
secondary key (unlikely case).
MDEV-31022: SIGSEGV in maria_create from create_internal_tmp_table
The code in create_internal_tmp_table() didn't take into account that
now temporary (derived) tables may have multiple indexes:
- one index due to duplicate removal
= In this example created by conversion of big-IN(...) into subquery
= this index might be converted into a "unique constraint" if the key
length is too large.
- one index added by derived_with_keys optimization.
Make create_internal_tmp_table() handle multiple indexes.
Before this patch, use of a unique constraint was indicated in
TABLE_SHARE::uniques. This was ok as unique constraint was the only index
in the table. Now it's no longer the case so TABLE_SHARE::uniques is removed
and replaced with an in-memory-only flag HA_UNIQUE_HASH.
This patch is based on Monty's patch.
Co-Author: Monty <email address hidden>