1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-07 06:01:31 +03:00

fixed substring() length calculation in case of constant negative argument (BUG#10269)

mysql-test/r/func_str.result:
  Correct length reporting from substring()
mysql-test/t/func_str.test:
  Correct length reporting from substring()
sql/item_strfunc.cc:
  fixed substring() length calculation in case of constant negative argument
This commit is contained in:
unknown
2005-06-28 21:45:11 +03:00
parent dadf91f0ff
commit 2637338014
3 changed files with 26 additions and 1 deletions

View File

@ -800,3 +800,18 @@ SELECT * FROM t1, t2 WHERE num=substring(str from 1 for 6);
str num
notnumber 0
DROP TABLE t1,t2;
create table t1 (b varchar(5));
insert t1 values ('ab'), ('abc'), ('abcd'), ('abcde');
select *,substring(b,1),substring(b,-1),substring(b,-2),substring(b,-3),substring(b,-4),substring(b,-5) from t1;
b substring(b,1) substring(b,-1) substring(b,-2) substring(b,-3) substring(b,-4) substring(b,-5)
ab ab b ab
abc abc c bc abc
abcd abcd d cd bcd abcd
abcde abcde e de cde bcde abcde
select * from (select *,substring(b,1),substring(b,-1),substring(b,-2),substring(b,-3),substring(b,-4),substring(b,-5) from t1) t;
b substring(b,1) substring(b,-1) substring(b,-2) substring(b,-3) substring(b,-4) substring(b,-5)
ab ab b ab
abc abc c bc abc
abcd abcd d cd bcd abcd
abcde abcde e de cde bcde abcde
drop table t1;