summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <serg@serg.mylan>2005-02-23 14:55:16 +0100
committerunknown <serg@serg.mylan>2005-02-23 14:55:16 +0100
commit0cd185ea6a54ca2c8980b6c18371ed365d53f07c (patch)
tree553f259ed15c24faef8d9820ec14c75113487e6c
parent7d4ea5cfc2c9288f9f3d75e4477f85db86e90313 (diff)
downloadmariadb-git-0cd185ea6a54ca2c8980b6c18371ed365d53f07c.tar.gz
write "COMMIT" into binlog if there's no Xid at the end of transaction
new tests mysql-test/r/innodb.result: savepoint test mysql-test/t/innodb.test: savepoint test sql/log.cc: write "COMMIT" into binlog if there's no Xid at the end of transaction
-rw-r--r--mysql-test/r/binlog.result22
-rw-r--r--mysql-test/r/innodb.result6
-rw-r--r--mysql-test/t/binlog.test23
-rw-r--r--mysql-test/t/innodb.test4
-rw-r--r--sql/log.cc26
5 files changed, 72 insertions, 9 deletions
diff --git a/mysql-test/r/binlog.result b/mysql-test/r/binlog.result
new file mode 100644
index 00000000000..c49b764ed8d
--- /dev/null
+++ b/mysql-test/r/binlog.result
@@ -0,0 +1,22 @@
+drop table if exists t1, t2;
+create table t1 (a int) engine=bdb;
+create table t2 (a int) engine=innodb;
+begin;
+insert t1 values (5);
+commit;
+begin;
+insert t2 values (5);
+commit;
+show binlog events from 96;
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 96 Query 1 187 use `test`; drop table if exists t1, t2
+master-bin.000001 187 Query 1 285 use `test`; create table t1 (a int) engine=bdb
+master-bin.000001 285 Query 1 386 use `test`; create table t2 (a int) engine=innodb
+master-bin.000001 386 Query 1 455 use `test`; BEGIN
+master-bin.000001 455 Query 1 84 use `test`; insert t1 values (5)
+master-bin.000001 539 Query 1 154 use `test`; COMMIT
+master-bin.000001 609 Query 1 678 use `test`; BEGIN
+master-bin.000001 678 Query 1 84 use `test`; insert t2 values (5)
+master-bin.000001 762 Xid 1 111 COMMIT /* xid=10 */
+reset master;
+drop table t1,t2;
diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result
index d65ce794a75..91f74be9453 100644
--- a/mysql-test/r/innodb.result
+++ b/mysql-test/r/innodb.result
@@ -272,6 +272,10 @@ n
7
rollback to savepoint `my_savepoint`;
ERROR 42000: SAVEPOINT my_savepoint does not exist
+insert into t1 values (8);
+savepoint sv;
+commit;
+savepoint sv;
set autocommit=1;
rollback;
drop table t1;
@@ -1717,7 +1721,7 @@ Variable_name Value
Innodb_rows_deleted 2070
show status like "Innodb_rows_inserted";
Variable_name Value
-Innodb_rows_inserted 31708
+Innodb_rows_inserted 31709
show status like "Innodb_rows_updated";
Variable_name Value
Innodb_rows_updated 29530
diff --git a/mysql-test/t/binlog.test b/mysql-test/t/binlog.test
new file mode 100644
index 00000000000..bf2d949c106
--- /dev/null
+++ b/mysql-test/t/binlog.test
@@ -0,0 +1,23 @@
+#
+# misc binlogging tests that do not require a slave running
+#
+-- source include/have_bdb.inc
+-- source include/have_innodb.inc
+
+--disable_warnings
+drop table if exists t1, t2;
+--enable_warnings
+
+create table t1 (a int) engine=bdb;
+create table t2 (a int) engine=innodb;
+begin;
+insert t1 values (5);
+commit;
+begin;
+insert t2 values (5);
+commit;
+# first COMMIT must be Query_log_event, second - Xid_log_event
+show binlog events from 96;
+reset master;
+drop table t1,t2;
+
diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test
index 6514f3d5c94..82f91081d03 100644
--- a/mysql-test/t/innodb.test
+++ b/mysql-test/t/innodb.test
@@ -141,6 +141,10 @@ release savepoint `my_savepoint`;
select n from t1;
-- error 1305
rollback to savepoint `my_savepoint`;
+insert into t1 values (8);
+savepoint sv;
+commit;
+savepoint sv;
set autocommit=1;
# nop
rollback;
diff --git a/sql/log.cc b/sql/log.cc
index 5348ae795b5..1b5d533738a 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -103,11 +103,21 @@ static int binlog_prepare(THD *thd, bool all)
return 0;
}
-static int binlog_commit(THD *thd, bool all)
+static int binlog_real_commit(THD *thd, IO_CACHE *trans_log)
{
int error;
+ DBUG_ENTER("binlog_real_commit");
+
+ /* Update the binary log as we have cached some queries */
+ error= mysql_bin_log.write(thd, trans_log);
+ binlog_cleanup_trans(trans_log);
+ DBUG_RETURN(error);
+}
+
+static int binlog_commit(THD *thd, bool all)
+{
IO_CACHE *trans_log= (IO_CACHE*)thd->ha_data[binlog_hton.slot];
- DBUG_ENTER("binlog_commit");
+ DBUG_ENTER("binlog_real_commit");
DBUG_ASSERT(mysql_bin_log.is_open() &&
(all || !(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))));
@@ -116,11 +126,10 @@ static int binlog_commit(THD *thd, bool all)
// we're here because trans_log was flushed in MYSQL_LOG::log()
DBUG_RETURN(0);
}
+ Query_log_event qev(thd, "COMMIT", 6, TRUE, FALSE);
+ qev.write(trans_log);
- /* Update the binary log as we have cached some queries */
- error= mysql_bin_log.write(thd, trans_log);
- binlog_cleanup_trans(trans_log);
- DBUG_RETURN(error);
+ DBUG_RETURN(binlog_real_commit(thd, trans_log));
}
static int binlog_rollback(THD *thd, bool all)
@@ -2985,10 +2994,11 @@ void TC_LOG_BINLOG::close()
int TC_LOG_BINLOG::log(THD *thd, my_xid xid)
{
Xid_log_event xle(thd, xid);
- if (xle.write((IO_CACHE*)thd->ha_data[binlog_hton.slot]))
+ IO_CACHE *trans_log= (IO_CACHE*)thd->ha_data[binlog_hton.slot];
+ if (xle.write(trans_log))
return 0;
thread_safe_increment(prepared_xids, &LOCK_prep_xids);
- return !binlog_commit(thd,1); // invert return value
+ return !binlog_real_commit(thd, trans_log); // invert return value
}
void TC_LOG_BINLOG::unlog(ulong cookie, my_xid xid)