MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Jim Winstead Date:June 26 2006 11:59pm
Subject:bk commit into 5.0 tree (jimw:1.2200) BUG#16494
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of jimw. When jimw 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.2200 06/06/26 16:59:52 jimw@stripped +3 -0
  Bug #16494: Updates that set a column to NULL fail sometimes
  
   When building the UPDATE query to send to the remote server, the
   federated storage engine built the query incorrectly if it was updating
   a field to be NULL.
  

  sql/ha_federated.cc
    1.61 06/06/26 16:59:49 jimw@stripped +7 -10
    Fix logic of how fields are added to SET and WHERE clauses of an
    UPDATE statement. Fields that were NULL were being handled incorrectly.
    Also reorganizes the code a little bit so the update of the two
    clauses is consistent.

  mysql-test/t/federated.test
    1.23 06/06/26 16:59:49 jimw@stripped +17 -0
    Add new regression test

  mysql-test/r/federated.result
    1.27 06/06/26 16:59:49 jimw@stripped +16 -0
    Add new results

# 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:	jimw
# Host:	rama.(none)
# Root:	/home/jimw/my/mysql-5.0-16494

--- 1.26/mysql-test/r/federated.result	2006-02-28 02:17:35 -08:00
+++ 1.27/mysql-test/r/federated.result	2006-06-26 16:59:49 -07:00
@@ -1601,6 +1601,22 @@ fld_cid	fld_name	fld_parentid	fld_delt
 5	Torkel	0	0
 DROP TABLE federated.t1;
 DROP TABLE federated.bug_17377_table;
+create table t1 (id int not null auto_increment primary key, val int);
+create table t1
+(id int not null auto_increment primary key, val int) engine=federated
+connection='mysql://root@stripped:9308/test/t1';
+insert into t1 values (1,0),(2,0);
+update t1 set val = NULL where id = 1;
+select * from t1;
+id	val
+1	NULL
+2	0
+select * from t1;
+id	val
+1	NULL
+2	0
+drop table t1;
+drop table t1;
 DROP TABLE IF EXISTS federated.t1;
 DROP DATABASE IF EXISTS federated;
 DROP TABLE IF EXISTS federated.t1;

--- 1.22/mysql-test/t/federated.test	2006-02-28 02:17:35 -08:00
+++ 1.23/mysql-test/t/federated.test	2006-06-26 16:59:49 -07:00
@@ -1309,5 +1309,22 @@ DROP TABLE federated.t1;
 connection slave;
 DROP TABLE federated.bug_17377_table;
 
+#
+# Bug #16494: Updates that set a column to NULL fail sometimes
+#
+connection slave;
+create table t1 (id int not null auto_increment primary key, val int);
+connection master;
+eval create table t1
+  (id int not null auto_increment primary key, val int) engine=federated
+  connection='mysql://root@stripped:$SLAVE_MYPORT/test/t1';
+insert into t1 values (1,0),(2,0);
+update t1 set val = NULL where id = 1;
+select * from t1;
+connection slave;
+select * from t1;
+drop table t1;
+connection master;
+drop table t1;
 
 source include/federated_cleanup.inc;

--- 1.60/sql/ha_federated.cc	2006-02-28 02:17:35 -08:00
+++ 1.61/sql/ha_federated.cc	2006-06-26 16:59:49 -07:00
@@ -1857,8 +1857,8 @@ int ha_federated::update_row(const byte 
   In this loop, we want to match column names to values being inserted
   (while building INSERT statement).
 
-  Iterate through table->field (new data) and share->old_filed (old_data)
-  using the same index to created an SQL UPDATE statement, new data is
+  Iterate through table->field (new data) and share->old_field (old_data)
+  using the same index to create an SQL UPDATE statement. New data is
   used to create SET field=value and old data is used to create WHERE
   field=oldvalue
  */
@@ -1870,30 +1870,28 @@ int ha_federated::update_row(const byte 
     update_string.append(FEDERATED_EQ);
 
     if ((*field)->is_null())
-      new_field_value.append(FEDERATED_NULL);
+      update_string.append(FEDERATED_NULL);
     else
     {
       /* otherwise = */
       (*field)->val_str(&new_field_value);
       (*field)->quote_data(&new_field_value);
-
-      if (!field_in_record_is_null(table, *field, (char*) old_data))
-        where_string.append(FEDERATED_EQ);
+      update_string.append(new_field_value);
+      new_field_value.length(0);
     }
 
     if (field_in_record_is_null(table, *field, (char*) old_data))
       where_string.append(FEDERATED_ISNULL);
     else
     {
+      where_string.append(FEDERATED_EQ);
       (*field)->val_str(&old_field_value,
                         (char*) (old_data + (*field)->offset()));
       (*field)->quote_data(&old_field_value);
       where_string.append(old_field_value);
+      old_field_value.length(0);
     }
 
-    update_string.append(new_field_value);
-    new_field_value.length(0);
-
     /*
       Only append conjunctions if we have another field in which
       to iterate
@@ -1903,7 +1901,6 @@ int ha_federated::update_row(const byte 
       update_string.append(FEDERATED_COMMA);
       where_string.append(FEDERATED_AND);
     }
-    old_field_value.length(0);
   }
   update_string.append(FEDERATED_WHERE);
   update_string.append(where_string);
Thread
bk commit into 5.0 tree (jimw:1.2200) BUG#16494Jim Winstead27 Jun