List:Commits« Previous MessageNext Message »
From:knielsen Date:December 10 2007 11:43am
Subject:bk commit into 5.1 tree (knielsen:1.2582) BUG#22045
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of knielsen. When knielsen 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-12-10 11:42:45+01:00, knielsen@ymer.(none) +3 -0
  BUG#22045: Got error 839 'Illegal null attribute' from NDBCLUSTER when 'Replace Into'
  
  Temporary workaround/fix for REPLACE INTO in NDB with partial column
  list.
  
  REPLACE INTO with partial column list expects handler::write_row() to
  overwrite columns not in write_set() with default values.
  
  However, NDB replication expects handler::write_row() to leave columns
  not in write_set alone.
  
  Replication team is working to resolve this inconsistency. This is a
  temporary work-around that implements different semantics based on
  whether running in slave SQL thread or not.

  mysql-test/suite/ndb/r/ndb_replace.result@stripped, 2007-12-10 11:42:37+01:00,
knielsen@ymer.(none) +38 -0
    Test case.

  mysql-test/suite/ndb/t/ndb_replace.test@stripped, 2007-12-10 11:42:37+01:00,
knielsen@ymer.(none) +30 -0
    Test case.

  sql/ha_ndbcluster.cc@stripped, 2007-12-10 11:42:38+01:00, knielsen@ymer.(none) +16 -1
    Different write_set semantics for slave SQL thread and normal threads.

diff -Nrup a/mysql-test/suite/ndb/r/ndb_replace.result
b/mysql-test/suite/ndb/r/ndb_replace.result
--- a/mysql-test/suite/ndb/r/ndb_replace.result	2007-06-27 14:27:24 +02:00
+++ b/mysql-test/suite/ndb/r/ndb_replace.result	2007-12-10 11:42:37 +01:00
@@ -97,3 +97,41 @@ pk	apk	data
 4	1	NULL
 drop table t1;
 End of 5.0 tests.
+CREATE TABLE t1(c1 INT NOT NULL PRIMARY KEY,
+c2 INT NOT NULL DEFAULT 3,
+c3 INT NULL DEFAULT 7,
+c4 INT NOT NULL
+) ENGINE = NDB;
+REPLACE INTO t1 (c1) VALUES (5);
+Warnings:
+Warning	1364	Field 'c4' doesn't have a default value
+SELECT * FROM t1;
+c1	c2	c3	c4
+5	3	7	0
+DELETE FROM t1;
+INSERT INTO t1 (c1) VALUES (5);
+Warnings:
+Warning	1364	Field 'c4' doesn't have a default value
+SELECT * FROM t1;
+c1	c2	c3	c4
+5	3	7	0
+DROP TABLE t1;
+CREATE TABLE t1(c1 INT NOT NULL,
+c2 INT NOT NULL DEFAULT 3,
+c3 INT NULL DEFAULT 7,
+c4 INT NOT NULL
+) ENGINE = NDB;
+REPLACE INTO t1 (c1) VALUES (5);
+Warnings:
+Warning	1364	Field 'c4' doesn't have a default value
+SELECT * FROM t1;
+c1	c2	c3	c4
+5	3	7	0
+DELETE FROM t1;
+INSERT INTO t1 (c1) VALUES (5);
+Warnings:
+Warning	1364	Field 'c4' doesn't have a default value
+SELECT * FROM t1;
+c1	c2	c3	c4
+5	3	7	0
+DROP TABLE t1;
diff -Nrup a/mysql-test/suite/ndb/t/ndb_replace.test
b/mysql-test/suite/ndb/t/ndb_replace.test
--- a/mysql-test/suite/ndb/t/ndb_replace.test	2007-07-04 22:06:24 +02:00
+++ b/mysql-test/suite/ndb/t/ndb_replace.test	2007-12-10 11:42:37 +01:00
@@ -102,3 +102,33 @@ select * from t1 order by pk;
 drop table t1;
 
 --echo End of 5.0 tests.
+
+#
+# Bug #22045 "Got error 839 'Illegal null attribute' from NDBCLUSTER when
+#             'Replace Into'"
+#
+
+
+CREATE TABLE t1(c1 INT NOT NULL PRIMARY KEY,
+                c2 INT NOT NULL DEFAULT 3,
+                c3 INT NULL DEFAULT 7,
+                c4 INT NOT NULL
+) ENGINE = NDB;
+REPLACE INTO t1 (c1) VALUES (5);
+SELECT * FROM t1;
+DELETE FROM t1;
+INSERT INTO t1 (c1) VALUES (5);
+SELECT * FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1(c1 INT NOT NULL,
+                c2 INT NOT NULL DEFAULT 3,
+                c3 INT NULL DEFAULT 7,
+                c4 INT NOT NULL
+) ENGINE = NDB;
+REPLACE INTO t1 (c1) VALUES (5);
+SELECT * FROM t1;
+DELETE FROM t1;
+INSERT INTO t1 (c1) VALUES (5);
+SELECT * FROM t1;
+DROP TABLE t1;
diff -Nrup a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
--- a/sql/ha_ndbcluster.cc	2007-11-01 15:07:57 +01:00
+++ b/sql/ha_ndbcluster.cc	2007-12-10 11:42:38 +01:00
@@ -2820,8 +2820,23 @@ int ha_ndbcluster::write_row(uchar *reco
   for (i= 0; i < table_share->fields; i++) 
   {
     Field *field= table->field[i];
+    /*
+      The use of table->write_set is tricky here. This is done as a temporary
+      workaround for BUG#22045.
+
+      There is some confusion on the precise meaning of write_set in write_row,
+      with REPLACE INTO and replication SQL thread having different opinions.
+      There is work on the way to sort that out, but until then we need to
+      implement different semantics depending on whether we are in the slave
+      SQL thread or not.
+
+        SQL thread -> use the write_set for writeTuple().
+        otherwise (REPLACE INTO) -> do not use write_set.
+    */
     if (!(field->flags & PRI_KEY_FLAG) &&
-	(bitmap_is_set(table->write_set, i) || !m_use_write) &&
+	(bitmap_is_set(table->write_set, i) ||
+         !m_use_write ||
+         !thd->slave_thread) &&
         set_ndb_value(op, field, i, record-table->record[0], &set_blob_value))
     {
       m_skip_auto_increment= TRUE;
Thread
bk commit into 5.1 tree (knielsen:1.2582) BUG#22045knielsen10 Dec