summaryrefslogtreecommitdiff
path: root/sql/item_func.cc
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2013-03-18 08:44:24 +0100
committerSergei Golubchik <sergii@pisem.net>2013-03-18 08:44:24 +0100
commit8f607aae127439e132dae00b2750727162f4d564 (patch)
tree2a470ac1ca3ad8c0f9e782d9ed0edcaadf112538 /sql/item_func.cc
parent3827d70a0edb9b88f30dd64a2d7ee2853524dd4e (diff)
downloadmariadb-git-8f607aae127439e132dae00b2750727162f4d564.tar.gz
MDEV-4283 Assertion `scale <= precision' fails in strings/decimal.c
with decimals=NOT_FIXED_DEC it is possible to have 'decimals' larger than 'max_length', it's not an error for temporal functions. But when Item_func_numhybrid converts the value to DECIMAL_RESULT, it must limit 'decimals' to be a valid scale of a decimal number.
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r--sql/item_func.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc
index f3a5c08d621..120e3d73a34 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -742,13 +742,14 @@ void Item_num_op::find_num_type(void)
{
hybrid_type= DECIMAL_RESULT;
result_precision();
+ fix_decimals();
}
else
{
DBUG_ASSERT(r0 == INT_RESULT && r1 == INT_RESULT);
- decimals= 0;
hybrid_type=INT_RESULT;
result_precision();
+ decimals= 0;
}
DBUG_PRINT("info", ("Type: %s",
(hybrid_type == REAL_RESULT ? "REAL_RESULT" :
@@ -1492,6 +1493,7 @@ void Item_func_div::fix_length_and_dec()
break;
case DECIMAL_RESULT:
result_precision();
+ fix_decimals();
break;
case STRING_RESULT:
case ROW_RESULT: