summaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2013-06-06 17:51:28 +0200
committerSergei Golubchik <sergii@pisem.net>2013-06-06 17:51:28 +0200
commit4749d40c635634e25e07d28ce1a04e9263bcc375 (patch)
treec5bb3287675cd8676d76c8ee42ef2d79cc599e25 /plugin
parent1ff1cb10fc236010b5969058cab934c2b306c931 (diff)
parent33ef993773449cb3917665b188f6b6575d399bd0 (diff)
downloadmariadb-git-4749d40c635634e25e07d28ce1a04e9263bcc375.tar.gz
5.5 merge
Diffstat (limited to 'plugin')
-rw-r--r--plugin/audit_null/audit_null.c94
-rw-r--r--plugin/qc_info/qc_info.cc2
2 files changed, 72 insertions, 24 deletions
diff --git a/plugin/audit_null/audit_null.c b/plugin/audit_null/audit_null.c
index 0616f192f20..2747063670c 100644
--- a/plugin/audit_null/audit_null.c
+++ b/plugin/audit_null/audit_null.c
@@ -1,4 +1,5 @@
-/* Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2006, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2012, 2013, Monty Program Ab.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@@ -22,11 +23,16 @@
#define __attribute__(A)
#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;
+#ifdef _MSC_VER
+#define snprintf _snprintf
+#endif
+
+static volatile int ncalls; /* for SHOW STATUS, see below */
+static volatile int ncalls_general_log;
+static volatile int ncalls_general_error;
+static volatile int ncalls_general_result;
+FILE *f;
/*
Initialize the plugin at server start or plugin installation.
@@ -44,11 +50,16 @@ static volatile int number_of_calls_general_result;
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);
+ ncalls= 0;
+ ncalls_general_log= 0;
+ ncalls_general_error= 0;
+ ncalls_general_result= 0;
+
+ f = fopen("audit_null_tables.log", "w");
+ if (!f)
+ return 1;
+
+ return 0;
}
@@ -67,7 +78,8 @@ static int audit_null_plugin_init(void *arg __attribute__((unused)))
static int audit_null_plugin_deinit(void *arg __attribute__((unused)))
{
- return(0);
+ fclose(f);
+ return 0;
}
@@ -86,7 +98,7 @@ static void audit_null_notify(MYSQL_THD thd __attribute__((unused)),
const void *event)
{
/* prone to races, oh well */
- number_of_calls++;
+ ncalls++;
if (event_class == MYSQL_AUDIT_GENERAL_CLASS)
{
const struct mysql_event_general *event_general=
@@ -94,18 +106,56 @@ static void audit_null_notify(MYSQL_THD thd __attribute__((unused)),
switch (event_general->event_subclass)
{
case MYSQL_AUDIT_GENERAL_LOG:
- number_of_calls_general_log++;
+ ncalls_general_log++;
+ fprintf(f, "%s\t>> %s\n", event_general->general_user,
+ event_general->general_query);
break;
case MYSQL_AUDIT_GENERAL_ERROR:
- number_of_calls_general_error++;
+ ncalls_general_error++;
break;
case MYSQL_AUDIT_GENERAL_RESULT:
- number_of_calls_general_result++;
+ ncalls_general_result++;
break;
default:
break;
}
}
+ else
+ if (event_class == MYSQL_AUDIT_TABLE_CLASS)
+ {
+ const struct mysql_event_table *event_table=
+ (const struct mysql_event_table *) event;
+ const char *ip= event_table->ip ? event_table->ip : "";
+ const char *op= 0;
+ char buf[1024];
+
+ switch (event_table->event_subclass)
+ {
+ case MYSQL_AUDIT_TABLE_LOCK:
+ op= event_table->read_only ? "read" : "write";
+ break;
+ case MYSQL_AUDIT_TABLE_CREATE:
+ op= "create";
+ break;
+ case MYSQL_AUDIT_TABLE_DROP:
+ op= "drop";
+ break;
+ case MYSQL_AUDIT_TABLE_ALTER:
+ op= "alter";
+ break;
+ case MYSQL_AUDIT_TABLE_RENAME:
+ snprintf(buf, sizeof(buf), "rename to %s.%s",
+ event_table->new_database, event_table->new_table);
+ buf[sizeof(buf)-1]= 0;
+ op= buf;
+ break;
+ }
+
+ fprintf(f, "%s[%s] @ %s [%s]\t%s.%s : %s\n",
+ event_table->priv_user, event_table->user,
+ event_table->host, ip,
+ event_table->database, event_table->table, op);
+ }
}
@@ -115,10 +165,8 @@ 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) MYSQL_AUDIT_GENERAL_CLASSMASK } /* class mask */
+ MYSQL_AUDIT_INTERFACE_VERSION, NULL, audit_null_notify,
+ { MYSQL_AUDIT_GENERAL_CLASSMASK | MYSQL_AUDIT_TABLE_CLASSMASK }
};
/*
@@ -127,10 +175,10 @@ static struct st_mysql_audit audit_null_descriptor=
static struct st_mysql_show_var simple_status[]=
{
- { "called", (char *) &number_of_calls, SHOW_INT },
- { "general_log", (char *) &number_of_calls_general_log, SHOW_INT },
- { "general_error", (char *) &number_of_calls_general_error, SHOW_INT },
- { "general_result", (char *) &number_of_calls_general_result, SHOW_INT },
+ { "called", (char *) &ncalls, SHOW_INT },
+ { "general_error", (char *) &ncalls_general_error, SHOW_INT },
+ { "general_log", (char *) &ncalls_general_log, SHOW_INT },
+ { "general_result", (char *) &ncalls_general_result, SHOW_INT },
{ 0, 0, 0}
};
diff --git a/plugin/qc_info/qc_info.cc b/plugin/qc_info/qc_info.cc
index af13b6edf93..8489b14c5db 100644
--- a/plugin/qc_info/qc_info.cc
+++ b/plugin/qc_info/qc_info.cc
@@ -83,7 +83,7 @@ static int qc_info_fill_table(THD *thd, TABLE_LIST *tables,
return 0;
if (qc->try_lock(thd))
- return status;
+ return 0; // QC is or is being disabled
/* loop through all queries in the query cache */
for (uint i= 0; i < queries->records; i++)