mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Merge olga.mysql.com:/home/igor/mysql-5.0-opt
into olga.mysql.com:/home/igor/dev-opt/mysql-5.0-opt-bug27130
This commit is contained in:
@ -2137,4 +2137,19 @@ id
|
|||||||
3
|
3
|
||||||
4
|
4
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
SELECT SUBSTR('foo',1,0) FROM DUAL;
|
||||||
|
SUBSTR('foo',1,0)
|
||||||
|
|
||||||
|
SELECT SUBSTR('foo',1,CAST(0 AS SIGNED)) FROM DUAL;
|
||||||
|
SUBSTR('foo',1,CAST(0 AS SIGNED))
|
||||||
|
|
||||||
|
SELECT SUBSTR('foo',1,CAST(0 AS UNSIGNED)) FROM DUAL;
|
||||||
|
SUBSTR('foo',1,CAST(0 AS UNSIGNED))
|
||||||
|
|
||||||
|
CREATE TABLE t1 (a varchar(10), len int unsigned);
|
||||||
|
INSERT INTO t1 VALUES ('bar', 2), ('foo', 0);
|
||||||
|
SELECT SUBSTR(a,1,len) FROM t1;
|
||||||
|
SUBSTR(a,1,len)
|
||||||
|
ba
|
||||||
|
DROP TABLE t1;
|
||||||
End of 5.0 tests
|
End of 5.0 tests
|
||||||
|
@ -1109,4 +1109,19 @@ SELECT id FROM t1 WHERE LOCATE(a,p) <=> NULL;
|
|||||||
|
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Bug #27130: SUBSTR with UNSIGNED 0 as the last argument
|
||||||
|
#
|
||||||
|
|
||||||
|
SELECT SUBSTR('foo',1,0) FROM DUAL;
|
||||||
|
SELECT SUBSTR('foo',1,CAST(0 AS SIGNED)) FROM DUAL;
|
||||||
|
SELECT SUBSTR('foo',1,CAST(0 AS UNSIGNED)) FROM DUAL;
|
||||||
|
|
||||||
|
CREATE TABLE t1 (a varchar(10), len int unsigned);
|
||||||
|
INSERT INTO t1 VALUES ('bar', 2), ('foo', 0);
|
||||||
|
|
||||||
|
SELECT SUBSTR(a,1,len) FROM t1;
|
||||||
|
|
||||||
|
DROP TABLE t1;
|
||||||
|
|
||||||
--echo End of 5.0 tests
|
--echo End of 5.0 tests
|
||||||
|
@ -1145,8 +1145,9 @@ String *Item_func_substr::val_str(String *str)
|
|||||||
(arg_count == 3 && args[2]->null_value))))
|
(arg_count == 3 && args[2]->null_value))))
|
||||||
return 0; /* purecov: inspected */
|
return 0; /* purecov: inspected */
|
||||||
|
|
||||||
/* Negative length, will return empty string. */
|
/* Negative or zero length, will return empty string. */
|
||||||
if ((arg_count == 3) && (length <= 0) && !args[2]->unsigned_flag)
|
if ((arg_count == 3) && (length <= 0) &&
|
||||||
|
(length == 0 || !args[2]->unsigned_flag))
|
||||||
return &my_empty_string;
|
return &my_empty_string;
|
||||||
|
|
||||||
/* Assumes that the maximum length of a String is < INT_MAX32. */
|
/* Assumes that the maximum length of a String is < INT_MAX32. */
|
||||||
|
Reference in New Issue
Block a user