Details
-
Bug
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Not a Bug
-
11.6.2, 10.11.13
-
None
-
Not for Release Notes
Description
Audit plugin incorrectly reports the order of the AFTER trigger statements prior to the statement that triggered them. Both statements (the initiating and the triggered ones) have identical query ID and there is no way to programmatically determine which statement came first.
This really complicates various types of automated analysis since the order of statements is actually wrong.
This reproduces always.
INSTALL SONAME 'server_audit';
|
SET GLOBAL server_audit_events = 'CONNECT,QUERY';
|
SET GLOBAL server_audit_logging='ON';
|
|
CREATE DATABASE test;
|
USE test;
|
|
CREATE TABLE source (id bigint(20) NOT NULL AUTO_INCREMENT, PRIMARY KEY(id)) ENGINE InnoDB;
|
CREATE TABLE dest (id bigint(20) NOT NULL, PRIMARY KEY(id)) ENGINE InnoDB;
|
CREATE OR REPLACE TRIGGER test_trigger
|
AFTER INSERT ON source FOR EACH ROW
|
INSERT INTO dest (id) VALUES(NEW.id);
|
|
INSERT INTO source VALUES();
|
This is the audit log that results from the above test case:
20250614 01:37:39,991307f83455,root,172.20.0.1,3,4,QUERY,,'SET GLOBAL server_audit_logging=\'ON\'',0
|
20250614 01:37:39,991307f83455,root,172.20.0.1,3,5,QUERY,,'CREATE DATABASE test',0
|
20250614 01:37:39,991307f83455,root,172.20.0.1,3,6,QUERY,,'SELECT DATABASE()',0
|
20250614 01:37:39,991307f83455,root,172.20.0.1,3,8,QUERY,test,'show databases',0
|
20250614 01:37:39,991307f83455,root,172.20.0.1,3,9,QUERY,test,'show tables',0
|
20250614 01:37:39,991307f83455,root,172.20.0.1,3,10,QUERY,test,'CREATE TABLE source (id bigint(20) NOT NULL AUTO_INCREMENT, PRIMARY KEY(id)) ENGINE InnoDB',0
|
20250614 01:37:39,991307f83455,root,172.20.0.1,3,11,QUERY,test,'CREATE TABLE dest (id bigint(20) NOT NULL, PRIMARY KEY(id)) ENGINE InnoDB',0
|
20250614 01:37:40,991307f83455,root,172.20.0.1,3,12,QUERY,test,'CREATE OR REPLACE TRIGGER test_trigger\nAFTER INSERT ON source FOR EACH ROW\nINSERT INTO dest (id) VALUES(NEW.id)',0
|
20250614 01:38:54,991307f83455,root,172.20.0.1,3,13,QUERY,test,'INSERT INTO dest (id) VALUES(NEW.id)',0
|
20250614 01:38:54,991307f83455,root,172.20.0.1,3,13,QUERY,test,'INSERT INTO source VALUES()',0
|