File: transactions.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 (155 lines) | stat: -rw-r--r-- 4,723 bytes parent folder | download
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
--echo #
--echo # Tests of touching the rules table from different transactions.
--echo #

--source suite/query_rewrite_plugins/include/have_plugin_rewriter.inc
--source suite/query_rewrite_plugins/include/install_rewriter.inc

SET autocommit = 0;
SELECT @@autocommit;

--connect (conn1, localhost, root, , test)

START TRANSACTION;

INSERT INTO query_rewrite.rewrite_rules ( pattern, replacement )
VALUES ( 'SELECT "Rewrite me conn 1"', 'SELECT "Rewritten conn 1 rule 1"' );

COMMIT;

--connect (conn2, localhost, root, , test)

START TRANSACTION;

INSERT INTO query_rewrite.rewrite_rules ( pattern, replacement )
VALUES ( 'SELECT "Rewrite me conn 2"', 'SELECT "Rewritten conn 2 rule 1"' );

COMMIT;

CALL query_rewrite.flush_rewrite_rules();
SELECT "Rewrite me conn 1";
SELECT "Rewrite me conn 2";

--connection conn1
CALL query_rewrite.flush_rewrite_rules();
SELECT "Rewrite me conn 1";
SELECT "Rewrite me conn 2";

--disconnect conn1
--disconnect conn2
--connection default

SELECT "Rewrite me conn 1";
SELECT "Rewrite me conn 2";

--echo # This would cause failed assertion unless the mdl locks are released.
--error ER_SP_DOES_NOT_EXIST
SELECT xxx(pattern) FROM query_rewrite.rewrite_rules;

--source suite/query_rewrite_plugins/include/uninstall_rewriter.inc
--source include/disconnect_connections.inc

--echo #
--echo # Now make sure that everything works as long we do as we're supposed
--echo # to, even with autocommit = 0.
--echo #
SET autocommit = 0;
SELECT @@autocommit;
--source suite/query_rewrite_plugins/include/install_rewriter.inc
START TRANSACTION;

INSERT INTO query_rewrite.rewrite_rules ( pattern, replacement )
VALUES ( 'SELECT "Rewrite me"', 'SELECT "Rewritten w/rule 1"' );

CALL query_rewrite.flush_rewrite_rules();
SELECT 'Rewrite me';
SHOW STATUS LIKE 'Rewriter_%';

--source suite/query_rewrite_plugins/include/uninstall_rewriter.inc
--source include/disconnect_connections.inc

--echo #
--echo # Now check that we don't fail even if @@autocommit is 0. In this case
--echo # InnoDB times out waiting for a lock, the plugin can't load the rules,
--echo # and we expect a message in the error log.
--echo #
SET autocommit = 0;
SELECT @@autocommit;
--source suite/query_rewrite_plugins/include/install_rewriter.inc

CALL mtr.add_suppression("Got error from storage engine while refreshing rewrite rules.");

--echo # This would cause failed assertion unless the mdl locks are released.
--error ER_SP_DOES_NOT_EXIST
SELECT xxx(pattern) FROM query_rewrite.rewrite_rules;

START TRANSACTION;

INSERT INTO query_rewrite.rewrite_rules ( pattern, replacement )
VALUES ( 'SELECT "Rewrite me"', 'SELECT "Rewritten w/rule 1"' );

SET @@global.innodb_lock_wait_timeout = 1;
SELECT load_rewrite_rules();
SET @@global.innodb_lock_wait_timeout = DEFAULT;

SELECT 'Rewrite me';
SHOW STATUS LIKE 'Rewriter_%';
COMMIT;
SELECT 'Rewrite me';
SHOW STATUS LIKE 'Rewriter_%';
SELECT load_rewrite_rules();
SELECT 'Rewrite me';
SHOW STATUS LIKE 'Rewriter_%';

--source suite/query_rewrite_plugins/include/uninstall_rewriter.inc
--source include/disconnect_connections.inc

--echo #
--echo # Now let's make sure that everything works fine if we run with
--echo # autocommit.
--echo #
SET autocommit = 1;
SELECT @@autocommit;
--source suite/query_rewrite_plugins/include/install_rewriter.inc

--echo # This would cause failed assertion unless the mdl locks are released.
--error ER_SP_DOES_NOT_EXIST
SELECT xxx(pattern) FROM query_rewrite.rewrite_rules;

START TRANSACTION;

INSERT INTO query_rewrite.rewrite_rules ( pattern, replacement )
VALUES ( 'SELECT "Rewrite me"', 'SELECT "Rewritten w/rule 1"' );

SET @@global.innodb_lock_wait_timeout = 1;
SELECT load_rewrite_rules();
SET @@global.innodb_lock_wait_timeout = DEFAULT;
SELECT 'Rewrite me';
COMMIT;
SELECT 'Rewrite me';
SELECT load_rewrite_rules();
SELECT 'Rewrite me';

SET autocommit = DEFAULT;
--source suite/query_rewrite_plugins/include/uninstall_rewriter.inc
--source include/disconnect_connections.inc

--echo #
--echo # Bug#36784795 Query rewrite plugin not working when server runs with
--echo #              autocommit=OFF
--echo #
--source suite/query_rewrite_plugins/include/install_rewriter_with_optional_columns.inc

SET GLOBAL autocommit = 0;
SET SESSION autocommit = ON;
#Session autocommit is not needed to set to OFF for this test.
DELETE FROM query_rewrite.rewrite_rules;
INSERT INTO query_rewrite.rewrite_rules (pattern, replacement)
        VALUES('SELECT ?', 'SELECT ? + 1');
SELECT * FROM query_rewrite.rewrite_rules;
CALL query_rewrite.flush_rewrite_rules();
SELECT * FROM query_rewrite.rewrite_rules;
SET GLOBAL autocommit = DEFAULT;
SET SESSION autocommit = DEFAULT;

--source suite/query_rewrite_plugins/include/uninstall_rewriter.inc