diff options
author | Mikael Ronstrom <mikael.ronstrom@oracle.com> | 2011-01-20 18:35:57 +0100 |
---|---|---|
committer | Mikael Ronstrom <mikael.ronstrom@oracle.com> | 2011-01-20 18:35:57 +0100 |
commit | c6de041ebcf53ced34a4c22e9604eb40fa208feb (patch) | |
tree | a1c0b7bc3b8449e48d210fab73769316ee296d5c /sql/item_func.cc | |
parent | e31d7282090dadf3020874549bd690363276e772 (diff) | |
parent | 76d2e222094661ce11e93f5e55c0968ee257956d (diff) | |
download | mariadb-git-c6de041ebcf53ced34a4c22e9604eb40fa208feb.tar.gz |
merge
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r-- | sql/item_func.cc | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc index 27e069df3c4..b7532951230 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1583,24 +1583,27 @@ longlong Item_func_int_div::val_int() if (args[0]->result_type() != INT_RESULT || args[1]->result_type() != INT_RESULT) { - my_decimal value0, value1, tmp; - my_decimal *val0, *val1; - longlong res; - int err; + my_decimal tmp; + my_decimal *val0p= args[0]->val_decimal(&tmp); + if ((null_value= args[0]->null_value)) + return 0; + my_decimal val0= *val0p; - val0= args[0]->val_decimal(&value0); - val1= args[1]->val_decimal(&value1); - if ((null_value= (args[0]->null_value || args[1]->null_value))) + my_decimal *val1p= args[1]->val_decimal(&tmp); + if ((null_value= args[1]->null_value)) return 0; + my_decimal val1= *val1p; + int err; if ((err= my_decimal_div(E_DEC_FATAL_ERROR & ~E_DEC_DIV_ZERO, &tmp, - val0, val1, 0)) > 3) + &val0, &val1, 0)) > 3) { if (err == E_DEC_DIV_ZERO) signal_divide_by_null(); return 0; } + longlong res; if (my_decimal2int(E_DEC_FATAL_ERROR, &tmp, unsigned_flag, &res) & E_DEC_OVERFLOW) raise_integer_overflow(); |