File: enforce_gtid_consistency_trx_nontrx_violation.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (94 lines) | stat: -rw-r--r-- 3,472 bytes parent folder | download | duplicates (2)
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
--let $gtid_violation= 1
--let $error_code= ER_GTID_UNSAFE_NON_TRANSACTIONAL_TABLE
--let $error_message= Statement violates GTID consistency: Updates to non-transactional tables
--let $sync_point= end_decide_logging_format
--let $statement_ends_transaction= 0

CREATE TABLE myisam1 (a INT) ENGINE = MyISAM;
CREATE TABLE myisam2 (a INT) ENGINE = MyISAM;
CREATE TABLE innodb (a INT) ENGINE = InnoDB;



# InnoDB and MyISAM on base tables in the same transaction or in the
# same statement is a GTID-violation.

--echo ---- InnoDB followed by MyISAM in one trx ----
if ($binlog_direct_non_transactional_updates == 0)
{
  if ($binlog_format == 'STATEMENT')
  {
    # In this case we get a warning for unsafe statement.
    --let $extra_warning_count= 1
  }
}
--disable_warnings
--let $pre_statement= BEGIN; INSERT INTO innodb VALUES (1)
--let $statement= INSERT INTO myisam1 VALUES (1)
--source extra/binlog_tests/enforce_gtid_consistency_statement.inc
--enable_warnings
--let $extra_warning_count= 0

--echo ---- InnoDB and MyISAM in one autocommit statement ----
CREATE TRIGGER trig BEFORE INSERT ON innodb FOR EACH ROW INSERT INTO myisam1 VALUES (1);
--let $statement= INSERT INTO innodb VALUES (1)
--let $statement_ends_transaction= 1
--source extra/binlog_tests/enforce_gtid_consistency_statement.inc

--echo ---- InnoDB and MyISAM in one statement inside trx ----
# If binlog_format==STATEMENT, there is a warning for unsafe statement.
if ($binlog_format == 'STATEMENT')
{
  --let $extra_warning_count= 1
}
# Disable warnings to make result the same regardles of binlog_format.
--disable_warnings
--let $pre_statement= BEGIN
--let $statement= INSERT INTO innodb VALUES (1)
--let $statement_ends_transaction= 0
--source extra/binlog_tests/enforce_gtid_consistency_statement.inc
DROP TRIGGER trig;
--let $extra_warning_count= 0
--enable_warnings

# If the MyISAM update is temporary and binlog_format='row', it is not a
# GTID-violation since the temporary updates are not logged. But if
# binlog_format=statement or mixed, it is an violation; that is what
# we check here.

--echo ---- InnoDB followed by temp MyISAM in one trx, binlog_format=stm ----
SET SESSION BINLOG_FORMAT = STATEMENT;

CREATE TEMPORARY TABLE tmp_myisam1 (a INT) ENGINE = MyISAM;
CREATE TEMPORARY TABLE tmp_myisam2 (a INT) ENGINE = MyISAM;

--let $pre_statement= BEGIN; INSERT INTO innodb VALUES (1)
--let $statement= INSERT INTO tmp_myisam1 VALUES (1)
--let $statement_ends_transaction= 0
--source extra/binlog_tests/enforce_gtid_consistency_statement.inc

--echo ---- InnoDB and temp MyISAM in one autocommit statement, binlog_format=stm ----
CREATE TRIGGER trig BEFORE INSERT ON innodb FOR EACH ROW INSERT INTO tmp_myisam1 VALUES (1);
--let $statement= INSERT INTO innodb VALUES (1)
--let $statement_ends_transaction= 1
--source extra/binlog_tests/enforce_gtid_consistency_statement.inc

--echo ---- InnoDB and temp MyISAM in one statement inside trx, binlog_format=stm ----
if (`SELECT @@GLOBAL.BINLOG_DIRECT_NON_TRANSACTIONAL_UPDATES`)
{
  # Unsafe warning
  --let $extra_warning_count= 1
}
--disable_warnings
--let $pre_statement= BEGIN
--let $statement= INSERT INTO innodb VALUES (1)
--let $statement_ends_transaction= 0
--source extra/binlog_tests/enforce_gtid_consistency_statement.inc
DROP TRIGGER trig;
--let $extra_warning_count= 0
--enable_warnings

DROP TABLE myisam1, myisam2, tmp_myisam1, tmp_myisam2, innodb;

--replace_regex /'[A-Z]*'/#/
eval SET BINLOG_FORMAT = '$binlog_format';