From: Date: October 25 2005 10:56pm Subject: bk commit into 4.1 tree (sergefp:1.2460) BUG#14139 List-Archive: http://lists.mysql.com/internals/31470 X-Bug: 14139 Message-Id: <20051025205623.03DAF37AE7@newbox.mylan> Below is the list of changes that have just been committed into a local 4.1 repository of psergey. When psergey does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet 1.2460 05/10/26 00:56:17 sergefp@stripped +5 -0 BUG#14139: When handling "CREATE TABLE(field_X type_spec,...) SELECT smth AS field_X, ...." avoid multiplying length of field_X by charset->mbmaxlen twice when calculating space required for field_X in the new table. sql/sql_table.cc 1.303 05/10/26 00:56:10 sergefp@stripped +2 -2 BUG#14139: When handling "CREATE TABLE(field_X type_spec,...) SELECT smth AS field_X, ...." we get two instances of create_field: (1) is occurence of field_X in create list, and (2) is in select list. If we figure they both refer to the same field, we "join" them according to some rule that is not explicitly specified anywhere. When we do this "join", create_field::length already contains length-in-bytes for both, so when we transfer field length (in characters) from (1) to (2), use length-in-characters that we have saved in create_length::chars_length. sql/field.h 1.130 05/10/26 00:56:10 sergefp@stripped +8 -0 BUG#14139: Add create_length::chars_length where we save length-in-characters, added comments. sql/field.cc 1.225 05/10/26 00:56:10 sergefp@stripped +12 -0 BUG#14139: Make create_length_to_internal_length() save length-in-characters in create_field::chars_length. mysql-test/t/create.test 1.60 05/10/26 00:56:10 sergefp@stripped +8 -0 Testcase for BUG#14139 mysql-test/r/create.result 1.86 05/10/26 00:56:10 sergefp@stripped +11 -0 Testcase for BUG#14139 # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: sergefp # Host: newbox.mylan # Root: /home/psergey/mysql-4.1-bug14139 --- 1.224/sql/field.cc 2005-07-28 22:24:02 +04:00 +++ 1.225/sql/field.cc 2005-10-26 00:56:10 +04:00 @@ -6511,8 +6511,20 @@ ** Handling of field and create_field *****************************************************************************/ +/* + Convert create_field::length from number of characters to number of bytes + + SYNOPSIS + create_field::create_length_to_internal_length() + + DESCRIPTION + Convert create_field::length from number of characters to number of bytes, + save original value in chars_length. +*/ + void create_field::create_length_to_internal_length(void) { + chars_length= length; switch (sql_type) { case MYSQL_TYPE_TINY_BLOB: case MYSQL_TYPE_MEDIUM_BLOB: --- 1.129/sql/field.h 2005-06-20 21:44:01 +04:00 +++ 1.130/sql/field.h 2005-10-26 00:56:10 +04:00 @@ -1180,7 +1180,15 @@ LEX_STRING comment; // Comment for field Item *def; // Default value enum enum_field_types sql_type; + /* + At various stages in execution this can be length of field in bytes or + max number of characters. + */ uint32 length; + /* + The value of 'length' before a call to create_length_to_internal_length + */ + uint32 chars_length; uint decimals,flags,pack_length; Field::utype unireg_check; TYPELIB *interval; // Which interval to use --- 1.302/sql/sql_table.cc 2005-09-12 16:08:36 +04:00 +++ 1.303/sql/sql_table.cc 2005-10-26 00:56:10 +04:00 @@ -643,8 +643,8 @@ sql_field->charset= (dup_field->charset ? dup_field->charset : create_info->default_table_charset); - sql_field->length= dup_field->length; - sql_field->pack_length= dup_field->pack_length; + sql_field->length= dup_field->chars_length; + sql_field->pack_length= dup_field->pack_length; sql_field->create_length_to_internal_length(); sql_field->decimals= dup_field->decimals; sql_field->flags= dup_field->flags; --- 1.85/mysql-test/r/create.result 2005-09-12 16:08:36 +04:00 +++ 1.86/mysql-test/r/create.result 2005-10-26 00:56:10 +04:00 @@ -621,3 +621,14 @@ Warnings: Note 1050 Table 't1' already exists drop table t1; +create table t1 ( +a varchar(112) charset utf8 collate utf8_bin not null, +primary key (a) +) select 'test' as a ; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(112) character set utf8 collate utf8_bin NOT NULL default '', + PRIMARY KEY (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; --- 1.59/mysql-test/t/create.test 2005-09-12 16:08:36 +04:00 +++ 1.60/mysql-test/t/create.test 2005-10-26 00:56:10 +04:00 @@ -526,4 +526,12 @@ create table if not exists t1 (a int); drop table t1; +# BUG#14139 +create table t1 ( + a varchar(112) charset utf8 collate utf8_bin not null, + primary key (a) +) select 'test' as a ; +show create table t1; +drop table t1; + # End of 4.1 tests