diff options
author | unknown <bar@mysql.com> | 2004-11-08 14:23:14 +0400 |
---|---|---|
committer | unknown <bar@mysql.com> | 2004-11-08 14:23:14 +0400 |
commit | 06cf873d8f14b6963e2cccf5ca4a214caeb94977 (patch) | |
tree | 8f54723f7ba5e7dd0e74fed10c13366449cbee70 | |
parent | bf14010d517460de1e6fa4b342b93917135c0818 (diff) | |
download | mariadb-git-06cf873d8f14b6963e2cccf5ca4a214caeb94977.tar.gz |
alter_table.result, alter_table.test, field_conv.cc:
Bug #6479 ALTER TABLE ... changing charset fails for TEXT columns
Fix: use do_conv_blob rather than do_copy_blob
if the column's character sets are different.
sql/field_conv.cc:
Bug #6479 ALTER TABLE ... changing charset fails for TEXT columns
Fix: use do_conv_blob rather than do_copy_blob
if the column's character sets are different.
mysql-test/t/alter_table.test:
Bug #6479 ALTER TABLE ... changing charset fails for TEXT columns
Fix: use do_conv_blob rather than do_copy_blob
if the column's character sets are different.
mysql-test/r/alter_table.result:
Bug #6479 ALTER TABLE ... changing charset fails for TEXT columns
Fix: use do_conv_blob rather than do_copy_blob
if the column's character sets are different.
-rw-r--r-- | mysql-test/r/alter_table.result | 10 | ||||
-rw-r--r-- | mysql-test/t/alter_table.test | 12 | ||||
-rw-r--r-- | sql/field_conv.cc | 2 |
3 files changed, 24 insertions, 0 deletions
diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result index 89b8bd66848..9e14ca85a29 100644 --- a/mysql-test/r/alter_table.result +++ b/mysql-test/r/alter_table.result @@ -483,3 +483,13 @@ ERROR 42000: Incorrect table name 't1\\' rename table t1 to `t1\\`; ERROR 42000: Incorrect table name 't1\\' drop table t1; +create table t1 (a text) character set koi8r; +insert into t1 values (_koi8r'ΤΕΣΤ'); +select hex(a) from t1; +hex(a) +D4C5D3D4 +alter table t1 convert to character set cp1251; +select hex(a) from t1; +hex(a) +F2E5F1F2 +drop table t1; diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test index e46027ae8d9..66a4adc90fe 100644 --- a/mysql-test/t/alter_table.test +++ b/mysql-test/t/alter_table.test @@ -324,3 +324,15 @@ alter table t1 rename to `t1\\`; rename table t1 to `t1\\`; drop table t1; +# +# Bug #6479 ALTER TABLE ... changing charset fails for TEXT columns +# +# The column's character set was changed but the actual data was not +# modified. In other words, the values were reinterpreted +# as UTF8 instead of being converted. +create table t1 (a text) character set koi8r; +insert into t1 values (_koi8r'ΤΕΣΤ'); +select hex(a) from t1; +alter table t1 convert to character set cp1251; +select hex(a) from t1; +drop table t1; diff --git a/sql/field_conv.cc b/sql/field_conv.cc index 890687fc925..8a36fcd153c 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -475,6 +475,8 @@ void (*Copy_field::get_copy_func(Field *to,Field *from))(Copy_field*) { if (!(from->flags & BLOB_FLAG)) return do_conv_blob; + if (from->charset() != to->charset()) + return do_conv_blob; if (from_length != to_length || to->table->db_low_byte_first != from->table->db_low_byte_first) { |