diff options
author | Alexander Barkov <bar@mysql.com> | 2010-08-19 15:55:35 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mysql.com> | 2010-08-19 15:55:35 +0400 |
commit | 7f98714247d601c353779d8615a5624cf00b5e6a (patch) | |
tree | 0da012c099ad33a789a218b378cd58bbe76ccb47 /sql/item.h | |
parent | 27f5c57cb0c622281b2dd4a9e9c5b327b2bcc6d7 (diff) | |
download | mariadb-git-7f98714247d601c353779d8615a5624cf00b5e6a.tar.gz |
Bug#54916 GROUP_CONCAT + IFNULL truncates output
Problem: a few functions did not calculate their max_length correctly.
This is an after-fix for WL#2649 Number-to-string conversions".
Fix: changing the buggy functions to calculate max_length
using fix_char_length() introduced in WL#2649,
instead of setting max_length directly
mysql-test/include/ctype_numconv.inc
Adding new tests
mysql-test/r/ctype_binary.result
Adding new tests
mysql-test/r/ctype_cp1251.result
Adding new tests
mysql-test/r/ctype_latin1.result
Adding new tests
mysql-test/r/ctype_ucs.result
Adding new tests
mysql-test/r/ctype_utf8.result
Adding new tests
mysql-test/t/ctype_utf8.test
Including ctype_numconv
sql/item.h
- Introducing new method fix_char_length_ulonglong(),
for the cases when length is potentially greater
than UINT_MAX32. This method removes a few
instances of duplicate code, e.g. in item_strfunc.cc.
- Setting collation in Item_copy properly. This change
fixes wrong metadata on client side in some cases, when
"binary" instead of the real character set was reported.
sql/item_cmpfunc.cc
- Using fix_char_length() and max_char_length() methods,
instead of direct access to max_length, to calculate
item length properly.
- Moving count_only_length() in COALESCE after
agg_arg_charsets_for_string_result(). The old
order was incorrect and led to wrong length
calucation in case of multi-byte character sets.
sql/item_func.cc
Fixing that count_only_length() didn't work
properly for multi-byte character sets.
Using fix_char_length() and max_char_length()
instead of direct access to max_length.
sql/item_strfunc.cc
- Using fix_char_length(), fix_char_length_ulonglong(),
max_char_length() instead of direct access to max_length.
- Removing wierd condition: "if (collation.collation->mbmaxlen > 0)",
which is never FALSE.
Diffstat (limited to 'sql/item.h')
-rw-r--r-- | sql/item.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/sql/item.h b/sql/item.h index 3af33fd2d31..8e8199ecac8 100644 --- a/sql/item.h +++ b/sql/item.h @@ -547,7 +547,7 @@ public: @see Query_arena::free_list */ Item *next; - uint32 max_length; + uint32 max_length; /* Maximum length, in bytes */ uint name_length; /* Length of name */ int8 marker; uint8 decimals; @@ -1221,6 +1221,18 @@ public: max_length= char_to_byte_length_safe(max_char_length_arg, collation.collation->mbmaxlen); } + void fix_char_length_ulonglong(ulonglong max_char_length_arg) + { + ulonglong max_result_length= max_char_length_arg * + collation.collation->mbmaxlen; + if (max_result_length >= MAX_BLOB_WIDTH) + { + max_length= MAX_BLOB_WIDTH; + maybe_null= 1; + } + else + max_length= max_result_length; + } void fix_length_and_charset_datetime(uint32 max_char_length_arg) { collation.set(&my_charset_numeric, DERIVATION_NUMERIC, MY_REPERTOIRE_ASCII); @@ -2825,6 +2837,7 @@ protected: cached_result_type= item->result_type(); unsigned_flag= item->unsigned_flag; fixed= item->fixed; + collation.set(item->collation); } public: |