List:Commits« Previous MessageNext Message »
From:knielsen Date:December 17 2007 8:45am
Subject:bk commit into 5.1 tree (knielsen:1.2639) 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-17 08:45:18+01:00, knielsen@ymer.(none) +3 -0
  BUG#22045: Got error 839 'Illegal null attribute' from NDBCLUSTER when 'Replace Into'
  
  Temporary workaround, check if running in slave SQL thread or not, and
  change semantics of write_set in write_row() as expected by the different
  upper layers.

  mysql-test/suite/ndb/r/ndb_replace.result@stripped, 2007-12-17 08:45:14+01:00,
knielsen@ymer.(none) +42 -0
    Test case.

  mysql-test/suite/ndb/t/ndb_replace.test@stripped, 2007-12-17 08:45:14+01:00,
knielsen@ymer.(none) +34 -0
    Test case.

  sql/ha_ndbcluster.cc@stripped, 2007-12-17 08:45:14+01:00, knielsen@ymer.(none) +32 -2
    Slave SQL thread expects write_row() to leave columns not in write_set
    unchanged.
    
    Non-slave mysqld code expects to set those columns to default values.

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-17 08:45:14 +01:00
@@ -97,3 +97,45 @@ 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,
+c5 TEXT NOT NULL,
+c6 TEXT NULL
+) ENGINE = NDB;
+REPLACE INTO t1 (c1) VALUES (5);
+Warnings:
+Warning	1364	Field 'c4' doesn't have a default value
+Warning	1364	Field 'c5' doesn't have a default value
+SELECT * FROM t1;
+c1	c2	c3	c4	c5	c6
+5	3	7	0		NULL
+DELETE FROM t1;
+INSERT INTO t1 (c1) VALUES (5);
+Warnings:
+Warning	1364	Field 'c4' doesn't have a default value
+Warning	1364	Field 'c5' doesn't have a default value
+SELECT * FROM t1;
+c1	c2	c3	c4	c5	c6
+5	3	7	0		NULL
+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-17 08:45:14 +01:00
@@ -102,3 +102,37 @@ 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,
+                c5 TEXT NOT NULL,
+                c6 TEXT 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;
+
+# Same without a primary key (but blobs not supported in binlog for tables
+# with no primary key, error 1475).
+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-26 13:37:32 +01:00
+++ b/sql/ha_ndbcluster.cc	2007-12-17 08:45:14 +01:00
@@ -3572,16 +3572,46 @@ int ha_ndbcluster::ndb_write_row(uchar *
     This means that we now suffer from BUG#22045... :-/
   */
 
+  const MY_BITMAP *bitmap;
   if (m_use_write)
   {
+    const uchar *mask;
+#ifdef HAVE_NDB_BINLOG
+    /*
+      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 (thd->slave_thread)
+    {
+      bitmap= table->write_set;
+      mask= (uchar *)(bitmap->bitmap);
+    }
+    else
+#endif
+    {
+      bitmap= NULL;
+      mask= NULL;
+    }
     op= trans->writeTuple(key_rec, (const char *)key_row, m_ndb_record,
-                          (char *)record, (uchar *)(table->write_set->bitmap),
+                          (char *)record, mask,
                           poptions, sizeof(NdbOperation::OperationOptions));
   }
   else
+  {
     op= trans->insertTuple(key_rec, (const char *)key_row, m_ndb_record,
                            (char *)record, NULL, // No mask
                            poptions, sizeof(NdbOperation::OperationOptions));
+    bitmap= NULL;
+  }
   if (!(op))
     ERR_RETURN(trans->getNdbError());
 
@@ -3592,7 +3622,7 @@ int ha_ndbcluster::ndb_write_row(uchar *
   if (table_share->blob_fields > 0)
   {
     my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set);
-    int res= set_blob_values(op, record - table->record[0], NULL, &blob_count,
+    int res= set_blob_values(op, record - table->record[0], bitmap, &blob_count,
                              do_batch);
     dbug_tmp_restore_column_map(table->read_set, old_map);
     if (res != 0)
Thread
bk commit into 5.1 tree (knielsen:1.2639) BUG#22045knielsen17 Dec