From bb453729b8860fca3f3064287fecf566faa35397 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Mar 2006 12:52:38 +0400 Subject: Fix for bug#16678 FORMAT gives wrong result if client run with default-character-set=utf8 calculate Item_func_format::max_length using charset->mbmaxlen mysql-test/r/func_math.result: Fix for bug#16678 FORMAT gives wrong result if client run with default-character-set=utf8 test case mysql-test/t/func_math.test: Fix for bug#16678 FORMAT gives wrong result if client run with default-character-set=utf8 test case --- sql/item_strfunc.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sql/item_strfunc.h') diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 50ec0b36ce8..6a95a9e5d1f 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -471,7 +471,9 @@ public: void fix_length_and_dec() { collation.set(default_charset()); - max_length=args[0]->max_length+(args[0]->max_length-args[0]->decimals)/3; + uint char_length= args[0]->max_length/args[0]->collation.collation->mbmaxlen; + max_length= ((char_length + (char_length-args[0]->decimals)/3) * + collation.collation->mbmaxlen); } const char *func_name() const { return "format"; } void print(String *); -- cgit v1.2.1