diff options
author | unknown <monty@mysql.com> | 2004-02-16 10:31:05 +0200 |
---|---|---|
committer | unknown <monty@mysql.com> | 2004-02-16 10:31:05 +0200 |
commit | 0c259c54b062f065e375fa185556cdf7fd419c13 (patch) | |
tree | e792af64f95eba198633387e3b36f50f096c3001 /sql/sql_select.cc | |
parent | 70eef0cb05296b7c60c7dbc32811d306675e997a (diff) | |
parent | d00fbce3083f11d071300447e11dab124debb2b7 (diff) | |
download | mariadb-git-0c259c54b062f065e375fa185556cdf7fd419c13.tar.gz |
Merge with public tree
client/mysqldump.c:
Auto merged
configure.in:
Auto merged
include/m_ctype.h:
Auto merged
include/m_string.h:
Auto merged
include/my_global.h:
Auto merged
mysql-test/r/ctype_utf8.result:
Auto merged
mysql-test/r/fulltext.result:
Auto merged
mysql-test/r/subselect.result:
Auto merged
mysql-test/t/fulltext.test:
Auto merged
mysql-test/t/grant.test:
Auto merged
mysql-test/t/subselect.test:
Auto merged
mysql-test/t/union.test:
Auto merged
sql/field.cc:
Auto merged
sql/field.h:
Auto merged
sql/item.cc:
Auto merged
sql/item_func.cc:
Auto merged
sql/item_strfunc.cc:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/set_var.cc:
Auto merged
sql/sql_acl.cc:
Auto merged
sql/sql_class.h:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/share/english/errmsg.txt:
Auto merged
sql/sql_select.cc:
Auto merged
sql/sql_show.cc:
Auto merged
sql/sql_string.cc:
Auto merged
sql/sql_table.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
strings/ctype-mb.c:
Auto merged
strings/ctype-simple.c:
Auto merged
mysql-test/r/warnings.result:
Fix error numbers after merge
sql/share/czech/errmsg.txt:
Add missing ',' and fix typo
sql/share/danish/errmsg.txt:
Add missing ',' and fix typo
sql/share/dutch/errmsg.txt:
Add missing ',' and fix typo
sql/share/estonian/errmsg.txt:
Add missing ',' and fix typo
sql/share/french/errmsg.txt:
Add missing ',' and fix typo
sql/share/german/errmsg.txt:
Add missing ',' and fix typo
sql/share/greek/errmsg.txt:
Add missing ',' and fix typo
sql/share/hungarian/errmsg.txt:
Add missing ',' and fix typo
sql/share/italian/errmsg.txt:
Add missing ',' and fix typo
sql/share/japanese/errmsg.txt:
Add missing ',' and fix typo
sql/share/korean/errmsg.txt:
Add missing ',' and fix typo
sql/share/norwegian-ny/errmsg.txt:
Add missing ',' and fix typo
sql/share/norwegian/errmsg.txt:
Add missing ',' and fix typo
sql/share/polish/errmsg.txt:
Add missing ',' and fix typo
sql/share/portuguese/errmsg.txt:
Add missing ',' and fix typo
sql/share/romanian/errmsg.txt:
Add missing ',' and fix typo
sql/share/russian/errmsg.txt:
Add missing ',' and fix typo
sql/share/slovak/errmsg.txt:
Add missing ',' and fix typo
sql/share/spanish/errmsg.txt:
Add missing ',' and fix typo
sql/share/swedish/errmsg.txt:
Add missing ',' and fix typo
sql/share/ukrainian/errmsg.txt:
Add missing ',' and fix typo
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r-- | sql/sql_select.cc | 69 |
1 files changed, 58 insertions, 11 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 0e1a25bc42b..69e3469bd7f 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2144,8 +2144,8 @@ add_key_field(KEY_FIELD **key_fields,uint and_level, COND *cond, bool optimizable=0; for (uint i=0; i<num_values; i++) { - used_tables|=(*value)->used_tables(); - if (!((*value)->used_tables() & (field->table->map | RAND_TABLE_BIT))) + used_tables|=(value[i])->used_tables(); + if (!((value[i])->used_tables() & (field->table->map | RAND_TABLE_BIT))) optimizable=1; } if (!optimizable) @@ -2645,7 +2645,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) { @@ -2817,7 +2818,7 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count, will match */ if (table->quick_keys.is_set(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 { @@ -2859,7 +2860,15 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count, } records=(ulong) tmp; } - if (found_ref_or_null) + /* + 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.is_set(key) && + table->quick_key_parts[key] <= max_key_part && + records > (double) table->quick_rows[key]) + tmp= records= (double) table->quick_rows[key]; + else if (found_ref_or_null) { /* We need to do two key searches to find key */ tmp*= 2.0; @@ -3335,9 +3344,15 @@ store_val_in_field(Field *field,Item *item) bool error; THD *thd=current_thd; ha_rows cuted_fields=thd->cuted_fields; + /* + we should restore old value of count_cuted_fields because + store_val_in_field can be called from mysql_insert + with select_insert, which make count_cuted_fields= 1 + */ + enum_check_fields old_count_cuted_fields= thd->count_cuted_fields; thd->count_cuted_fields= CHECK_FIELD_WARN; error= item->save_in_field(field, 1); - thd->count_cuted_fields= CHECK_FIELD_IGNORE; + thd->count_cuted_fields= old_count_cuted_fields; return error || cuted_fields != thd->cuted_fields; } @@ -3569,6 +3584,7 @@ make_join_readinfo(JOIN *join, uint options) { uint i; SELECT_LEX *select_lex= &join->thd->lex->select_lex; + bool statistics= test(!(join->select_options & SELECT_DESCRIBE)); DBUG_ENTER("make_join_readinfo"); for (i=join->const_tables ; i < join->tables ; i++) @@ -3662,7 +3678,8 @@ make_join_readinfo(JOIN *join, uint options) { join->thd->server_status|=SERVER_QUERY_NO_GOOD_INDEX_USED; tab->read_first_record= join_init_quick_read_record; - statistic_increment(select_range_check_count, &LOCK_status); + if (statistics) + statistic_increment(select_range_check_count, &LOCK_status); } else { @@ -3671,24 +3688,28 @@ make_join_readinfo(JOIN *join, uint options) { if (tab->select && tab->select->quick) { - statistic_increment(select_range_count, &LOCK_status); + if (statistics) + statistic_increment(select_range_count, &LOCK_status); } else { join->thd->server_status|=SERVER_QUERY_NO_INDEX_USED; - statistic_increment(select_scan_count, &LOCK_status); + if (statistics) + statistic_increment(select_scan_count, &LOCK_status); } } else { if (tab->select && tab->select->quick) { - statistic_increment(select_full_range_join_count, &LOCK_status); + if (statistics) + statistic_increment(select_full_range_join_count, &LOCK_status); } else { join->thd->server_status|=SERVER_QUERY_NO_INDEX_USED; - statistic_increment(select_full_join_count, &LOCK_status); + if (statistics) + statistic_increment(select_full_join_count, &LOCK_status); } } if (!table->no_keyread) @@ -6700,8 +6721,11 @@ static bool test_if_ref(Item_field *left_item,Item *right_item) /* We can remove binary fields and numerical fields except float, as float comparison isn't 100 % secure + We have to keep binary strings to be able to check for end spaces */ if (field->binary() && + field->real_type() != FIELD_TYPE_STRING && + field->real_type() != FIELD_TYPE_VAR_STRING && (field->type() != FIELD_TYPE_FLOAT || field->decimals() == 0)) { return !store_val_in_field(field,right_item); @@ -7914,6 +7938,29 @@ int setup_order(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, } +/* + Intitialize the GROUP BY list. + + SYNOPSIS + setup_group() + thd Thread handler + ref_pointer_array We store references to all fields that was not in + 'fields' here. + fields All fields in the select part. Any item in 'order' + that is part of these list is replaced by a pointer + to this fields. + all_fields Total list of all unique fields used by the select. + All items in 'order' that was not part of fields will + be added first to this list. + order The fields we should do GROUP BY on. + hidden_group_fields Pointer to flag that is set to 1 if we added any fields + to all_fields. + + RETURN + 0 ok + 1 error (probably out of memory) +*/ + int setup_group(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, List<Item> &fields, List<Item> &all_fields, ORDER *order, |