diff options
author | unknown <igor@olga.mysql.com> | 2007-07-07 10:33:02 -0700 |
---|---|---|
committer | unknown <igor@olga.mysql.com> | 2007-07-07 10:33:02 -0700 |
commit | 3756819e4bd548f4fd6ac8773697768435dbd129 (patch) | |
tree | 198e5aba09467140997eca3bd0a0a88d7db60b8c /sql/item_create.cc | |
parent | 8195a213c2fadfb185e755ce6dda2162df1a5529 (diff) | |
download | mariadb-git-3756819e4bd548f4fd6ac8773697768435dbd129.tar.gz |
Fixed bug #29415.
The cast operation ignored the cases when the precision and/or the scale exceeded
the limits, 65 and 30 respectively. No errors were reported in these cases.
For some queries this may lead to an assertion abort.
Fixed by throwing errors for such cases.
mysql-test/r/type_newdecimal.result:
Added a test case for bug #29415.
mysql-test/t/type_newdecimal.test:
Added a test case for bug #29415.
Diffstat (limited to 'sql/item_create.cc')
-rw-r--r-- | sql/item_create.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/sql/item_create.cc b/sql/item_create.cc index 42cbdc8c280..50db1c37371 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -471,6 +471,18 @@ Item *create_func_cast(Item *a, Cast_target cast_type, my_error(ER_M_BIGGER_THAN_D, MYF(0), ""); return 0; } + if (len > DECIMAL_MAX_PRECISION) + { + my_error(ER_TOO_BIG_PRECISION, MYF(0), len, a->name, + DECIMAL_MAX_PRECISION); + return 0; + } + if (dec > DECIMAL_MAX_SCALE) + { + my_error(ER_TOO_BIG_SCALE, MYF(0), dec, a->name, + DECIMAL_MAX_SCALE); + return 0; + } res= new Item_decimal_typecast(a, len, dec); break; case ITEM_CAST_CHAR: |