From f735822720b5e004d0f9cc3f490242c154cfbbac Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Thu, 31 Jul 2014 22:17:43 -0700 Subject: Fixed bug mdev-5721. Do not define a look-up key for a temporary table if its length exceeds the maximum length of such keys. --- sql/sql_select.cc | 47 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) (limited to 'sql/sql_select.cc') diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 15bd6886682..e7afdef6874 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -8977,6 +8977,25 @@ uint get_next_field_for_derived_key(uchar *arg) } +static +uint get_next_field_for_derived_key_simple(uchar *arg) +{ + KEYUSE *keyuse= *(KEYUSE **) arg; + if (!keyuse) + return (uint) (-1); + TABLE *table= keyuse->table; + uint key= keyuse->key; + uint fldno= keyuse->keypart; + for ( ; + keyuse->table == table && keyuse->key == key && keyuse->keypart == fldno; + keyuse++) + ; + if (keyuse->key != key) + keyuse= 0; + *((KEYUSE **) arg)= keyuse; + return fldno; +} + static bool generate_derived_keys_for_table(KEYUSE *keyuse, uint count, uint keys) { @@ -9007,12 +9026,28 @@ bool generate_derived_keys_for_table(KEYUSE *keyuse, uint count, uint keys) } else { - if (table->add_tmp_key(table->s->keys, parts, - get_next_field_for_derived_key, - (uchar *) &first_keyuse, - FALSE)) - return TRUE; - table->reginfo.join_tab->keys.set_bit(table->s->keys); + KEYUSE *save_first_keyuse= first_keyuse; + if (table->check_tmp_key(table->s->keys, parts, + get_next_field_for_derived_key_simple, + (uchar *) &first_keyuse)) + + { + first_keyuse= save_first_keyuse; + if (table->add_tmp_key(table->s->keys, parts, + get_next_field_for_derived_key, + (uchar *) &first_keyuse, + FALSE)) + return TRUE; + table->reginfo.join_tab->keys.set_bit(table->s->keys); + } + else + { + /* Mark keyuses for this key to be excluded */ + for (KEYUSE *curr=save_first_keyuse; curr < first_keyuse; curr++) + { + curr->key= MAX_KEY; + } + } first_keyuse= keyuse; key_count++; parts= 0; -- cgit v1.2.1 From fbaaf3688d5fac4b1b867155a9f09575367c0f98 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Wed, 3 Sep 2014 01:56:21 +0400 Subject: Moving Item::str_value from public to protected. --- sql/sql_select.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/sql_select.cc') diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 160ffe11abc..8146eb7a909 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2521,7 +2521,7 @@ void JOIN::exec_inner() Item *cur_const_item; while ((cur_const_item= const_item_it++)) { - cur_const_item->val_str(&cur_const_item->str_value); + cur_const_item->val_str(); // This caches val_str() to Item::str_value if (thd->is_error()) { error= thd->is_error(); -- cgit v1.2.1 From 1e66871713b7196daf1e9416823d57d5bbac85a1 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Wed, 3 Sep 2014 18:24:31 +0400 Subject: Adding Item_string_sys and Item_string_ascii to reduce duplicate code --- sql/sql_select.cc | 47 +++++++++++++++++------------------------------ 1 file changed, 17 insertions(+), 30 deletions(-) (limited to 'sql/sql_select.cc') diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 8146eb7a909..52015ee5ba7 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -22950,13 +22950,11 @@ int print_explain_message_line(select_result_sink *result, ha_rows *rows, const char *message) { - const CHARSET_INFO *cs= system_charset_info; Item *item_null= new Item_null(); List item_list; item_list.push_back(new Item_int((int32) select_number)); - item_list.push_back(new Item_string(select_type, - strlen(select_type), cs)); + item_list.push_back(new Item_string_sys(select_type)); /* `table` */ item_list.push_back(item_null); @@ -22983,7 +22981,7 @@ int print_explain_message_line(select_result_sink *result, /* `Extra` */ if (message) - item_list.push_back(new Item_string(message,strlen(message),cs)); + item_list.push_back(new Item_string_sys(message)); else item_list.push_back(item_null); @@ -23042,45 +23040,39 @@ int print_explain_row(select_result_sink *result, ha_rows *rows, const char *extra) { - const CHARSET_INFO *cs= system_charset_info; Item *item_null= new Item_null(); List item_list; Item *item; item_list.push_back(new Item_int((int32) select_number)); - item_list.push_back(new Item_string(select_type, - strlen(select_type), cs)); - item_list.push_back(new Item_string(table_name, - strlen(table_name), cs)); + item_list.push_back(new Item_string_sys(select_type)); + item_list.push_back(new Item_string_sys(table_name)); if (options & DESCRIBE_PARTITIONS) { if (partitions) { - item_list.push_back(new Item_string(partitions, - strlen(partitions), cs)); + item_list.push_back(new Item_string_sys(partitions)); } else item_list.push_back(item_null); } const char *jtype_str= join_type_str[jtype]; - item_list.push_back(new Item_string(jtype_str, - strlen(jtype_str), cs)); + item_list.push_back(new Item_string_sys(jtype_str)); - item= possible_keys? new Item_string(possible_keys, strlen(possible_keys), - cs) : item_null; + item= possible_keys? new Item_string_sys(possible_keys) : item_null; item_list.push_back(item); /* 'index */ - item= index ? new Item_string(index, strlen(index), cs) : item_null; + item= index ? new Item_string_sys(index) : item_null; item_list.push_back(item); /* 'key_len */ - item= key_len ? new Item_string(key_len, strlen(key_len), cs) : item_null; + item= key_len ? new Item_string_sys(key_len) : item_null; item_list.push_back(item); /* 'ref' */ - item= ref ? new Item_string(ref, strlen(ref), cs) : item_null; + item= ref ? new Item_string_sys(ref) : item_null; item_list.push_back(item); /* 'rows' */ @@ -23099,7 +23091,7 @@ int print_explain_row(select_result_sink *result, /* 'Extra' */ if (extra) - item_list.push_back(new Item_string(extra, strlen(extra), cs)); + item_list.push_back(new Item_string_sys(extra)); else item_list.push_back(item_null); @@ -23112,7 +23104,6 @@ int print_explain_row(select_result_sink *result, int print_fake_select_lex_join(select_result_sink *result, bool on_the_fly, SELECT_LEX *select_lex, uint8 explain_flags) { - const CHARSET_INFO *cs= system_charset_info; Item *item_null= new Item_null(); List item_list; if (on_the_fly) @@ -23129,9 +23120,7 @@ int print_fake_select_lex_join(select_result_sink *result, bool on_the_fly, /* id */ item_list.push_back(new Item_null); /* select_type */ - item_list.push_back(new Item_string(select_lex->type, - strlen(select_lex->type), - cs)); + item_list.push_back(new Item_string_sys(select_lex->type)); /* table */ { SELECT_LEX *sl= select_lex->master_unit()->first_select(); @@ -23153,15 +23142,14 @@ int print_fake_select_lex_join(select_result_sink *result, bool on_the_fly, len+= lastop; table_name_buffer[len - 1]= '>'; // change ',' to '>' } - item_list.push_back(new Item_string(table_name_buffer, len, cs)); + item_list.push_back(new Item_string_sys(table_name_buffer, len)); } /* partitions */ if (explain_flags & DESCRIBE_PARTITIONS) item_list.push_back(item_null); /* type */ - item_list.push_back(new Item_string(join_type_str[JT_ALL], - strlen(join_type_str[JT_ALL]), - cs)); + item_list.push_back(new Item_string_sys(join_type_str[JT_ALL])); + /* possible_keys */ item_list.push_back(item_null); /* key*/ @@ -23177,10 +23165,9 @@ int print_fake_select_lex_join(select_result_sink *result, bool on_the_fly, item_list.push_back(item_null); /* extra */ if (select_lex->master_unit()->global_parameters->order_list.first) - item_list.push_back(new Item_string("Using filesort", - 14, cs)); + item_list.push_back(new Item_string_sys("Using filesort", 14)); else - item_list.push_back(new Item_string("", 0, cs)); + item_list.push_back(new Item_string_sys("", 0)); if (result->send_data(item_list)) return 1; -- cgit v1.2.1 From 504c6cccd70f3ae78707145d2832eb5b29e0c810 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Mon, 22 Sep 2014 23:25:56 +0300 Subject: Fixed test failures Added comments Ensure that tokudb test works even if jemalloc is not installed Removed not referenced function Item::remove_fixed() mysql-test/suite/rpl/t/rpl_gtid_reconnect.test: Fixed race condition sql/item.cc: Indentation fix sql/item.h: Removed not used function Added comment sql/sql_select.cc: Fixed indentation storage/tokudb/mysql-test/rpl/include/have_tokudb.opt: Ensure that tokudb test works even if jemalloc is not installed storage/tokudb/mysql-test/tokudb/suite.opt: Ensure that tokudb test works even if jemalloc is not installed storage/tokudb/mysql-test/tokudb_add_index/suite.opt: Ensure that tokudb test works even if jemalloc is not installed storage/tokudb/mysql-test/tokudb_alter_table/suite.opt: Ensure that tokudb test works even if jemalloc is not installed storage/tokudb/mysql-test/tokudb_bugs/suite.opt: Ensure that tokudb test works even if jemalloc is not installed storage/tokudb/mysql-test/tokudb_mariadb/suite.opt: Ensure that tokudb test works even if jemalloc is not installed --- sql/sql_select.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'sql/sql_select.cc') diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 6aecfca39f4..79f38e2884a 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -21101,7 +21101,7 @@ cp_buffer_from_ref(THD *thd, TABLE *table, TABLE_REF *ref) ref_pointer_array and all_fields are updated. - @param[in] thd Pointer to current thread structure + @param[in] thd Pointer to current thread structure @param[in,out] ref_pointer_array All select, group and order by fields @param[in] tables List of tables to search in (usually FROM clause) @@ -21147,7 +21147,7 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, order->in_field_list= 1; order->counter= count; order->counter_used= 1; - return FALSE; + return FALSE; } /* Lookup the current GROUP/ORDER field in the SELECT clause. */ select_item= find_item_in_list(order_item, fields, &counter, @@ -21215,7 +21215,8 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, warning so the user knows that the field from the FROM clause overshadows the column reference from the SELECT list. */ - push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_NON_UNIQ_ERROR, + push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, + ER_NON_UNIQ_ERROR, ER(ER_NON_UNIQ_ERROR), ((Item_ident*) order_item)->field_name, current_thd->where); -- cgit v1.2.1 From f1afc003eefe0aafd3e070c7453d9e029d8445a8 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 24 Sep 2014 15:41:42 +0200 Subject: MDEV-6743 crash in GROUP_CONCAT(IF () ORDER BY 1) new fix --- sql/sql_select.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/sql_select.cc') diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 79f38e2884a..eff1c382945 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -21143,7 +21143,7 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, order_item->full_name(), thd->where); return TRUE; } - order->item= ref_pointer_array + count - 1; + thd->change_item_tree((Item**)&order->item, (Item*)(ref_pointer_array + count - 1)); order->in_field_list= 1; order->counter= count; order->counter_used= 1; -- cgit v1.2.1