summaryrefslogtreecommitdiff
path: root/plugin/audit_null
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@sun.com>2010-04-15 13:05:17 +0400
committerSergey Vojtovich <svoj@sun.com>2010-04-15 13:05:17 +0400
commit8e7939167d3fd3482038fbc052672e049b52c667 (patch)
treee6172f142ebc0e905e7330a98779304ea71c9acc /plugin/audit_null
parent1cdc0b3a4cb9a338c62be9375f951bb905fc65f6 (diff)
downloadmariadb-git-8e7939167d3fd3482038fbc052672e049b52c667.tar.gz
BUG#47059 - In audit plugin I cannot see the event subclasses,
e.g.MYSQL_AUDIT_GENERAL_ERROR General audit API (MYSQL_AUDIT_GENERAL_CLASS) didn't expose event subclass to plugins. This patch exposes event subclass to plugins via struct mysql_event_general::event_subclass. This change is not compatible with existing general audit plugins. Audit interface major version has been incremented. include/mysql/plugin_audit.h: Expose event subclass to audit general plugins. plugin/audit_null/audit_null.c: Added distinct counters for general event sub-classes. Removed printf() from deinit(). One can easily see number of calls via status variables. To make code nicer, modified class mask to use macro instead of hardcoded number. Incremented audit plugin minor version. sql/sql_audit.cc: Expose event subclass to audit general plugins.
Diffstat (limited to 'plugin/audit_null')
-rw-r--r--plugin/audit_null/audit_null.c48
1 files changed, 38 insertions, 10 deletions
diff --git a/plugin/audit_null/audit_null.c b/plugin/audit_null/audit_null.c
index 52a9df08cf4..e0c53ed0f19 100644
--- a/plugin/audit_null/audit_null.c
+++ b/plugin/audit_null/audit_null.c
@@ -22,6 +22,9 @@
#endif
static volatile int number_of_calls; /* for SHOW STATUS, see below */
+static volatile int number_of_calls_general_log;
+static volatile int number_of_calls_general_error;
+static volatile int number_of_calls_general_result;
/*
@@ -41,6 +44,9 @@ static volatile int number_of_calls; /* for SHOW STATUS, see below */
static int audit_null_plugin_init(void *arg __attribute__((unused)))
{
number_of_calls= 0;
+ number_of_calls_general_log= 0;
+ number_of_calls_general_error= 0;
+ number_of_calls_general_result= 0;
return(0);
}
@@ -60,7 +66,6 @@ static int audit_null_plugin_init(void *arg __attribute__((unused)))
static int audit_null_plugin_deinit(void *arg __attribute__((unused)))
{
- printf("audit_null was invoked %u times\n", number_of_calls);
return(0);
}
@@ -76,11 +81,29 @@ static int audit_null_plugin_deinit(void *arg __attribute__((unused)))
*/
static void audit_null_notify(MYSQL_THD thd __attribute__((unused)),
- const struct mysql_event *event
- __attribute__((unused)))
+ const struct mysql_event *event)
{
/* prone to races, oh well */
number_of_calls++;
+ if (event->event_class == MYSQL_AUDIT_GENERAL_CLASS)
+ {
+ const struct mysql_event_general *event_general=
+ (const struct mysql_event_general *) event;
+ switch (event_general->event_subclass)
+ {
+ case MYSQL_AUDIT_GENERAL_LOG:
+ number_of_calls_general_log++;
+ break;
+ case MYSQL_AUDIT_GENERAL_ERROR:
+ number_of_calls_general_error++;
+ break;
+ case MYSQL_AUDIT_GENERAL_RESULT:
+ number_of_calls_general_result++;
+ break;
+ default:
+ break;
+ }
+ }
}
@@ -90,10 +113,10 @@ static void audit_null_notify(MYSQL_THD thd __attribute__((unused)),
static struct st_mysql_audit audit_null_descriptor=
{
- MYSQL_AUDIT_INTERFACE_VERSION, /* interface version */
- NULL, /* release_thd function */
- audit_null_notify, /* notify function */
- { (unsigned long) -1 } /* class mask */
+ MYSQL_AUDIT_INTERFACE_VERSION, /* interface version */
+ NULL, /* release_thd function */
+ audit_null_notify, /* notify function */
+ { (unsigned long) MYSQL_AUDIT_GENERAL_CLASSMASK } /* class mask */
};
/*
@@ -102,8 +125,13 @@ static struct st_mysql_audit audit_null_descriptor=
static struct st_mysql_show_var simple_status[]=
{
- {"audit_null_called", (char *)&number_of_calls, SHOW_INT},
- {0,0,0}
+ { "Audit_null_called", (char *) &number_of_calls, SHOW_INT },
+ { "Audit_null_general_log", (char *) &number_of_calls_general_log, SHOW_INT },
+ { "Audit_null_general_error", (char *) &number_of_calls_general_error,
+ SHOW_INT },
+ { "Audit_null_general_result", (char *) &number_of_calls_general_result,
+ SHOW_INT },
+ { 0, 0, 0}
};
@@ -121,7 +149,7 @@ mysql_declare_plugin(audit_null)
PLUGIN_LICENSE_GPL,
audit_null_plugin_init, /* init function (when loaded) */
audit_null_plugin_deinit, /* deinit function (when unloaded) */
- 0x0001, /* version */
+ 0x0002, /* version */
simple_status, /* status variables */
NULL, /* system variables */
NULL