From: Date: August 15 2008 10:13pm Subject: bzr commit into mysql-5.0 branch (chad:2665) Bug#37301 List-Archive: http://lists.mysql.com/commits/51781 X-Bug: 37301 Message-Id: <20080815201346.1C83183063@cornsilk.net> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit #At file:///home/cmiller/work/mysqlbzr/mysql-5.0-bugteam/ 2665 Chad MILLER 2008-08-15 Bug#37301 Length and Max_length differ with no obvious reason(2nd version) Length value is the length of the field, Max_length is the length of the field value. So Max_length can not be more than Length. The fix: fixed calculation of the Item_empty_string item length (Patch applied and queued on demand of Trudy/Davi.) modified: mysql-test/r/ps_1general.result mysql-test/r/ps_2myisam.result mysql-test/r/ps_3innodb.result mysql-test/r/ps_4heap.result mysql-test/r/ps_5merge.result mysql-test/r/ps_6bdb.result mysql-test/r/ps_7ndb.result mysql-test/r/show_check.result mysql-test/t/show_check.test sql/item.h sql/sql_show.cc tests/mysql_client_test.c per-file messages: sql/item.h fixed calculation of the item length sql/sql_show.cc removed unnecessary code === modified file 'mysql-test/r/ps_1general.result' --- a/mysql-test/r/ps_1general.result 2007-09-20 08:54:46 +0000 +++ b/mysql-test/r/ps_1general.result 2008-08-15 20:13:27 +0000 @@ -468,7 +468,7 @@ def table 253 64 2 Y 0 31 8 def type 253 10 3 Y 0 31 8 def possible_keys 253 4096 0 Y 0 31 8 def key 253 64 0 Y 0 31 8 -def key_len 253 1365 0 Y 0 31 8 +def key_len 253 4096 0 Y 0 31 8 def ref 253 1024 0 Y 0 31 8 def rows 8 10 1 Y 32928 0 63 def Extra 253 255 14 N 1 31 8 @@ -484,7 +484,7 @@ def table 253 64 2 Y 0 31 8 def type 253 10 5 Y 0 31 8 def possible_keys 253 4096 7 Y 0 31 8 def key 253 64 7 Y 0 31 8 -def key_len 253 1365 1 Y 0 31 8 +def key_len 253 4096 1 Y 0 31 8 def ref 253 1024 0 Y 0 31 8 def rows 8 10 1 Y 32928 0 63 def Extra 253 255 27 N 1 31 8 === modified file 'mysql-test/r/ps_2myisam.result' --- a/mysql-test/r/ps_2myisam.result 2007-12-06 07:46:01 +0000 +++ b/mysql-test/r/ps_2myisam.result 2008-08-15 20:13:27 +0000 @@ -1158,7 +1158,7 @@ def table 253 64 2 Y 0 31 8 def type 253 10 3 Y 0 31 8 def possible_keys 253 4096 0 Y 0 31 8 def key 253 64 0 Y 0 31 8 -def key_len 253 1365 0 Y 0 31 8 +def key_len 253 4096 0 Y 0 31 8 def ref 253 1024 0 Y 0 31 8 def rows 8 10 1 Y 32928 0 63 def Extra 253 255 0 N 1 31 8 === modified file 'mysql-test/r/ps_3innodb.result' --- a/mysql-test/r/ps_3innodb.result 2007-12-06 07:46:01 +0000 +++ b/mysql-test/r/ps_3innodb.result 2008-08-15 20:13:27 +0000 @@ -1158,7 +1158,7 @@ def table 253 64 2 Y 0 31 8 def type 253 10 3 Y 0 31 8 def possible_keys 253 4096 0 Y 0 31 8 def key 253 64 0 Y 0 31 8 -def key_len 253 1365 0 Y 0 31 8 +def key_len 253 4096 0 Y 0 31 8 def ref 253 1024 0 Y 0 31 8 def rows 8 10 1 Y 32928 0 63 def Extra 253 255 0 N 1 31 8 === modified file 'mysql-test/r/ps_4heap.result' --- a/mysql-test/r/ps_4heap.result 2007-12-06 07:46:01 +0000 +++ b/mysql-test/r/ps_4heap.result 2008-08-15 20:13:27 +0000 @@ -1159,7 +1159,7 @@ def table 253 64 2 Y 0 31 8 def type 253 10 3 Y 0 31 8 def possible_keys 253 4096 0 Y 0 31 8 def key 253 64 0 Y 0 31 8 -def key_len 253 1365 0 Y 0 31 8 +def key_len 253 4096 0 Y 0 31 8 def ref 253 1024 0 Y 0 31 8 def rows 8 10 1 Y 32928 0 63 def Extra 253 255 0 N 1 31 8 === modified file 'mysql-test/r/ps_5merge.result' --- a/mysql-test/r/ps_5merge.result 2007-12-06 07:46:01 +0000 +++ b/mysql-test/r/ps_5merge.result 2008-08-15 20:13:27 +0000 @@ -1201,7 +1201,7 @@ def table 253 64 2 Y 0 31 8 def type 253 10 3 Y 0 31 8 def possible_keys 253 4096 0 Y 0 31 8 def key 253 64 0 Y 0 31 8 -def key_len 253 1365 0 Y 0 31 8 +def key_len 253 4096 0 Y 0 31 8 def ref 253 1024 0 Y 0 31 8 def rows 8 10 1 Y 32928 0 63 def Extra 253 255 0 N 1 31 8 @@ -4223,7 +4223,7 @@ def table 253 64 2 Y 0 31 8 def type 253 10 3 Y 0 31 8 def possible_keys 253 4096 0 Y 0 31 8 def key 253 64 0 Y 0 31 8 -def key_len 253 1365 0 Y 0 31 8 +def key_len 253 4096 0 Y 0 31 8 def ref 253 1024 0 Y 0 31 8 def rows 8 10 1 Y 32928 0 63 def Extra 253 255 0 N 1 31 8 === modified file 'mysql-test/r/ps_6bdb.result' --- a/mysql-test/r/ps_6bdb.result 2007-12-06 07:46:01 +0000 +++ b/mysql-test/r/ps_6bdb.result 2008-08-15 20:13:27 +0000 @@ -1158,7 +1158,7 @@ def table 253 64 2 Y 0 31 8 def type 253 10 3 Y 0 31 8 def possible_keys 253 4096 0 Y 0 31 8 def key 253 64 0 Y 0 31 8 -def key_len 253 1365 0 Y 0 31 8 +def key_len 253 4096 0 Y 0 31 8 def ref 253 1024 0 Y 0 31 8 def rows 8 10 1 Y 32928 0 63 def Extra 253 255 0 N 1 31 8 === modified file 'mysql-test/r/ps_7ndb.result' --- a/mysql-test/r/ps_7ndb.result 2007-12-06 07:46:01 +0000 +++ b/mysql-test/r/ps_7ndb.result 2008-08-15 20:13:27 +0000 @@ -1158,7 +1158,7 @@ def table 253 64 2 Y 0 31 8 def type 253 10 3 Y 0 31 8 def possible_keys 253 4096 0 Y 0 31 8 def key 253 64 0 Y 0 31 8 -def key_len 253 1365 0 Y 0 31 8 +def key_len 253 4096 0 Y 0 31 8 def ref 253 1024 0 Y 0 31 8 def rows 8 10 1 Y 32928 0 63 def Extra 253 255 0 N 1 31 8 === modified file 'mysql-test/r/show_check.result' --- a/mysql-test/r/show_check.result 2007-09-20 08:54:46 +0000 +++ b/mysql-test/r/show_check.result 2008-08-15 20:13:27 +0000 @@ -12,51 +12,51 @@ insert into t1 values (1,2,2),(2,2,3),(3 -- after Bug#29394 is implemented. check table t1 fast; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def Table 253 42 7 Y 0 31 8 -def Op 253 3 5 Y 0 31 8 -def Msg_type 253 3 6 Y 0 31 8 -def Msg_text 253 85 27 Y 0 31 8 +def Table 253 128 7 Y 0 31 8 +def Op 253 10 5 Y 0 31 8 +def Msg_type 253 10 6 Y 0 31 8 +def Msg_text 253 255 27 Y 0 31 8 Table Op Msg_type Msg_text test.t1 check status Table is already up to date check table t1 fast; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def Table 253 42 7 Y 0 31 8 -def Op 253 3 5 Y 0 31 8 -def Msg_type 253 3 6 Y 0 31 8 -def Msg_text 253 85 27 Y 0 31 8 +def Table 253 128 7 Y 0 31 8 +def Op 253 10 5 Y 0 31 8 +def Msg_type 253 10 6 Y 0 31 8 +def Msg_text 253 255 27 Y 0 31 8 Table Op Msg_type Msg_text test.t1 check status Table is already up to date check table t1 changed; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def Table 253 42 7 Y 0 31 8 -def Op 253 3 5 Y 0 31 8 -def Msg_type 253 3 6 Y 0 31 8 -def Msg_text 253 85 2 Y 0 31 8 +def Table 253 128 7 Y 0 31 8 +def Op 253 10 5 Y 0 31 8 +def Msg_type 253 10 6 Y 0 31 8 +def Msg_text 253 255 2 Y 0 31 8 Table Op Msg_type Msg_text test.t1 check status OK insert into t1 values (5,5,5); check table t1 changed; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def Table 253 42 7 Y 0 31 8 -def Op 253 3 5 Y 0 31 8 -def Msg_type 253 3 6 Y 0 31 8 -def Msg_text 253 85 2 Y 0 31 8 +def Table 253 128 7 Y 0 31 8 +def Op 253 10 5 Y 0 31 8 +def Msg_type 253 10 6 Y 0 31 8 +def Msg_text 253 255 2 Y 0 31 8 Table Op Msg_type Msg_text test.t1 check status OK check table t1 medium; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def Table 253 42 7 Y 0 31 8 -def Op 253 3 5 Y 0 31 8 -def Msg_type 253 3 6 Y 0 31 8 -def Msg_text 253 85 2 Y 0 31 8 +def Table 253 128 7 Y 0 31 8 +def Op 253 10 5 Y 0 31 8 +def Msg_type 253 10 6 Y 0 31 8 +def Msg_text 253 255 2 Y 0 31 8 Table Op Msg_type Msg_text test.t1 check status OK check table t1 extended; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def Table 253 42 7 Y 0 31 8 -def Op 253 3 5 Y 0 31 8 -def Msg_type 253 3 6 Y 0 31 8 -def Msg_text 253 85 2 Y 0 31 8 +def Table 253 128 7 Y 0 31 8 +def Op 253 10 5 Y 0 31 8 +def Msg_type 253 10 6 Y 0 31 8 +def Msg_text 253 255 2 Y 0 31 8 Table Op Msg_type Msg_text test.t1 check status OK show index from t1; @@ -84,10 +84,10 @@ ERROR 23000: Duplicate entry '5' for key -- after Bug#29394 is implemented. optimize table t1; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def Table 253 42 7 Y 0 31 8 -def Op 253 3 8 Y 0 31 8 -def Msg_type 253 3 6 Y 0 31 8 -def Msg_text 253 85 2 Y 0 31 8 +def Table 253 128 7 Y 0 31 8 +def Op 253 10 8 Y 0 31 8 +def Msg_type 253 10 6 Y 0 31 8 +def Msg_text 253 255 2 Y 0 31 8 Table Op Msg_type Msg_text test.t1 optimize status OK optimize table t1; @@ -154,10 +154,10 @@ insert into t1 values (1,1,1,0),(1,1,2,0 -- after Bug#29394 is implemented. analyze table t1; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def Table 253 42 7 Y 0 31 8 -def Op 253 3 7 Y 0 31 8 -def Msg_type 253 3 6 Y 0 31 8 -def Msg_text 253 85 2 Y 0 31 8 +def Table 253 128 7 Y 0 31 8 +def Op 253 10 7 Y 0 31 8 +def Msg_type 253 10 6 Y 0 31 8 +def Msg_text 253 255 2 Y 0 31 8 Table Op Msg_type Msg_text test.t1 analyze status OK show index from t1; @@ -171,10 +171,10 @@ t1 0 PRIMARY 4 f4 A 18 NULL NULL BTREE -- after Bug#29394 is implemented. repair table t1; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def Table 253 42 7 Y 0 31 8 -def Op 253 3 6 Y 0 31 8 -def Msg_type 253 3 6 Y 0 31 8 -def Msg_text 253 85 2 Y 0 31 8 +def Table 253 128 7 Y 0 31 8 +def Op 253 10 6 Y 0 31 8 +def Msg_type 253 10 6 Y 0 31 8 +def Msg_text 253 255 2 Y 0 31 8 Table Op Msg_type Msg_text test.t1 repair status OK show index from t1; @@ -788,8 +788,8 @@ latin1_bin latin1 47 Yes 1 ---------------------------------------------------------------- SHOW CREATE DATABASE mysqltest1; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def Database 253 63 10 N 1 31 33 -def Create Database 253 1023 69 N 1 31 33 +def Database 253 192 10 N 1 31 33 +def Create Database 253 3072 69 N 1 31 33 Database Create Database mysqltest1 CREATE DATABASE `mysqltest1` /*!40100 DEFAULT CHARACTER SET latin1 */ ---------------------------------------------------------------- @@ -801,8 +801,8 @@ mysqltest1 ---------------------------------------------------------------- SHOW CREATE TABLE t1; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def Table 253 63 2 N 1 31 33 -def Create Table 253 1023 103 N 1 31 33 +def Table 253 192 2 N 1 31 33 +def Create Table 253 3072 103 N 1 31 33 Table Create Table t1 CREATE TABLE `t1` ( `c` int(11) NOT NULL, @@ -959,8 +959,8 @@ NULL test t1_bi INSERT NULL test t1 NULL ---------------------------------------------------------------- SHOW CREATE VIEW v1; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def View 253 63 2 N 1 31 33 -def Create View 253 1023 103 N 1 31 33 +def View 253 192 2 N 1 31 33 +def Create View 253 3072 103 N 1 31 33 View Create View v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 AS `1` ---------------------------------------------------------------- @@ -981,9 +981,9 @@ NULL test v1 /* ALGORITHM=UNDEFINED */ s ---------------------------------------------------------------- SHOW CREATE PROCEDURE p1; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def Procedure 253 63 2 N 1 31 33 +def Procedure 253 192 2 N 1 31 33 def sql_mode 253 0 0 N 1 31 33 -def Create Procedure 253 2046 59 Y 0 31 33 +def Create Procedure 253 6144 59 Y 0 31 33 Procedure sql_mode Create Procedure p1 CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`() SELECT 1 @@ -1033,9 +1033,9 @@ p1 NULL test p1 PROCEDURE NULL SQL SELEC ---------------------------------------------------------------- SHOW CREATE FUNCTION f1; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def Function 253 63 2 N 1 31 33 +def Function 253 192 2 N 1 31 33 def sql_mode 253 0 0 N 1 31 33 -def Create Function 253 2046 74 Y 0 31 33 +def Create Function 253 6144 74 Y 0 31 33 Function sql_mode Create Function f1 CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11) RETURN 1 @@ -1141,4 +1141,34 @@ Slow_queries 2 show variables like 'myisam_recover_options'; Variable_name Value myisam_recover_options OFF +CREATE TABLE t1 ( +Codigo int(10) unsigned NOT NULL auto_increment, +Nombre varchar(255) default NULL, +Telefono varchar(255) default NULL, +Observaciones longtext, +Direccion varchar(255) default NULL, +Dni varchar(255) default NULL, +CP int(11) default NULL, +Provincia varchar(255) default NULL, +Poblacion varchar(255) default NULL, +PRIMARY KEY (Codigo) +) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=utf8; +show create table t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def Table 253 64 2 N 1 31 7 +def Create Table 253 1024 446 N 1 31 7 +Table Create Table +t1 CREATE TABLE `t1` ( + `Codigo` int(10) unsigned NOT NULL auto_increment, + `Nombre` varchar(255) default NULL, + `Telefono` varchar(255) default NULL, + `Observaciones` longtext, + `Direccion` varchar(255) default NULL, + `Dni` varchar(255) default NULL, + `CP` int(11) default NULL, + `Provincia` varchar(255) default NULL, + `Poblacion` varchar(255) default NULL, + PRIMARY KEY (`Codigo`) +) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=utf8 +drop table t1; End of 5.0 tests === modified file 'mysql-test/t/show_check.test' --- a/mysql-test/t/show_check.test 2007-08-02 13:23:23 +0000 +++ b/mysql-test/t/show_check.test 2008-08-15 20:13:27 +0000 @@ -844,4 +844,24 @@ show status like 'slow_queries'; # show variables like 'myisam_recover_options'; +# +# Bug#37301 Length and Max_length differ with no obvious reason +# +CREATE TABLE t1 ( + Codigo int(10) unsigned NOT NULL auto_increment, + Nombre varchar(255) default NULL, + Telefono varchar(255) default NULL, + Observaciones longtext, + Direccion varchar(255) default NULL, + Dni varchar(255) default NULL, + CP int(11) default NULL, + Provincia varchar(255) default NULL, + Poblacion varchar(255) default NULL, + PRIMARY KEY (Codigo) +) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=utf8; +--enable_metadata +show create table t1; +--disable_metadata +drop table t1; + --echo End of 5.0 tests === modified file 'sql/item.h' --- a/sql/item.h 2008-08-11 16:10:00 +0000 +++ b/sql/item.h 2008-08-15 20:13:27 +0000 @@ -1817,7 +1817,7 @@ class Item_empty_string :public Item_str public: Item_empty_string(const char *header,uint length, CHARSET_INFO *cs= NULL) : Item_string("",0, cs ? cs : &my_charset_utf8_general_ci) - { name=(char*) header; max_length= cs ? length * cs->mbmaxlen : length; } + { name=(char*) header; max_length= length * collation.collation->mbmaxlen; } void make_field(Send_field *field); }; === modified file 'sql/sql_show.cc' --- a/sql/sql_show.cc 2008-03-19 13:32:28 +0000 +++ b/sql/sql_show.cc 2008-08-15 20:13:27 +0000 @@ -3666,12 +3666,10 @@ TABLE *create_schema_table(THD *thd, TAB /* Don't let unimplemented types pass through. Could be a grave error. */ DBUG_ASSERT(fields_info->field_type == MYSQL_TYPE_STRING); - /* this should be changed when Item_empty_string is fixed(in 4.1) */ - if (!(item= new Item_empty_string("", 0, cs))) + if (!(item= new Item_empty_string("", fields_info->field_length, cs))) { DBUG_RETURN(0); } - item->max_length= fields_info->field_length * cs->mbmaxlen; item->set_name(fields_info->field_name, strlen(fields_info->field_name), cs); break; === modified file 'tests/mysql_client_test.c' --- a/tests/mysql_client_test.c 2008-08-11 23:27:09 +0000 +++ b/tests/mysql_client_test.c 2008-08-15 20:13:27 +0000 @@ -7578,9 +7578,7 @@ static void test_explain_bug() else { verify_prepare_field(result, 6, "key_len", "", MYSQL_TYPE_VAR_STRING, "", - "", "", - NAME_LEN*MAX_KEY / my_charset_utf8_general_ci.mbmaxlen, - 0); + "", "", NAME_LEN*MAX_KEY, 0); } verify_prepare_field(result, 7, "ref", "", MYSQL_TYPE_VAR_STRING,