Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
aebe728d
Commit
aebe728d
authored
Sep 26, 2004
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug #5723 length(varchar utf8 field) returns verying results
parent
cd1cd0df
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
100 additions
and
11 deletions
+100
-11
mysql-test/r/bdb.result
mysql-test/r/bdb.result
+9
-0
mysql-test/r/ctype_utf8.result
mysql-test/r/ctype_utf8.result
+16
-0
mysql-test/t/bdb.test
mysql-test/t/bdb.test
+12
-0
mysql-test/t/ctype_utf8.test
mysql-test/t/ctype_utf8.test
+14
-0
sql/field.cc
sql/field.cc
+49
-11
No files found.
mysql-test/r/bdb.result
View file @
aebe728d
...
@@ -1251,3 +1251,12 @@ truncate t1;
...
@@ -1251,3 +1251,12 @@ truncate t1;
select * from t1;
select * from t1;
a b
a b
drop table t1;
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;
mysql-test/r/ctype_utf8.result
View file @
aebe728d
...
@@ -644,3 +644,19 @@ INSERT INTO t1 VALUES ('test');
...
@@ -644,3 +644,19 @@ INSERT INTO t1 VALUES ('test');
SELECT a FROM t1 WHERE a LIKE '%te';
SELECT a FROM t1 WHERE a LIKE '%te';
a
a
DROP TABLE t1;
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;
mysql-test/t/bdb.test
View file @
aebe728d
...
@@ -897,3 +897,15 @@ commit;
...
@@ -897,3 +897,15 @@ commit;
truncate
t1
;
truncate
t1
;
select
*
from
t1
;
select
*
from
t1
;
drop
table
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
;
mysql-test/t/ctype_utf8.test
View file @
aebe728d
...
@@ -499,3 +499,17 @@ CREATE TABLE t1 (a varchar(32) BINARY) CHARACTER SET utf8;
...
@@ -499,3 +499,17 @@ CREATE TABLE t1 (a varchar(32) BINARY) CHARACTER SET utf8;
INSERT
INTO
t1
VALUES
(
'test'
);
INSERT
INTO
t1
VALUES
(
'test'
);
SELECT
a
FROM
t1
WHERE
a
LIKE
'%te'
;
SELECT
a
FROM
t1
WHERE
a
LIKE
'%te'
;
DROP
TABLE
t1
;
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
;
sql/field.cc
View file @
aebe728d
...
@@ -4384,12 +4384,19 @@ void Field_string::sql_type(String &res) const
...
@@ -4384,12 +4384,19 @@ void Field_string::sql_type(String &res) const
char
*
Field_string
::
pack
(
char
*
to
,
const
char
*
from
,
uint
max_length
)
char
*
Field_string
::
pack
(
char
*
to
,
const
char
*
from
,
uint
max_length
)
{
{
const
char
*
end
=
from
+
min
(
field_length
,
max_length
);
const
char
*
end
=
from
+
min
(
field_length
,
max_length
);
u
char
length
;
u
int
length
;
while
(
end
>
from
&&
end
[
-
1
]
==
' '
)
while
(
end
>
from
&&
end
[
-
1
]
==
' '
)
end
--
;
end
--
;
*
to
=
length
=
(
uchar
)
(
end
-
from
);
length
=
(
end
-
from
);
memcpy
(
to
+
1
,
from
,
(
int
)
length
);
if
(
field_length
>
255
)
return
to
+
1
+
length
;
{
int2store
(
to
,
length
);
to
+=
2
;
}
else
*
to
++=
(
char
)
(
uchar
)
length
;
memcpy
(
to
,
from
,
(
int
)
length
);
return
to
+
length
;
}
}
...
@@ -4402,15 +4409,28 @@ char *Field_string::pack_key(char *to, const char *from, uint max_length)
...
@@ -4402,15 +4409,28 @@ char *Field_string::pack_key(char *to, const char *from, uint max_length)
set_if_smaller
(
length
,
char_length
);
set_if_smaller
(
length
,
char_length
);
while
(
length
&&
from
[
length
-
1
]
==
' '
)
while
(
length
&&
from
[
length
-
1
]
==
' '
)
length
--
;
length
--
;
*
to
=
(
uchar
)
length
;
if
(
field_length
>
255
)
memcpy
(
to
+
1
,
from
,
length
);
{
return
to
+
1
+
length
;
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
)
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
);
memcpy
(
to
,
from
,
(
int
)
length
);
bfill
(
to
+
length
,
field_length
-
length
,
' '
);
bfill
(
to
+
length
,
field_length
-
length
,
' '
);
return
from
+
length
;
return
from
+
length
;
...
@@ -4419,8 +4439,19 @@ const char *Field_string::unpack(char *to, const char *from)
...
@@ -4419,8 +4439,19 @@ const char *Field_string::unpack(char *to, const char *from)
int
Field_string
::
pack_cmp
(
const
char
*
a
,
const
char
*
b
,
uint
length
)
int
Field_string
::
pack_cmp
(
const
char
*
a
,
const
char
*
b
,
uint
length
)
{
{
uint
a_length
=
(
uint
)
(
uchar
)
*
a
++
;
uint
a_length
,
b_length
;
uint
b_length
=
(
uint
)
(
uchar
)
*
b
++
;
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
,
return
my_strnncoll
(
field_charset
,
(
const
uchar
*
)
a
,
a_length
,
(
const
uchar
*
)
a
,
a_length
,
(
const
uchar
*
)
b
,
b_length
);
(
const
uchar
*
)
b
,
b_length
);
...
@@ -4429,7 +4460,14 @@ int Field_string::pack_cmp(const char *a, const char *b, uint length)
...
@@ -4429,7 +4460,14 @@ int Field_string::pack_cmp(const char *a, const char *b, uint length)
int
Field_string
::
pack_cmp
(
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
;
char
*
end
=
ptr
+
field_length
;
while
(
end
>
ptr
&&
end
[
-
1
]
==
' '
)
while
(
end
>
ptr
&&
end
[
-
1
]
==
' '
)
end
--
;
end
--
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment