summaryrefslogtreecommitdiff
path: root/mysql-test/suite/binlog/t/binlog_innodb.test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/suite/binlog/t/binlog_innodb.test')
-rw-r--r--mysql-test/suite/binlog/t/binlog_innodb.test133
1 files changed, 133 insertions, 0 deletions
diff --git a/mysql-test/suite/binlog/t/binlog_innodb.test b/mysql-test/suite/binlog/t/binlog_innodb.test
new file mode 100644
index 00000000000..3bad61db23a
--- /dev/null
+++ b/mysql-test/suite/binlog/t/binlog_innodb.test
@@ -0,0 +1,133 @@
+source include/have_innodb.inc;
+source include/have_log_bin.inc;
+
+SET BINLOG_FORMAT=MIXED;
+
+RESET MASTER;
+
+CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=INNODB;
+INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4),(5,5),(6,6);
+
+BEGIN;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+# Should be logged as statement
+UPDATE t1 SET b = 2*a WHERE a > 1;
+COMMIT;
+
+BEGIN;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+# Should be logged as rows
+UPDATE t1 SET b = a * a WHERE a > 3;
+COMMIT;
+
+# Check that errors are generated when trying to use READ COMMITTED
+# transaction isolation level in STATEMENT binlog mode.
+
+SET BINLOG_FORMAT=STATEMENT;
+
+BEGIN;
+SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
+error ER_BINLOG_LOGGING_IMPOSSIBLE;
+UPDATE t1 SET b = 1*a WHERE a > 1;
+COMMIT;
+
+BEGIN;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+error ER_BINLOG_LOGGING_IMPOSSIBLE;
+UPDATE t1 SET b = 2*a WHERE a > 2;
+COMMIT;
+
+BEGIN;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+UPDATE t1 SET b = 3*a WHERE a > 3;
+COMMIT;
+
+BEGIN;
+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+UPDATE t1 SET b = 4*a WHERE a > 4;
+COMMIT;
+
+SET BINLOG_FORMAT=MIXED;
+
+BEGIN;
+SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
+UPDATE t1 SET b = 1*a WHERE a > 1;
+COMMIT;
+
+BEGIN;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+UPDATE t1 SET b = 2*a WHERE a > 2;
+COMMIT;
+
+BEGIN;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+UPDATE t1 SET b = 3*a WHERE a > 3;
+COMMIT;
+
+BEGIN;
+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+UPDATE t1 SET b = 4*a WHERE a > 4;
+COMMIT;
+
+SET BINLOG_FORMAT=ROW;
+
+BEGIN;
+SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
+UPDATE t1 SET b = 1*a WHERE a > 1;
+COMMIT;
+
+BEGIN;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+UPDATE t1 SET b = 2*a WHERE a > 2;
+COMMIT;
+
+BEGIN;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+UPDATE t1 SET b = 3*a WHERE a > 3;
+COMMIT;
+
+BEGIN;
+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+UPDATE t1 SET b = 4*a WHERE a > 4;
+COMMIT;
+
+source include/show_binlog_events.inc;
+
+DROP TABLE t1;
+
+
+#
+# Let us test binlog_cache_use and binlog_cache_disk_use status vars.
+# Actually this test has nothing to do with innodb per se, it just requires
+# transactional table.
+#
+show status like "binlog_cache_use";
+show status like "binlog_cache_disk_use";
+
+create table t1 (a int) engine=innodb;
+
+# Now we are going to create transaction which is long enough so its
+# transaction binlog will be flushed to disk...
+let $1=2000;
+disable_query_log;
+begin;
+while ($1)
+{
+ eval insert into t1 values( $1 );
+ dec $1;
+}
+commit;
+enable_query_log;
+show status like "binlog_cache_use";
+show status like "binlog_cache_disk_use";
+
+# Transaction which should not be flushed to disk and so should not
+# increase binlog_cache_disk_use.
+begin;
+delete from t1;
+commit;
+show status like "binlog_cache_use";
+show status like "binlog_cache_disk_use";
+drop table t1;
+
+--echo End of tests