List:Commits« Previous MessageNext Message »
From:Alexander Nozdrin Date:May 5 2010 11:02am
Subject:bzr push into mysql-trunk-bugfixing branch (alik:3034 to 3035)
Bug#50511
View as plain text  
 3035 Alexander Nozdrin	2010-05-05
      Patch for Bug#50511 (Sometimes wrong handling of user variables containing NULL).
            
      The bug happened under the following condition:
        - there was a user variable of type REAL, containing NULL value
        - there was a table with a NOT_NULL column of any type but REAL, having
          default value (or auto increment);
        - a row was inserted into the table with the user variable as value.
          A warning was emitted here.
      
      The problem was that handling of NULL values of REAL type was not properly
      implemented: it didn't expect that REAL NULL value can be assigned to other
      data type.
      
      Basically, the problem was that set_field_to_null() was used instead of
      set_field_to_null_with_conversions().
      
      The fix is to use the right function, or more generally, to allow conversion of
      REAL NULL values to other data types.

    modified:
      mysql-test/r/null.result
      mysql-test/r/user_var.result
      mysql-test/t/user_var.test
      sql/item.cc
 3034 Alexander Barkov	2010-05-05
       Bug#51571 load xml infile causes server crash
        
        Problem:
        item->name was NULL for Item_user_var_as_out_param
        which made strcmp(something, item->name) crash in the LOAD XML code.
        
        Fix:
        - item_func.h: Adding set_name() in constuctor for Item_user_var_as_out_param
        - sql_load.cc: Changing the condition in write_execute_load_query_log_event() which
        distiguished between Item_user_var_as_out_param and Item_field
        from
          if (item->name == NULL)
        to
          if (item->type() == Item::FIELD_ITEM)
        - loadxml.result, loadxml.test: adding tests

    modified:
      mysql-test/r/loadxml.result
      mysql-test/t/loadxml.test
      sql/item_func.h
      sql/sql_load.cc
=== modified file 'mysql-test/r/null.result'
--- a/mysql-test/r/null.result	2009-02-05 09:49:32 +0000
+++ b/mysql-test/r/null.result	2010-05-05 11:00:59 +0000
@@ -94,7 +94,7 @@ Warnings:
 Warning	1265	Data truncated for column 'd' at row 1
 UPDATE t1 SET d=1/NULL;
 Warnings:
-Warning	1265	Data truncated for column 'd' at row 1
+Warning	1048	Column 'd' cannot be null
 UPDATE t1 SET d=NULL;
 Warnings:
 Warning	1048	Column 'd' cannot be null

=== modified file 'mysql-test/r/user_var.result'
--- a/mysql-test/r/user_var.result	2010-01-19 16:36:14 +0000
+++ b/mysql-test/r/user_var.result	2010-05-05 11:00:59 +0000
@@ -429,3 +429,34 @@ INSERT INTO t1 VALUES (1);
 INSERT INTO t1 VALUES (1);
 DROP TABLE t1;
 End of 5.1 tests
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1(f1 INT AUTO_INCREMENT, PRIMARY KEY(f1));
+INSERT INTO t1 SET f1 = NULL ;
+SET @aux = NULL ;
+INSERT INTO t1 SET f1 = @aux ;
+SET @aux1 = 0.123E-1;
+SET @aux1 = NULL;
+INSERT INTO t1 SET f1 = @aux1 ;
+SELECT * FROM t1;
+f1
+1
+2
+3
+DROP TABLE t1;
+CREATE TABLE t1(f1 VARCHAR(257) , f2 INT, PRIMARY KEY(f2));
+CREATE TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW SET @aux = 1;
+SET @aux = 1;
+SET @aux = NULL;
+INSERT INTO test.t1 (f1, f2) VALUES (1, 1), (@aux, 2);
+SET @aux = 'text';
+SET @aux = NULL;
+INSERT INTO t1(f1, f2) VALUES (1, 3), (@aux, 4);
+SELECT f1, f2 FROM t1 ORDER BY f2;
+f1	f2
+1	1
+1	2
+1	3
+1	4
+DROP TRIGGER trg1;
+DROP TABLE t1;
+End of 5.5 tests

=== modified file 'mysql-test/t/user_var.test'
--- a/mysql-test/t/user_var.test	2010-01-19 16:36:14 +0000
+++ b/mysql-test/t/user_var.test	2010-05-05 11:00:59 +0000
@@ -327,3 +327,44 @@ INSERT INTO t1 VALUES (1);
 DROP TABLE t1;
 
 --echo End of 5.1 tests
+
+#
+# Bug#50511: Sometimes wrong handling of user variables containing NULL.
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1(f1 INT AUTO_INCREMENT, PRIMARY KEY(f1));
+
+INSERT INTO t1 SET f1 = NULL ;
+
+SET @aux = NULL ;
+INSERT INTO t1 SET f1 = @aux ;
+
+SET @aux1 = 0.123E-1;
+SET @aux1 = NULL;
+INSERT INTO t1 SET f1 = @aux1 ;
+
+SELECT * FROM t1;
+
+DROP TABLE t1;
+
+CREATE TABLE t1(f1 VARCHAR(257) , f2 INT, PRIMARY KEY(f2));
+CREATE TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW SET @aux = 1;
+
+SET @aux = 1; # INT
+SET @aux = NULL;
+INSERT INTO test.t1 (f1, f2) VALUES (1, 1), (@aux, 2);
+
+SET @aux = 'text'; # STRING
+SET @aux = NULL;
+INSERT INTO t1(f1, f2) VALUES (1, 3), (@aux, 4);
+
+SELECT f1, f2 FROM t1 ORDER BY f2;
+
+DROP TRIGGER trg1;
+DROP TABLE t1;
+
+--echo End of 5.5 tests

=== modified file 'sql/item.cc'
--- a/sql/item.cc	2010-05-05 09:28:37 +0000
+++ b/sql/item.cc	2010-05-05 11:00:59 +0000
@@ -5423,7 +5423,7 @@ int Item::save_in_field(Field *field, bo
   {
     double nr= val_real();
     if (null_value)
-      return set_field_to_null(field);
+      return set_field_to_null_with_conversions(field, no_conversions);
     field->set_notnull();
     error=field->store(nr);
   }


Attachment: [text/bzr-bundle] bzr/alik@sun.com-20100505110059-92tpnjfagry0374x.bundle
Thread
bzr push into mysql-trunk-bugfixing branch (alik:3034 to 3035)Bug#50511Alexander Nozdrin5 May