List:Internals« Previous MessageNext Message »
From:holyfoot Date:September 4 2005 4:00pm
Subject:bk commit into 5.0 tree (hf:1.1954) BUG#12938
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of hf. When hf 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.1954 05/09/04 21:00:00 hf@deer.(none) +3 -0
  Fix for bug #12938 (decimal arithmetic in the loop fails)

  strings/decimal.c
    1.61 05/09/04 20:59:55 hf@deer.(none) +15 -1
    code to cut heading zeroes off the result of the multiplication added

  mysql-test/t/type_newdecimal.test
    1.28 05/09/04 20:59:55 hf@deer.(none) +22 -0
    test case added

  mysql-test/r/type_newdecimal.result
    1.28 05/09/04 20:59:55 hf@deer.(none) +32 -0
    test result fixed

# 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:	hf
# Host:	deer.(none)
# Root:	/home/hf/work/mysql-5.0.12938

--- 1.27/mysql-test/r/type_newdecimal.result	Thu Sep  1 20:04:15 2005
+++ 1.28/mysql-test/r/type_newdecimal.result	Sun Sep  4 20:59:55 2005
@@ -984,3 +984,35 @@
   `f1` decimal(10,0) unsigned zerofill NOT NULL default '0000000000'
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
 drop table t1;
+drop procedure if exists wg2;
+Warnings:
+Note	1305	PROCEDURE wg2 does not exist
+create procedure wg2()
+begin
+declare v int default 1;
+declare tdec decimal(5) default 0;
+while v <= 9 do set tdec =tdec * 10;
+select v, tdec;
+set v = v + 1;
+end while;
+end//
+call wg2()//
+v	tdec
+1	0
+v	tdec
+2	0
+v	tdec
+3	0
+v	tdec
+4	0
+v	tdec
+5	0
+v	tdec
+6	0
+v	tdec
+7	0
+v	tdec
+8	0
+v	tdec
+9	0
+drop procedure wg2;

--- 1.27/mysql-test/t/type_newdecimal.test	Thu Sep  1 20:04:16 2005
+++ 1.28/mysql-test/t/type_newdecimal.test	Sun Sep  4 20:59:55 2005
@@ -1015,3 +1015,25 @@
         f1 decimal (0,0) zerofill not null default 0);
 show create table t1;
 drop table t1;
+
+#
+# Bug 12938 (arithmetic loop's zero)
+#
+--disable-warnings
+drop procedure if exists wg2;
+--enable-warnings
+delimiter //;
+create procedure wg2()
+begin
+  declare v int default 1;
+  declare tdec decimal(5) default 0;
+  while v <= 9 do set tdec =tdec * 10;
+    select v, tdec;
+    set v = v + 1;
+  end while;
+end//
+
+call wg2()//
+
+delimiter ;//
+drop procedure wg2;

--- 1.60/strings/decimal.c	Fri Jul 29 14:38:05 2005
+++ 1.61/strings/decimal.c	Sun Sep  4 20:59:55 2005
@@ -1933,7 +1933,7 @@
   int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
       frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac),
       intg0=ROUND_UP(from1->intg+from2->intg),
-      frac0=frac1+frac2, error, i, j;
+      frac0=frac1+frac2, error, i, j, d_to_move;
   dec1 *buf1=from1->buf+intg1, *buf2=from2->buf+intg2, *buf0,
        *start2, *stop2, *stop1, *start0, carry;
 
@@ -2006,6 +2006,20 @@
         break;
       }
     }
+  }
+  buf1= to->buf;
+  d_to_move= intg0 + ROUND_UP(to->frac);
+  while (!*buf1 && (to->intg > DIG_PER_DEC1))
+  {
+    buf1++;
+    to->intg-= DIG_PER_DEC1;
+    d_to_move--;
+  }
+  if (to->buf < buf1)
+  {
+    dec1 *cur_d= to->buf;
+    for (; d_to_move; d_to_move--, cur_d++, buf1++)
+      *cur_d= *buf1;
   }
   return error;
 }
Thread
bk commit into 5.0 tree (hf:1.1954) BUG#12938holyfoot4 Sep