From: Date: April 4 2008 11:54am Subject: bk commit into 5.1 tree (knielsen:1.2533) BUG#22045 List-Archive: http://lists.mysql.com/commits/44903 X-Bug: 22045 Message-Id: <1207302872.0@ymer> 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, 2008-04-04 11:54:23+02:00, knielsen@ymer.(none) +7 -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, 2008-04-04 11:54:15+02:00, knielsen@ymer.(none) +38 -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/t/ndb_replace.test@stripped, 2008-04-04 11:54:15+02:00, knielsen@ymer.(none) +30 -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/rpl_ndb/r/rpl_ndb_basic.result@stripped, 2008-04-04 11:54:15+02:00, knielsen@ymer.(none) +48 -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/rpl_ndb/r/rpl_ndb_blob.result@stripped, 2008-04-04 11:54:15+02:00, knielsen@ymer.(none) +50 -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/rpl_ndb/t/rpl_ndb_basic.test@stripped, 2008-04-04 11:54:15+02:00, knielsen@ymer.(none) +33 -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/rpl_ndb/t/rpl_ndb_blob.test@stripped, 2008-04-04 11:54:15+02:00, knielsen@ymer.(none) +34 -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. sql/ha_ndbcluster.cc@stripped, 2008-04-04 11:54:15+02:00, knielsen@ymer.(none) +16 -1 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. 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 2008-04-04 11:54:15 +02: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 2008-04-04 11:54:15 +02: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/mysql-test/suite/rpl_ndb/r/rpl_ndb_basic.result b/mysql-test/suite/rpl_ndb/r/rpl_ndb_basic.result --- a/mysql-test/suite/rpl_ndb/r/rpl_ndb_basic.result 2007-06-27 14:28:30 +02:00 +++ b/mysql-test/suite/rpl_ndb/r/rpl_ndb_basic.result 2008-04-04 11:54:15 +02:00 @@ -229,3 +229,51 @@ c1 104 105 DROP TABLE t1; +create table t1 (a int primary key, +b varchar(100) default 'b', +c varchar(100)) engine=ndbcluster; +insert into t1 values (1, 'b1', 'c1'); +insert into t1 (a) values (2); +insert into t1 (a, b) values (3, 'b3'); +replace into t1 values (5, 'b5', 'c5'); +replace into t1 (a) values (6); +replace into t1 (a, c) values (7, 'c7'); +select * from t1 order by a; +a b c +1 b1 c1 +2 b NULL +3 b3 NULL +5 b5 c5 +6 b NULL +7 b c7 +select * from t1 order by a; +a b c +1 b1 c1 +2 b NULL +3 b3 NULL +5 b5 c5 +6 b NULL +7 b c7 +replace into t1 (a) values (1); +replace into t1 (a, b) values (2, 'b2x'); +replace into t1 (a, c) values (3, 'c3x'); +replace into t1 (a, b, c) values (5, 'b5x', 'c5x'); +replace into t1 (a) values (6); +replace into t1 (a) values (7); +select * from t1 order by a; +a b c +1 b NULL +2 b2x NULL +3 b c3x +5 b5x c5x +6 b NULL +7 b NULL +select * from t1 order by a; +a b c +1 b NULL +2 b2x NULL +3 b c3x +5 b5x c5x +6 b NULL +7 b NULL +drop table t1; diff -Nrup a/mysql-test/suite/rpl_ndb/r/rpl_ndb_blob.result b/mysql-test/suite/rpl_ndb/r/rpl_ndb_blob.result --- a/mysql-test/suite/rpl_ndb/r/rpl_ndb_blob.result 2007-06-27 14:27:24 +02:00 +++ b/mysql-test/suite/rpl_ndb/r/rpl_ndb_blob.result 2008-04-04 11:54:15 +02:00 @@ -133,3 +133,53 @@ S testtttttttttt t1 8fc937d303ee7e4795c0 S testttttttttttt t1 a5229e9f8977bc99afc3b3627c56f083e97e01bd 21 22 23 24 25 S testtttttttttttt t1 0820e6ad3eeb06ea60e5e04d0bfe36f286b91098 31 32 33 34 35 drop table t1; +create table t1 (a int primary key, +b varchar(100) default 'b', +c varchar(100), +d text, +e text) engine=ndbcluster; +insert into t1 values (1, 'b1', 'c1', 'd1', 'e1'); +insert into t1 (a) values (2); +insert into t1 (a, b, d) values (3, 'b3', 'd3'); +replace into t1 values (5, 'b5', 'c5', 'd5', 'e5'); +replace into t1 (a) values (6); +replace into t1 (a, c, e) values (7, 'c7', 'e7'); +select * from t1 order by a; +a b c d e +1 b1 c1 d1 e1 +2 b NULL NULL NULL +3 b3 NULL d3 NULL +5 b5 c5 d5 e5 +6 b NULL NULL NULL +7 b c7 NULL e7 +select * from t1 order by a; +a b c d e +1 b1 c1 d1 e1 +2 b NULL NULL NULL +3 b3 NULL d3 NULL +5 b5 c5 d5 e5 +6 b NULL NULL NULL +7 b c7 NULL e7 +replace into t1 (a) values (1); +replace into t1 (a, b, d) values (2, 'b2x', 'd2x'); +replace into t1 (a, c, e) values (3, 'c3x', 'e3x'); +replace into t1 (a, b, c, d, e) values (5, 'b5x', 'c5x', 'd5x', 'e5x'); +replace into t1 (a) values (6); +replace into t1 (a, e) values (7, 'e7x'); +select * from t1 order by a; +a b c d e +1 b NULL NULL NULL +2 b2x NULL d2x NULL +3 b c3x NULL e3x +5 b5x c5x d5x e5x +6 b NULL NULL NULL +7 b NULL NULL e7x +select * from t1 order by a; +a b c d e +1 b NULL NULL NULL +2 b2x NULL d2x NULL +3 b c3x NULL e3x +5 b5x c5x d5x e5x +6 b NULL NULL NULL +7 b NULL NULL e7x +drop table t1; diff -Nrup a/mysql-test/suite/rpl_ndb/t/rpl_ndb_basic.test b/mysql-test/suite/rpl_ndb/t/rpl_ndb_basic.test --- a/mysql-test/suite/rpl_ndb/t/rpl_ndb_basic.test 2007-09-05 18:44:44 +02:00 +++ b/mysql-test/suite/rpl_ndb/t/rpl_ndb_basic.test 2008-04-04 11:54:15 +02:00 @@ -257,4 +257,37 @@ SELECT c1 FROM t1 ORDER BY c1 LIMIT 5; # cleanup --connection master DROP TABLE t1; + +# BUG#22045: Got error 839 'Illegal null attribute' from NDBCLUSTER when 'Replace Into'. +# Check that REPLACE INTO replicates correctly with partial value list and no blobs. +connection master; +create table t1 (a int primary key, + b varchar(100) default 'b', + c varchar(100)) engine=ndbcluster; +insert into t1 values (1, 'b1', 'c1'); +insert into t1 (a) values (2); +insert into t1 (a, b) values (3, 'b3'); +replace into t1 values (5, 'b5', 'c5'); +replace into t1 (a) values (6); +replace into t1 (a, c) values (7, 'c7'); +select * from t1 order by a; + +--sync_slave_with_master +select * from t1 order by a; + +connection master; +replace into t1 (a) values (1); +replace into t1 (a, b) values (2, 'b2x'); +replace into t1 (a, c) values (3, 'c3x'); +replace into t1 (a, b, c) values (5, 'b5x', 'c5x'); +replace into t1 (a) values (6); +replace into t1 (a) values (7); +select * from t1 order by a; + +--sync_slave_with_master +select * from t1 order by a; + +--connection master +drop table t1; + -- source include/master-slave-end.inc diff -Nrup a/mysql-test/suite/rpl_ndb/t/rpl_ndb_blob.test b/mysql-test/suite/rpl_ndb/t/rpl_ndb_blob.test --- a/mysql-test/suite/rpl_ndb/t/rpl_ndb_blob.test 2007-09-05 18:44:44 +02:00 +++ b/mysql-test/suite/rpl_ndb/t/rpl_ndb_blob.test 2008-04-04 11:54:15 +02:00 @@ -131,6 +131,40 @@ from t1 order by db, name; drop table t1; --sync_slave_with_master +# BUG#22045: Got error 839 'Illegal null attribute' from NDBCLUSTER when 'Replace Into'. +# Check that REPLACE INTO replicates correctly with partial value list and blobs. +connection master; +create table t1 (a int primary key, + b varchar(100) default 'b', + c varchar(100), + d text, + e text) engine=ndbcluster; +insert into t1 values (1, 'b1', 'c1', 'd1', 'e1'); +insert into t1 (a) values (2); +insert into t1 (a, b, d) values (3, 'b3', 'd3'); +replace into t1 values (5, 'b5', 'c5', 'd5', 'e5'); +replace into t1 (a) values (6); +replace into t1 (a, c, e) values (7, 'c7', 'e7'); +select * from t1 order by a; + +--sync_slave_with_master +select * from t1 order by a; + +connection master; +replace into t1 (a) values (1); +replace into t1 (a, b, d) values (2, 'b2x', 'd2x'); +replace into t1 (a, c, e) values (3, 'c3x', 'e3x'); +replace into t1 (a, b, c, d, e) values (5, 'b5x', 'c5x', 'd5x', 'e5x'); +replace into t1 (a) values (6); +replace into t1 (a, e) values (7, 'e7x'); +select * from t1 order by a; + +--sync_slave_with_master +select * from t1 order by a; + +--connection master +drop table t1; + # # view the binlog - not deterministic (mats) # diff -Nrup a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc --- a/sql/ha_ndbcluster.cc 2008-02-11 17:38:31 +01:00 +++ b/sql/ha_ndbcluster.cc 2008-04-04 11:54:15 +02:00 @@ -2837,8 +2837,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;