Skip to content

Commit 4bbed79

Browse files
committed
WL#8505: Transformed the query rewrite plugins to audit plugins
1 parent b5bbc1b commit 4bbed79

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+576
-870
lines changed

cmake/abi_check.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ IF(CMAKE_COMPILER_IS_GNUCC AND RUN_ABI_CHECK)
4444
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_v2.h
4545
${CMAKE_SOURCE_DIR}/include/mysql/client_plugin.h
4646
${CMAKE_SOURCE_DIR}/include/mysql/plugin_auth.h
47-
${CMAKE_SOURCE_DIR}/include/mysql/plugin_query_rewrite.h
4847
${CMAKE_SOURCE_DIR}/include/mysql/services.h
4948
)
5049

include/mysql/plugin.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,8 @@ typedef struct st_mysql_xid MYSQL_XID;
9494
#define MYSQL_REPLICATION_PLUGIN 6 /* The replication plugin type */
9595
#define MYSQL_AUTHENTICATION_PLUGIN 7 /* The authentication plugin type */
9696
#define MYSQL_VALIDATE_PASSWORD_PLUGIN 8 /* validate password plugin type */
97-
#define MYSQL_REWRITE_PRE_PARSE_PLUGIN 9 /* Pre-parse query rewrite. */
98-
#define MYSQL_REWRITE_POST_PARSE_PLUGIN 10 /* Post-parse query rewrite. */
99-
#define MYSQL_GROUP_REPLICATION_PLUGIN 11 /* The Group Replication plugin */
100-
#define MYSQL_MAX_PLUGIN_TYPE_NUM 12 /* The number of plugin types */
97+
#define MYSQL_GROUP_REPLICATION_PLUGIN 9 /* The Group Replication plugin */
98+
#define MYSQL_MAX_PLUGIN_TYPE_NUM 10 /* The number of plugin types */
10199

102100
/* We use the following strings to define licenses for plugins */
103101
#define PLUGIN_LICENSE_PROPRIETARY 0

include/mysql/plugin_audit.h

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
#define MYSQL_AUDIT_CLASS_MASK_SIZE 1
2828

29-
#define MYSQL_AUDIT_INTERFACE_VERSION 0x0301
29+
#define MYSQL_AUDIT_INTERFACE_VERSION 0x0302
3030

3131

3232
/*************************************************************************
@@ -103,6 +103,34 @@ struct mysql_event_connection
103103
int connection_type;
104104
};
105105

106+
#define MYSQL_AUDIT_PARSE_CLASS 2
107+
#define MYSQL_AUDIT_PARSE_CLASSMASK (1UL << MYSQL_AUDIT_PARSE_CLASS)
108+
#define MYSQL_AUDIT_PREPARSE 0
109+
#define MYSQL_AUDIT_POSTPARSE 1
110+
111+
/// mysql_event_parse::flags Must be set by a plugin if the query is rewritten.
112+
#define FLAG_REWRITE_PLUGIN_QUERY_REWRITTEN 1
113+
/// mysql_event_parse::flags Is set by the server if the query is prepared statement.
114+
#define FLAG_REWRITE_PLUGIN_IS_PREPARED_STATEMENT 2
115+
116+
117+
/** Data for the MYSQL_AUDIT_[PRE|POST]_PARSE events */
118+
struct mysql_event_parse
119+
{
120+
/** MYSQL_AUDIT_[PRE|POST]_PARSE event id */
121+
unsigned int event_subclass;
122+
/** one of FLAG_REWRITE_PLUGIN_* */
123+
int *flags;
124+
/** input: the original query text */
125+
const char *query;
126+
/** input: the original query length */
127+
size_t query_length;
128+
/** output: returns the null-terminated rewriten query allocated by my_malloc() */
129+
char **rewritten_query;
130+
/** output: if not null returns the rewriten query length */
131+
size_t *rewritten_query_length;
132+
};
133+
106134

107135
/*************************************************************************
108136
Here we define the descriptor structure, that is referred from

include/mysql/plugin_audit.h.pp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,15 @@
158158
unsigned int database_length;
159159
int connection_type;
160160
};
161+
struct mysql_event_parse
162+
{
163+
unsigned int event_subclass;
164+
int *flags;
165+
const char *query;
166+
size_t query_length;
167+
char **rewritten_query;
168+
size_t *rewritten_query_length;
169+
};
161170
struct st_mysql_audit
162171
{
163172
int interface_version;

include/mysql/plugin_query_rewrite.h

Lines changed: 0 additions & 94 deletions
This file was deleted.

include/mysql/plugin_query_rewrite.h.pp

Lines changed: 0 additions & 141 deletions
This file was deleted.

mysql-test/suite/query_rewrite_plugins/include/uninstall_rewriter.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ DROP FUNCTION IF EXISTS load_rewrite_rules;
44
error 0, ER_SP_DOES_NOT_EXIST;
55
UNINSTALL PLUGIN rewriter;
66
enable_query_log;
7-
echo # Query rewrite plugin was uninstalled.;
7+
echo # Query rewrite plugin was queued for uninstalling.;

0 commit comments

Comments
 (0)