diff options
author | unknown <ramil/ram@mysql.com/ramil.myoffice.izhnet.ru> | 2007-01-22 14:52:23 +0400 |
---|---|---|
committer | unknown <ramil/ram@mysql.com/ramil.myoffice.izhnet.ru> | 2007-01-22 14:52:23 +0400 |
commit | 39fb7b2423c01b168ca4947307426edb945abfe2 (patch) | |
tree | 92f4172628767940174a433e7ba2477e138dae6e /sql | |
parent | 74eac22e4e1d437191be8b9fc536071382330f2e (diff) | |
download | mariadb-git-39fb7b2423c01b168ca4947307426edb945abfe2.tar.gz |
Fix for bug #22026: Warning when using IF statement and large unsigned bigint
We use INT_RESULT type if all arguments are of type INT for 'if', 'case',
'coalesce' functions regardless of arguments' unsigned flag, so sometimes we can
exceed the INT bounds.
mysql-test/r/select.result:
Fix for bug #22026: Warning when using IF statement and large unsigned bigint
- test result.
mysql-test/t/select.test:
Fix for bug #22026: Warning when using IF statement and large unsigned bigint
- test case.
sql/item_cmpfunc.cc:
Fix for bug #22026: Warning when using IF statement and large unsigned bigint
- take into account unsigned flags aggregating result types:
return INT_RESULT only if two items with INT_RESULT type
have equal unsigned_flags, otherwise return REAL_RESULT.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_cmpfunc.cc | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 936ae04e93d..f4b99e19864 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -26,13 +26,17 @@ static bool convert_constant_item(THD *thd, Field *field, Item **item); -static Item_result item_store_type(Item_result a,Item_result b) +static Item_result item_store_type(Item_result a, Item *item, + my_bool unsigned_flag) { + Item_result b= item->result_type(); + if (a == STRING_RESULT || b == STRING_RESULT) return STRING_RESULT; else if (a == REAL_RESULT || b == REAL_RESULT) return REAL_RESULT; - else if (a == DECIMAL_RESULT || b == DECIMAL_RESULT) + else if (a == DECIMAL_RESULT || b == DECIMAL_RESULT || + unsigned_flag != item->unsigned_flag) return DECIMAL_RESULT; else return INT_RESULT; @@ -41,6 +45,7 @@ static Item_result item_store_type(Item_result a,Item_result b) static void agg_result_type(Item_result *type, Item **items, uint nitems) { Item **item, **item_end; + my_bool unsigned_flag= 0; *type= STRING_RESULT; /* Skip beginning NULL items */ @@ -49,6 +54,7 @@ static void agg_result_type(Item_result *type, Item **items, uint nitems) if ((*item)->type() != Item::NULL_ITEM) { *type= (*item)->result_type(); + unsigned_flag= (*item)->unsigned_flag; item++; break; } @@ -57,7 +63,7 @@ static void agg_result_type(Item_result *type, Item **items, uint nitems) for (; item < item_end; item++) { if ((*item)->type() != Item::NULL_ITEM) - *type= item_store_type(type[0], (*item)->result_type()); + *type= item_store_type(*type, *item, unsigned_flag); } } |