mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
4.1->5.0 merge for bug #16458
mysql-test/r/distinct.result: 4.1->5.0 merge for bug #16458 * 5.0 is better in detecting duplicate columns sql/sql_select.cc: 4.1->5.0 merge for bug #16458 * Should not do the optimization if using index for group by * chnaged structures in 5.0
This commit is contained in:
@ -537,7 +537,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 index NULL PRIMARY 8 NULL 3 Using index
|
||||
EXPLAIN SELECT DISTINCT a,a FROM t2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 index NULL PRIMARY 8 NULL 3 Using index; Using temporary
|
||||
1 SIMPLE t2 index NULL PRIMARY 8 NULL 3 Using index
|
||||
EXPLAIN SELECT DISTINCT b,a FROM t2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 index NULL PRIMARY 8 NULL 3 Using index
|
||||
|
@ -874,7 +874,11 @@ JOIN::optimize()
|
||||
The FROM clause must contain a single non-constant table.
|
||||
*/
|
||||
if (tables - const_tables == 1 && (group_list || select_distinct) &&
|
||||
!tmp_table_param.sum_func_count)
|
||||
!tmp_table_param.sum_func_count &&
|
||||
(!join_tab[const_tables].select ||
|
||||
!join_tab[const_tables].select->quick ||
|
||||
join_tab[const_tables].select->quick->get_type() !=
|
||||
QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX))
|
||||
{
|
||||
if (group_list &&
|
||||
list_contains_unique_index(join_tab[const_tables].table,
|
||||
@ -11279,9 +11283,9 @@ static bool
|
||||
list_contains_unique_index(TABLE *table,
|
||||
bool (*find_func) (Field *, void *), void *data)
|
||||
{
|
||||
for (uint keynr= 0; keynr < table->keys; keynr++)
|
||||
for (uint keynr= 0; keynr < table->s->keys; keynr++)
|
||||
{
|
||||
if (keynr == table->primary_key ||
|
||||
if (keynr == table->s->primary_key ||
|
||||
(table->key_info[keynr].flags & HA_NOSAME))
|
||||
{
|
||||
KEY *keyinfo= table->key_info + keynr;
|
||||
|
Reference in New Issue
Block a user