From: Date: December 14 2006 2:34am Subject: bk commit into 4.1 tree (tnurnberg:1.2588) BUG#24660 List-Archive: http://lists.mysql.com/commits/16922 X-Bug: 24660 Message-Id: Below is the list of changes that have just been committed into a local 4.1 repository of tnurnberg. When tnurnberg 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@stripped, 2006-12-14 02:34:06+01:00, tnurnberg@stripped +4 -0 Bug#24660: "enum" field type definition problem ENUMs weren't allowed to have character 0xff, a perfectly good character in some locales. This was circumvented by mapping 0xff in ENUMs to ',', thereby prevent actual commas from being used. Now if 0xff makes an appearance, we find a character not used in the enum and use that as a separator. If no such character exists, we throw an error. Any solution would have broken some sort of existing behaviour. This solution should serve both fractions (those with 0xff and those with ',' in their enums), but WILL REQUIRE A DUMP/RESTORE CYCLE FROM THOSE WITH 0xff IN THEIR ENUMS. :-/ That is, mysqldump with their current server, and restore when upgrading to one with this patch. mysql-test/r/type_enum.result@stripped, 2006-12-14 02:34:04+01:00, tnurnberg@stripped +24 -0 Bug#24660: "enum" field type definition problem Show that enums can now contain NAMES_SEP_CHAR (0xff, which is a perfectly respectable char in some locales), or ',', or both. mysql-test/t/type_enum.test@stripped, 2006-12-14 02:34:04+01:00, tnurnberg@stripped +20 -0 Bug#24660: "enum" field type definition problem Show that enums can now contain NAMES_SEP_CHAR (0xff, which is a perfectly respectable char in some locales), or ',', or both. sql/table.cc@stripped, 2006-12-14 02:34:04+01:00, tnurnberg@stripped +0 -11 Bug#24660: "enum" field type definition problem Revert fix for Bug#20922. sql/unireg.cc@stripped, 2006-12-14 02:34:04+01:00, tnurnberg@stripped +40 -15 Bug#24660: "enum" field type definition problem Use a field-separator for ENUM-values that is not part of those values. If impossible, throw error. # 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: tnurnberg # Host: sin.azundris.com # Root: /home/tnurnberg/24660/41-24660 --- 1.140/sql/table.cc 2006-11-02 23:20:33 +01:00 +++ 1.141/sql/table.cc 2006-12-14 02:34:04 +01:00 @@ -391,17 +391,6 @@ int openfrm(const char *name, const char { char *val= (char*) interval->type_names[count]; interval->type_lengths[count]= strlen(val); - /* - Replace all ',' symbols with NAMES_SEP_CHAR. - See the comment in unireg.cc, pack_fields() function - for details. - */ - for (uint cnt= 0 ; cnt < interval->type_lengths[count] ; cnt++) - { - char c= val[cnt]; - if (c == ',') - val[cnt]= NAMES_SEP_CHAR; - } } interval->type_lengths[count]= 0; } --- 1.51/sql/unireg.cc 2006-10-05 13:38:16 +02:00 +++ 1.52/sql/unireg.cc 2006-12-14 02:34:04 +01:00 @@ -657,27 +657,52 @@ static bool pack_fields(File file, List< { if (field->interval_id > int_count) { - int_count=field->interval_id; - tmp.append(NAMES_SEP_CHAR); + unsigned char sep= 0; + unsigned char occ[256]; + uint i; + + for (i=0; i<256; i++) + occ[i]=0; + for (const char **pos=field->interval->type_names ; *pos ; pos++) { - char *val= (char*) *pos; - uint str_len= strlen(val); - /* - Note, hack: in old frm NAMES_SEP_CHAR is used to separate - names in the interval (ENUM/SET). To allow names to contain - NAMES_SEP_CHAR, we replace it with a comma before writing frm. - Backward conversion is done during frm file opening, - See table.cc, openfrm() function - */ + unsigned char *val= (unsigned char*) *pos; + uint str_len= strlen((const char *) *pos); + for (uint cnt= 0 ; cnt < str_len ; cnt++) { - char c= val[cnt]; - if (c == NAMES_SEP_CHAR) - val[cnt]= ','; + i= *(val+cnt); + occ[i]= 1; + } + } + + if (occ[(unsigned char)NAMES_SEP_CHAR]) { + if (!occ[',']) + sep= ','; + else + { + for (uint i=1; !sep && (i<256); i++) + { + if(!occ[i]) + sep= i; + } + } + + if(!sep) { /* desaster, enum uses all characters, none left as separator */ + my_message(ER_WRONG_FIELD_TERMINATORS,ER(ER_WRONG_FIELD_TERMINATORS), + MYF(0)); + DBUG_RETURN(1); } + } + else + sep= NAMES_SEP_CHAR; + + int_count=field->interval_id; + tmp.append(sep); + for (const char **pos=field->interval->type_names ; *pos ; pos++) + { tmp.append(*pos); - tmp.append(NAMES_SEP_CHAR); + tmp.append(sep); } tmp.append('\0'); // End of intervall } --- 1.26/mysql-test/r/type_enum.result 2006-09-11 11:50:43 +02:00 +++ 1.27/mysql-test/r/type_enum.result 2006-12-14 02:34:04 +01:00 @@ -1754,3 +1754,27 @@ t1 CREATE TABLE `t1` ( `f2` enum('') default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; +create table t1(russian enum('E','F','EF','FE') NOT NULL DEFAULT'E'); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `russian` enum('E','F','EF','FE') NOT NULL default 'E' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1(denormal enum('E','F','E,F','F,E') NOT NULL DEFAULT'E'); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `denormal` enum('E','F','E,F','F,E') NOT NULL default 'E' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1(russian_deviant enum('E','F','EF','F,E') NOT NULL DEFAULT'E'); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `russian_deviant` enum('E','F','EF','F,E') NOT NULL default 'E' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1(exhausting_charset enum('ABCDEFGHIJKLMNOPQRSTUVWXYZ',' +  !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~','xx\','yy\','zz')); +ERROR 42000: Field separator argument is not what is expected; check the manual --- 1.16/mysql-test/t/type_enum.test 2006-09-11 11:50:43 +02:00 +++ 1.17/mysql-test/t/type_enum.test 2006-12-14 02:34:04 +01:00 @@ -136,4 +136,24 @@ alter table t1 add f2 enum(0xFFFF); show create table t1; drop table t1; +# +# Bug#24660 "enum" field type definition problem +# +create table t1(russian enum('E','F','EF','FE') NOT NULL DEFAULT'E'); +show create table t1; +drop table t1; + +create table t1(denormal enum('E','F','E,F','F,E') NOT NULL DEFAULT'E'); +show create table t1; +drop table t1; + +create table t1(russian_deviant enum('E','F','EF','F,E') NOT NULL DEFAULT'E'); +show create table t1; +drop table t1; + +# ER_WRONG_FIELD_TERMINATORS +--error 1083 +create table t1(exhausting_charset enum('ABCDEFGHIJKLMNOPQRSTUVWXYZ',' +  !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~','xx\','yy\','zz')); + # End of 4.1 tests