| 1 |
call mtr.add_suppression("Event 'MYSQL_AUDIT_GENERAL_ERROR' cannot be aborted."); |
| 2 |
# |
| 3 |
# Bug #22142209: MY_MESSAGE FAILS TO ABORT MYSQL_AUDIT_SERVER_STARTUP_CLASS EVENT |
| 4 |
# |
| 5 |
# Shutdown the server |
| 6 |
# Load the plugin at startup and abort on STARTUP with default message |
| 7 |
# Search for default abort message |
| 8 |
Pattern "\[ERROR\] \[[^]]*\] \[[^]]*\] Aborted by Audit API \(\'MYSQL_AUDIT_SERVER_STARTUP_STARTUP\'.1\)\." found |
| 9 |
# Load the plugin at startup and abort on STARTUP event with custom message |
| 10 |
# Search for custom abort message |
| 11 |
Pattern "\[ERROR\] \[[^]]*\] \[[^]]*\] Abort message custom" found |
| 12 |
# Startup the server |
| 13 |
# |
| 14 |
# Bug #22136709: INFINITE RECURSION BY CALLING MY_MESSAGE FROM |
| 15 |
# MYSQL_AUDIT_GENERAL_CLASS HANDLER |
| 16 |
INSTALL PLUGIN null_audit SONAME 'adt_null.so'; |
| 17 |
SET @@GLOBAL.null_audit_event_order_check= "MYSQL_AUDIT_GENERAL_ERROR;;ABORT_RET"; |
| 18 |
SET @@GLOBAL.null_audit_abort_message= "Abort message."; |
| 19 |
# Try to enter error state recursively 2 times. |
| 20 |
SET @@GLOBAL.null_audit_event_order_check_consume_ignore_count= 2; |
| 21 |
connect(localhost,wrong_root,,test,MASTER_PORT,MASTER_SOCKET); |
| 22 |
ERROR 28000: Access denied for user 'wrong_root'@'localhost' (using password: NO) |
| 23 |
SELECT @@null_audit_event_order_check_consume_ignore_count; |
| 24 |
@@null_audit_event_order_check_consume_ignore_count |
| 25 |
0 |
| 26 |
# Try to enter error state infinitely. my_message calls cause stack overrun. |
| 27 |
SET @@GLOBAL.null_audit_event_order_check_consume_ignore_count= 10000; |
| 28 |
connect(localhost,wrong_root,,test,MASTER_PORT,MASTER_SOCKET); |
| 29 |
SELECT @@null_audit_event_order_check_consume_ignore_count; |
| 30 |
@@null_audit_event_order_check_consume_ignore_count |
| 31 |
0 |
| 32 |
SET @@GLOBAL.null_audit_event_order_check= NULL; |
| 33 |
SET @@GLOBAL.null_audit_abort_message= NULL; |
| 34 |
SET @@GLOBAL.null_audit_event_order_check_consume_ignore_count= 0; |
| 35 |
End of 5.7 tests |
| 36 |
# |
| 37 |
# Bug#24961932 - create function at bootstrap attempts to evaluate |
| 38 |
# non-resolved expressions |
| 39 |
# |
| 40 |
# Initial value of the status variable "Audit_null_global_variable_get". |
| 41 |
SELECT variable_value FROM performance_schema.global_status |
| 42 |
WHERE variable_name = 'Audit_null_global_variable_get' |
| 43 |
INTO @initial_global_var_get_count; |
| 44 |
CREATE PROCEDURE check_global_var_count() |
| 45 |
BEGIN |
| 46 |
SELECT variable_value FROM performance_schema.global_status |
| 47 |
WHERE variable_name = 'Audit_null_global_variable_get' |
| 48 |
INTO @cur_global_var_get_count; |
| 49 |
SELECT @cur_global_var_get_count - @initial_global_var_get_count AS |
| 50 |
global_var_count; |
| 51 |
END |
| 52 |
$ |
| 53 |
# Procedure p1 using global system variables. |
| 54 |
CREATE PROCEDURE p1() |
| 55 |
BEGIN |
| 56 |
SET @a=@@global.max_execution_time; |
| 57 |
CREATE TABLE t1 AS SELECT @@global.max_execution_time; |
| 58 |
DROP TABLE t1; |
| 59 |
SELECT @@global.optimizer_trace, @@session.max_execution_time; |
| 60 |
END |
| 61 |
$ |
| 62 |
# Without fix, non-resolved expression is evaluated to audit the global |
| 63 |
# system variable get event while creating the stored routines. |
| 64 |
# The audit for the system variable get event should be done while |
| 65 |
# executing the stored routine but not while creating it. With the fix, |
| 66 |
# global system variable get event is audited while executing the stored |
| 67 |
# routine. At this time, expression is resolved. Hence status variable |
| 68 |
# "Audit_null_global_variable_get" remains unchanged while creating the |
| 69 |
# stored routine. |
| 70 |
CALL check_global_var_count(); |
| 71 |
global_var_count |
| 72 |
0 |
| 73 |
# The same issue exits with the prepared statement too. With the fix, |
| 74 |
# system variable get event is not audited while preparing the statement. |
| 75 |
# Instead it is done while executing the statement. Hence status variable |
| 76 |
# "Audit_null_global_variable_get" remains same here too. |
| 77 |
PREPARE stmt FROM 'SELECT @@global.max_execution_time,@@global.optimizer_trace'; |
| 78 |
CALL check_global_var_count(); |
| 79 |
global_var_count |
| 80 |
0 |
| 81 |
# With the fix, system variable get event is audited on each execution of |
| 82 |
# the routine. Hence status variable "Audit_null_global_variable_get" is |
| 83 |
# incremented by value three by p1() here. |
| 84 |
CALL p1(); |
| 85 |
@@global.optimizer_trace @@session.max_execution_time |
| 86 |
enabled=off,one_line=off 0 |
| 87 |
CALL check_global_var_count(); |
| 88 |
global_var_count |
| 89 |
3 |
| 90 |
# With the fix, system variable get event is audited on each execution of |
| 91 |
# the routine. Hence status variable "Audit_null_global_variable_get" is |
| 92 |
# incremented by value three by p1() here. |
| 93 |
CALL p1(); |
| 94 |
@@global.optimizer_trace @@session.max_execution_time |
| 95 |
enabled=off,one_line=off 0 |
| 96 |
CALL check_global_var_count(); |
| 97 |
global_var_count |
| 98 |
6 |
| 99 |
# System variable get event is audited for global variables only. Hence |
| 100 |
# status variable "Audit_null_global_variable_get" remain same here. |
| 101 |
SELECT @@session.max_execution_time, @@session.optimizer_trace; |
| 102 |
@@session.max_execution_time @@session.optimizer_trace |
| 103 |
0 enabled=off,one_line=off |
| 104 |
CALL check_global_var_count(); |
| 105 |
global_var_count |
| 106 |
6 |
| 107 |
# With the fix, system variable get event is audited on each execution of |
| 108 |
# the prepared statement. Hence status "Audit_null_global_variable_get" |
| 109 |
# variable is incremented by value two here. |
| 110 |
EXECUTE stmt; |
| 111 |
@@global.max_execution_time @@global.optimizer_trace |
| 112 |
0 enabled=off,one_line=off |
| 113 |
CALL check_global_var_count(); |
| 114 |
global_var_count |
| 115 |
8 |
| 116 |
# With the fix, system variable get event is audited on each execution of |
| 117 |
# the prepared statement. Hence status "Audit_null_global_variable_get" |
| 118 |
# variable is incremented by value two here. |
| 119 |
EXECUTE stmt; |
| 120 |
@@global.max_execution_time @@global.optimizer_trace |
| 121 |
0 enabled=off,one_line=off |
| 122 |
CALL check_global_var_count(); |
| 123 |
global_var_count |
| 124 |
10 |
| 125 |
# Verify if system variable get event is audited in the simple select. |
| 126 |
# Status variable "Audit_null_global_variable_get" is incremented by |
| 127 |
# value two here. |
| 128 |
SELECT @@global.max_execution_time, @@global.optimizer_trace; |
| 129 |
@@global.max_execution_time @@global.optimizer_trace |
| 130 |
0 enabled=off,one_line=off |
| 131 |
CALL check_global_var_count(); |
| 132 |
global_var_count |
| 133 |
12 |
| 134 |
DROP PROCEDURE p1; |
| 135 |
DROP PROCEDURE check_global_var_count; |
| 136 |
DROP PREPARE stmt; |
| 137 |
|
| 138 |
# |
| 139 |
# Bug#27638290 - Set @@null_audit_event_record_def = |
| 140 |
# 'mysql_audit_authentication_flush'; crashed |
| 141 |
# |
| 142 |
# New connection, unbound thread |
| 143 |
# Expect NULL |
| 144 |
SELECT @@null_audit_event_record_def; |
| 145 |
@@null_audit_event_record_def |
| 146 |
NULL |
| 147 |
|
| 148 |
# Invalid data |
| 149 |
SET @@null_audit_event_record_def = 'ABSOLUTE_NONSENSE'; |
| 150 |
SELECT 1; |
| 151 |
1 |
| 152 |
1 |
| 153 |
# Expect NULL |
| 154 |
SELECT @@null_audit_event_record; |
| 155 |
@@null_audit_event_record |
| 156 |
NULL |
| 157 |
SELECT @@null_audit_event_record_def; |
| 158 |
@@null_audit_event_record_def |
| 159 |
ABSOLUTE_NONSENSE |
| 160 |
|
| 161 |
# Invalid data again |
| 162 |
SET @@null_audit_event_record_def = 'MYSQL_AUDIT_AUTHENTICATION_FLUSH;JUNK'; |
| 163 |
SELECT 1; |
| 164 |
1 |
| 165 |
1 |
| 166 |
# Expect NULL |
| 167 |
SELECT @@null_audit_event_record; |
| 168 |
@@null_audit_event_record |
| 169 |
NULL |
| 170 |
SELECT @@null_audit_event_record_def; |
| 171 |
@@null_audit_event_record_def |
| 172 |
MYSQL_AUDIT_AUTHENTICATION_FLUSH;JUNK |
| 173 |
|
| 174 |
# Valid data |
| 175 |
SET @@null_audit_event_record_def = 'MYSQL_AUDIT_GENERAL_RESULT;MYSQL_AUDIT_COMMAND_END'; |
| 176 |
SELECT 1; |
| 177 |
1 |
| 178 |
1 |
| 179 |
SELECT @@null_audit_event_record; |
| 180 |
@@null_audit_event_record |
| 181 |
MYSQL_AUDIT_GENERAL_RESULT;; |
| 182 |
MYSQL_AUDIT_GENERAL_STATUS;; |
| 183 |
MYSQL_AUDIT_COMMAND_END;command_id="<expected_command_id>"; |
| 184 |
|
| 185 |
End of 8.0 tests |
| 186 |
# cleanup |
| 187 |
UNINSTALL PLUGIN null_audit; |
| 188 |
Warnings: |
| 189 |
Warning 1620 Plugin is busy and will be uninstalled on shutdown |