1
by brian
clean slate |
1 |
/* Copyright (C) 2007 MySQL AB
|
2 |
||
3 |
This program is free software; you can redistribute it and/or modify
|
|
4 |
it under the terms of the GNU General Public License as published by
|
|
5 |
the Free Software Foundation; version 2 of the License.
|
|
6 |
||
7 |
This program is distributed in the hope that it will be useful,
|
|
8 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
10 |
GNU General Public License for more details.
|
|
11 |
||
12 |
You should have received a copy of the GNU General Public License
|
|
13 |
along with this program; if not, write to the Free Software
|
|
14 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
15 |
||
16 |
#ifndef _my_audit_h
|
|
17 |
#define _my_audit_h
|
|
18 |
||
19 |
/*************************************************************************
|
|
20 |
API for Audit plugin. (MYSQL_AUDIT_PLUGIN)
|
|
21 |
*/
|
|
22 |
||
23 |
#include "plugin.h" |
|
24 |
||
25 |
#define MYSQL_AUDIT_CLASS_MASK_SIZE 1
|
|
26 |
||
27 |
#define MYSQL_AUDIT_INTERFACE_VERSION ( 0x010000 | MYSQL_AUDIT_CLASS_MASK_SIZE )
|
|
28 |
||
29 |
||
30 |
/*
|
|
31 |
The first word in every event class struct indicates the specific
|
|
32 |
class of the event.
|
|
33 |
*/
|
|
34 |
struct mysql_event |
|
35 |
{
|
|
36 |
int event_class; |
|
37 |
};
|
|
38 |
||
39 |
||
40 |
/*************************************************************************
|
|
41 |
AUDIT CLASS : GENERAL
|
|
42 |
|
|
43 |
LOG events occurs before emitting to the general query log.
|
|
44 |
ERROR events occur before transmitting errors to the user.
|
|
45 |
RESULT events occur after transmitting a resultset to the user.
|
|
46 |
*/
|
|
47 |
||
48 |
#define MYSQL_AUDIT_GENERAL_CLASS 0
|
|
49 |
#define MYSQL_AUDIT_GENERAL_CLASSMASK (1 << MYSQL_AUDIT_GENERAL_CLASS)
|
|
50 |
#define MYSQL_AUDIT_GENERAL_LOG 0
|
|
51 |
#define MYSQL_AUDIT_GENERAL_ERROR 1
|
|
52 |
#define MYSQL_AUDIT_GENERAL_RESULT 2
|
|
53 |
||
54 |
struct mysql_event_general |
|
55 |
{
|
|
56 |
int event_class; |
|
57 |
int general_error_code; |
|
58 |
unsigned long general_thread_id; |
|
59 |
const char *general_user; |
|
60 |
unsigned int general_user_length; |
|
61 |
const char *general_command; |
|
62 |
unsigned int general_command_length; |
|
63 |
const char *general_query; |
|
64 |
unsigned int general_query_length; |
|
65 |
struct charset_info_st *general_charset; |
|
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
66 |
uint64_t general_time; |
67 |
uint64_t general_rows; |
|
1
by brian
clean slate |
68 |
};
|
69 |
||
70 |
||
71 |
/*************************************************************************
|
|
72 |
Here we define the descriptor structure, that is referred from
|
|
73 |
st_mysql_plugin.
|
|
74 |
||
75 |
release_thd() event occurs when the event class consumer is to be
|
|
76 |
disassociated from the specified THD. This would typically occur
|
|
77 |
before some operation which may require sleeping - such as when
|
|
78 |
waiting for the next query from the client.
|
|
79 |
|
|
80 |
event_notify() is invoked whenever an event occurs which is of any
|
|
81 |
class for which the plugin has interest. The first word of the
|
|
82 |
mysql_event argument indicates the specific event class and the
|
|
83 |
remainder of the structure is as required for that class.
|
|
84 |
|
|
85 |
class_mask is an array of bits used to indicate what event classes
|
|
86 |
that this plugin wants to receive.
|
|
87 |
*/
|
|
88 |
||
89 |
struct st_mysql_audit |
|
90 |
{
|
|
91 |
int interface_version; |
|
92 |
void (*release_thd)(MYSQL_THD); |
|
93 |
void (*event_notify)(MYSQL_THD, const struct mysql_event *); |
|
94 |
unsigned long class_mask[MYSQL_AUDIT_CLASS_MASK_SIZE]; |
|
95 |
};
|
|
96 |
||
97 |
||
98 |
#endif
|