From 36936ecd64153436b8ae756d7c06da79a3dd0200 Mon Sep 17 00:00:00 2001 From: "elliot@mysql.com" <> Date: Fri, 2 Dec 2005 01:11:49 +0100 Subject: [PATCH] BUG#15406: Adding support for transactions to blackhole. Now when rolling back a transaction on a blackhole table, the transaction will not be written to the binlog. --- mysql-test/r/blackhole.result | 25 +++++++++++++++++++++++++ mysql-test/t/blackhole.test | 17 +++++++++++++++++ sql/ha_blackhole.h | 1 + 3 files changed, 43 insertions(+) diff --git a/mysql-test/r/blackhole.result b/mysql-test/r/blackhole.result index 38e548490fe..7b6e61984ec 100644 --- a/mysql-test/r/blackhole.result +++ b/mysql-test/r/blackhole.result @@ -110,16 +110,41 @@ 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 # Query 1 # use `test`; delete from t1 where a=10 +master-bin.000001 # Query 1 # use `test`; COMMIT master-bin.000001 # Query 1 # use `test`; update t1 set a=11 where a=15 +master-bin.000001 # Query 1 # use `test`; COMMIT master-bin.000001 # Query 1 # use `test`; insert into t1 values(1) +master-bin.000001 # Query 1 # use `test`; COMMIT master-bin.000001 # Query 1 # use `test`; insert ignore into t1 values(1) +master-bin.000001 # Query 1 # use `test`; COMMIT master-bin.000001 # Query 1 # use `test`; replace into t1 values(100) +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 # Begin_load_query 1 # ;file_id=1;block_len=581 master-bin.000001 # Execute_load_query 1 # use `test`; load data infile '../../std_data/words.dat' into table t2 ;file_id=1 +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 # Query 1 # use `test`; insert into t1 select * from t3 +master-bin.000001 # Query 1 # use `test`; COMMIT master-bin.000001 # Query 1 # use `test`; replace into t1 select * from t3 +master-bin.000001 # Query 1 # use `test`; COMMIT drop table t1,t2,t3; +reset master; +create table t1 (a int) engine=blackhole; +set autocommit=0; +start transaction; +insert into t1 values(1); +commit; +start transaction; +insert into t1 values(2); +rollback; +set autocommit=1; +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 (a int) engine=blackhole +master-bin.000001 # Query 1 # use `test`; BEGIN +master-bin.000001 # Query 1 # use `test`; insert into t1 values(1) +master-bin.000001 # Query 1 # use `test`; COMMIT diff --git a/mysql-test/t/blackhole.test b/mysql-test/t/blackhole.test index 257770d311c..1b5a9beb887 100644 --- a/mysql-test/t/blackhole.test +++ b/mysql-test/t/blackhole.test @@ -127,3 +127,20 @@ show binlog events; drop table t1,t2,t3; # End of 4.1 tests + +# Test that a transaction which is rolled back does not go into binlog +# and that a transaction which is committed does + +reset master; +create table t1 (a int) engine=blackhole; +set autocommit=0; +start transaction; +insert into t1 values(1); +commit; +start transaction; +insert into t1 values(2); +rollback; +set autocommit=1; +--replace_result $VERSION VERSION +--replace_column 2 # 5 # +show binlog events; diff --git a/sql/ha_blackhole.h b/sql/ha_blackhole.h index 1a5fc514644..15e12659aa0 100644 --- a/sql/ha_blackhole.h +++ b/sql/ha_blackhole.h @@ -84,4 +84,5 @@ public: THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to, enum thr_lock_type lock_type); + bool has_transactions() { return 1; } };