Commit e626e9f1 authored by unknown's avatar unknown

WL#3023 (RBR: Use locks in a statement-like manner):

  Adaptions to make it work with NDB.


mysql-test/extra/binlog_tests/binlog.test:
  Using replace_regex to remove table id.
mysql-test/extra/binlog_tests/blackhole.test:
  Using replace_regex to remove table id.
mysql-test/extra/binlog_tests/ctype_cp932.test:
  Using replace_regex to remove table id.
mysql-test/extra/binlog_tests/ctype_cp932_binlog.test:
  Using replace_regex to remove table id.
mysql-test/extra/binlog_tests/ctype_ucs_binlog.test:
  Using replace_regex to remove table id.
mysql-test/extra/binlog_tests/drop_temp_table.test:
  Using replace_regex to remove table id.
mysql-test/extra/binlog_tests/insert_select-binlog.test:
  Using replace_regex to remove table id.
mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test:
  Using replace_regex to remove table id.
mysql-test/extra/rpl_tests/rpl_flsh_tbls.test:
  Using replace_regex to remove table id.
mysql-test/extra/rpl_tests/rpl_log.test:
  Using replace_regex to remove table id.
mysql-test/extra/rpl_tests/rpl_multi_query.test:
  Using replace_regex to remove table id.
mysql-test/extra/rpl_tests/rpl_row_charset.test:
  Using replace_regex to remove table id.
mysql-test/extra/rpl_tests/rpl_row_delayed_ins.test:
  Using replace_regex to remove table id.
mysql-test/extra/rpl_tests/rpl_stm_charset.test:
  Using replace_regex to remove table id.
mysql-test/include/rpl_row_basic.inc:
  Removing sync with master on cleanup since there are engines that does
  not work in a "syncronized" fashion on dropping tables.
mysql-test/r/binlog_row_binlog.result:
  Result change
mysql-test/r/binlog_row_blackhole.result:
  Result change
mysql-test/r/binlog_row_ctype_cp932.result:
  Result change
mysql-test/r/binlog_row_ctype_ucs.result:
  Result change
mysql-test/r/binlog_row_insert_select.result:
  Result change
mysql-test/r/binlog_row_mix_innodb_myisam.result:
  Result change
mysql-test/r/ctype_cp932_binlog_row.result:
  Result change
mysql-test/r/rpl_row_basic_11bugs.result:
  Result change
mysql-test/r/rpl_row_basic_2myisam.result:
  Result change
mysql-test/r/rpl_row_basic_3innodb.result:
  Result change
mysql-test/r/rpl_row_charset.result:
  Result change
mysql-test/r/rpl_row_create_table.result:
  Result change
mysql-test/r/rpl_row_delayed_ins.result:
  Result change
mysql-test/r/rpl_row_log.result:
  Result change
mysql-test/r/rpl_row_log_innodb.result:
  Result change
mysql-test/r/rpl_row_max_relay_size.result:
  Result change
mysql-test/r/rpl_row_sp008.result:
  Result change
mysql-test/t/binlog_stm_binlog.test:
  Using replace_regex to remove table id.
mysql-test/t/ndb_binlog_ddl_multi.test:
  Using replace_regex to remove table id.
mysql-test/t/ndb_binlog_ignore_db.test:
  Using replace_regex to remove table id.
mysql-test/t/rpl_heap.test:
  Using replace_regex to remove table id.
mysql-test/t/rpl_loaddata_s.test:
  Using replace_regex to remove table id.
mysql-test/t/rpl_ndb_blob.test:
  Using replace_regex to remove table id.
mysql-test/t/rpl_ndb_disk.test:
  Using replace_regex to remove table id.
mysql-test/t/rpl_row_basic_11bugs.test:
  Using replace_regex to remove table id.
mysql-test/t/rpl_row_create_table.test:
  Using replace_regex to remove table id.
mysql-test/t/rpl_row_drop.test:
  Using replace_regex to remove table id.
mysql-test/t/rpl_row_sp008.test:
  Using replace_regex to remove table id.
mysql-test/t/rpl_sp.test:
  Using replace_regex to remove table id.
mysql-test/t/sp.test:
  Using replace_regex to remove table id.
mysql-test/t/sp_notembedded.test:
  Using replace_regex to remove table id.
mysql-test/t/user_var-binlog.test:
  Using replace_regex to remove table id.
sql/ha_ndbcluster_binlog.cc:
  Assign_new_table_id() now takes table share.
  Removed gratuitous friend declaration of ndb_add_binlog_index().
  Turning of binlogging during execution of ndb_add_binlog_index().
sql/handler.h:
  Removed gratuitous friend declaration of ndb_add_binlog_index().
sql/log.cc:
  Adding debug printout.
sql/log_event.cc:
  Closing thread tables on dummy event.
sql/rpl_injector.cc:
  Added support for new locking scheme.
sql/rpl_injector.h:
  Added support for new locking scheme.
parent 43fb0200
......@@ -21,6 +21,7 @@ insert t2 values (5);
commit;
# first COMMIT must be Query_log_event, second - Xid_log_event
--replace_column 2 # 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events from 102;
drop table t1,t2;
......@@ -42,6 +43,8 @@ while ($1)
commit;
drop table t1;
--replace_column 2 # 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events in 'master-bin.000001' from 102;
--replace_column 2 # 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events in 'master-bin.000002' from 102;
......@@ -122,6 +122,7 @@ select * from t3;
let $VERSION=`select version()`;
--replace_result $VERSION VERSION
--replace_column 2 # 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events;
drop table t1,t2,t3;
......@@ -143,4 +144,5 @@ rollback;
set autocommit=1;
--replace_result $VERSION VERSION
--replace_column 2 # 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events;
......@@ -415,6 +415,7 @@ SET @var1= x'8300';
# code (and I have used it to test the fix) until there is some way to
# exercise this code from mysql-test-run.
EXECUTE stmt1 USING @var1;
--replace_regex /table_id: [0-9]+/table_id: #/
SHOW BINLOG EVENTS FROM 102;
SELECT HEX(f1) FROM t1;
DROP table t1;
......
......@@ -27,6 +27,7 @@ SET @var1= x'8300';
# exercise this code from mysql-test-run.
EXECUTE stmt1 USING @var1;
--replace_column 2 # 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
SHOW BINLOG EVENTS FROM 102;
SELECT HEX(f1) FROM t1;
DROP table t1;
......
......@@ -9,6 +9,7 @@ create table t2 (c char(30)) charset=ucs2;
set @v=convert('abc' using ucs2);
reset master;
insert into t2 values (@v);
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events from 102;
# more important than SHOW BINLOG EVENTS, mysqlbinlog (where we
# absolutely need variables names to be quoted and strings to be
......
......@@ -25,6 +25,7 @@ select get_lock("a",10);
let $VERSION=`select version()`;
--replace_result $VERSION VERSION
--replace_column 2 # 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events;
drop database `drop-temp+table-test`;
......
......@@ -15,6 +15,7 @@ insert into t1 select * from t2;
# verify the binlog :
let $VERSION=`select version()`;
--replace_result $VERSION VERSION
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events;
select * from t1;
drop table t1, t2;
......@@ -29,6 +30,7 @@ create table t2(unique(a)) select a from t1;
# The above should produce an error, *and* not appear in the binlog
let $VERSION=`select version()`;
--replace_result $VERSION VERSION
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events;
drop table t1;
......
......@@ -30,6 +30,7 @@ insert into t2 select * from t1;
commit;
--replace_column 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events from 102;
delete from t1;
......@@ -43,6 +44,7 @@ insert into t2 select * from t1;
rollback;
--replace_column 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events from 102;
delete from t1;
......@@ -58,6 +60,7 @@ rollback to savepoint my_savepoint;
commit;
--replace_column 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events from 102;
delete from t1;
......@@ -75,6 +78,7 @@ commit;
select a from t1 order by a; # check that savepoints work :)
--replace_column 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events from 102;
# and when ROLLBACK is not explicit?
......@@ -96,6 +100,7 @@ connection con2;
# logging has been done, we use a user lock.
select get_lock("a",10);
--replace_column 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events from 102;
# and when not in a transact1on?
......@@ -107,6 +112,7 @@ insert into t1 values(9);
insert into t2 select * from t1;
--replace_column 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events from 102;
# Check that when the query updat1ng the MyISAM table is the first in the
......@@ -119,11 +125,13 @@ insert into t1 values(10); # first make t1 non-empty
begin;
insert into t2 select * from t1;
--replace_column 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events from 102;
insert into t1 values(11);
commit;
--replace_column 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events from 102;
......@@ -142,6 +150,7 @@ insert into t2 select * from t1;
commit;
--replace_column 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events from 102;
delete from t1;
......@@ -154,6 +163,7 @@ insert into t2 select * from t1;
rollback;
--replace_column 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events from 102;
delete from t1;
......@@ -169,6 +179,7 @@ rollback to savepoint my_savepoint;
commit;
--replace_column 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events from 102;
delete from t1;
......@@ -186,6 +197,7 @@ commit;
select a from t1 order by a; # check that savepoints work :)
--replace_column 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events from 102;
# Test for BUG#5714, where a MyISAM update in the transaction used to
......@@ -246,6 +258,7 @@ disconnect con2;
connection con3;
select get_lock("lock1",60);
--replace_column 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events from 102;
do release_lock("lock1");
drop table t0,t2;
......
......@@ -19,6 +19,7 @@ flush no_write_to_binlog tables;
# Check that it's not in the binlog.
--replace_result $SERVER_VERSION SERVER_VERSION
--replace_column 2 # 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
eval SHOW BINLOG EVENTS FROM $rename_event_pos ;
# Check that the master is not confused.
select * from t3;
......@@ -27,6 +28,7 @@ flush tables;
# Check that it's in the binlog.
--replace_result $SERVER_VERSION SERVER_VERSION
--replace_column 2 # 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
eval SHOW BINLOG EVENTS FROM $rename_event_pos ;
save_master_pos;
connection slave;
......
......@@ -39,16 +39,16 @@ select count(*) from t1;
drop table t1;
--replace_result $VERSION VERSION
--replace_column 2 # 5 #
--replace_regex /\/\* xid=.* \*\//\/* XID *\//
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
show binlog events;
--replace_column 2 # 5 #
--replace_regex /\/\* xid=.* \*\//\/* XID *\//
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
show binlog events from 102 limit 1;
--replace_column 2 # 5 #
--replace_regex /\/\* xid=.* \*\//\/* XID *\//
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
show binlog events from 102 limit 2;
--replace_column 2 # 5 #
--replace_regex /\/\* xid=.* \*\//\/* XID *\//
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
show binlog events from 102 limit 2,1;
flush logs;
......@@ -91,11 +91,11 @@ insert into t1 values (1);
drop table t1;
--replace_result $VERSION VERSION
--replace_column 2 # 5 #
--replace_regex /\/\* xid=.* \*\//\/* XID *\//
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
show binlog events;
--replace_result $VERSION VERSION
--replace_column 2 # 5 #
--replace_regex /\/\* xid=.* \*\//\/* XID *\//
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
show binlog events in 'master-bin.000002';
show binary logs;
save_master_pos;
......@@ -105,11 +105,11 @@ sync_with_master;
show binary logs;
--replace_result $MASTER_MYPORT MASTER_PORT $VERSION VERSION
--replace_column 2 # 5 #
--replace_regex /\/\* xid=.* \*\//\/* XID *\//
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
show binlog events in 'slave-bin.000001' from 4;
--replace_result $MASTER_MYPORT MASTER_PORT $VERSION VERSION
--replace_column 2 # 5 #
--replace_regex /\/\* xid=.* \*\//\/* XID *\//
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
show binlog events in 'slave-bin.000002' from 4;
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 8 # 9 # 16 # 23 # 33 #
......
......@@ -24,6 +24,7 @@ sync_slave_with_master;
select * from mysqltest.t1;
connection master;
--replace_column 2 # 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events from 102;
drop database mysqltest;
sync_slave_with_master;
......@@ -114,6 +114,7 @@ connection master;
drop database mysqltest2;
drop database mysqltest3;
--replace_column 2 # 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events from 102;
sync_slave_with_master;
......@@ -162,7 +163,7 @@ select hex(c1), hex(c2) from t1;
connection master;
# Let's have a look at generated SETs.
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
#--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
#--exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000001
drop table t1;
sync_slave_with_master;
......
......@@ -14,6 +14,7 @@ sync_slave_with_master;
connection master;
--replace_result $VERSION VERSION
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events;
sync_slave_with_master;
select * from t1;
......
......@@ -110,6 +110,7 @@ connection master;
drop database mysqltest2;
drop database mysqltest3;
--replace_column 2 # 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events from 102;
sync_slave_with_master;
......
......@@ -174,22 +174,16 @@ SELECT C1,HEX(B1),HEX(B2) FROM t4 ORDER BY C1;
connection master;
eval CREATE TABLE t7 (C1 INT PRIMARY KEY, C2 INT) ENGINE = $type ;
sync_slave_with_master;
--disable_query_log
SELECT "--- on slave: original values ---" AS "";
--enable_query_log
--echo --- on slave: original values ---
INSERT INTO t7 VALUES (1,3), (2,6), (3,9);
SELECT * FROM t7 ORDER BY C1;
connection master;
--disable_query_log
SELECT "--- on master: new values inserted ---" AS "";
--enable_query_log
--echo --- on master: new values inserted ---
INSERT INTO t7 VALUES (1,2), (2,4), (3,6);
SELECT * FROM t7 ORDER BY C1;
sync_slave_with_master;
--disable_query_log
SELECT "--- on slave: old values should be overwritten by replicated values ---" AS "";
--enable_query_log
--echo --- on slave: old values should be overwritten by replicated values ---
SELECT * FROM t7 ORDER BY C1;
#
......@@ -197,42 +191,33 @@ SELECT * FROM t7 ORDER BY C1;
# causing a conflict for a key that is not "last".
#
connection master;
--disable_query_log
SELECT "--- on master ---" AS "";
--enable_query_log
DROP TABLE t7;
eval CREATE TABLE t7 (a INT PRIMARY KEY, b INT UNIQUE, c INT UNIQUE) ENGINE = $type ;
--echo --- on master ---
eval CREATE TABLE t8 (a INT PRIMARY KEY, b INT UNIQUE, c INT UNIQUE) ENGINE = $type ;
# First we make sure that the constraints are correctly set.
INSERT INTO t7 VALUES (99,99,99);
INSERT INTO t8 VALUES (99,99,99);
--error 1062
INSERT INTO t7 VALUES (99,22,33);
INSERT INTO t8 VALUES (99,22,33);
--error 1062
INSERT INTO t7 VALUES (11,99,33);
INSERT INTO t8 VALUES (11,99,33);
--error 1062
INSERT INTO t7 VALUES (11,22,99);
SELECT * FROM t7 ORDER BY a;
INSERT INTO t8 VALUES (11,22,99);
SELECT * FROM t8 ORDER BY a;
sync_slave_with_master;
--disable_query_log
SELECT "--- on slave ---" AS "";
--enable_query_log
SELECT * FROM t7 ORDER BY a;
INSERT INTO t7 VALUES (1,2,3), (2,4,6), (3,6,9);
SELECT * FROM t7 ORDER BY a;
--echo --- on slave ---
SELECT * FROM t8 ORDER BY a;
INSERT INTO t8 VALUES (1,2,3), (2,4,6), (3,6,9);
SELECT * FROM t8 ORDER BY a;
connection master;
--disable_query_log
SELECT "--- on master ---" AS "";
--enable_query_log
--echo --- on master ---
# We insert a row that will cause conflict on the primary key but not
# on the other keys.
INSERT INTO t7 VALUES (2,4,8);
INSERT INTO t8 VALUES (2,4,8);
sync_slave_with_master;
--disable_query_log
SELECT "--- on slave ---" AS "";
--enable_query_log
SELECT * FROM t7 ORDER BY a;
--echo --- on slave ---
SELECT * FROM t8 ORDER BY a;
#
# Test conflicting operations when changing in a table referenced by a
......@@ -245,5 +230,4 @@ SELECT * FROM t7 ORDER BY a;
#
connection master;
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7;
sync_slave_with_master;
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8;
This diff is collapsed.
......@@ -109,33 +109,33 @@ Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4
master-bin.000001 # Query 1 # use `test`; drop table t1,t2
master-bin.000001 # Query 1 # use `test`; create table t1 (a int) engine=blackhole
master-bin.000001 # Table_map 1 # test.t1
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # table_id: # (test.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # use `test`; COMMIT
master-bin.000001 # Table_map 1 # test.t1
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # table_id: # (test.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # use `test`; COMMIT
master-bin.000001 # Table_map 1 # test.t1
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # table_id: # (test.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # use `test`; COMMIT
master-bin.000001 # Table_map 1 # test.t1
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # table_id: # (test.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # use `test`; COMMIT
master-bin.000001 # Table_map 1 # test.t1
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # table_id: # (test.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # use `test`; COMMIT
master-bin.000001 # Query 1 # use `test`; create table t2 (a varchar(200)) engine=blackhole
master-bin.000001 # Table_map 1 # test.t2
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # table_id: # (test.t2)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # use `test`; COMMIT
master-bin.000001 # Query 1 # use `test`; alter table t1 add b int
master-bin.000001 # Query 1 # use `test`; alter table t1 drop b
master-bin.000001 # Query 1 # use `test`; create table t3 like t1
master-bin.000001 # Table_map 1 # test.t1
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # table_id: # (test.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # use `test`; COMMIT
master-bin.000001 # Table_map 1 # test.t1
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # table_id: # (test.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # use `test`; COMMIT
drop table t1,t2,t3;
reset master;
......@@ -153,6 +153,6 @@ Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4
master-bin.000001 # Query 1 # use `test`; create table t1 (a int) engine=blackhole
master-bin.000001 # Query 1 # use `test`; BEGIN
master-bin.000001 # Table_map 1 # test.t1
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # table_id: # (test.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # use `test`; COMMIT
......@@ -11323,8 +11323,8 @@ EXECUTE stmt1 USING @var1;
SHOW BINLOG EVENTS FROM 102;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 102 Query 1 189 use `test`; CREATE TABLE t1(f1 blob)
master-bin.000001 189 Table_map 1 228 test.t1
master-bin.000001 228 Write_rows 1 262
master-bin.000001 189 Table_map 1 228 table_id: # (test.t1)
master-bin.000001 228 Write_rows 1 262 table_id: # flags: STMT_END_F
SELECT HEX(f1) FROM t1;
HEX(f1)
8300
......@@ -11366,4 +11366,3 @@ col1
a
a
a
drop table t1;
......@@ -5,8 +5,8 @@ reset master;
insert into t2 values (@v);
show binlog events from 102;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 102 Table_map 1 141 test.t2
master-bin.000001 141 Write_rows 1 231
master-bin.000001 102 Table_map 1 141 table_id: # (test.t2)
master-bin.000001 141 Write_rows 1 231 table_id: # flags: STMT_END_F
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
ROLLBACK;
......
......@@ -4,12 +4,12 @@ create table t2(a int);
insert into t2 values(1),(2);
reset master;
insert into t1 select * from t2;
ERROR 23000: Duplicate entry '2' for key 1
ERROR 23000: Duplicate entry '2' for key 'a'
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 Table_map 1 141 test.t1
master-bin.000001 141 Write_rows 1 175
master-bin.000001 102 Table_map 1 141 table_id: # (test.t1)
master-bin.000001 141 Write_rows 1 175 table_id: # flags: STMT_END_F
select * from t1;
a
1
......@@ -19,7 +19,7 @@ create table t1(a int);
insert into t1 values(1),(1);
reset master;
create table t2(unique(a)) select a from t1;
ERROR 23000: Duplicate entry '1' for key 1
ERROR 23000: Duplicate entry '1' for key 'a'
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
......
......@@ -9,8 +9,8 @@ EXECUTE stmt1 USING @var1;
SHOW BINLOG EVENTS FROM 102;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query 1 # use `test`; CREATE TABLE t1(f1 blob)
master-bin.000001 # Table_map 1 # test.t1
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # table_id: # (test.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
SELECT HEX(f1) FROM t1;
HEX(f1)
8300
......
......@@ -28,8 +28,8 @@ INSERT INTO t2 VALUES (3,3), (4,4);
SHOW BINLOG EVENTS FROM 102;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 102 Query 1 195 use `test`; CREATE TABLE t1 (a INT, b INT)
master-bin.000001 195 Table_map 1 235 test.t1
master-bin.000001 235 Write_rows 1 282
master-bin.000001 195 Table_map 1 235 table_id: # (test.t1)
master-bin.000001 235 Write_rows 1 282 table_id: # flags: STMT_END_F
**** On Slave ****
SHOW DATABASES;
Database
......
......@@ -363,7 +363,6 @@ SELECT C1,HEX(B1),HEX(B2) FROM t4 ORDER BY C1;
C1 HEX(B1) HEX(B2)
1 NULL 0
CREATE TABLE t7 (C1 INT PRIMARY KEY, C2 INT) ENGINE = 'MYISAM' ;
--- on slave: original values ---
INSERT INTO t7 VALUES (1,3), (2,6), (3,9);
SELECT * FROM t7 ORDER BY C1;
......@@ -371,7 +370,6 @@ C1 C2
1 3
2 6
3 9
--- on master: new values inserted ---
INSERT INTO t7 VALUES (1,2), (2,4), (3,6);
SELECT * FROM t7 ORDER BY C1;
......@@ -379,48 +377,42 @@ C1 C2
1 2
2 4
3 6
--- on slave: old values should be overwritten by replicated values ---
SELECT * FROM t7 ORDER BY C1;
C1 C2
1 2
2 4
3 6
--- on master ---
DROP TABLE t7;
CREATE TABLE t7 (a INT PRIMARY KEY, b INT UNIQUE, c INT UNIQUE) ENGINE = 'MYISAM' ;
INSERT INTO t7 VALUES (99,99,99);
INSERT INTO t7 VALUES (99,22,33);
ERROR 23000: Duplicate entry '99' for key 1
INSERT INTO t7 VALUES (11,99,33);
ERROR 23000: Duplicate entry '99' for key 2
INSERT INTO t7 VALUES (11,22,99);
ERROR 23000: Duplicate entry '99' for key 3
SELECT * FROM t7 ORDER BY a;
CREATE TABLE t8 (a INT PRIMARY KEY, b INT UNIQUE, c INT UNIQUE) ENGINE = 'MYISAM' ;
INSERT INTO t8 VALUES (99,99,99);
INSERT INTO t8 VALUES (99,22,33);
ERROR 23000: Duplicate entry '99' for key 'PRIMARY'
INSERT INTO t8 VALUES (11,99,33);
ERROR 23000: Duplicate entry '99' for key 'b'
INSERT INTO t8 VALUES (11,22,99);
ERROR 23000: Duplicate entry '99' for key 'c'
SELECT * FROM t8 ORDER BY a;
a b c
99 99 99
--- on slave ---
SELECT * FROM t7 ORDER BY a;
SELECT * FROM t8 ORDER BY a;
a b c
99 99 99
INSERT INTO t7 VALUES (1,2,3), (2,4,6), (3,6,9);
SELECT * FROM t7 ORDER BY a;
INSERT INTO t8 VALUES (1,2,3), (2,4,6), (3,6,9);
SELECT * FROM t8 ORDER BY a;
a b c
1 2 3
2 4 6
3 6 9
99 99 99
--- on master ---
INSERT INTO t7 VALUES (2,4,8);
INSERT INTO t8 VALUES (2,4,8);
--- on slave ---
SELECT * FROM t7 ORDER BY a;
SELECT * FROM t8 ORDER BY a;
a b c
1 2 3
2 4 8
3 6 9
99 99 99
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7;
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8;
......@@ -363,7 +363,6 @@ SELECT C1,HEX(B1),HEX(B2) FROM t4 ORDER BY C1;
C1 HEX(B1) HEX(B2)
1 NULL 0
CREATE TABLE t7 (C1 INT PRIMARY KEY, C2 INT) ENGINE = 'INNODB' ;
--- on slave: original values ---
INSERT INTO t7 VALUES (1,3), (2,6), (3,9);
SELECT * FROM t7 ORDER BY C1;
......@@ -371,7 +370,6 @@ C1 C2
1 3
2 6
3 9
--- on master: new values inserted ---
INSERT INTO t7 VALUES (1,2), (2,4), (3,6);
SELECT * FROM t7 ORDER BY C1;
......@@ -379,48 +377,42 @@ C1 C2
1 2
2 4
3 6
--- on slave: old values should be overwritten by replicated values ---
SELECT * FROM t7 ORDER BY C1;
C1 C2
1 2
2 4
3 6
--- on master ---
DROP TABLE t7;
CREATE TABLE t7 (a INT PRIMARY KEY, b INT UNIQUE, c INT UNIQUE) ENGINE = 'INNODB' ;
INSERT INTO t7 VALUES (99,99,99);
INSERT INTO t7 VALUES (99,22,33);
ERROR 23000: Duplicate entry '99' for key 1
INSERT INTO t7 VALUES (11,99,33);
ERROR 23000: Duplicate entry '99' for key 2
INSERT INTO t7 VALUES (11,22,99);
ERROR 23000: Duplicate entry '99' for key 3
SELECT * FROM t7 ORDER BY a;
CREATE TABLE t8 (a INT PRIMARY KEY, b INT UNIQUE, c INT UNIQUE) ENGINE = 'INNODB' ;
INSERT INTO t8 VALUES (99,99,99);
INSERT INTO t8 VALUES (99,22,33);
ERROR 23000: Duplicate entry '99' for key 'PRIMARY'
INSERT INTO t8 VALUES (11,99,33);
ERROR 23000: Duplicate entry '99' for key 'b'
INSERT INTO t8 VALUES (11,22,99);
ERROR 23000: Duplicate entry '99' for key 'c'
SELECT * FROM t8 ORDER BY a;
a b c
99 99 99
--- on slave ---
SELECT * FROM t7 ORDER BY a;
SELECT * FROM t8 ORDER BY a;
a b c
99 99 99
INSERT INTO t7 VALUES (1,2,3), (2,4,6), (3,6,9);
SELECT * FROM t7 ORDER BY a;
INSERT INTO t8 VALUES (1,2,3), (2,4,6), (3,6,9);
SELECT * FROM t8 ORDER BY a;
a b c
1 2 3
2 4 6
3 6 9
99 99 99
--- on master ---
INSERT INTO t7 VALUES (2,4,8);
INSERT INTO t8 VALUES (2,4,8);
--- on slave ---
SELECT * FROM t7 ORDER BY a;
SELECT * FROM t8 ORDER BY a;
a b c
1 2 3
2 4 8
3 6 9
99 99 99
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7;
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8;
......@@ -112,46 +112,56 @@ drop database mysqltest3;
show binlog events from 102;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query 1 # drop database if exists mysqltest2
master-bin.000001 # Table_map 1 # mysql.proc
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # table_id: # (mysql.proc)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Table_map 1 # table_id: # (mysql.event)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # drop database if exists mysqltest3
master-bin.000001 # Table_map 1 # mysql.proc
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # table_id: # (mysql.proc)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Table_map 1 # table_id: # (mysql.event)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # create database mysqltest2 character set latin2
master-bin.000001 # Query 1 # create database mysqltest3
master-bin.000001 # Query 1 # drop database mysqltest3
master-bin.000001 # Table_map 1 # mysql.proc
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # table_id: # (mysql.proc)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Table_map 1 # table_id: # (mysql.event)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # create database mysqltest3
master-bin.000001 # Query 1 # use `mysqltest2`; create table t1 (a int auto_increment primary key, b varchar(100))
master-bin.000001 # Table_map 1 # mysqltest2.t1
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # mysqltest2.t1
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # mysqltest2.t1
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # mysqltest2.t1
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # mysqltest2.t1
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # table_id: # (mysqltest2.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Table_map 1 # table_id: # (mysqltest2.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Table_map 1 # table_id: # (mysqltest2.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Table_map 1 # table_id: # (mysqltest2.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Table_map 1 # table_id: # (mysqltest2.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # use `mysqltest2`; truncate table t1
master-bin.000001 # Table_map 1 # mysqltest2.t1
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # mysqltest2.t1
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # mysqltest2.t1
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # mysqltest2.t1
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # table_id: # (mysqltest2.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Table_map 1 # table_id: # (mysqltest2.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Table_map 1 # table_id: # (mysqltest2.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Table_map 1 # table_id: # (mysqltest2.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # use `mysqltest2`; truncate table t1
master-bin.000001 # Table_map 1 # mysqltest2.t1
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # table_id: # (mysqltest2.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # drop database mysqltest2
master-bin.000001 # Table_map 1 # mysql.proc
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # table_id: # (mysql.proc)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Table_map 1 # table_id: # (mysql.event)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # drop database mysqltest3
master-bin.000001 # Table_map 1 # mysql.proc
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # table_id: # (mysql.proc)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Table_map 1 # table_id: # (mysql.event)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
select "--- --global--" as "";
--- --global--
......
......@@ -126,12 +126,12 @@ NULL 4 2
NULL 5 10
NULL 6 12
CREATE TABLE t7 (UNIQUE(b)) SELECT a,b FROM tt3;
ERROR 23000: Duplicate entry '2' for key 1
ERROR 23000: Duplicate entry '2' for key 'b'
SHOW BINLOG EVENTS FROM 1326;
Log_name Pos Event_type Server_id End_log_pos Info
CREATE TABLE t7 (a INT, b INT UNIQUE);
INSERT INTO t7 SELECT a,b FROM tt3;
ERROR 23000: Duplicate entry '2' for key 1
ERROR 23000: Duplicate entry '2' for key 'b'
SELECT * FROM t7 ORDER BY a,b;
a b
1 2
......@@ -140,8 +140,8 @@ a b
SHOW BINLOG EVENTS FROM 1326;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 1326 Query 1 1426 use `test`; CREATE TABLE t7 (a INT, b INT UNIQUE)
master-bin.000001 1426 Table_map 1 1466 test.t7
master-bin.000001 1466 Write_rows 1 1522
master-bin.000001 1426 Table_map 1 1466 table_id: # (test.t7)
master-bin.000001 1466 Write_rows 1 1522 table_id: # flags: STMT_END_F
SELECT * FROM t7 ORDER BY a,b;
a b
1 2
......@@ -156,8 +156,8 @@ Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
SHOW BINLOG EVENTS FROM 1522;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 1522 Table_map 1 1562 test.t7
master-bin.000001 1562 Write_rows 1 1618
master-bin.000001 1522 Table_map 1 1562 table_id: # (test.t7)
master-bin.000001 1562 Write_rows 1 1618 table_id: # flags: STMT_END_F
SELECT * FROM t7 ORDER BY a,b;
a b
1 2
......
......@@ -16,8 +16,8 @@ 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 222 use `test`; create table t1(a int not null primary key) engine=myisam
master-bin.000001 222 Table_map 1 261 test.t1
master-bin.000001 261 Write_rows 1 305
master-bin.000001 222 Table_map 1 261 table_id: # (test.t1)
master-bin.000001 261 Write_rows 1 305 table_id: # flags: STMT_END_F
master-bin.000001 305 Query 1 380 use `test`; flush tables
select * from t1;
a
......
......@@ -21,12 +21,12 @@ show binlog events;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4
master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=MyISAM
master-bin.000001 # Table_map 1 # test.t1
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # table_id: # (test.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # use `test`; drop table t1
master-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null)ENGINE=MyISAM
master-bin.000001 # Table_map 1 # test.t1
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # table_id: # (test.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # use `test`; drop table t1
show binlog events from 102 limit 1;
Log_name Pos Event_type Server_id End_log_pos Info
......@@ -34,10 +34,10 @@ master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_in
show binlog events from 102 limit 2;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=MyISAM
master-bin.000001 # Table_map 1 # test.t1
master-bin.000001 # Table_map 1 # table_id: # (test.t1)
show binlog events from 102 limit 2,1;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
flush logs;
create table t5 (a int)ENGINE=MyISAM;
drop table t5;
......@@ -51,42 +51,44 @@ show binlog events;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4
master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=MyISAM
master-bin.000001 # Table_map 1 # test.t1
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # table_id: # (test.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # use `test`; drop table t1
master-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null)ENGINE=MyISAM
master-bin.000001 # Table_map 1 # test.t1
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # table_id: # (test.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # use `test`; drop table t1
master-bin.000001 # Rotate 1 # master-bin.000002;pos=4
show binlog events in 'master-bin.000002';
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000002 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4
master-bin.000002 # Table_map 1 # table_id: # (mysql.slow_log)
master-bin.000002 # Table_map 1 # table_id: # (mysql.general_log)
master-bin.000002 # Query 1 # use `test`; create table t5 (a int)ENGINE=MyISAM
master-bin.000002 # Query 1 # use `test`; drop table t5
master-bin.000002 # Query 1 # use `test`; create table t1 (n int)ENGINE=MyISAM
master-bin.000002 # Table_map 1 # test.t1
master-bin.000002 # Write_rows 1 #
master-bin.000002 # Table_map 1 # table_id: # (test.t1)
master-bin.000002 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000002 # Query 1 # use `test`; drop table t1
show binary logs;
Log_name File_size
master-bin.000001 1332
master-bin.000002 525
master-bin.000002 635
start slave;
show binary logs;
Log_name File_size
slave-bin.000001 1506
slave-bin.000002 350
slave-bin.000002 460
show binlog events in 'slave-bin.000001' from 4;
Log_name Pos Event_type Server_id End_log_pos Info
slave-bin.000001 # Format_desc 2 # Server ver: VERSION, Binlog ver: 4
slave-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=MyISAM
slave-bin.000001 # Table_map 1 # test.t1
slave-bin.000001 # Write_rows 1 #
slave-bin.000001 # Table_map 1 # table_id: # (test.t1)
slave-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
slave-bin.000001 # Query 1 # use `test`; drop table t1
slave-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null)ENGINE=MyISAM
slave-bin.000001 # Table_map 1 # test.t1
slave-bin.000001 # Write_rows 1 #
slave-bin.000001 # Table_map 1 # table_id: # (test.t1)
slave-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
slave-bin.000001 # Query 1 # use `test`; drop table t1
slave-bin.000001 # Query 1 # use `test`; create table t5 (a int)ENGINE=MyISAM
slave-bin.000001 # Query 1 # use `test`; drop table t5
......@@ -94,12 +96,14 @@ slave-bin.000001 # Rotate 2 # slave-bin.000002;pos=4
show binlog events in 'slave-bin.000002' from 4;
Log_name Pos Event_type Server_id End_log_pos Info
slave-bin.000002 # Format_desc 2 # Server ver: VERSION, Binlog ver: 4
slave-bin.000002 # Table_map 2 # table_id: # (mysql.slow_log)
slave-bin.000002 # Table_map 2 # table_id: # (mysql.general_log)
slave-bin.000002 # Query 1 # use `test`; create table t1 (n int)ENGINE=MyISAM
slave-bin.000002 # Table_map 1 # test.t1
slave-bin.000002 # Write_rows 1 #
slave-bin.000002 # Table_map 1 # table_id: # (test.t1)
slave-bin.000002 # Write_rows 1 # table_id: # flags: STMT_END_F
slave-bin.000002 # Query 1 # use `test`; drop table t1
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
# 127.0.0.1 root MASTER_PORT 1 master-bin.000002 525 # # master-bin.000002 Yes Yes # 0 0 525 # None 0 No #
# 127.0.0.1 root MASTER_PORT 1 master-bin.000002 635 # # master-bin.000002 Yes Yes # 0 0 635 # None 0 No #
show binlog events in 'slave-bin.000005' from 4;
ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Could not find target log
......@@ -21,13 +21,13 @@ show binlog events;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4
master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=InnoDB
master-bin.000001 # Table_map 1 # test.t1
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # table_id: # (test.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Xid 1 # COMMIT /* XID */
master-bin.000001 # Query 1 # use `test`; drop table t1
master-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null)ENGINE=InnoDB
master-bin.000001 # Table_map 1 # test.t1
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # table_id: # (test.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Xid 1 # COMMIT /* XID */
master-bin.000001 # Query 1 # use `test`; drop table t1
show binlog events from 102 limit 1;
......@@ -36,10 +36,10 @@ master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_in
show binlog events from 102 limit 2;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=InnoDB
master-bin.000001 # Table_map 1 # test.t1
master-bin.000001 # Table_map 1 # table_id: # (test.t1)
show binlog events from 102 limit 2,1;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
flush logs;
create table t5 (a int)ENGINE=InnoDB;
drop table t5;
......@@ -53,46 +53,48 @@ show binlog events;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4
master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=InnoDB
master-bin.000001 # Table_map 1 # test.t1
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # table_id: # (test.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Xid 1 # COMMIT /* XID */
master-bin.000001 # Query 1 # use `test`; drop table t1
master-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null)ENGINE=InnoDB
master-bin.000001 # Table_map 1 # test.t1
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # table_id: # (test.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Xid 1 # COMMIT /* XID */
master-bin.000001 # Query 1 # use `test`; drop table t1
master-bin.000001 # Rotate 1 # master-bin.000002;pos=4
show binlog events in 'master-bin.000002';
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000002 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4
master-bin.000002 # Table_map 1 # table_id: # (mysql.slow_log)
master-bin.000002 # Table_map 1 # table_id: # (mysql.general_log)
master-bin.000002 # Query 1 # use `test`; create table t5 (a int)ENGINE=InnoDB
master-bin.000002 # Query 1 # use `test`; drop table t5
master-bin.000002 # Query 1 # use `test`; create table t1 (n int)ENGINE=InnoDB
master-bin.000002 # Table_map 1 # test.t1
master-bin.000002 # Write_rows 1 #
master-bin.000002 # Table_map 1 # table_id: # (test.t1)
master-bin.000002 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000002 # Xid 1 # COMMIT /* XID */
master-bin.000002 # Query 1 # use `test`; drop table t1
show binary logs;
Log_name File_size
master-bin.000001 1386
master-bin.000002 552
master-bin.000002 662
start slave;
show binary logs;
Log_name File_size
slave-bin.000001 1560
slave-bin.000002 377
slave-bin.000002 487
show binlog events in 'slave-bin.000001' from 4;
Log_name Pos Event_type Server_id End_log_pos Info
slave-bin.000001 # Format_desc 2 # Server ver: VERSION, Binlog ver: 4
slave-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=InnoDB
slave-bin.000001 # Table_map 1 # test.t1
slave-bin.000001 # Write_rows 1 #
slave-bin.000001 # Table_map 1 # table_id: # (test.t1)
slave-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
slave-bin.000001 # Xid 1 # COMMIT /* XID */
slave-bin.000001 # Query 1 # use `test`; drop table t1
slave-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null)ENGINE=InnoDB
slave-bin.000001 # Table_map 1 # test.t1
slave-bin.000001 # Write_rows 1 #
slave-bin.000001 # Table_map 1 # table_id: # (test.t1)
slave-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
slave-bin.000001 # Xid 1 # COMMIT /* XID */
slave-bin.000001 # Query 1 # use `test`; drop table t1
slave-bin.000001 # Query 1 # use `test`; create table t5 (a int)ENGINE=InnoDB
......@@ -101,13 +103,15 @@ slave-bin.000001 # Rotate 2 # slave-bin.000002;pos=4
show binlog events in 'slave-bin.000002' from 4;
Log_name Pos Event_type Server_id End_log_pos Info
slave-bin.000002 # Format_desc 2 # Server ver: VERSION, Binlog ver: 4
slave-bin.000002 # Table_map 2 # table_id: # (mysql.slow_log)
slave-bin.000002 # Table_map 2 # table_id: # (mysql.general_log)
slave-bin.000002 # Query 1 # use `test`; create table t1 (n int)ENGINE=InnoDB
slave-bin.000002 # Table_map 1 # test.t1
slave-bin.000002 # Write_rows 1 #
slave-bin.000002 # Table_map 1 # table_id: # (test.t1)
slave-bin.000002 # Write_rows 1 # table_id: # flags: STMT_END_F
slave-bin.000002 # Xid 1 # COMMIT /* XID */
slave-bin.000002 # Query 1 # use `test`; drop table t1
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
# 127.0.0.1 root MASTER_PORT 1 master-bin.000002 552 # # master-bin.000002 Yes Yes # 0 0 552 # None 0 No #
# 127.0.0.1 root MASTER_PORT 1 master-bin.000002 662 # # master-bin.000002 Yes Yes # 0 0 662 # None 0 No #
show binlog events in 'slave-bin.000005' from 4;
ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Could not find target log
......@@ -58,4 +58,4 @@ Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File
flush logs;
show master status;
File Position Binlog_Do_DB Binlog_Ignore_DB
master-bin.000002 102 <Binlog_Ignore_DB>
master-bin.000002 212 <Binlog_Ignore_DB>
......@@ -35,11 +35,11 @@ master-bin.000001 4 Format_desc 1 102 Server ver: VERSION, Binlog ver: 4
master-bin.000001 102 Query 1 193 use `test`; DROP TABLE IF EXISTS test.t2
master-bin.000001 193 Query 1 299 use `test`; CREATE TABLE test.t1 (a INT,PRIMARY KEY(a))
master-bin.000001 299 Query 1 405 use `test`; CREATE TABLE test.t2 (a INT,PRIMARY KEY(a))
master-bin.000001 405 Table_map 1 444 test.t1
master-bin.000001 444 Write_rows 1 483
master-bin.000001 483 Table_map 1 540 mysql.proc
master-bin.000001 540 Write_rows 1 723
master-bin.000001 723 Table_map 1 762 test.t2
master-bin.000001 762 Write_rows 1 796
master-bin.000001 405 Table_map 1 444 table_id: # (test.t1)
master-bin.000001 444 Write_rows 1 483 table_id: # flags: STMT_END_F
master-bin.000001 483 Table_map 1 540 table_id: # (mysql.proc)
master-bin.000001 540 Write_rows 1 723 table_id: # flags: STMT_END_F
master-bin.000001 723 Table_map 1 762 table_id: # (test.t2)
master-bin.000001 762 Write_rows 1 796 table_id: # flags: STMT_END_F
DROP PROCEDURE IF EXISTS test.p1;
DROP TABLE IF EXISTS test.t1;
......@@ -5,7 +5,7 @@ create table t1 (a int, b int) engine=innodb;
begin;
insert into t1 values (1,2);
commit;
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /Server ver: .*, Binlog ver: .*/Server ver: #, Binlog ver: #/
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /Server ver: .*, Binlog ver: .*/Server ver: #, Binlog ver: #/ /table_id: [0-9]+/table_id: #/
show binlog events;
drop table t1;
......
......@@ -35,11 +35,13 @@ create table t1 (a int primary key) engine=ndb;
create table t2 (a int primary key) engine=ndb;
--replace_result $binlog_start <binlog_start>
--replace_column 2 # 4 # 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
--eval show binlog events from $binlog_start
--connection server1
--replace_result $binlog_start <binlog_start>
--replace_column 2 # 4 # 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
--eval show binlog events from $binlog_start
......@@ -55,6 +57,7 @@ alter table t2 add column (b int);
--connections server1
--replace_result $binlog_start <binlog_start>
--replace_column 2 # 4 # 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
--eval show binlog events from $binlog_start
......@@ -75,6 +78,7 @@ drop table mysqltest.t1;
--connection server1
--replace_result $binlog_start <binlog_start>
--replace_column 2 # 4 # 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
--eval show binlog events from $binlog_start
......@@ -93,6 +97,7 @@ create table t1 (a int primary key) engine=ndb;
--connection server2
--replace_result $binlog_start <binlog_start>
--replace_column 2 # 4 # 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
--eval show binlog events from $binlog_start
--connection server2
......@@ -146,4 +151,5 @@ drop table t1;
--connection server2
--replace_result $binlog_start <binlog_start>
--replace_column 2 # 4 # 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
--eval show binlog events from $binlog_start
......@@ -14,6 +14,7 @@ create table t1 (a int primary key, b int) engine=ndb;
insert into t1 values (1, 1);
--replace_result $binlog_start <binlog_start>
--replace_column 2 # 4 # 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
--eval show binlog events from $binlog_start
drop database mysqltest;
......@@ -22,6 +22,7 @@ create table t1 engine=HEAP select 10 as a;
insert into t1 values(11);
save_master_pos;
--replace_column 2 # 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events from 79;
connection slave;
reset slave;
......@@ -40,6 +41,7 @@ select * from t1;
select * from t1 limit 10;
save_master_pos;
--replace_column 2 # 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events in 'master-bin.002' from 79;
connection slave;
......
......@@ -21,6 +21,7 @@ connection slave;
sync_with_master;
select count(*) from test.t1; # check that LOAD was replicated
--replace_column 2 # 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events from 102; # should be nothing
# Cleanup
......
......@@ -90,4 +90,5 @@ drop table t1;
--connection master
let $VERSION=`select version()`;
--replace_result $VERSION VERSION
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events;
......@@ -69,6 +69,7 @@ select * from t1 order by pk1;
--connection master
let $VERSION=`select version()`;
--replace_result $VERSION VERSION
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events;
#
......
......@@ -17,6 +17,7 @@ USE test_ignore;
CREATE TABLE t2 (a INT, b INT);
SHOW TABLES;
INSERT INTO t2 VALUES (3,3), (4,4);
--replace_regex /table_id: [0-9]+/table_id: #/
SHOW BINLOG EVENTS FROM 102;
sync_slave_with_master;
--echo **** On Slave ****
......
......@@ -26,6 +26,7 @@ CREATE TABLE t2 (a INT, b INT) ENGINE=Merge;
CREATE TABLE t3 (a INT, b INT) CHARSET=utf8;
CREATE TABLE t4 (a INT, b INT) ENGINE=Merge CHARSET=utf8;
--replace_column 1 # 4 # 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
--query_vertical SHOW BINLOG EVENTS FROM 212
--echo **** On Master ****
--query_vertical SHOW CREATE TABLE t1
......@@ -60,6 +61,7 @@ connection master;
--error 1062
CREATE TABLE t7 (UNIQUE(b)) SELECT a,b FROM tt3;
# Shouldn't be written to the binary log
--replace_regex /table_id: [0-9]+/table_id: #/
SHOW BINLOG EVENTS FROM 1326;
# Test that INSERT-SELECT works the same way as for SBR.
......@@ -68,6 +70,7 @@ CREATE TABLE t7 (a INT, b INT UNIQUE);
INSERT INTO t7 SELECT a,b FROM tt3;
SELECT * FROM t7 ORDER BY a,b;
# Should be written to the binary log
--replace_regex /table_id: [0-9]+/table_id: #/
SHOW BINLOG EVENTS FROM 1326;
sync_slave_with_master;
SELECT * FROM t7 ORDER BY a,b;
......@@ -78,6 +81,7 @@ INSERT INTO tt4 VALUES (4,8), (5,10), (6,12);
BEGIN;
INSERT INTO t7 SELECT a,b FROM tt4;
ROLLBACK;
--replace_regex /table_id: [0-9]+/table_id: #/
SHOW BINLOG EVENTS FROM 1522;
SELECT * FROM t7 ORDER BY a,b;
sync_slave_with_master;
......@@ -91,6 +95,7 @@ CREATE TEMPORARY TABLE tt6 LIKE tt4;
--echo **** On Master ****
--query_vertical SHOW CREATE TABLE t8
--query_vertical SHOW CREATE TABLE t9
--replace_regex /table_id: [0-9]+/table_id: #/
SHOW BINLOG EVENTS FROM 1618;
sync_slave_with_master;
--echo **** On Slave ****
......
......@@ -32,6 +32,7 @@ connection master;
DROP TABLE t1,t2;
let $VERSION=`select version()`;
--replace_result $VERSION VERSION
--replace_regex /table_id: [0-9]+/table_id: #/
SHOW BINLOG EVENTS;
SHOW TABLES;
sync_slave_with_master;
......
......@@ -49,6 +49,7 @@ SELECT * FROM test.t2;
connection master;
let $VERSION=`select version()`;
--replace_result $VERSION VERSION
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events;
# Cleanup
......
......@@ -343,6 +343,7 @@ drop trigger trg;
insert into t1 values (1);
select * from t1;
--replace_column 2 # 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events in 'master-bin.000001' from 102;
sync_slave_with_master;
select * from t1;
......
......@@ -2583,6 +2583,7 @@ begin
show warnings;
end|
--disable_parsing
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events;
show storage engines;
show master status;
......
......@@ -15,6 +15,7 @@ begin
show grants for 'root'@'localhost';
end|
--disable_parsing
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events;
show storage engines;
show master status;
......
......@@ -14,6 +14,7 @@ set @var1= "';aaa";
SET @var2=char(ascii('a'));
insert into t1 values (@var1),(@var2);
--replace_column 2 # 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events from 102;
# more important than SHOW BINLOG EVENTS, mysqlbinlog (where we
# absolutely need variables names to be quoted and strings to be
......
......@@ -310,7 +310,7 @@ void ndbcluster_binlog_init_share(NDB_SHARE *share, TABLE *_table)
table= 0;
break;
}
assign_new_table_id(table);
assign_new_table_id(table_share);
if (!table->record[1] || table->record[1] == table->record[0])
{
table->record[1]= alloc_root(&table->mem_root,
......@@ -1620,15 +1620,20 @@ static int open_binlog_index(THD *thd, TABLE_LIST *tables,
/*
Insert one row in the cluster_replication.binlog_index
declared friend in handler.h to be able to call write_row directly
so that this insert is not replicated
*/
int ndb_add_binlog_index(THD *thd, void *_row)
{
Binlog_index_row &row= *(Binlog_index_row *) _row;
int error= 0;
bool need_reopen;
/*
Turn of binlogging to prevent the table changes to be written to
the binary log.
*/
ulong saved_options= thd->options;
thd->options&= ~(OPTION_BIN_LOG);
for ( ; ; ) /* loop for need_reopen */
{
if (!binlog_index && open_binlog_index(thd, &binlog_tables, &binlog_index))
......@@ -1663,7 +1668,7 @@ int ndb_add_binlog_index(THD *thd, void *_row)
binlog_index->field[6]->store(row.n_schemaops);
int r;
if ((r= binlog_index->file->write_row(binlog_index->record[0])))
if ((r= binlog_index->file->ha_write_row(binlog_index->record[0])))
{
sql_print_error("NDB Binlog: Writing row to binlog_index: %d", r);
error= -1;
......@@ -1672,10 +1677,12 @@ int ndb_add_binlog_index(THD *thd, void *_row)
mysql_unlock_tables(thd, thd->lock);
thd->lock= 0;
thd->options= saved_options;
return 0;
add_binlog_index_err:
close_thread_tables(thd);
binlog_index= 0;
thd->options= saved_options;
return error;
}
......
......@@ -1907,8 +1907,6 @@ class handler :public Sql_alloc
{ return COMPATIBLE_DATA_NO; }
private:
friend int ndb_add_binlog_index(THD *, void *);
/*
Row-level primitives for storage engines. These should be
overridden by the storage engine class. To call these methods, use
......
......@@ -2680,6 +2680,8 @@ int MYSQL_LOG::flush_and_set_pending_rows_event(THD *thd, Rows_log_event* event)
DBUG_ASSERT(trx_data);
DBUG_PRINT("info", ("trx_data->pending=%p", trx_data->pending));
if (Rows_log_event* pending= trx_data->pending)
{
IO_CACHE *file= &log_file;
......
......@@ -5268,8 +5268,8 @@ int Rows_log_event::exec_event(st_relay_log_info *rli)
/*
If m_table_id == ULONG_MAX, then we have a dummy event that does
not contain any data. In that case, we just remove all tables in
the tables_to_lock list, step the relay log position, and return
with success.
the tables_to_lock list, close the thread tables, step the relay
log position, and return with success.
*/
if (m_table_id == ULONG_MAX)
{
......@@ -5280,6 +5280,7 @@ int Rows_log_event::exec_event(st_relay_log_info *rli)
DBUG_ASSERT(get_flags(STMT_END_F));
rli->clear_tables_to_lock();
close_thread_tables(thd);
thd->clear_error();
rli->inc_event_relay_log_pos();
DBUG_RETURN(0);
......@@ -5414,12 +5415,16 @@ int Rows_log_event::exec_event(st_relay_log_info *rli)
DBUG_ASSERT(row_end != NULL); // cannot happen
DBUG_ASSERT(row_end <= (const char*)m_rows_end);
#if 0
/* in_use can have been set to NULL in close_tables_for_reopen */
THD* old_thd= table->in_use;
if (!table->in_use)
table->in_use= thd;
#endif
error= do_exec_row(table);
#if 0
table->in_use = old_thd;
#endif
switch (error)
{
/* Some recoverable errors */
......@@ -5599,14 +5604,12 @@ bool Rows_log_event::write_data_body(IO_CACHE*file)
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
void Rows_log_event::pack_info(Protocol *protocol)
{
#ifdef DBUG_RBR
char buf[256];
char const *const flagstr=
get_flags(STMT_END_F) ? " flags: STMT_END_F" : "";
my_size_t bytes= snprintf(buf, sizeof(buf),
"table_id: %lu%s", m_table_id, flagstr);
protocol->store(buf, bytes, &my_charset_bin);
#endif
}
#endif
......@@ -6009,17 +6012,11 @@ bool Table_map_log_event::write_data_body(IO_CACHE *file)
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
void Table_map_log_event::pack_info(Protocol *protocol)
{
#ifdef DBUG_RBR
char buf[256];
my_size_t bytes= snprintf(buf, sizeof(buf),
"table_id: %lu (%s.%s)",
m_table_id, m_dbnam, m_tblnam);
protocol->store(buf, bytes, &my_charset_bin);
#else
char buf[256];
my_size_t bytes= snprintf(buf, sizeof(buf), "%s.%s", m_dbnam, m_tblnam);
protocol->store(buf, bytes, &my_charset_bin);
#endif
}
#endif
......
......@@ -26,7 +26,7 @@
/* inline since it's called below */
inline
injector::transaction::transaction(MYSQL_LOG *log, THD *thd)
: m_thd(thd)
: m_state(START_STATE), m_thd(thd)
{
/*
Default initialization of m_start_pos (which initializes it to garbage).
......@@ -64,12 +64,31 @@ int injector::transaction::commit()
DBUG_RETURN(0);
}
int injector::transaction::use_table(server_id_type sid, table tbl)
{
DBUG_ENTER("injector::transaction::use_table");
int error;
if ((error= check_state(TABLE_STATE)))
DBUG_RETURN(error);
m_thd->set_server_id(sid);
error= m_thd->binlog_write_table_map(tbl.get_table(),
tbl.is_transactional());
DBUG_RETURN(error);
}
int injector::transaction::write_row (server_id_type sid, table tbl,
MY_BITMAP const* cols, size_t colcnt,
record_type record)
{
DBUG_ENTER("injector::transaction::write_row(...)");
if (int error= check_state(ROW_STATE))
DBUG_RETURN(error);
m_thd->set_server_id(sid);
m_thd->binlog_write_row(tbl.get_table(), tbl.is_transactional(),
cols, colcnt, record);
......@@ -82,6 +101,10 @@ int injector::transaction::delete_row(server_id_type sid, table tbl,
record_type record)
{
DBUG_ENTER("injector::transaction::delete_row(...)");
if (int error= check_state(ROW_STATE))
DBUG_RETURN(error);
m_thd->set_server_id(sid);
m_thd->binlog_delete_row(tbl.get_table(), tbl.is_transactional(),
cols, colcnt, record);
......@@ -94,6 +117,10 @@ int injector::transaction::update_row(server_id_type sid, table tbl,
record_type before, record_type after)
{
DBUG_ENTER("injector::transaction::update_row(...)");
if (int error= check_state(ROW_STATE))
DBUG_RETURN(error);
m_thd->set_server_id(sid);
m_thd->binlog_update_row(tbl.get_table(), tbl.is_transactional(),
cols, colcnt, before, after);
......
......@@ -159,6 +159,24 @@ class injector
return *this;
}
/*
DESCRIPTION
Register table for use within the transaction. All tables
that are going to be used need to be registered before being
used below. The member function will fail with an error if
use_table() is called after any *_row() function has been
called for the transaction.
RETURN VALUE
0 All OK
>0 Failure
*/
int use_table(server_id_type sid, table tbl);
/*
Add a 'write row' entry to the transaction.
*/
......@@ -219,6 +237,62 @@ class injector
}
}
enum enum_state
{
START_STATE, /* Start state */
TABLE_STATE, /* At least one table has been registered */
ROW_STATE, /* At least one row has been registered */
STATE_COUNT /* State count and sink state */
} m_state;
/*
Check and update the state.
PARAMETER(S)
target_state
The state we are moving to: TABLE_STATE if we are
writing a table and ROW_STATE if we are writing a row.
DESCRIPTION
The internal state will be updated to the target state if
and only if it is a legal move. The only legal moves are:
START_STATE -> START_STATE
START_STATE -> TABLE_STATE
TABLE_STATE -> TABLE_STATE
TABLE_STATE -> ROW_STATE
That is:
- It is not possible to write any row before having written at
least one table
- It is not possible to write a table after at least one row
has been written
RETURN VALUE
0 All OK
-1 Incorrect call sequence
*/
int check_state(enum_state const target_state)
{
static char const *state_name[] = {
"START_STATE", "TABLE_STATE", "ROW_STATE", "STATE_COUNT"
};
DBUG_ASSERT(0 <= target_state && target_state <= STATE_COUNT);
DBUG_PRINT("info", ("In state %s", state_name[m_state]));
if (m_state <= target_state && target_state <= m_state + 1 &&
m_state < STATE_COUNT)
m_state= target_state;
else
m_state= STATE_COUNT;
return m_state == STATE_COUNT ? 1 : 0;
}
binlog_pos m_start_pos;
THD *m_thd;
};
......
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