mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
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
This commit is contained in:
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
60
sql/field.cc
60
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--;
|
||||
|
Reference in New Issue
Block a user