MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:ramil Date:March 15 2007 8:06am
Subject:bk commit into 5.0 tree (ramil:1.2466) BUG#24558
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of ram. When ram 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-03-15 12:06:06+04:00, ramil@stripped +3 -0
  Fix for bug #24558: Increasing decimal column length causes data loss
  
  Altering to a decimal field we get double value then store it 
  that may cause data loss. 
  Fix: use store_decimal() instead.
  

  mysql-test/r/type_newdecimal.result@stripped, 2007-03-15 12:06:05+04:00, ramil@stripped +8 -0
    Fix for bug #24558: Increasing decimal column length causes data loss
      - test result.

  mysql-test/t/type_newdecimal.test@stripped, 2007-03-15 12:06:05+04:00, ramil@stripped +11 -0
    Fix for bug #24558: Increasing decimal column length causes data loss
      - test case.

  sql/field_conv.cc@stripped, 2007-03-15 12:06:05+04:00, ramil@stripped +9 -0
    Fix for bug #24558: Increasing decimal column length causes data loss
      - if target field's result type is DECIMAL_RESULT
        use store_decimal(val_decimal()) in order not to loss data.

# 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:	ramil
# Host:	ramil.myoffice.izhnet.ru
# Root:	/home/ram/work/b24558/b24558.5.0

--- 1.61/sql/field_conv.cc	2007-03-15 12:06:11 +04:00
+++ 1.62/sql/field_conv.cc	2007-03-15 12:06:11 +04:00
@@ -337,6 +337,13 @@ static void do_field_real(Copy_field *co
 }
 
 
+static void do_field_decimal(Copy_field *copy)
+{
+  my_decimal value;
+  copy->to_field->store_decimal(copy->from_field->val_decimal(&value));
+}
+
+
 /*
   string copy for single byte characters set when to string is shorter than
   from string
@@ -581,6 +588,8 @@ void (*Copy_field::get_copy_func(Field *
     if (to->real_type() == FIELD_TYPE_BIT ||
         from->real_type() == FIELD_TYPE_BIT)
       return do_field_int;
+    if (to->result_type() == DECIMAL_RESULT)
+      return do_field_decimal;
     // Check if identical fields
     if (from->result_type() == STRING_RESULT)
     {

--- 1.43/mysql-test/r/type_newdecimal.result	2007-03-15 12:06:11 +04:00
+++ 1.44/mysql-test/r/type_newdecimal.result	2007-03-15 12:06:11 +04:00
@@ -1423,3 +1423,11 @@ cast(19999999999999999999 as unsigned)
 18446744073709551615
 Warnings:
 Error	1292	Truncated incorrect DECIMAL value: ''
+create table t1(a decimal(18));
+insert into t1 values(123456789012345678);
+alter table t1 modify column a decimal(19);
+select * from t1;
+a
+123456789012345678
+drop table t1;
+End of 5.0 tests

--- 1.42/mysql-test/t/type_newdecimal.test	2007-03-15 12:06:11 +04:00
+++ 1.43/mysql-test/t/type_newdecimal.test	2007-03-15 12:06:11 +04:00
@@ -1120,3 +1120,14 @@ drop table t1;
 #
 select cast(19999999999999999999 as unsigned);
 
+#
+# Bug #24558: Increasing decimal column length causes data loss
+#
+
+create table t1(a decimal(18));
+insert into t1 values(123456789012345678);
+alter table t1 modify column a decimal(19);
+select * from t1;
+drop table t1;
+
+--echo End of 5.0 tests
Thread
bk commit into 5.0 tree (ramil:1.2466) BUG#24558ramil15 Mar