diff options
author | monty@mysql.com <> | 2004-01-30 10:46:30 +0100 |
---|---|---|
committer | monty@mysql.com <> | 2004-01-30 10:46:30 +0100 |
commit | ed44e769ba34d6c4f71b99d74b6762ecbe1256d2 (patch) | |
tree | 2a068ced93fee028dc48d93be3aa5b24618ebef8 /sql | |
parent | 71c6d0c4f9e3047d70c60b3bc2f13efbd9fe3b7e (diff) | |
download | mariadb-git-ed44e769ba34d6c4f71b99d74b6762ecbe1256d2.tar.gz |
Fixed parsing of column names and foreign key constraints in Innobase to handle quoted identifiers and identifiers with space. (Bug #1725)
Fix optimizer tuning bug when first used key part was a constant. (Bug #1679)
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_class.cc | 22 | ||||
-rw-r--r-- | sql/sql_class.h | 4 | ||||
-rw-r--r-- | sql/sql_select.cc | 15 |
3 files changed, 29 insertions, 12 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 3ea61da28fc..fc83131e98a 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -538,7 +538,6 @@ select_export::~select_export() int select_export::prepare(List<Item> &list) { - char path[FN_REFLEN]; uint option=4; bool blob_flag=0; #ifdef DONT_ALLOW_FULL_LOAD_DATA_PATHS @@ -739,9 +738,13 @@ err: void select_export::send_error(uint errcode,const char *err) { ::send_error(&thd->net,errcode,err); - (void) end_io_cache(&cache); - (void) my_close(file,MYF(0)); - file= -1; + if (file > 0) + { + (void) end_io_cache(&cache); + (void) my_close(file,MYF(0)); + (void) my_delete(path,MYF(0)); // Delete file on error + file= -1; + } } @@ -849,10 +852,13 @@ err: void select_dump::send_error(uint errcode,const char *err) { ::send_error(&thd->net,errcode,err); - (void) end_io_cache(&cache); - (void) my_close(file,MYF(0)); - (void) my_delete(path,MYF(0)); // Delete file on error - file= -1; + if (file > 0) + { + (void) end_io_cache(&cache); + (void) my_close(file,MYF(0)); + (void) my_delete(path,MYF(0)); // Delete file on error + file= -1; + } } diff --git a/sql/sql_class.h b/sql/sql_class.h index f4fc7b4770f..d96c6bb53cc 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -665,11 +665,13 @@ class select_export :public select_result { File file; IO_CACHE cache; ha_rows row_count; + char path[FN_REFLEN]; uint field_term_length; int field_sep_char,escape_char,line_sep_char; bool fixed_row_size; public: - select_export(sql_exchange *ex) :exchange(ex),file(-1),row_count(0L) {} + select_export(sql_exchange *ex) :exchange(ex),file(-1),row_count(0L) + { path[0]=0; } ~select_export(); int prepare(List<Item> &list); bool send_fields(List<Item> &list, diff --git a/sql/sql_select.cc b/sql/sql_select.cc index e3bd3c8b570..36ef97cbf30 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1912,7 +1912,8 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count, read_time+=record_count/(double) TIME_FOR_COMPARE; if (join->sort_by_table && - join->sort_by_table != join->positions[join->const_tables].table->table) + join->sort_by_table != + join->positions[join->const_tables].table->table) read_time+=record_count; // We have to make a temp table if (read_time < join->best_read) { @@ -1946,7 +1947,7 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count, uint max_key_part=0; /* Test how we can use keys */ - rec= s->records/MATCHING_ROWS_IN_OTHER_TABLE; /* Assumed records/key */ + rec= s->records/MATCHING_ROWS_IN_OTHER_TABLE; // Assumed records/key for (keyuse=s->keyuse ; keyuse->table == table ;) { key_map found_part=0; @@ -2085,7 +2086,7 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count, will match */ if (table->quick_keys & ((key_map) 1 << key) && - table->quick_key_parts[key] <= max_key_part) + table->quick_key_parts[key] == max_key_part) tmp=records= (double) table->quick_rows[key]; else { @@ -2127,6 +2128,14 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count, } records=(ulong) tmp; } + /* + If quick_select was used on a part of this key, we know + the maximum number of rows that the key can match. + */ + if (table->quick_keys & ((key_map) 1 << key) && + table->quick_key_parts[key] <= max_key_part && + records > (double) table->quick_rows[key]) + tmp= records= (double) table->quick_rows[key]; } /* Limit the number of matched rows */ set_if_smaller(tmp, (double) thd->variables.max_seeks_for_key); |