Commit 9f573182 authored by unknown's avatar unknown

ndb - bug#18067 bug#18075 closes these bugs


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