18 #include <mysql/plugin.h>
19 #include <mysql/plugin_audit.h>
21 #if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ < 8)
22 #define __attribute__(A)
25 static volatile int number_of_calls;
27 static volatile int number_of_calls_general_log;
28 static volatile int number_of_calls_general_error;
29 static volatile int number_of_calls_general_result;
30 static volatile int number_of_calls_general_status;
32 static volatile int number_of_calls_connection_connect;
33 static volatile int number_of_calls_connection_disconnect;
34 static volatile int number_of_calls_connection_change_user;
51 static int audit_null_plugin_init(
void *arg __attribute__((unused)))
54 number_of_calls_general_log= 0;
55 number_of_calls_general_error= 0;
56 number_of_calls_general_result= 0;
57 number_of_calls_general_status= 0;
58 number_of_calls_connection_connect= 0;
59 number_of_calls_connection_disconnect= 0;
60 number_of_calls_connection_change_user= 0;
78 static int audit_null_plugin_deinit(
void *arg __attribute__((unused)))
94 static void audit_null_notify(MYSQL_THD thd __attribute__((unused)),
95 unsigned int event_class,
100 if (event_class == MYSQL_AUDIT_GENERAL_CLASS)
104 switch (event_general->event_subclass)
106 case MYSQL_AUDIT_GENERAL_LOG:
107 number_of_calls_general_log++;
109 case MYSQL_AUDIT_GENERAL_ERROR:
110 number_of_calls_general_error++;
112 case MYSQL_AUDIT_GENERAL_RESULT:
113 number_of_calls_general_result++;
115 case MYSQL_AUDIT_GENERAL_STATUS:
116 number_of_calls_general_status++;
122 else if (event_class == MYSQL_AUDIT_CONNECTION_CLASS)
126 switch (event_connection->event_subclass)
128 case MYSQL_AUDIT_CONNECTION_CONNECT:
129 number_of_calls_connection_connect++;
131 case MYSQL_AUDIT_CONNECTION_DISCONNECT:
132 number_of_calls_connection_disconnect++;
134 case MYSQL_AUDIT_CONNECTION_CHANGE_USER:
135 number_of_calls_connection_change_user++;
150 MYSQL_AUDIT_INTERFACE_VERSION,
153 { (
unsigned long) MYSQL_AUDIT_GENERAL_CLASSMASK |
154 MYSQL_AUDIT_CONNECTION_CLASSMASK }
163 {
"Audit_null_called",
164 (
char *) &number_of_calls,
166 {
"Audit_null_general_log",
167 (
char *) &number_of_calls_general_log,
169 {
"Audit_null_general_error",
170 (
char *) &number_of_calls_general_error,
172 {
"Audit_null_general_result",
173 (
char *) &number_of_calls_general_result,
175 {
"Audit_null_general_status",
176 (
char *) &number_of_calls_general_status,
178 {
"Audit_null_connection_connect",
179 (
char *) &number_of_calls_connection_connect,
181 {
"Audit_null_connection_disconnect",
182 (
char *) &number_of_calls_connection_disconnect,
184 {
"Audit_null_connection_change_user",
185 (
char *) &number_of_calls_connection_change_user,
195 mysql_declare_plugin(audit_null)
198 &audit_null_descriptor,
203 audit_null_plugin_init,
204 audit_null_plugin_deinit,
211 mysql_declare_plugin_end;