From e6ba48b942fae459b113e95110406944c1da53e8 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 17 May 2005 20:31:26 +0200 Subject: [PATCH] BUG#9535 Warning for "create table t as select uuid();" - Set max_length of Item_func_uuid to max_length*system_charset_info->mbmaxlen Note! Item_func_uuid should be set to use 'ascii' charset when hex(), format(), md5() etc will use 'ascii' --- mysql-test/r/func_misc.result | 8 ++++++++ mysql-test/t/func_misc.test | 8 ++++++++ sql/item_strfunc.h | 7 ++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result index 1d9b813e68a..5e74e6fa68a 100644 --- a/mysql-test/r/func_misc.result +++ b/mysql-test/r/func_misc.result @@ -51,3 +51,11 @@ select a from t1 where mid(a+0,6,3) = ( mid(20040106123400,6,3) ); a 2004-01-06 12:34:00 drop table t1; +create table t1 as select uuid(), length(uuid()); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `uuid()` varchar(36) character set utf8 NOT NULL default '', + `length(uuid())` int(10) NOT NULL default '0' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test index 89aba7ee583..78ff0907b39 100644 --- a/mysql-test/t/func_misc.test +++ b/mysql-test/t/func_misc.test @@ -38,3 +38,11 @@ select a from t1 where mid(a+0,6,3) = ( mid(20040106123400,6,3) ); drop table t1; +# Test for BUG#9535 +create table t1 as select uuid(), length(uuid()); +show create table t1; +drop table t1; + + + + diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index d7c77829cfc..3ddf225d593 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -727,7 +727,12 @@ class Item_func_uuid: public Item_str_func Item_func_uuid(): Item_str_func() {} void fix_length_and_dec() { collation.set(system_charset_info); - max_length= UUID_LENGTH; + /* + NOTE! uuid() should be changed to use 'ascii' + charset when hex(), format(), md5(), etc, and implicit + number-to-string conversion will use 'ascii' + */ + max_length= UUID_LENGTH * system_charset_info->mbmaxlen; } const char *func_name() const{ return "uuid"; } String *val_str(String *); -- 2.30.9