Current Path : /usr/opt/mysql57/mysql-test/suite/binlog/t/ |
FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64 |
Current File : //usr/opt/mysql57/mysql-test/suite/binlog/t/binlog_gtid_errors.test |
# ==== Purpose ==== # # Test errors/restrictions/conditions for the following variables: # # - GTID_EXECUTED # - readable, read-only, both session and global # - GTID_PURGED # - readable, read-only, global only # - GTID_OWNED # - readable, read-only, both session and global # - GTID_NEXT # - read-writable, session only # - must be set to UUID:NUMBER or AUTOMATIC (when gtid_mode=ON) # - only settable by SUPER # - not settable from sub-statement # - not settable from statement that also invokes sub-statement # - not settable inside transaction # - not settable when some gtid is owned # # Note: some variables related to GTIDs are tested in other files: # GTID_MODE - rpl_gtid_mode.test # ENFORCE_GTID_CONSISTENCY - binlog_enforce_gtid_consistency.test # GTID_PURGED - rpl_gtid_purged_*.test # # ==== Implementation ==== # # Just try all possibilities, verify that the correct error message is # given. # # ==== References ==== # # Implemented in WL#3584: Global Transaction Identifiers # Bug#20343644 ASSERTION AT BINLOG.CC:1120 WHEN GTID_MODE=ON, GTID_NEXT='UUID:NUMBER' --source include/have_innodb.inc --source include/have_log_bin.inc --source include/have_gtid.inc --source include/have_debug.inc # Clean gtid_executed so that test can execute after other tests RESET MASTER; --let $ida= aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa --let $idb= bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb --let $idc= cccccccc-cccc-cccc-cccc-cccccccccccc --let $idd= dddddddd-dddd-dddd-dddd-dddddddddddd --let $ide= eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee --let $idf= ffffffff-ffff-ffff-ffff-ffffffffffff --let $tab= `SELECT '\t'` --echo ==== Conditions for gtid_executed ==== --echo # Readable. --replace_regex /[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}:[0-9-]*// SELECT @@GLOBAL.GTID_EXECUTED; SELECT @@SESSION.GTID_EXECUTED; --echo # Read-only. --error ER_INCORRECT_GLOBAL_LOCAL_VAR eval SET @@GLOBAL.GTID_EXECUTED= '$ida:1'; --error ER_INCORRECT_GLOBAL_LOCAL_VAR eval SET @@SESSION.GTID_EXECUTED= '$ida:2'; --echo ==== Conditions for gtid_purged ==== --echo # Readable global variable --replace_regex /[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}:[0-9-]*// SELECT @@GLOBAL.GTID_PURGED; --echo # Not a session variable --error ER_INCORRECT_GLOBAL_LOCAL_VAR SELECT @@SESSION.GTID_PURGED; --echo # Read-only. --error ER_GLOBAL_VARIABLE eval SET @@SESSION.GTID_PURGED= '$ida:3'; --echo ==== Conditions for gtid_owned ==== --echo # Readable. SELECT @@GLOBAL.GTID_OWNED; SELECT @@SESSION.GTID_OWNED; --echo # Read-only. --error ER_INCORRECT_GLOBAL_LOCAL_VAR eval SET @@SESSION.GTID_OWNED= '$ida:5'; --error ER_INCORRECT_GLOBAL_LOCAL_VAR eval SET @@GLOBAL.GTID_OWNED= '$ida:6#1'; --echo ==== Valid and invalid values for gtid_next ==== --echo # Default should be AUTOMATIC SELECT @@SESSION.GTID_NEXT; SET @@SESSION.GTID_NEXT= 'AUTOMATIC'; SELECT @@SESSION.GTID_NEXT; eval SET @@SESSION.GTID_NEXT= '$ida:10'; SELECT @@SESSION.GTID_NEXT; ROLLBACK; eval SET @@SESSION.GTID_NEXT= ' $ida $tab : $tab 10 '; SELECT @@SESSION.GTID_NEXT; ROLLBACK; eval SET @@SESSION.GTID_NEXT= '$ida:0x10'; SELECT @@SESSION.GTID_NEXT; ROLLBACK; eval SET @@SESSION.GTID_NEXT= '$ida:010'; SELECT @@SESSION.GTID_NEXT; ROLLBACK; SET @@SESSION.GTID_NEXT= 'AUTOMATIC'; --error ER_MALFORMED_GTID_SPECIFICATION eval SET @@SESSION.GTID_NEXT= '$ida:10#'; SELECT @@SESSION.GTID_NEXT; --error ER_MALFORMED_GTID_SPECIFICATION eval SET @@SESSION.GTID_NEXT= '$ida:1-10'; SELECT @@SESSION.GTID_NEXT; --error ER_MALFORMED_GTID_SPECIFICATION eval SET @@SESSION.GTID_NEXT= '$ida:1:3'; SELECT @@SESSION.GTID_NEXT; --error ER_MALFORMED_GTID_SPECIFICATION eval SET @@SESSION.GTID_NEXT= '$ida:1,$ida:3'; SELECT @@SESSION.GTID_NEXT; --error ER_WRONG_VALUE_FOR_VAR SET @@SESSION.GTID_NEXT= NULL; SELECT @@SESSION.GTID_NEXT; --error ER_WRONG_TYPE_FOR_VAR SET @@SESSION.GTID_NEXT= 10; SELECT @@SESSION.GTID_NEXT; --error ER_MALFORMED_GTID_SPECIFICATION SET @@SESSION.GTID_NEXT= '10'; SELECT @@SESSION.GTID_NEXT; --error ER_MALFORMED_GTID_SPECIFICATION eval SET @@SESSION.GTID_NEXT= '$ida:'; SELECT @@SESSION.GTID_NEXT; --error ER_MALFORMED_GTID_SPECIFICATION eval SET @@SESSION.GTID_NEXT= '$ida:0'; SELECT @@SESSION.GTID_NEXT; --error ER_MALFORMED_GTID_SPECIFICATION eval SET @@SESSION.GTID_NEXT= '$ida:0x8000000000000000'; SELECT @@SESSION.GTID_NEXT; --error ER_MALFORMED_GTID_SPECIFICATION eval SET @@SESSION.GTID_NEXT= '$ida:-33'; SELECT @@SESSION.GTID_NEXT; --error ER_MALFORMED_GTID_SPECIFICATION eval SET @@SESSION.GTID_NEXT= '$ida:66-33'; SELECT @@SESSION.GTID_NEXT; --error ER_MALFORMED_GTID_SPECIFICATION eval SET @@SESSION.GTID_NEXT= '$ida:33 33'; SELECT @@SESSION.GTID_NEXT; --error ER_MALFORMED_GTID_SPECIFICATION eval SET @@SESSION.GTID_NEXT= '$ida-33'; SELECT @@SESSION.GTID_NEXT; --echo ==== Conditions for gtid_next ==== --echo # Initialize --eval CREATE FUNCTION f() RETURNS INT BEGIN RETURN 1; END CREATE TABLE t1 (a INT) ENGINE = InnoDB; CREATE USER nonsuper@localhost; GRANT SELECT ON *.* TO nonsuper@localhost; --connect (nonsuper,localhost,nonsuper,,) --connection default --echo # Read/write session SELECT @@SESSION.GTID_NEXT; eval SET @@SESSION.GTID_NEXT= '$ida:7'; ROLLBACK; --echo # not global --error ER_INCORRECT_GLOBAL_LOCAL_VAR SELECT @@GLOBAL.GTID_NEXT; --error ER_LOCAL_VARIABLE eval SET @@GLOBAL.GTID_NEXT= '$ida:8'; ROLLBACK; SET GTID_NEXT = 'AUTOMATIC'; --echo # Can't set value from stored function --eval CREATE FUNCTION set_var() RETURNS INT BEGIN SET @@SESSION.GTID_NEXT = '$ida:9'; RETURN 1; END --error ER_VARIABLE_NOT_SETTABLE_IN_SF_OR_TRIGGER SELECT set_var(); DROP FUNCTION set_var; --echo # Can't set value from trigger eval CREATE TRIGGER t BEFORE INSERT ON t1 FOR EACH ROW SET @@SESSION.GTID_NEXT = '$ida:10'; --error ER_VARIABLE_NOT_SETTABLE_IN_SF_OR_TRIGGER INSERT INTO t1 VALUES (1); DROP TRIGGER t; --echo # Can't set value when invoking SF --error ER_SET_STATEMENT_CANNOT_INVOKE_FUNCTION SET @@SESSION.GTID_NEXT = f(); --echo # must be SUPER --connection nonsuper --error ER_SPECIFIC_ACCESS_DENIED_ERROR eval SET @@SESSION.GTID_NEXT = '$ida:11'; --echo # can read even if non-SUPER SELECT @@SESSION.GTID_NEXT; --connection default --echo # can't set inside transaction BEGIN; --error ER_VARIABLE_NOT_SETTABLE_IN_TRANSACTION eval SET @@SESSION.GTID_NEXT = '$ida:12'; INSERT INTO t1 VALUES (4); ROLLBACK; --echo # can't set while owning a GTID eval SET @@SESSION.GTID_NEXT = '$ida:13'; --error ER_CANT_SET_GTID_NEXT_WHEN_OWNING_GTID eval SET @@SESSION.GTID_NEXT = '$ida:14'; # the above error will clean owned_gtid eval SET @@SESSION.GTID_NEXT = 'AUTOMATIC'; ROLLBACK; --echo # can't set while owning a GTID eval SET @@SESSION.GTID_NEXT = '$ida:13'; --error ER_CANT_SET_GTID_NEXT_WHEN_OWNING_GTID eval SET @@SESSION.GTID_NEXT = 'AUTOMATIC'; ROLLBACK; --echo # Can't set while owning ANONYMOUS --let $rpl_gtid_mode= OFF --source include/rpl_set_gtid_mode.inc SET GTID_NEXT = 'ANONYMOUS'; --error ER_CANT_SET_GTID_NEXT_WHEN_OWNING_GTID SET GTID_NEXT = 'ANONYMOUS'; SET GTID_NEXT = 'ANONYMOUS'; --error ER_CANT_SET_GTID_NEXT_WHEN_OWNING_GTID eval SET GTID_NEXT = '$ida:1'; SET GTID_NEXT = 'ANONYMOUS'; --error ER_CANT_SET_GTID_NEXT_WHEN_OWNING_GTID SET GTID_NEXT = 'AUTOMATIC'; SET GTID_NEXT = 'AUTOMATIC'; --let $rpl_gtid_mode= ON --source include/rpl_set_gtid_mode.inc eval SET @@SESSION.GTID_NEXT = '$ida:14'; --echo # can't do implicit commit while gtid_next=SID:GNO BEGIN; --error ER_CANT_DO_IMPLICIT_COMMIT_IN_TRX_WHEN_GTID_NEXT_IS_SET CREATE TABLE t2 (a INT); ROLLBACK; # ==== Purpose ==== # # Verify that we can succeed to commit a transaction with a specified gtid, # even if an error is caused by executing the statement 'CREATE TABLE' # in the middle. # # ==== References ==== # # Bug#20343644 ASSERTION AT BINLOG.CC:1120 WHEN GTID_MODE=ON, GTID_NEXT='UUID:NUMBER' eval SET @@SESSION.GTID_NEXT= '$ida:15'; BEGIN; INSERT INTO t1 VALUES (1); --error ER_CANT_DO_IMPLICIT_COMMIT_IN_TRX_WHEN_GTID_NEXT_IS_SET CREATE TABLE t2 (a INT); COMMIT; # ==== Purpose ==== # # Verify that we can succeed to commit a transaction with a specified gtid, # even if an error is caused by executing the statement 'CREATE..SELECT' # in the middle. # # ==== References ==== # # Bug#20444828 WL7592: ASSERT `THD->VARIABLES.GTID_NEXT.TYPE == GTID_GROUP' ON CREATE..SELECT --eval SET @@SESSION.GTID_NEXT= '$ida:16' --error ER_GTID_UNSAFE_CREATE_SELECT CREATE TABLE t2 AS SELECT * FROM t1; COMMIT; eval SET @@SESSION.GTID_NEXT = '$ida:17'; --echo # can't do implicit commit while gtid_next=SID:GNO SET AUTOCOMMIT = 0; INSERT INTO t1 VALUES (1); --error ER_CANT_DO_IMPLICIT_COMMIT_IN_TRX_WHEN_GTID_NEXT_IS_SET CREATE TABLE t2 (a INT); ROLLBACK; SELECT @@SESSION.GTID_NEXT; eval SET @@SESSION.GTID_NEXT = 'AUTOMATIC'; DROP TABLE t1; DROP FUNCTION f; DROP USER nonsuper@localhost; # It is (unfortunately) possible to set the value from a stored # procedure. No user should do this, it's just weird, but was hard # to prevent so instead we allow it. Although this is unsupported, we # have to check that at least there is no crash. --delimiter | eval CREATE PROCEDURE p () BEGIN SET @@SESSION.GTID_NEXT = '$ida:16'; ROLLBACK; SET @@SESSION.GTID_NEXT = 'AUTOMATIC'; END| --delimiter ; CALL p(); DROP PROCEDURE p;