diff options
author | unknown <bar@noter.intranet.mysql.r18.ru> | 2004-09-26 21:55:17 +0500 |
---|---|---|
committer | unknown <bar@noter.intranet.mysql.r18.ru> | 2004-09-26 21:55:17 +0500 |
commit | 29c44aa910150b1eae6b0cefc5fec23ba39cc9c4 (patch) | |
tree | 4417aaba3b750fca3e8cfd3a29e057c13720e3dd | |
parent | 5ba00ff0bcbc0936745d3e4e800639a44709b806 (diff) | |
parent | aebe728dd188c4c668a9f4649c0bcc127032c54f (diff) | |
download | mariadb-git-29c44aa910150b1eae6b0cefc5fec23ba39cc9c4.tar.gz |
Merge abarkov@bk-internal.mysql.com:/home/bk/mysql-4.1/
into noter.intranet.mysql.r18.ru:/root/mysql-4.1
sql/field.cc:
Auto merged
-rw-r--r-- | mysql-test/r/bdb.result | 9 | ||||
-rw-r--r-- | mysql-test/r/ctype_utf8.result | 16 | ||||
-rw-r--r-- | mysql-test/t/bdb.test | 12 | ||||
-rw-r--r-- | mysql-test/t/ctype_utf8.test | 14 | ||||
-rw-r--r-- | sql/field.cc | 60 |
5 files changed, 100 insertions, 11 deletions
diff --git a/mysql-test/r/bdb.result b/mysql-test/r/bdb.result index 25118702d09..846adaf53ef 100644 --- a/mysql-test/r/bdb.result +++ b/mysql-test/r/bdb.result @@ -1251,3 +1251,12 @@ truncate t1; select * from t1; a b drop table t1; +SET NAMES utf8; +create table t1 (a varchar(255) character set utf8) engine=bdb; +set @a:= convert(repeat(_latin1 0xFF, 255) using utf8); +insert into t1 values (@a); +select a, length(a), char_length(a) from t1; +a length(a) char_length(a) +ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 510 255 +drop table t1; +SET NAMES latin1; diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index c7d015da9dc..dcd19584c31 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -644,3 +644,19 @@ INSERT INTO t1 VALUES ('test'); SELECT a FROM t1 WHERE a LIKE '%te'; a DROP TABLE t1; +SET NAMES utf8; +CREATE TABLE t1 ( +subject varchar(255) character set utf8 collate utf8_unicode_ci, +p varchar(15) character set utf8 +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES ('谷川俊二と申しますが、インターネット予約の会員登録をしましたところ、メールアドレスを間違えてしまい会員IDが受け取ることが出来ませんでした。間違えアドレスはtani-shun@n.vodafone.ne.jpを書き込みました。どうすればよいですか? その他、住所等は間違えありません。連絡ください。よろしくお願いします。m(__)m','040312-000057'); +INSERT INTO t1 VALUES ('aaa','bbb'); +SELECT length(subject) FROM t1; +length(subject) +432 +3 +SELECT length(subject) FROM t1 ORDER BY 1; +length(subject) +3 +432 +DROP TABLE t1; diff --git a/mysql-test/t/bdb.test b/mysql-test/t/bdb.test index 7ee7d18439d..86214ecd5a8 100644 --- a/mysql-test/t/bdb.test +++ b/mysql-test/t/bdb.test @@ -897,3 +897,15 @@ commit; truncate t1; select * from t1; drop table t1; + +# +# Check that BDB works fine with a string which is +# longer than 255 bytes for multibyte characters. +# +SET NAMES utf8; +create table t1 (a varchar(255) character set utf8) engine=bdb; +set @a:= convert(repeat(_latin1 0xFF, 255) using utf8); +insert into t1 values (@a); +select a, length(a), char_length(a) from t1; +drop table t1; +SET NAMES latin1; diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index f5bd9ede673..4c6ff2abde7 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -499,3 +499,17 @@ CREATE TABLE t1 (a varchar(32) BINARY) CHARACTER SET utf8; INSERT INTO t1 VALUES ('test'); SELECT a FROM t1 WHERE a LIKE '%te'; DROP TABLE t1; + +# +# Bug #5723: length(<varchar utf8 field>) returns varying results +# +SET NAMES utf8; +CREATE TABLE t1 ( + subject varchar(255) character set utf8 collate utf8_unicode_ci, + p varchar(15) character set utf8 +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES ('谷川俊二と申しますが、インターネット予約の会員登録をしましたところ、メールアドレスを間違えてしまい会員IDが受け取ることが出来ませんでした。間違えアドレスはtani-shun@n.vodafone.ne.jpを書き込みました。どうすればよいですか? その他、住所等は間違えありません。連絡ください。よろしくお願いします。m(__)m','040312-000057'); +INSERT INTO t1 VALUES ('aaa','bbb'); +SELECT length(subject) FROM t1; +SELECT length(subject) FROM t1 ORDER BY 1; +DROP TABLE t1; diff --git a/sql/field.cc b/sql/field.cc index 59d18dabcab..a3a19d93e58 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4414,12 +4414,19 @@ void Field_string::sql_type(String &res) const char *Field_string::pack(char *to, const char *from, uint max_length) { const char *end=from+min(field_length,max_length); - uchar length; + uint length; while (end > from && end[-1] == ' ') end--; - *to= length=(uchar) (end-from); - memcpy(to+1, from, (int) length); - return to+1+length; + length= (end-from); + if (field_length > 255) + { + int2store(to, length); + to+= 2; + } + else + *to++= (char) (uchar) length; + memcpy(to, from, (int) length); + return to+length; } @@ -4432,15 +4439,28 @@ char *Field_string::pack_key(char *to, const char *from, uint max_length) set_if_smaller(length, char_length); while (length && from[length-1] == ' ') length--; - *to= (uchar)length; - memcpy(to+1, from, length); - return to+1+length; + if (field_length > 255) + { + int2store(to, length); + to+= 2; + } + else + *to++= (char) (uchar) length; + memcpy(to, from, length); + return to+length; } const char *Field_string::unpack(char *to, const char *from) { - uint length= (uint) (uchar) *from++; + uint length; + if (field_length > 255) + { + length= uint2korr(from); + from+= 2; + } + else + length= (uint) (uchar) *from++; memcpy(to, from, (int) length); bfill(to+length, field_length - length, ' '); return from+length; @@ -4449,8 +4469,19 @@ const char *Field_string::unpack(char *to, const char *from) int Field_string::pack_cmp(const char *a, const char *b, uint length) { - uint a_length= (uint) (uchar) *a++; - uint b_length= (uint) (uchar) *b++; + uint a_length, b_length; + if (field_length > 255) + { + a_length= uint2korr(a); + b_length= uint2korr(b); + a+= 2; + b+= 2; + } + else + { + a_length= (uint) (uchar) *a++; + b_length= (uint) (uchar) *b++; + } return my_strnncoll(field_charset, (const uchar*)a,a_length, (const uchar*)b,b_length); @@ -4459,7 +4490,14 @@ int Field_string::pack_cmp(const char *a, const char *b, uint length) int Field_string::pack_cmp(const char *b, uint length) { - uint b_length= (uint) (uchar) *b++; + uint b_length; + if (field_length > 255) + { + b_length= uint2korr(b); + b+= 2; + } + else + b_length= (uint) (uchar) *b++; char *end= ptr + field_length; while (end > ptr && end[-1] == ' ') end--; |