diff options
author | Alexander Barkov <bar@mariadb.org> | 2017-04-27 21:58:10 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2017-04-27 21:58:10 +0400 |
commit | a147eea62c7ad0462f1ee85e50c7628a734c33ae (patch) | |
tree | da5b6427e3726e2cfc35a07ffe1b54da387af5e7 /sql/item_func.cc | |
parent | 9346939545a513abee09b2c65e27737a66cb1864 (diff) | |
download | mariadb-git-a147eea62c7ad0462f1ee85e50c7628a734c33ae.tar.gz |
MDEV-12607 Hybrid functions create wrong VARBINARY length when mixing character and binary data
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r-- | sql/item_func.cc | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc index 5574ae7511e..0bdf708aecb 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -632,6 +632,18 @@ void Item_func::count_only_length(Item **item, uint nitems) } +void Item_func::count_octet_length(Item **item, uint nitems) +{ + max_length= 0; + unsigned_flag= 0; + for (uint i= 0; i < nitems ; i++) + { + set_if_bigger(max_length, item[i]->max_length); + set_if_bigger(unsigned_flag, item[i]->unsigned_flag); + } +} + + /** Set max_length/decimals of function if function is floating point and result length/precision depends on argument ones. @@ -681,7 +693,10 @@ bool Item_func::count_string_length(Item **items, uint nitems) DBUG_ASSERT(!is_temporal_type(field_type())); if (agg_arg_charsets_for_string_result(collation, items, nitems, 1)) return true; - count_only_length(items, nitems); + if (collation.collation == &my_charset_bin) + count_octet_length(items, nitems); + else + count_only_length(items, nitems); decimals= max_length ? NOT_FIXED_DEC : 0; return false; } |