Commit 8a5c6502 authored by bar@noter.(none)'s avatar bar@noter.(none)

bug#10344: some string function fail for UCS2

substr fix
parent b580a12d
......@@ -598,6 +598,24 @@ ucs2_bin 00610009
ucs2_bin 0061
ucs2_bin 00610020
drop table t1;
select hex(substr(_ucs2 0x00e400e50068,1));
hex(substr(_ucs2 0x00e400e50068,1))
00E400E50068
select hex(substr(_ucs2 0x00e400e50068,2));
hex(substr(_ucs2 0x00e400e50068,2))
00E50068
select hex(substr(_ucs2 0x00e400e50068,3));
hex(substr(_ucs2 0x00e400e50068,3))
0068
select hex(substr(_ucs2 0x00e400e50068,-1));
hex(substr(_ucs2 0x00e400e50068,-1))
0068
select hex(substr(_ucs2 0x00e400e50068,-2));
hex(substr(_ucs2 0x00e400e50068,-2))
00E50068
select hex(substr(_ucs2 0x00e400e50068,-3));
hex(substr(_ucs2 0x00e400e50068,-3))
00E400E50068
SET NAMES latin1;
SET collation_connection='ucs2_swedish_ci';
CREATE TABLE t1 (Field1 int(10) default '0');
......
......@@ -374,6 +374,16 @@ SET NAMES latin1;
SET collation_connection='ucs2_bin';
-- source include/ctype_filesort.inc
#
# Bug#10344 Some string functions fail for UCS2
#
select hex(substr(_ucs2 0x00e400e50068,1));
select hex(substr(_ucs2 0x00e400e50068,2));
select hex(substr(_ucs2 0x00e400e50068,3));
select hex(substr(_ucs2 0x00e400e50068,-1));
select hex(substr(_ucs2 0x00e400e50068,-2));
select hex(substr(_ucs2 0x00e400e50068,-3));
SET NAMES latin1;
#
# Bug#8235
......
......@@ -1261,7 +1261,7 @@ uint my_charpos_ucs2(CHARSET_INFO *cs __attribute__((unused)),
const char *e __attribute__((unused)),
uint pos)
{
return pos*2;
return pos > e - b ? e - b + 2 : pos * 2;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment