diff options
author | unknown <monty@hundin.mysql.fi> | 2001-08-18 14:24:01 +0300 |
---|---|---|
committer | unknown <monty@hundin.mysql.fi> | 2001-08-18 14:24:01 +0300 |
commit | a14d63ba6e6b9ee411ac576e513fa31f652138e6 (patch) | |
tree | 185409a9024f800dcf89ef564b4baaccbaa1c5b2 /sql | |
parent | b82ec23adc4040e195e75fb5564cedc74df19e1d (diff) | |
download | mariadb-git-a14d63ba6e6b9ee411ac576e513fa31f652138e6.tar.gz |
Fix for handling of floats inside val_int() of +, - * and /.
Build-tools/Do-compile:
Make shutdown safer
Docs/manual.texi:
Fix of bad merge
sql/log.cc:
cleanup
sql/sql_acl.cc:
cleanup
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_func.cc | 54 | ||||
-rw-r--r-- | sql/log.cc | 10 | ||||
-rw-r--r-- | sql/sql_acl.cc | 2 |
3 files changed, 40 insertions, 26 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc index 1d1a72d35eb..ef3372629f6 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -259,10 +259,14 @@ double Item_func_plus::val() longlong Item_func_plus::val_int() { - longlong value=args[0]->val_int()+args[1]->val_int(); - if ((null_value=args[0]->null_value || args[1]->null_value)) - return 0; - return value; + if (hybrid_type == INT_RESULT) + { + longlong value=args[0]->val_int()+args[1]->val_int(); + if ((null_value=args[0]->null_value || args[1]->null_value)) + return 0; + return value; + } + return (longlong) Item_func_plus::val(); } double Item_func_minus::val() @@ -275,12 +279,17 @@ double Item_func_minus::val() longlong Item_func_minus::val_int() { - longlong value=args[0]->val_int() - args[1]->val_int(); - if ((null_value=args[0]->null_value || args[1]->null_value)) - return 0; - return value; + if (hybrid_type == INT_RESULT) + { + longlong value=args[0]->val_int() - args[1]->val_int(); + if ((null_value=args[0]->null_value || args[1]->null_value)) + return 0; + return value; + } + return (longlong) Item_func_minus::val(); } + double Item_func_mul::val() { double value=args[0]->val()*args[1]->val(); @@ -291,10 +300,14 @@ double Item_func_mul::val() longlong Item_func_mul::val_int() { - longlong value=args[0]->val_int()*args[1]->val_int(); - if ((null_value=args[0]->null_value || args[1]->null_value)) - return 0; /* purecov: inspected */ - return value; + if (hybrid_type == INT_RESULT) + { + longlong value=args[0]->val_int()*args[1]->val_int(); + if ((null_value=args[0]->null_value || args[1]->null_value)) + return 0; /* purecov: inspected */ + return value; + } + return (longlong) Item_func_mul::val(); } @@ -309,14 +322,15 @@ double Item_func_div::val() longlong Item_func_div::val_int() { - // the integer result of division of two arguments needs to be computed - // as a type-cast division of val(), not as diviion of val_int() of each - // argument. For example, val_int(41.5/3.4) = val_int(12.206) = 12, but - // if you do val_int(41.5)/val_int(3.4), as in the old code, we get 42/3= - // 14, which is wrong. This would break sec_to_time(a/b), - // from_unixtime(a/b), and - // all functions that do val_int() on their arguments - return (longlong)val(); + if (hybrid_type == INT_RESULT) + { + longlong value=args[0]->val_int(); + longlong val2=args[1]->val_int(); + if ((null_value= val2 == 0 || args[0]->null_value || args[1]->null_value)) + return 0; + return value/val2; + } + return (longlong) Item_func_div::val(); } void Item_func_div::fix_length_and_dec() diff --git a/sql/log.cc b/sql/log.cc index 33e6ba1de45..d7825ce0e93 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -149,11 +149,11 @@ void MYSQL_LOG::init(enum_log_type log_type_arg) void MYSQL_LOG::close_index() { - if(index_file >= 0) - { - my_close(index_file, MYF(0)); - index_file = -1; - } + if (index_file >= 0) + { + my_close(index_file, MYF(0)); + index_file = -1; + } } void MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg, diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 86d3f61776c..798cd78cab1 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -354,7 +354,7 @@ static uint get_access(TABLE *form,uint fieldnr) /* - return a number with if sorted put string in this order: + return a number which, if sorted 'desc', puts strings in this order: no wildcards wildcards empty string |