List:Commits« Previous MessageNext Message »
From:ramil Date:June 26 2007 11:26am
Subject:bk commit into 5.1 tree (ramil:1.2510) BUG#29353
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 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-06-26 16:26:32+05:00, ramil@stripped +3 -0
  Fix for bug #29353: inserting a negative value to a csv table leads to the table corruption
  
  Problem: we believe a number cannot start with '-' ['+'] sign reading rows.
  
  Fix: properly handle starting '-' and '+' signs that may occur before numbers.

  mysql-test/r/csv.result@stripped, 2007-06-26 16:26:31+05:00, ramil@stripped +13 -0
    Fix for bug #29353: inserting a negative value to a csv table leads to the table corruption
      - test result.

  mysql-test/t/csv.test@stripped, 2007-06-26 16:26:31+05:00, ramil@stripped +11 -0
    Fix for bug #29353: inserting a negative value to a csv table leads to the table corruption
      - test case.

  storage/csv/ha_tina.cc@stripped, 2007-06-26 16:26:31+05:00, ramil@stripped +36 -24
    Fix for bug #29353: inserting a negative value to a csv table leads to the table corruption
      - handle '-' and '+' sings before numbers.

# 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/b29353/b29353.5.1

--- 1.19/mysql-test/r/csv.result	2007-06-26 16:26:36 +05:00
+++ 1.20/mysql-test/r/csv.result	2007-06-26 16:26:36 +05:00
@@ -5261,3 +5261,16 @@ CREATE TABLE `bug21328` (
 insert into bug21328 values (1,NULL,NULL);
 alter table bug21328 engine=myisam;
 drop table bug21328;
+create table t1(a int) engine=csv;
+insert into t1 values(-1), (-123.34), (2), (-23);
+select * from t1;
+a
+-1
+-123
+2
+-23
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	status	OK
+drop table t1;
+End of 5.1 tests

--- 1.24/mysql-test/t/csv.test	2007-06-26 16:26:36 +05:00
+++ 1.25/mysql-test/t/csv.test	2007-06-26 16:26:36 +05:00
@@ -1674,3 +1674,14 @@ CREATE TABLE `bug21328` (
 insert into bug21328 values (1,NULL,NULL);
 alter table bug21328 engine=myisam;
 drop table bug21328;
+
+#
+# Bug #29353: negative values
+#
+create table t1(a int) engine=csv;
+insert into t1 values(-1), (-123.34), (2), (-23);
+select * from t1;
+check table t1;
+drop table t1;
+
+--echo End of 5.1 tests

--- 1.78/storage/csv/ha_tina.cc	2007-06-26 16:26:36 +05:00
+++ 1.79/storage/csv/ha_tina.cc	2007-06-26 16:26:36 +05:00
@@ -609,37 +609,41 @@ int ha_tina::find_current_row(uchar *buf
 
   for (Field **field=table->field ; *field ; field++)
   {
+    char curr_char;
+    
     buffer.length(0);
-    if (curr_offset < end_offset &&
-        file_buff->get_value(curr_offset) == '"')
+    if (curr_offset >= end_offset)
+      goto err;
+    curr_char= file_buff->get_value(curr_offset);
+    if (curr_char == '"')
     {
       curr_offset++; // Incrementpast the first quote
 
-      for(;curr_offset < end_offset; curr_offset++)
+      for(; curr_offset < end_offset; curr_offset++)
       {
+        curr_char= file_buff->get_value(curr_offset);
         // Need to convert line feeds!
-        if (file_buff->get_value(curr_offset) == '"' &&
-            ((file_buff->get_value(curr_offset + 1) == ',') ||
-             (curr_offset == end_offset -1 )))
+        if (curr_char == '"' &&
+            (curr_offset == end_offset - 1 ||
+             file_buff->get_value(curr_offset + 1) == ','))
         {
           curr_offset+= 2; // Move past the , and the "
           break;
         }
-        if (file_buff->get_value(curr_offset) == '\\' &&
-            curr_offset != (end_offset - 1))
+        if (curr_char == '\\' && curr_offset != (end_offset - 1))
         {
           curr_offset++;
-          if (file_buff->get_value(curr_offset) == 'r')
+          curr_char= file_buff->get_value(curr_offset);
+          if (curr_char == 'r')
             buffer.append('\r');
-          else if (file_buff->get_value(curr_offset) == 'n' )
+          else if (curr_char == 'n' )
             buffer.append('\n');
-          else if ((file_buff->get_value(curr_offset) == '\\') ||
-                   (file_buff->get_value(curr_offset) == '"'))
-            buffer.append(file_buff->get_value(curr_offset));
+          else if (curr_char == '\\' || curr_char == '"')
+            buffer.append(curr_char);
           else  /* This could only happed with an externally created file */
           {
             buffer.append('\\');
-            buffer.append(file_buff->get_value(curr_offset));
+            buffer.append(curr_char);
           }
         }
         else // ordinary symbol
@@ -650,25 +654,33 @@ int ha_tina::find_current_row(uchar *buf
           */
           if (curr_offset == end_offset - 1)
             goto err;
-          buffer.append(file_buff->get_value(curr_offset));
+          buffer.append(curr_char);
         }
       }
     }
-    else if (my_isdigit(system_charset_info, 
-                        file_buff->get_value(curr_offset))) 
+    else if (my_isdigit(system_charset_info, curr_char) ||
+             curr_char == '-' ||
+             curr_char == '+') 
     {
-      for(;curr_offset < end_offset; curr_offset++)
+      /* Check if there is a sign not followed by a digit */
+      if (!my_isdigit(system_charset_info, curr_char) &&
+          (curr_offset == end_offset - 1 ||
+           !my_isdigit(system_charset_info,
+                       file_buff->get_value(curr_offset + 1))))
+        goto err;
+      buffer.append(curr_char);
+      curr_offset++;
+      for(; curr_offset < end_offset; curr_offset++)
       {
-        if (file_buff->get_value(curr_offset) == ',')
+        curr_char= file_buff->get_value(curr_offset);
+        if (curr_char == ',')
         {
-          curr_offset+= 1; // Move past the ,
+          curr_offset++; // Move past the ,
           break;
         }
 
-        if (my_isdigit(system_charset_info, file_buff->get_value(curr_offset))) 
-          buffer.append(file_buff->get_value(curr_offset));
-        else if (file_buff->get_value(curr_offset) == '.')
-          buffer.append(file_buff->get_value(curr_offset));
+        if (my_isdigit(system_charset_info, curr_char)  || curr_char == '.')
+          buffer.append(curr_char);
         else
           goto err;
       }
Thread
bk commit into 5.1 tree (ramil:1.2510) BUG#29353ramil26 Jun