Below is the list of changes that have just been committed into a local
5.0 repository of igor. When igor does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-06-16 18:12:29-07:00, igor@stripped +3 -0
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@stripped, 2007-06-16 18:12:27-07:00, igor@stripped +16 -0
Added a test case for bug #27130.
mysql-test/t/func_str.test@stripped, 2007-06-16 18:12:27-07:00, igor@stripped +15 -0
Added a test case for bug #27130.
sql/item_strfunc.cc@stripped, 2007-06-16 18:12:27-07:00, igor@stripped +2 -1
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.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: igor
# Host: olga.mysql.com
# Root: /home/igor/dev-opt/mysql-5.0-opt-bug27130
--- 1.302/sql/item_strfunc.cc 2007-06-16 18:12:36 -07:00
+++ 1.303/sql/item_strfunc.cc 2007-06-16 18:12:36 -07:00
@@ -1146,7 +1146,8 @@
return 0; /* purecov: inspected */
/* Negative 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;
/* Assumes that the maximum length of a String is < INT_MAX32. */
--- 1.133/mysql-test/r/func_str.result 2007-06-16 18:12:36 -07:00
+++ 1.134/mysql-test/r/func_str.result 2007-06-16 18:12:36 -07:00
@@ -2061,4 +2061,20 @@
2707236321
DROP TABLE t1, t2;
DROP VIEW v1;
+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
--- 1.105/mysql-test/t/func_str.test 2007-06-16 18:12:36 -07:00
+++ 1.106/mysql-test/t/func_str.test 2007-06-16 18:12:36 -07:00
@@ -1076,4 +1076,19 @@
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
| Thread |
|---|
| • bk commit into 5.0 tree (igor:1.2522) BUG#27130 | igor | 17 Jun |