mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
SUBSTR with negative argument didn't work
with multi-byte strings, length() instead of numchars() where used in a mistake.
This commit is contained in:
@ -817,6 +817,9 @@ drop table t1;
|
|||||||
select 'c' like '\_' as want0;
|
select 'c' like '\_' as want0;
|
||||||
want0
|
want0
|
||||||
0
|
0
|
||||||
|
SELECT SUBSTR('вася',-2);
|
||||||
|
SUBSTR('вася',-2)
|
||||||
|
ся
|
||||||
create table t1 (id integer, a varchar(100) character set utf8 collate utf8_unicode_ci);
|
create table t1 (id integer, a varchar(100) character set utf8 collate utf8_unicode_ci);
|
||||||
insert into t1 values (1, 'Test');
|
insert into t1 values (1, 'Test');
|
||||||
select * from t1 where soundex(a) = soundex('Test');
|
select * from t1 where soundex(a) = soundex('Test');
|
||||||
|
@ -666,6 +666,12 @@ drop table t1;
|
|||||||
#
|
#
|
||||||
select 'c' like '\_' as want0;
|
select 'c' like '\_' as want0;
|
||||||
|
|
||||||
|
#
|
||||||
|
# SUBSTR with negative offset didn't work with multi-byte strings
|
||||||
|
#
|
||||||
|
SELECT SUBSTR('вася',-2);
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Bug #7730 Server crash using soundex on an utf8 table
|
# Bug #7730 Server crash using soundex on an utf8 table
|
||||||
#
|
#
|
||||||
|
@ -1023,7 +1023,7 @@ String *Item_func_substr::val_str(String *str)
|
|||||||
if ((null_value=(args[0]->null_value || args[1]->null_value ||
|
if ((null_value=(args[0]->null_value || args[1]->null_value ||
|
||||||
(arg_count == 3 && args[2]->null_value))))
|
(arg_count == 3 && args[2]->null_value))))
|
||||||
return 0; /* purecov: inspected */
|
return 0; /* purecov: inspected */
|
||||||
start= (int32)((start < 0) ? res->length() + start : start -1);
|
start= (int32)((start < 0) ? res->numchars() + start : start -1);
|
||||||
start=res->charpos(start);
|
start=res->charpos(start);
|
||||||
length=res->charpos(length,start);
|
length=res->charpos(length,start);
|
||||||
if (start < 0 || (uint) start+1 > res->length() || length <= 0)
|
if (start < 0 || (uint) start+1 > res->length() || length <= 0)
|
||||||
|
Reference in New Issue
Block a user