From a07b055b9ab75b54e9df33bb7634bde22543e8f1 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 17 Jun 2007 11:23:19 -0700 Subject: Fixed bug #27130. If the third argument of the function SUBSTR was represented by an expression of the type UNSIGNED INT and this expression was evaluated to 0 then the function erroneously returned the value of the first argument instead of an empty string. This problem was introduced by the patch for bug 10963. The problem has been resolved by a proper modification of the code of Item_func_substr::val_str. mysql-test/r/func_str.result: Added a test case for bug #27130. mysql-test/t/func_str.test: Added a test case for bug #27130. --- mysql-test/t/func_str.test | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'mysql-test/t/func_str.test') diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index bca977e6df3..012e6be2868 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -1076,4 +1076,19 @@ SELECT * FROM (SELECT * FROM v1) x; DROP TABLE t1, t2; DROP VIEW v1; +# +# 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 -- cgit v1.2.1