diff --git a/mysql-test/r/rpl_ndb_blob.result b/mysql-test/r/rpl_ndb_blob.result index 1419875c743..c11de8c27e3 100644 --- a/mysql-test/r/rpl_ndb_blob.result +++ b/mysql-test/r/rpl_ndb_blob.result @@ -78,49 +78,58 @@ S 7 a6bae0cfe6b45ff8c3c12d2ce577a1cd3931190f 107 39ee712b4b9e47f2cf3ba7c9790b2bf S 8 e139adcb7b2974ee7ff227fd405709e5cb7c896c 108 ba8073b0e1a281d4111bd2d82c7722b01574c00b NULL S 9 1fc5168fe4be566b17b658d94e7813f0b5032cdb NULL NULL NULL drop table t1; -show binlog events; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 4 Format_desc 1 102 Server ver: VERSION, Binlog ver: 4 -master-bin.000001 102 Query 1 239 use `test`; create table t1 ( -a int not null primary key, -b text not null -) engine=ndb -master-bin.000001 239 Query 1 303 BEGIN -master-bin.000001 303 Table_map 1 53 cluster.apply_status -master-bin.000001 356 Write_rows 1 95 -master-bin.000001 398 Table_map 1 135 test.t1 -master-bin.000001 438 Write_rows 1 806 -master-bin.000001 1109 Write_rows 1 9841 -master-bin.000001 10144 Query 1 10209 COMMIT -master-bin.000001 10209 Query 1 10273 BEGIN -master-bin.000001 10273 Table_map 1 53 cluster.apply_status -master-bin.000001 10326 Write_rows 1 95 -master-bin.000001 10368 Query 1 10433 COMMIT -master-bin.000001 10433 Query 1 10509 use `test`; drop table t1 -master-bin.000001 10509 Query 1 10684 use `test`; create table t1 ( -a int not null primary key, -b text not null, -c int, -d longblob, -e tinyblob -) engine=ndbcluster -master-bin.000001 10684 Query 1 10748 BEGIN -master-bin.000001 10748 Table_map 1 53 cluster.apply_status -master-bin.000001 10801 Write_rows 1 95 -master-bin.000001 10843 Table_map 1 138 test.t1 -master-bin.000001 10886 Write_rows 1 48922 -master-bin.000001 59670 Write_rows 1 124424 -master-bin.000001 135172 Write_rows 1 124530 -master-bin.000001 135278 Write_rows 1 205949 -master-bin.000001 216697 Write_rows 1 224233 -master-bin.000001 234981 Write_rows 1 227511 -master-bin.000001 238259 Write_rows 1 242379 -master-bin.000001 253127 Write_rows 1 254075 -master-bin.000001 264823 Write_rows 1 304323 -master-bin.000001 315071 Write_rows 1 330415 -master-bin.000001 341163 Query 1 341228 COMMIT -master-bin.000001 341228 Query 1 341292 BEGIN -master-bin.000001 341292 Table_map 1 53 cluster.apply_status -master-bin.000001 341345 Write_rows 1 95 -master-bin.000001 341387 Query 1 341452 COMMIT -master-bin.000001 341452 Query 1 341528 use `test`; drop table t1 +CREATE TABLE IF NOT EXISTS t1 ( +db VARBINARY(63) NOT NULL, +name VARBINARY(63) NOT NULL, +slock BINARY(32) NOT NULL, +query BLOB NOT NULL, +node_id INT UNSIGNED NOT NULL, +epoch BIGINT UNSIGNED NOT NULL, +id INT UNSIGNED NOT NULL, +version INT UNSIGNED NOT NULL, +type INT UNSIGNED NOT NULL, +PRIMARY KEY USING HASH (db,name)) +ENGINE=NDB; +insert into t1 values ('test','t1', +'abc',repeat(@s0,10), 11,12,13,14,15); +insert into t1 values ('test','t2', +'def',repeat(@s1,100), 21,22,23,24,25); +insert into t1 values ('test','t3', +'ghi',repeat(@s2,1000),31,32,33,34,35); +insert into t1 values ('testtttttttttt','t1', +'abc',repeat(@s0,10), 11,12,13,14,15); +insert into t1 values ('testttttttttttt','t1', +'def',repeat(@s1,100), 21,22,23,24,25); +insert into t1 values ('testtttttttttttt','t1', +'ghi',repeat(@s2,1000),31,32,33,34,35); +insert into t1 values ('t','t11111111111', +'abc',repeat(@s0,10), 11,12,13,14,15); +insert into t1 values ('t','t111111111111', +'def',repeat(@s1,100), 21,22,23,24,25); +insert into t1 values ('t','t1111111111111', +'ghi',repeat(@s2,1000),31,32,33,34,35); +select 'M', db, name, sha1(query), node_id, epoch, id, version, type +from t1 order by db, name; +M db name sha1(query) node_id epoch id version type +M t t11111111111 8fc937d303ee7e4795c0b964d4066cedd6d74cfd 11 12 13 14 15 +M t t111111111111 a5229e9f8977bc99afc3b3627c56f083e97e01bd 21 22 23 24 25 +M t t1111111111111 0820e6ad3eeb06ea60e5e04d0bfe36f286b91098 31 32 33 34 35 +M test t1 8fc937d303ee7e4795c0b964d4066cedd6d74cfd 11 12 13 14 15 +M test t2 a5229e9f8977bc99afc3b3627c56f083e97e01bd 21 22 23 24 25 +M test t3 0820e6ad3eeb06ea60e5e04d0bfe36f286b91098 31 32 33 34 35 +M testtttttttttt t1 8fc937d303ee7e4795c0b964d4066cedd6d74cfd 11 12 13 14 15 +M testttttttttttt t1 a5229e9f8977bc99afc3b3627c56f083e97e01bd 21 22 23 24 25 +M testtttttttttttt t1 0820e6ad3eeb06ea60e5e04d0bfe36f286b91098 31 32 33 34 35 +select 'S', db, name, sha1(query), node_id, epoch, id, version, type +from t1 order by db, name; +S db name sha1(query) node_id epoch id version type +S t t11111111111 8fc937d303ee7e4795c0b964d4066cedd6d74cfd 11 12 13 14 15 +S t t111111111111 a5229e9f8977bc99afc3b3627c56f083e97e01bd 21 22 23 24 25 +S t t1111111111111 0820e6ad3eeb06ea60e5e04d0bfe36f286b91098 31 32 33 34 35 +S test t1 8fc937d303ee7e4795c0b964d4066cedd6d74cfd 11 12 13 14 15 +S test t2 a5229e9f8977bc99afc3b3627c56f083e97e01bd 21 22 23 24 25 +S test t3 0820e6ad3eeb06ea60e5e04d0bfe36f286b91098 31 32 33 34 35 +S testtttttttttt t1 8fc937d303ee7e4795c0b964d4066cedd6d74cfd 11 12 13 14 15 +S testttttttttttt t1 a5229e9f8977bc99afc3b3627c56f083e97e01bd 21 22 23 24 25 +S testtttttttttttt t1 0820e6ad3eeb06ea60e5e04d0bfe36f286b91098 31 32 33 34 35 +drop table t1; diff --git a/mysql-test/t/rpl_ndb_blob.test b/mysql-test/t/rpl_ndb_blob.test index c31b629b9f8..94af986b222 100644 --- a/mysql-test/t/rpl_ndb_blob.test +++ b/mysql-test/t/rpl_ndb_blob.test @@ -83,11 +83,60 @@ from t1 order by a; drop table t1; --sync_slave_with_master -# -# view the binlog -# +# table with varsize key (future cluster/schema) + +# sql/ha_ndbcluster_binlog.cc +--connection master +CREATE TABLE IF NOT EXISTS t1 ( + db VARBINARY(63) NOT NULL, + name VARBINARY(63) NOT NULL, + slock BINARY(32) NOT NULL, + query BLOB NOT NULL, + node_id INT UNSIGNED NOT NULL, + epoch BIGINT UNSIGNED NOT NULL, + id INT UNSIGNED NOT NULL, + version INT UNSIGNED NOT NULL, + type INT UNSIGNED NOT NULL, + PRIMARY KEY USING HASH (db,name)) +ENGINE=NDB; + +insert into t1 values ('test','t1', + 'abc',repeat(@s0,10), 11,12,13,14,15); +insert into t1 values ('test','t2', + 'def',repeat(@s1,100), 21,22,23,24,25); +insert into t1 values ('test','t3', + 'ghi',repeat(@s2,1000),31,32,33,34,35); +insert into t1 values ('testtttttttttt','t1', + 'abc',repeat(@s0,10), 11,12,13,14,15); +insert into t1 values ('testttttttttttt','t1', + 'def',repeat(@s1,100), 21,22,23,24,25); +insert into t1 values ('testtttttttttttt','t1', + 'ghi',repeat(@s2,1000),31,32,33,34,35); +insert into t1 values ('t','t11111111111', + 'abc',repeat(@s0,10), 11,12,13,14,15); +insert into t1 values ('t','t111111111111', + 'def',repeat(@s1,100), 21,22,23,24,25); +insert into t1 values ('t','t1111111111111', + 'ghi',repeat(@s2,1000),31,32,33,34,35); + +select 'M', db, name, sha1(query), node_id, epoch, id, version, type +from t1 order by db, name; + +--sync_slave_with_master +--sleep 5 +--connection slave +select 'S', db, name, sha1(query), node_id, epoch, id, version, type +from t1 order by db, name; --connection master -let $VERSION=`select version()`; ---replace_result $VERSION VERSION -show binlog events; +drop table t1; +--sync_slave_with_master + +# +# view the binlog - not deterministic (mats) +# + +#--connection master +#let $VERSION=`select version()`; +#--replace_result $VERSION VERSION +#show binlog events; diff --git a/storage/ndb/include/ndbapi/NdbBlob.hpp b/storage/ndb/include/ndbapi/NdbBlob.hpp index 9ae0ba6f023..13bbfa59e50 100644 --- a/storage/ndb/include/ndbapi/NdbBlob.hpp +++ b/storage/ndb/include/ndbapi/NdbBlob.hpp @@ -288,6 +288,7 @@ private: Buf(); ~Buf(); void alloc(unsigned n); + void zerorest(); void copyfrom(const Buf& src); }; Buf theKeyBuf; diff --git a/storage/ndb/src/ndbapi/NdbBlob.cpp b/storage/ndb/src/ndbapi/NdbBlob.cpp index 680f9e5c70e..5fbfd6f5111 100644 --- a/storage/ndb/src/ndbapi/NdbBlob.cpp +++ b/storage/ndb/src/ndbapi/NdbBlob.cpp @@ -307,6 +307,13 @@ NdbBlob::Buf::alloc(unsigned n) #endif } +void +NdbBlob::Buf::zerorest() +{ + assert(size <= maxsize); + memset(data + size, 0, maxsize - size); +} + void NdbBlob::Buf::copyfrom(const NdbBlob::Buf& src) { @@ -441,6 +448,7 @@ NdbBlob::packKeyValue(const NdbTableImpl* aTable, const Buf& srcBuf) assert(4 * pos == srcBuf.size); assert(4 * pack_pos <= thePackKeyBuf.maxsize); thePackKeyBuf.size = 4 * pack_pos; + thePackKeyBuf.zerorest(); DBUG_RETURN(0); } @@ -1316,6 +1324,7 @@ NdbBlob::atPrepare(NdbTransaction* aCon, NdbOperation* anOp, const NdbColumnImpl DBUG_RETURN(-1); } thePackKeyBuf.size = 4 * size; + thePackKeyBuf.zerorest(); if (unpackKeyValue(theTable, theKeyBuf) == -1) DBUG_RETURN(-1); } @@ -1328,6 +1337,7 @@ NdbBlob::atPrepare(NdbTransaction* aCon, NdbOperation* anOp, const NdbColumnImpl DBUG_RETURN(-1); } thePackKeyBuf.size = 4 * size; + thePackKeyBuf.zerorest(); if (unpackKeyValue(theAccessTable, theAccessKeyBuf) == -1) DBUG_RETURN(-1); } @@ -1634,6 +1644,7 @@ NdbBlob::postExecute(NdbTransaction::ExecType anExecType) // copy key from first blob theKeyBuf.copyfrom(tFirstBlob->theKeyBuf); thePackKeyBuf.copyfrom(tFirstBlob->thePackKeyBuf); + thePackKeyBuf.zerorest(); } } if (isReadOp()) { @@ -1795,6 +1806,7 @@ NdbBlob::atNextResult() DBUG_RETURN(-1); } thePackKeyBuf.size = 4 * size; + thePackKeyBuf.zerorest(); if (unpackKeyValue(theTable, theKeyBuf) == -1) DBUG_RETURN(-1); }