summaryrefslogtreecommitdiff
path: root/sql/item_func.cc
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2017-04-27 21:58:10 +0400
committerAlexander Barkov <bar@mariadb.org>2017-04-27 21:58:10 +0400
commita147eea62c7ad0462f1ee85e50c7628a734c33ae (patch)
treeda5b6427e3726e2cfc35a07ffe1b54da387af5e7 /sql/item_func.cc
parent9346939545a513abee09b2c65e27737a66cb1864 (diff)
downloadmariadb-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.cc17
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;
}