summaryrefslogtreecommitdiff
path: root/sql/item_create.cc
diff options
context:
space:
mode:
authorgluh@mysql.com/gluh.(none) <>2006-08-08 14:40:07 +0500
committergluh@mysql.com/gluh.(none) <>2006-08-08 14:40:07 +0500
commit1be93531ee5e5b7e3b4adaf6305572712d020b49 (patch)
tree1c4e9e60ddcc2c66d5a522c08e9096113f87e1e7 /sql/item_create.cc
parente9b87a1a7f3c09501935acd20b2bc4a1a58160cc (diff)
downloadmariadb-git-1be93531ee5e5b7e3b4adaf6305572712d020b49.tar.gz
Bug#16172 DECIMAL data type processed incorrectly
issue an error in case of DECIMAL(M,N) if N > M
Diffstat (limited to 'sql/item_create.cc')
-rw-r--r--sql/item_create.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/sql/item_create.cc b/sql/item_create.cc
index 7d57757432e..e0e18094705 100644
--- a/sql/item_create.cc
+++ b/sql/item_create.cc
@@ -450,6 +450,7 @@ Item *create_func_cast(Item *a, Cast_target cast_type, int len, int dec,
CHARSET_INFO *cs)
{
Item *res;
+ int tmp_len;
LINT_INIT(res);
switch (cast_type) {
@@ -460,7 +461,13 @@ Item *create_func_cast(Item *a, Cast_target cast_type, int len, int dec,
case ITEM_CAST_TIME: res= new Item_time_typecast(a); break;
case ITEM_CAST_DATETIME: res= new Item_datetime_typecast(a); break;
case ITEM_CAST_DECIMAL:
- res= new Item_decimal_typecast(a, (len>0) ? len : 10, dec ? dec : 2);
+ tmp_len= (len>0) ? len : 10;
+ if (tmp_len < dec)
+ {
+ my_error(ER_M_BIGGER_THAN_D, MYF(0), "");
+ return 0;
+ }
+ res= new Item_decimal_typecast(a, tmp_len, dec ? dec : 2);
break;
case ITEM_CAST_CHAR:
res= new Item_char_typecast(a, len, cs ? cs :