mariadb/mysql-test/suite/binlog/t/binlog_write_error.test

103 lines
2.4 KiB
Text
Raw Normal View History

BUG#37148 Most callers of mysql_bin_log.write ignore the return result This is the non-ndb part of the patch. The return value of mysql_bin_log.write was ignored by most callers, which may lead to inconsistent on master and slave if the transaction was committed while the binlog was not correctly written. If my_error() is call in mysql_bin_log.write, this could also lead to assertion issue if my_ok() or my_error() is called after. This fixed the problem by let the caller to check and handle the return value of mysql_bin_log.write. This patch only adresses the simple cases. mysql-test/include/binlog_inject_error.inc: inject binlog write error when doing a query mysql-test/suite/binlog/t/binlog_write_error.test: Simple test case to check if proper error is reported when injecting binlog write errors. sql/events.cc: check return value of mysql_bin_log.write sql/log.cc: check return value of mysql_bin_log.write sql/log_event.cc: check return value of mysql_bin_log.write sql/log_event_old.cc: check return value of mysql_bin_log.write sql/mysql_priv.h: Change write_bin_log to return int instead of void sql/rpl_injector.cc: check return value of writing binlog sql/sp.cc: check return value of writing binlog sql/sp_head.cc: return 1 if writing binlog failed sql/sql_acl.cc: check return value of writing binlog sql/sql_base.cc: check return value of writing binlog sql/sql_class.h: Change binlog_show_create_table to return int sql/sql_db.cc: Change write_to_binlog to return int check return value of writing binlog sql/sql_delete.cc: check return value of writing binlog sql/sql_insert.cc: check return value of writing binlog sql/sql_load.cc: check return value of writing binlog sql/sql_parse.cc: check return value of writing binlog sql/sql_partition.cc: check return value of writing binlog sql/sql_rename.cc: check return value of writing binlog sql/sql_repl.cc: check return value of writing binlog sql/sql_table.cc: Change write_bin_log to return int, and return 1 if there was error writing binlog sql/sql_tablespace.cc: check return value of writing binlog sql/sql_trigger.cc: check return value of writing binlog sql/sql_udf.cc: check return value of writing binlog sql/sql_update.cc: check return value of writing binlog sql/sql_view.cc: check return value of writing binlog
2009-11-21 12:28:01 +08:00
#
# === Name ===
#
# binlog_write_error.test
#
# === Description ===
#
# This test case check if the error of writing binlog file is properly
# reported and handled when executing statements.
#
# === Related Bugs ===
#
# BUG#37148
#
source include/have_log_bin.inc;
source include/have_debug.inc;
merge mysql-5.1-rep+2-delivery1 --> mysql-5.1-rpl-merge Conflicts: Text conflict in .bzr-mysql/default.conf Text conflict in mysql-test/extra/rpl_tests/rpl_loaddata.test Text conflict in mysql-test/r/mysqlbinlog2.result Text conflict in mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result Text conflict in mysql-test/suite/binlog/r/binlog_unsafe.result Text conflict in mysql-test/suite/rpl/r/rpl_insert_id.result Text conflict in mysql-test/suite/rpl/r/rpl_loaddata.result Text conflict in mysql-test/suite/rpl/r/rpl_stm_auto_increment_bug33029.result Text conflict in mysql-test/suite/rpl/r/rpl_udf.result Text conflict in mysql-test/suite/rpl/t/rpl_slow_query_log.test Text conflict in sql/field.h Text conflict in sql/log.cc Text conflict in sql/log_event.cc Text conflict in sql/log_event_old.cc Text conflict in sql/mysql_priv.h Text conflict in sql/share/errmsg.txt Text conflict in sql/sp.cc Text conflict in sql/sql_acl.cc Text conflict in sql/sql_base.cc Text conflict in sql/sql_class.h Text conflict in sql/sql_db.cc Text conflict in sql/sql_delete.cc Text conflict in sql/sql_insert.cc Text conflict in sql/sql_lex.cc Text conflict in sql/sql_lex.h Text conflict in sql/sql_load.cc Text conflict in sql/sql_table.cc Text conflict in sql/sql_update.cc Text conflict in sql/sql_view.cc Conflict adding files to storage/innobase. Created directory. Conflict because storage/innobase is not versioned, but has versioned children. Versioned directory. Conflict adding file storage/innobase. Moved existing file to storage/innobase.moved. Conflict adding files to storage/innobase/handler. Created directory. Conflict because storage/innobase/handler is not versioned, but has versioned children. Versioned directory. Contents conflict in storage/innobase/handler/ha_innodb.cc
2010-01-07 15:39:11 +00:00
source include/have_binlog_format_mixed_or_statement.inc;
BUG#37148 Most callers of mysql_bin_log.write ignore the return result This is the non-ndb part of the patch. The return value of mysql_bin_log.write was ignored by most callers, which may lead to inconsistent on master and slave if the transaction was committed while the binlog was not correctly written. If my_error() is call in mysql_bin_log.write, this could also lead to assertion issue if my_ok() or my_error() is called after. This fixed the problem by let the caller to check and handle the return value of mysql_bin_log.write. This patch only adresses the simple cases. mysql-test/include/binlog_inject_error.inc: inject binlog write error when doing a query mysql-test/suite/binlog/t/binlog_write_error.test: Simple test case to check if proper error is reported when injecting binlog write errors. sql/events.cc: check return value of mysql_bin_log.write sql/log.cc: check return value of mysql_bin_log.write sql/log_event.cc: check return value of mysql_bin_log.write sql/log_event_old.cc: check return value of mysql_bin_log.write sql/mysql_priv.h: Change write_bin_log to return int instead of void sql/rpl_injector.cc: check return value of writing binlog sql/sp.cc: check return value of writing binlog sql/sp_head.cc: return 1 if writing binlog failed sql/sql_acl.cc: check return value of writing binlog sql/sql_base.cc: check return value of writing binlog sql/sql_class.h: Change binlog_show_create_table to return int sql/sql_db.cc: Change write_to_binlog to return int check return value of writing binlog sql/sql_delete.cc: check return value of writing binlog sql/sql_insert.cc: check return value of writing binlog sql/sql_load.cc: check return value of writing binlog sql/sql_parse.cc: check return value of writing binlog sql/sql_partition.cc: check return value of writing binlog sql/sql_rename.cc: check return value of writing binlog sql/sql_repl.cc: check return value of writing binlog sql/sql_table.cc: Change write_bin_log to return int, and return 1 if there was error writing binlog sql/sql_tablespace.cc: check return value of writing binlog sql/sql_trigger.cc: check return value of writing binlog sql/sql_udf.cc: check return value of writing binlog sql/sql_update.cc: check return value of writing binlog sql/sql_view.cc: check return value of writing binlog
2009-11-21 12:28:01 +08:00
--echo #
--echo # Initialization
--echo #
disable_warnings;
DROP TABLE IF EXISTS t1, t2;
DROP FUNCTION IF EXISTS f1;
DROP FUNCTION IF EXISTS f2;
DROP PROCEDURE IF EXISTS p1;
DROP PROCEDURE IF EXISTS p2;
DROP TRIGGER IF EXISTS tr1;
DROP TRIGGER IF EXISTS tr2;
DROP VIEW IF EXISTS v1, v2;
enable_warnings;
--echo #
--echo # Test injecting binlog write error when executing queries
--echo #
let $query= CREATE TABLE t1 (a INT);
source include/binlog_inject_error.inc;
INSERT INTO t1 VALUES (1),(2),(3);
let $query= INSERT INTO t1 VALUES (4),(5),(6);
source include/binlog_inject_error.inc;
let $query= UPDATE t1 set a=a+1;
source include/binlog_inject_error.inc;
let $query= DELETE FROM t1;
source include/binlog_inject_error.inc;
let $query= CREATE TRIGGER tr1 AFTER INSERT ON t1 FOR EACH ROW INSERT INTO t1 VALUES (new.a + 100);
source include/binlog_inject_error.inc;
let $query= DROP TRIGGER tr1;
source include/binlog_inject_error.inc;
let $query= ALTER TABLE t1 ADD (b INT);
source include/binlog_inject_error.inc;
let $query= CREATE VIEW v1 AS SELECT a FROM t1;
source include/binlog_inject_error.inc;
let $query= DROP VIEW v1;
source include/binlog_inject_error.inc;
let $query= CREATE PROCEDURE p1(OUT rows INT) SELECT count(*) INTO rows FROM t1;
source include/binlog_inject_error.inc;
let $query= DROP PROCEDURE p1;
source include/binlog_inject_error.inc;
let $query= DROP TABLE t1;
source include/binlog_inject_error.inc;
let $query= CREATE FUNCTION f1() RETURNS INT return 1;
source include/binlog_inject_error.inc;
let $query= DROP FUNCTION f1;
source include/binlog_inject_error.inc;
let $query= CREATE USER user1;
source include/binlog_inject_error.inc;
let $query= REVOKE ALL PRIVILEGES, GRANT OPTION FROM user1;
source include/binlog_inject_error.inc;
let $query= DROP USER user1;
source include/binlog_inject_error.inc;
--echo #
--echo # Cleanup
--echo #
disable_warnings;
DROP TABLE IF EXISTS t1, t2;
DROP FUNCTION IF EXISTS f1;
DROP PROCEDURE IF EXISTS p1;
DROP TRIGGER IF EXISTS tr1;
DROP VIEW IF EXISTS v1, v2;
enable_warnings;