| 1 |
--echo # |
| 2 |
--echo # Tests of touching the rules table from different transactions. |
| 3 |
--echo # |
| 4 |
|
| 5 |
--source suite/query_rewrite_plugins/include/have_plugin_rewriter.inc |
| 6 |
--source suite/query_rewrite_plugins/include/install_rewriter.inc |
| 7 |
|
| 8 |
SET autocommit = 0; |
| 9 |
SELECT @@autocommit; |
| 10 |
|
| 11 |
--connect (conn1, localhost, root, , test) |
| 12 |
|
| 13 |
START TRANSACTION; |
| 14 |
|
| 15 |
INSERT INTO query_rewrite.rewrite_rules ( pattern, replacement ) |
| 16 |
VALUES ( 'SELECT "Rewrite me conn 1"', 'SELECT "Rewritten conn 1 rule 1"' ); |
| 17 |
|
| 18 |
COMMIT; |
| 19 |
|
| 20 |
--connect (conn2, localhost, root, , test) |
| 21 |
|
| 22 |
START TRANSACTION; |
| 23 |
|
| 24 |
INSERT INTO query_rewrite.rewrite_rules ( pattern, replacement ) |
| 25 |
VALUES ( 'SELECT "Rewrite me conn 2"', 'SELECT "Rewritten conn 2 rule 1"' ); |
| 26 |
|
| 27 |
COMMIT; |
| 28 |
|
| 29 |
CALL query_rewrite.flush_rewrite_rules(); |
| 30 |
SELECT "Rewrite me conn 1"; |
| 31 |
SELECT "Rewrite me conn 2"; |
| 32 |
|
| 33 |
--connection conn1 |
| 34 |
CALL query_rewrite.flush_rewrite_rules(); |
| 35 |
SELECT "Rewrite me conn 1"; |
| 36 |
SELECT "Rewrite me conn 2"; |
| 37 |
|
| 38 |
--disconnect conn1 |
| 39 |
--disconnect conn2 |
| 40 |
--connection default |
| 41 |
|
| 42 |
SELECT "Rewrite me conn 1"; |
| 43 |
SELECT "Rewrite me conn 2"; |
| 44 |
|
| 45 |
--echo # This would cause failed assertion unless the mdl locks are released. |
| 46 |
--error ER_SP_DOES_NOT_EXIST |
| 47 |
SELECT xxx(pattern) FROM query_rewrite.rewrite_rules; |
| 48 |
|
| 49 |
--source suite/query_rewrite_plugins/include/uninstall_rewriter.inc |
| 50 |
--source include/disconnect_connections.inc |
| 51 |
|
| 52 |
--echo # |
| 53 |
--echo # Now make sure that everything works as long we do as we're supposed |
| 54 |
--echo # to, even with autocommit = 0. |
| 55 |
--echo # |
| 56 |
SET autocommit = 0; |
| 57 |
SELECT @@autocommit; |
| 58 |
--source suite/query_rewrite_plugins/include/install_rewriter.inc |
| 59 |
START TRANSACTION; |
| 60 |
|
| 61 |
INSERT INTO query_rewrite.rewrite_rules ( pattern, replacement ) |
| 62 |
VALUES ( 'SELECT "Rewrite me"', 'SELECT "Rewritten w/rule 1"' ); |
| 63 |
|
| 64 |
CALL query_rewrite.flush_rewrite_rules(); |
| 65 |
SELECT 'Rewrite me'; |
| 66 |
SHOW STATUS LIKE 'Rewriter_%'; |
| 67 |
|
| 68 |
--source suite/query_rewrite_plugins/include/uninstall_rewriter.inc |
| 69 |
--source include/disconnect_connections.inc |
| 70 |
|
| 71 |
--echo # |
| 72 |
--echo # Now check that we don't fail even if @@autocommit is 0. In this case |
| 73 |
--echo # InnoDB times out waiting for a lock, the plugin can't load the rules, |
| 74 |
--echo # and we expect a message in the error log. |
| 75 |
--echo # |
| 76 |
SET autocommit = 0; |
| 77 |
SELECT @@autocommit; |
| 78 |
--source suite/query_rewrite_plugins/include/install_rewriter.inc |
| 79 |
|
| 80 |
CALL mtr.add_suppression("Got error from storage engine while refreshing rewrite rules."); |
| 81 |
|
| 82 |
--echo # This would cause failed assertion unless the mdl locks are released. |
| 83 |
--error ER_SP_DOES_NOT_EXIST |
| 84 |
SELECT xxx(pattern) FROM query_rewrite.rewrite_rules; |
| 85 |
|
| 86 |
START TRANSACTION; |
| 87 |
|
| 88 |
INSERT INTO query_rewrite.rewrite_rules ( pattern, replacement ) |
| 89 |
VALUES ( 'SELECT "Rewrite me"', 'SELECT "Rewritten w/rule 1"' ); |
| 90 |
|
| 91 |
SET @@global.innodb_lock_wait_timeout = 1; |
| 92 |
SELECT load_rewrite_rules(); |
| 93 |
SET @@global.innodb_lock_wait_timeout = DEFAULT; |
| 94 |
|
| 95 |
SELECT 'Rewrite me'; |
| 96 |
SHOW STATUS LIKE 'Rewriter_%'; |
| 97 |
COMMIT; |
| 98 |
SELECT 'Rewrite me'; |
| 99 |
SHOW STATUS LIKE 'Rewriter_%'; |
| 100 |
SELECT load_rewrite_rules(); |
| 101 |
SELECT 'Rewrite me'; |
| 102 |
SHOW STATUS LIKE 'Rewriter_%'; |
| 103 |
|
| 104 |
--source suite/query_rewrite_plugins/include/uninstall_rewriter.inc |
| 105 |
--source include/disconnect_connections.inc |
| 106 |
|
| 107 |
--echo # |
| 108 |
--echo # Now let's make sure that everything works fine if we run with |
| 109 |
--echo # autocommit. |
| 110 |
--echo # |
| 111 |
SET autocommit = 1; |
| 112 |
SELECT @@autocommit; |
| 113 |
--source suite/query_rewrite_plugins/include/install_rewriter.inc |
| 114 |
|
| 115 |
--echo # This would cause failed assertion unless the mdl locks are released. |
| 116 |
--error ER_SP_DOES_NOT_EXIST |
| 117 |
SELECT xxx(pattern) FROM query_rewrite.rewrite_rules; |
| 118 |
|
| 119 |
START TRANSACTION; |
| 120 |
|
| 121 |
INSERT INTO query_rewrite.rewrite_rules ( pattern, replacement ) |
| 122 |
VALUES ( 'SELECT "Rewrite me"', 'SELECT "Rewritten w/rule 1"' ); |
| 123 |
|
| 124 |
SET @@global.innodb_lock_wait_timeout = 1; |
| 125 |
SELECT load_rewrite_rules(); |
| 126 |
SET @@global.innodb_lock_wait_timeout = DEFAULT; |
| 127 |
SELECT 'Rewrite me'; |
| 128 |
COMMIT; |
| 129 |
SELECT 'Rewrite me'; |
| 130 |
SELECT load_rewrite_rules(); |
| 131 |
SELECT 'Rewrite me'; |
| 132 |
|
| 133 |
SET autocommit = DEFAULT; |
| 134 |
--source suite/query_rewrite_plugins/include/uninstall_rewriter.inc |
| 135 |
--source include/disconnect_connections.inc |
| 136 |
|
| 137 |
--echo # |
| 138 |
--echo # Bug#36784795 Query rewrite plugin not working when server runs with |
| 139 |
--echo # autocommit=OFF |
| 140 |
--echo # |
| 141 |
--source suite/query_rewrite_plugins/include/install_rewriter_with_optional_columns.inc |
| 142 |
|
| 143 |
SET GLOBAL autocommit = 0; |
| 144 |
SET SESSION autocommit = ON; |
| 145 |
#Session autocommit is not needed to set to OFF for this test. |
| 146 |
DELETE FROM query_rewrite.rewrite_rules; |
| 147 |
INSERT INTO query_rewrite.rewrite_rules (pattern, replacement) |
| 148 |
VALUES('SELECT ?', 'SELECT ? + 1'); |
| 149 |
SELECT * FROM query_rewrite.rewrite_rules; |
| 150 |
CALL query_rewrite.flush_rewrite_rules(); |
| 151 |
SELECT * FROM query_rewrite.rewrite_rules; |
| 152 |
SET GLOBAL autocommit = DEFAULT; |
| 153 |
SET SESSION autocommit = DEFAULT; |
| 154 |
|
| 155 |
--source suite/query_rewrite_plugins/include/uninstall_rewriter.inc |