1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
#
# === 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;
source include/have_binlog_format_mixed_or_statement.inc;
--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;
--echo # The above CREATE TABLE should be rolled back.
--echo # Now we check this fact and create table for real.
--error ER_NO_SUCH_TABLE
SELECT * FROM t1;
CREATE TABLE t1 (a INT);
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;
--echo # Check that the above DML statements were rolled back and
--echo # had no effect on t1.
SELECT * FROM t1;
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;
# The statements CREATE/DROP TRIGGER fails in case error happen during write to binlog.
# Since the previous statement CREATE TRIGGER failed with error ER_ERROR_ON_WRITE
# the trigger tr1 wasn't created so SHOW CREATE TRIGGER should return ER_TRG_DOES_NOT_EXIST.
--error ER_TRG_DOES_NOT_EXIST
SHOW CREATE TRIGGER tr1;
let $query= ALTER TABLE t1 ADD (b INT);
source include/binlog_inject_error.inc;
--echo # The above ALTER TABLE was rolled back. Check this.
SHOW CREATE TABLE t1;
let $query= CREATE VIEW v1 AS SELECT a FROM t1;
source include/binlog_inject_error.inc;
--echo # The above CREATE VIEW was rolled back. Check this.
--error ER_NO_SUCH_TABLE
SHOW CREATE VIEW v1;
let $query= CREATE PROCEDURE p1(OUT `rows` INT) SELECT count(*) INTO `rows` FROM t1;
source include/binlog_inject_error.inc;
--echo # The above CREATE Procedure was rolled back. Check this.
--error ER_SP_DOES_NOT_EXIST
SHOW CREATE PROCEDURE p1;
let $query= DROP TABLE t1;
source include/binlog_inject_error.inc;
--echo # The above DROP TABLE was rolled back. Delete it for real
--echo # this also checks that table was not deleted by the above
--echo # attempt.
DROP TABLE t1;
let $query= CREATE FUNCTION f1() RETURNS INT return 1;
source include/binlog_inject_error.inc;
--echo # The above CREATE Procedure was rolled back. Check this.
--error ER_SP_DOES_NOT_EXIST
SHOW CREATE FUNCTION f1;
let $query= CREATE USER user1;
source include/binlog_inject_error.inc;
--echo # Since the previous CREATE USER is failed due to an error while writing
--echo # to binlog and changes made by the statement has been rolled back
--echo # we have to create user1 to be able to test REVOKE ALL and DROP USER.
CREATE USER user1;
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 # Since the previous DROP USER is failed we have to do a clean up explicitly.
DROP USER user1;
--echo #
--echo # Cleanup
--echo #
disable_warnings;
DROP FUNCTION IF EXISTS f1;
DROP PROCEDURE IF EXISTS p1;
DROP VIEW IF EXISTS v1, v2;
enable_warnings;
|