| 1 |
if (!$SERVER_AUDIT2_SO) { |
| 2 |
skip No SERVER_AUDIT2 plugin; |
| 3 |
} |
| 4 |
|
| 5 |
source include/master-slave.inc; |
| 6 |
|
| 7 |
--disable_warnings |
| 8 |
drop table if exists t1; |
| 9 |
sync_slave_with_master; |
| 10 |
reset master; |
| 11 |
--enable_warnings |
| 12 |
|
| 13 |
--disable_warnings |
| 14 |
CREATE TABLE IF NOT EXISTS mysql.server_audit_filters ( |
| 15 |
filtername char(80) COLLATE utf8_bin NOT NULL DEFAULT '', |
| 16 |
rule longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT 'true' CHECK (json_valid(rule)), |
| 17 |
CONSTRAINT c_filtername UNIQUE (filtername) |
| 18 |
) ENGINE=Aria; |
| 19 |
|
| 20 |
CREATE TABLE IF NOT EXISTS mysql.server_audit_users (host char(60) COLLATE utf8_bin NOT NULL DEFAULT '', |
| 21 |
user char(80) COLLATE utf8_bin NOT NULL DEFAULT '', |
| 22 |
filtername char(80) NOT NULL DEFAULT '', |
| 23 |
CONSTRAINT c_host_user UNIQUE (host, user) |
| 24 |
) ENGINE=Aria; |
| 25 |
--enable_warnings |
| 26 |
|
| 27 |
INSERT INTO mysql.server_audit_filters VALUES ('ignore_sys', '{"ignore_tables" : "mysql.*"}'); |
| 28 |
INSERT INTO mysql.server_audit_users VALUES ('%','<replication_slave>','ignore_sys'); |
| 29 |
INSERT INTO mysql.server_audit_users VALUES ('%','root','ignore_sys'); |
| 30 |
|
| 31 |
install plugin server_audit soname 'server_audit2'; |
| 32 |
set global server_audit_logging=on; |
| 33 |
|
| 34 |
# this is done to make test deterministic |
| 35 |
# so the above 'set' command is always logged before the 'create table t1' |
| 36 |
-- disable_query_log |
| 37 |
-- disable_result_log |
| 38 |
select * from mysql.server_audit_filters; |
| 39 |
select * from mysql.server_audit_users; |
| 40 |
-- enable_result_log |
| 41 |
-- enable_query_log |
| 42 |
|
| 43 |
connection master; |
| 44 |
create table t1 (a int); |
| 45 |
insert into t1 values (1); |
| 46 |
truncate t1; |
| 47 |
drop table t1; |
| 48 |
sync_slave_with_master; |
| 49 |
|
| 50 |
set global server_audit_logging=off; |
| 51 |
|
| 52 |
truncate mysql.server_audit_filters; |
| 53 |
truncate mysql.server_audit_users; |
| 54 |
INSERT INTO mysql.server_audit_filters VALUES ('no_logging','false'); |
| 55 |
INSERT INTO mysql.server_audit_users VALUES ('%','<replication_slave>','no_logging'); |
| 56 |
|
| 57 |
set global server_audit_logging=on; |
| 58 |
|
| 59 |
connection master; |
| 60 |
create table t1 (a int); |
| 61 |
insert into t1 values (1); |
| 62 |
truncate t1; |
| 63 |
drop table t1; |
| 64 |
sync_slave_with_master; |
| 65 |
|
| 66 |
set global server_audit_logging=off; |
| 67 |
uninstall plugin server_audit; |
| 68 |
truncate mysql.server_audit_filters; |
| 69 |
truncate mysql.server_audit_users; |
| 70 |
let $MYSQLD_DATADIR= `SELECT @@datadir`; |
| 71 |
# replace the timestamp and the hostname with constant values |
| 72 |
--replace_regex /[0-9]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9]\,[^,]*\,/TIME,HOSTNAME,/ /\,[1-9][0-9]*\,/,1,/ /\,[1-9][0-9]*/,ID/ /000001\\', [0-9]*,/#', POS,/ |
| 73 |
cat_file $MYSQLD_DATADIR/server_audit.log; |
| 74 |
remove_file $MYSQLD_DATADIR/server_audit.log; |
| 75 |
|
| 76 |
connection master; |
| 77 |
--source include/rpl_end.inc |