diff options
author | Joerg Bruehe <joerg@mysql.com> | 2008-12-10 21:14:50 +0100 |
---|---|---|
committer | Joerg Bruehe <joerg@mysql.com> | 2008-12-10 21:14:50 +0100 |
commit | 2181c959183262b6b7f64c67b12f2715d8528572 (patch) | |
tree | 0808625d28751a07f6894b2bffcf47fcf1e71fbf /sql/item_func.cc | |
parent | 96e0bf50d942258722b25e9d17d209d40eaacd28 (diff) | |
parent | ba816c14a9bc8012759da9d58f858f1e73bec708 (diff) | |
download | mariadb-git-2181c959183262b6b7f64c67b12f2715d8528572.tar.gz |
Merge main 5.1 into 5.1-build
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r-- | sql/item_func.cc | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc index 37f67d1a40e..3cf1671bfa7 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1301,8 +1301,10 @@ my_decimal *Item_func_div::decimal_op(my_decimal *decimal_value) void Item_func_div::result_precision() { - uint arg_prec= args[0]->decimal_precision() + prec_increment; - uint precision=min(arg_prec, DECIMAL_MAX_PRECISION); + uint precision=min(args[0]->decimal_precision() + + args[1]->decimals + prec_increment, + DECIMAL_MAX_PRECISION); + /* Integer operations keep unsigned_flag if one of arguments is unsigned */ if (result_type() == INT_RESULT) unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag; @@ -2257,7 +2259,7 @@ void Item_func_min_max::fix_length_and_dec() uint Item_func_min_max::cmp_datetimes(ulonglong *value) { - ulonglong min_max; + longlong min_max; uint min_max_idx= 0; LINT_INIT(min_max); @@ -2265,7 +2267,7 @@ uint Item_func_min_max::cmp_datetimes(ulonglong *value) { Item **arg= args + i; bool is_null; - ulonglong res= get_datetime_value(thd, &arg, 0, datetime_item, &is_null); + longlong res= get_datetime_value(thd, &arg, 0, datetime_item, &is_null); if ((null_value= args[i]->null_value)) return 0; if (i == 0 || (res < min_max ? cmp_sign : -cmp_sign) > 0) @@ -3808,11 +3810,14 @@ static user_var_entry *get_variable(HASH *hash, LEX_STRING &name, bool Item_func_set_user_var::set_entry(THD *thd, bool create_if_not_exists) { - if (thd == entry_thd && entry) + if (entry && thd->thread_id == entry_thread_id) goto end; // update entry->update_query_id for PS - entry_thd= thd; if (!(entry= get_variable(&thd->user_vars, name, create_if_not_exists))) + { + entry_thread_id= 0; return TRUE; + } + entry_thread_id= thd->thread_id; /* Remember the last query which updated it, this way a query can later know if this variable is a constant item in the query (it is if update_query_id @@ -4850,6 +4855,7 @@ void Item_func_get_system_var::fix_length_and_dec() max_length= MAX_BLOB_WIDTH; decimals=NOT_FIXED_DEC; break; + case SHOW_BOOL: case SHOW_MY_BOOL: unsigned_flag= FALSE; max_length= 1; @@ -4877,6 +4883,7 @@ enum Item_result Item_func_get_system_var::result_type() const { switch (var->show_type()) { + case SHOW_BOOL: case SHOW_MY_BOOL: case SHOW_INT: case SHOW_LONG: @@ -4899,6 +4906,7 @@ enum_field_types Item_func_get_system_var::field_type() const { switch (var->show_type()) { + case SHOW_BOOL: case SHOW_MY_BOOL: case SHOW_INT: case SHOW_LONG: @@ -4917,6 +4925,10 @@ enum_field_types Item_func_get_system_var::field_type() const } +/* + Uses var, var_type, component, cache_present, used_query_id, thd, + cached_llval, null_value, cached_null_value +*/ #define get_sys_var_safe(type) \ do { \ type value; \ @@ -4970,6 +4982,7 @@ longlong Item_func_get_system_var::val_int() case SHOW_LONG: get_sys_var_safe (ulong); case SHOW_LONGLONG: get_sys_var_safe (longlong); case SHOW_HA_ROWS: get_sys_var_safe (ha_rows); + case SHOW_BOOL: get_sys_var_safe (bool); case SHOW_MY_BOOL: get_sys_var_safe (my_bool); case SHOW_DOUBLE: { @@ -5067,6 +5080,7 @@ String* Item_func_get_system_var::val_str(String* str) case SHOW_LONG: case SHOW_LONGLONG: case SHOW_HA_ROWS: + case SHOW_BOOL: case SHOW_MY_BOOL: str->set (val_int(), collation.collation); break; @@ -5159,6 +5173,7 @@ double Item_func_get_system_var::val_real() case SHOW_LONG: case SHOW_LONGLONG: case SHOW_HA_ROWS: + case SHOW_BOOL: case SHOW_MY_BOOL: cached_dval= (double) val_int(); cache_present|= GET_SYS_VAR_CACHE_DOUBLE; @@ -5381,7 +5396,9 @@ bool Item_func_match::fix_index() for (keynr=0 ; keynr < table->s->keys ; keynr++) { if ((table->key_info[keynr].flags & HA_FULLTEXT) && - (table->s->keys_in_use.is_set(keynr))) + (flags & FT_BOOL ? table->keys_in_use_for_query.is_set(keynr) : + table->s->keys_in_use.is_set(keynr))) + { ft_to_key[fts]=keynr; ft_cnt[fts]=0; |