List:Internals« Previous MessageNext Message »
From:sanja Date:June 28 2005 8:45pm
Subject:bk commit into 4.1 tree (bell:1.2324) BUG#10269
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of bell. When bell 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
  1.2324 05/06/28 21:45:11 bell@stripped +3 -0
  fixed substring() length calculation in case of constant negative argument (BUG#10269)

  sql/item_strfunc.cc
    1.229 05/06/28 21:44:37 bell@stripped +2 -1
    fixed substring() length calculation in case of constant negative argument

  mysql-test/t/func_str.test
    1.74 05/06/28 21:44:37 bell@stripped +9 -0
    Correct length reporting from substring()

  mysql-test/r/func_str.result
    1.93 05/06/28 21:44:37 bell@stripped +15 -0
    Correct length reporting from substring()

# 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:	bell
# Host:	sanja.is.com.ua
# Root:	/home/bell/mysql/bk/work-bug4-4.1

--- 1.228/sql/item_strfunc.cc	Mon Jun 27 20:30:54 2005
+++ 1.229/sql/item_strfunc.cc	Tue Jun 28 21:44:37 2005
@@ -1065,7 +1065,8 @@
   collation.set(args[0]->collation);
   if (args[1]->const_item())
   {
-    int32 start=(int32) args[1]->val_int()-1;
+    int32 start= (int32) args[1]->val_int();
+    start= (int32)((start < 0) ? max_length + start : start - 1);
     if (start < 0 || start >= (int32) max_length)
       max_length=0; /* purecov: inspected */
     else

--- 1.92/mysql-test/r/func_str.result	Thu Jun 23 16:14:53 2005
+++ 1.93/mysql-test/r/func_str.result	Tue Jun 28 21:44:37 2005
@@ -800,3 +800,18 @@
 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;

--- 1.73/mysql-test/t/func_str.test	Thu Jun 23 16:14:28 2005
+++ 1.74/mysql-test/t/func_str.test	Tue Jun 28 21:44:37 2005
@@ -541,3 +541,12 @@
 SELECT * FROM t1, t2 WHERE num=substring(str from 1 for 6);
 
 DROP TABLE t1,t2;
+
+#
+# Correct length reporting from substring() (BUG#10269)
+#
+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;
+select * from (select *,substring(b,1),substring(b,-1),substring(b,-2),substring(b,-3),substring(b,-4),substring(b,-5) from t1) t;
+drop table t1;
Thread
bk commit into 4.1 tree (bell:1.2324) BUG#10269sanja28 Jun