mirror of
https://github.com/MariaDB/server.git
synced 2025-01-30 18:41:56 +01:00
Bug#21620 ALTER TABLE affects other columns
Problem: for character sets having mbmaxlen==2, any ALTER TABLE changed TEXT column type to MEDIUMTEXT, due to wrong "internal length to create length" formula. Fix: removing rounding code introduced in early 4.1 time, which is not correct anymore. mysql-test/r/ctype_gbk.result: Adding test case mysql-test/t/ctype_gbk.test: Adding test case sql/field.cc: Fixing "internal length to create length" formula.
This commit is contained in:
parent
695bcb9e7b
commit
880c9b2a8b
3 changed files with 21 additions and 1 deletions
|
@ -168,3 +168,13 @@ DROP TABLE t1;
|
||||||
select hex(convert(_gbk 0xA14041 using ucs2));
|
select hex(convert(_gbk 0xA14041 using ucs2));
|
||||||
hex(convert(_gbk 0xA14041 using ucs2))
|
hex(convert(_gbk 0xA14041 using ucs2))
|
||||||
003F0041
|
003F0041
|
||||||
|
create table t1 (c1 text not null, c2 text not null) character set gbk;
|
||||||
|
alter table t1 change c1 c1 mediumtext character set gbk not null;
|
||||||
|
show create table t1;
|
||||||
|
Table Create Table
|
||||||
|
t1 CREATE TABLE `t1` (
|
||||||
|
`c1` mediumtext NOT NULL,
|
||||||
|
`c2` text NOT NULL
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=gbk
|
||||||
|
drop table t1;
|
||||||
|
End of 5.0 tests
|
||||||
|
|
|
@ -42,3 +42,13 @@ DROP TABLE t1;
|
||||||
select hex(convert(_gbk 0xA14041 using ucs2));
|
select hex(convert(_gbk 0xA14041 using ucs2));
|
||||||
|
|
||||||
# End of 4.1 tests
|
# End of 4.1 tests
|
||||||
|
|
||||||
|
#
|
||||||
|
# Bug#21620 ALTER TABLE affects other columns
|
||||||
|
#
|
||||||
|
create table t1 (c1 text not null, c2 text not null) character set gbk;
|
||||||
|
alter table t1 change c1 c1 mediumtext character set gbk not null;
|
||||||
|
show create table t1;
|
||||||
|
drop table t1;
|
||||||
|
|
||||||
|
--echo End of 5.0 tests
|
||||||
|
|
|
@ -8877,7 +8877,7 @@ create_field::create_field(Field *old_field,Field *orig_field)
|
||||||
case 3: sql_type= FIELD_TYPE_MEDIUM_BLOB; break;
|
case 3: sql_type= FIELD_TYPE_MEDIUM_BLOB; break;
|
||||||
default: sql_type= FIELD_TYPE_LONG_BLOB; break;
|
default: sql_type= FIELD_TYPE_LONG_BLOB; break;
|
||||||
}
|
}
|
||||||
length=(length+charset->mbmaxlen-1) / charset->mbmaxlen;
|
length/= charset->mbmaxlen;
|
||||||
key_length/= charset->mbmaxlen;
|
key_length/= charset->mbmaxlen;
|
||||||
break;
|
break;
|
||||||
case MYSQL_TYPE_STRING:
|
case MYSQL_TYPE_STRING:
|
||||||
|
|
Loading…
Add table
Reference in a new issue