Bug#20922 mysql removes a name of first column in a table

0xFF is internal separator for SET|ENUM names. 
If this symbol is present in SET|ENUM names then we replace it with 
','(deprecated symbol for SET|ENUM names) during frm creation
and restore to 0xFF during frm opening
parent af9895d4
......@@ -1745,3 +1745,12 @@ create table t1 (a set('x','y') default 'x');
alter table t1 alter a set default 'z';
ERROR 42000: Invalid default value for 'a'
drop table t1;
create table t1 (f1 int);
alter table t1 add f2 enum(0xFFFF);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f1` int(11) default NULL,
`f2` enum('') default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
......@@ -127,4 +127,13 @@ create table t1 (a set('x','y') default 'x');
alter table t1 alter a set default 'z';
drop table t1;
#
# Bug#20922 mysql removes a name of first column in a table
#
create table t1 (f1 int);
alter table t1 add f2 enum(0xFFFF);
show create table t1;
drop table t1;
# End of 4.1 tests
......@@ -387,7 +387,21 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
count)))
goto err_not_open;
for (count= 0; count < interval->count; count++)
interval->type_lengths[count]= strlen(interval->type_names[count]);
{
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;
}
}
......
......@@ -637,6 +637,21 @@ static bool pack_fields(File file, List<create_field> &create_fields,
tmp.append(NAMES_SEP_CHAR);
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
*/
for (uint cnt= 0 ; cnt < str_len ; cnt++)
{
char c= val[cnt];
if (c == NAMES_SEP_CHAR)
val[cnt]= ',';
}
tmp.append(*pos);
tmp.append(NAMES_SEP_CHAR);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment