Merge lp:~posulliv/mysql-server/query-rewrite into lp:~mysql/mysql-server/mysql-next-mr

Proposed by Padraig O'Sullivan
Status: Needs review
Proposed branch: lp:~posulliv/mysql-server/query-rewrite
Merge into: lp:~mysql/mysql-server/mysql-next-mr
Diff against target: 987 lines (+639/-136)
17 files modified
Makefile.am (+1/-0)
include/mysql/plugin.h (+11/-2)
include/mysql/plugin_audit.h.pp (+10/-0)
include/mysql/plugin_ftparser.h.pp (+10/-0)
include/mysql/plugin_query_rewrite.h (+54/-0)
include/mysql/plugin_query_rewrite.h.pp (+198/-0)
include/probes_mysql_nodtrace.h (+0/-129)
plugin/rewrite_lower/CMakeLists.txt (+17/-0)
plugin/rewrite_lower/Makefile.am (+32/-0)
plugin/rewrite_lower/plug.in (+4/-0)
plugin/rewrite_lower/rewrite_lower.cc (+84/-0)
sql/CMakeLists.txt (+1/-1)
sql/Makefile.am (+2/-2)
sql/sql_parse.cc (+4/-0)
sql/sql_plugin.cc (+8/-2)
sql/sql_query_rewrite.cc (+167/-0)
sql/sql_query_rewrite.h (+36/-0)
To merge this branch: bzr merge lp:~posulliv/mysql-server/query-rewrite
Reviewer Review Type Date Requested Status
Oracle/MySQL Engineering Pending
Review via email: mp+38560@code.launchpad.net

Description of the change

This branch contains a new plugin type for query rewriting.

Based on discussions on the internals mailing list, I added 2 distinct plugin points where a plugin developer could choose to rewrite a query:

 1) pre-parsing
 2) post-parsing

In the pre-parsing case, the raw query string is passed to the plugin. If the plugin rewrites the raw query, it returns a new string which is then set as the current query by the MySQL kernel. There is also a callback function for freeing memory allocated for the rewritten query text in the plugin.

In the post-parsing case, the parse tree structure is passed as a parameter to the plugin. A plugin developer can modify the parse tree in place if they wish. MySQL will operate on the parse tree after this function returns.

I also included a simple example query rewriting plugin which simply converts the raw text of a query to lower case.

I logged bug 57459 as a feature request for this since this was suggested on the mailing list.

To post a comment you must log in.
3205. By Padraig O'Sullivan

Forgot new method when embedded server is defined.

Unmerged revisions

3205. By Padraig O'Sullivan

Forgot new method when embedded server is defined.

3204. By Padraig O'Sullivan

Added another plugin point for query rewrite which allows the parse tree to be rewritten.

3203. By Padraig O'Sullivan

Removed one call to query rewrite plugin point which is unneeded.

3202. By Padraig O'Sullivan

Updated query rewrite plugin interface and how query rewrite plugins are called from within the kernel.

3201. By Padraig O'Sullivan

Modified locations where query rewrite plugin point is to be always before mysql_parse function. This makes sure the rewritten query is placed in the general query log and also ensures the rewritten query is the query that shows up in profiling output.

3200. By Padraig O'Sullivan

Added functions for initializing and finalizing query rewrite plugins.

3199. By Padraig O'Sullivan

Update sample rewriting plugin to work with autoconf tools. Added preprocessor generated file for query rewrite interface.

3198. By Padraig O'Sullivan

Merge trunk.

3197. By Padraig O'Sullivan

Added simple query rewriting plugin that simply converts a query to lower case.

3196. By Padraig O'Sullivan

Added files to call into query rewrite plugins.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Makefile.am'
--- Makefile.am 2010-08-27 07:20:08 +0000
+++ Makefile.am 2010-10-15 16:16:49 +0000
@@ -267,6 +267,7 @@
267267
268API_PREPROCESSOR_HEADER = $(top_srcdir)/include/mysql/plugin_audit.h \268API_PREPROCESSOR_HEADER = $(top_srcdir)/include/mysql/plugin_audit.h \
269 $(top_srcdir)/include/mysql/plugin_ftparser.h \269 $(top_srcdir)/include/mysql/plugin_ftparser.h \
270 $(top_srcdir)/include/mysql/plugin_query_rewrite.h \
270 $(top_srcdir)/include/mysql.h \271 $(top_srcdir)/include/mysql.h \
271 $(top_srcdir)/include/mysql/psi/psi_abi_v1.h \272 $(top_srcdir)/include/mysql/psi/psi_abi_v1.h \
272 $(top_srcdir)/include/mysql/psi/psi_abi_v2.h273 $(top_srcdir)/include/mysql/psi/psi_abi_v2.h
273274
=== modified file 'include/mysql/plugin.h'
--- include/mysql/plugin.h 2010-09-01 13:06:14 +0000
+++ include/mysql/plugin.h 2010-10-15 16:16:49 +0000
@@ -42,10 +42,13 @@
4242
43#ifdef __cplusplus43#ifdef __cplusplus
44class THD;44class THD;
45class LEX;
45class Item;46class Item;
46#define MYSQL_THD THD*47#define MYSQL_THD THD*
48#define MYSQL_LEXPTR LEX*
47#else49#else
48#define MYSQL_THD void*50#define MYSQL_THD void*
51#define MYSQL_LEXPTR void*
49#endif52#endif
5053
51#include <mysql/services.h>54#include <mysql/services.h>
@@ -82,8 +85,9 @@
82#define MYSQL_DAEMON_PLUGIN 3 /* The daemon/raw plugin type */85#define MYSQL_DAEMON_PLUGIN 3 /* The daemon/raw plugin type */
83#define MYSQL_INFORMATION_SCHEMA_PLUGIN 4 /* The I_S plugin type */86#define MYSQL_INFORMATION_SCHEMA_PLUGIN 4 /* The I_S plugin type */
84#define MYSQL_AUDIT_PLUGIN 5 /* The Audit plugin type */87#define MYSQL_AUDIT_PLUGIN 5 /* The Audit plugin type */
85#define MYSQL_REPLICATION_PLUGIN 6 /* The replication plugin type */88#define MYSQL_QUERY_REWRITE_PLUGIN 6 /* The query rewrite plugin type */
86#define MYSQL_MAX_PLUGIN_TYPE_NUM 7 /* The number of plugin types */89#define MYSQL_REPLICATION_PLUGIN 7 /* The replication plugin type */
90#define MYSQL_MAX_PLUGIN_TYPE_NUM 8 /* The number of plugin types */
8791
88/* We use the following strings to define licenses for plugins */92/* We use the following strings to define licenses for plugins */
89#define PLUGIN_LICENSE_PROPRIETARY 093#define PLUGIN_LICENSE_PROPRIETARY 0
@@ -422,6 +426,11 @@
422#include "plugin_ftparser.h"426#include "plugin_ftparser.h"
423427
424/*************************************************************************428/*************************************************************************
429 API for query rewrite plugin. (MYSQL_QUERY_REWRITE_PLUGIN)
430*/
431#include "plugin_query_rewrite.h"
432
433/*************************************************************************
425 API for Storage Engine plugin. (MYSQL_DAEMON_PLUGIN)434 API for Storage Engine plugin. (MYSQL_DAEMON_PLUGIN)
426*/435*/
427436
428437
=== modified file 'include/mysql/plugin_audit.h.pp'
--- include/mysql/plugin_audit.h.pp 2010-08-30 14:07:40 +0000
+++ include/mysql/plugin_audit.h.pp 2010-10-15 16:16:49 +0000
@@ -143,6 +143,16 @@
143 int (*init)(MYSQL_FTPARSER_PARAM *param);143 int (*init)(MYSQL_FTPARSER_PARAM *param);
144 int (*deinit)(MYSQL_FTPARSER_PARAM *param);144 int (*deinit)(MYSQL_FTPARSER_PARAM *param);
145};145};
146#include "plugin_query_rewrite.h"
147#include <stdint.h>
148#include "plugin.h"
149struct st_mysql_query_rewrite
150{
151 int interface_version;
152 char* (*rewrite_query)(const char* schema, size_t schema_len, const char* query, size_t orig_query_len, size_t* rewritten_query_len);
153 void (*free_rewritten_query)(char* query);
154 void (*rewrite_parse_tree)(void* thd, void* parse_tree);
155};
146struct st_mysql_daemon156struct st_mysql_daemon
147{157{
148 int interface_version;158 int interface_version;
149159
=== modified file 'include/mysql/plugin_ftparser.h.pp'
--- include/mysql/plugin_ftparser.h.pp 2010-08-30 14:07:40 +0000
+++ include/mysql/plugin_ftparser.h.pp 2010-10-15 16:16:49 +0000
@@ -96,6 +96,16 @@
96 void * __reserved1;96 void * __reserved1;
97};97};
98#include "plugin_ftparser.h"98#include "plugin_ftparser.h"
99#include "plugin_query_rewrite.h"
100#include <stdint.h>
101#include "plugin.h"
102struct st_mysql_query_rewrite
103{
104 int interface_version;
105 char* (*rewrite_query)(const char* schema, size_t schema_len, const char* query, size_t orig_query_len, size_t* rewritten_query_len);
106 void (*free_rewritten_query)(char* query);
107 void (*rewrite_parse_tree)(void* thd, void* parse_tree);
108};
99struct st_mysql_daemon109struct st_mysql_daemon
100{110{
101 int interface_version;111 int interface_version;
102112
=== added file 'include/mysql/plugin_query_rewrite.h'
--- include/mysql/plugin_query_rewrite.h 1970-01-01 00:00:00 +0000
+++ include/mysql/plugin_query_rewrite.h 2010-10-15 16:16:49 +0000
@@ -0,0 +1,54 @@
1/* Copyright (C) 2010 Akiban Technologies
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_query_rewrite_h
17#define _my_query_rewrite_h
18
19#include <stdint.h>
20
21/*************************************************************************
22 API for query rewrite plugin. (MYSQL_QUERY_REWRITE_PLUGIN)
23*/
24
25#include "plugin.h"
26
27#define MYSQL_QUERY_REWRITE_INTERFACE_VERSION 0x0200
28
29/*************************************************************************
30 Here we define the descriptor structure, that is referred from
31 st_mysql_plugin.
32
33 rewrite_query() is invoked before a query is parsed allowing a plugin
34 the opporunity to rewrite the query string passed as a parameter
35 to the function
36
37 free_rewritten_query() is invoked only if a plugin rewrote the text of a query.
38 It frees any memory a plugin allocated for the rewritten query.
39
40 rewrite_parse_tree() is invoked after a query is parsed by MySQL. It
41 gives a rewriting plugin the opportunity to modify the parse tree
42 generated by MySQL. This allows a plugin developer to rewrite a query
43 without having to worry about parsing a query.
44*/
45struct st_mysql_query_rewrite
46{
47 int interface_version;
48 char* (*rewrite_query)(const char* schema, size_t schema_len, const char* query, size_t orig_query_len, size_t* rewritten_query_len);
49 void (*free_rewritten_query)(char* query);
50 void (*rewrite_parse_tree)(MYSQL_THD thd, MYSQL_LEXPTR parse_tree);
51};
52
53
54#endif /* _my_query_rewrite_h */
055
=== added file 'include/mysql/plugin_query_rewrite.h.pp'
--- include/mysql/plugin_query_rewrite.h.pp 1970-01-01 00:00:00 +0000
+++ include/mysql/plugin_query_rewrite.h.pp 2010-10-15 16:16:49 +0000
@@ -0,0 +1,198 @@
1#include <stdint.h>
2#include "plugin.h"
3#include <mysql/services.h>
4#include <mysql/service_my_snprintf.h>
5extern struct my_snprintf_service_st {
6 size_t (*my_snprintf_type)(char*, size_t, const char*, ...);
7 size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list);
8} *my_snprintf_service;
9size_t my_snprintf(char* to, size_t n, const char* fmt, ...);
10size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap);
11#include <mysql/service_thd_alloc.h>
12struct st_mysql_lex_string
13{
14 char *str;
15 size_t length;
16};
17typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
18extern struct thd_alloc_service_st {
19 void *(*thd_alloc_func)(void*, unsigned int);
20 void *(*thd_calloc_func)(void*, unsigned int);
21 char *(*thd_strdup_func)(void*, const char *);
22 char *(*thd_strmake_func)(void*, const char *, unsigned int);
23 void *(*thd_memdup_func)(void*, const void*, unsigned int);
24 MYSQL_LEX_STRING *(*thd_make_lex_string_func)(void*, MYSQL_LEX_STRING *,
25 const char *, unsigned int, int);
26} *thd_alloc_service;
27void *thd_alloc(void* thd, unsigned int size);
28void *thd_calloc(void* thd, unsigned int size);
29char *thd_strdup(void* thd, const char *str);
30char *thd_strmake(void* thd, const char *str, unsigned int size);
31void *thd_memdup(void* thd, const void* str, unsigned int size);
32MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str,
33 const char *str, unsigned int size,
34 int allocate_lex_string);
35#include <mysql/service_thd_wait.h>
36typedef enum _thd_wait_type_e {
37 THD_WAIT_MUTEX= 1,
38 THD_WAIT_DISKIO= 2,
39 THD_WAIT_ROW_TABLE_LOCK= 3,
40 THD_WAIT_GLOBAL_LOCK= 4
41} thd_wait_type;
42extern struct thd_wait_service_st {
43 void (*thd_wait_begin_func)(void*, thd_wait_type);
44 void (*thd_wait_end_func)(void*);
45} *thd_wait_service;
46void thd_wait_begin(void* thd, thd_wait_type wait_type);
47void thd_wait_end(void* thd);
48#include <mysql/service_thread_scheduler.h>
49struct scheduler_functions;
50extern struct my_thread_scheduler_service {
51 int (*set)(struct scheduler_functions *scheduler);
52 int (*reset)();
53} *my_thread_scheduler_service;
54int my_thread_scheduler_set(struct scheduler_functions *scheduler);
55int my_thread_scheduler_reset();
56struct st_mysql_xid {
57 long formatID;
58 long gtrid_length;
59 long bqual_length;
60 char data[128];
61};
62typedef struct st_mysql_xid MYSQL_XID;
63enum enum_mysql_show_type
64{
65 SHOW_UNDEF, SHOW_BOOL, SHOW_INT, SHOW_LONG,
66 SHOW_LONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
67 SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE,
68 SHOW_always_last
69};
70struct st_mysql_show_var {
71 const char *name;
72 char *value;
73 enum enum_mysql_show_type type;
74};
75typedef int (*mysql_show_var_func)(void*, struct st_mysql_show_var*, char *);
76struct st_mysql_sys_var;
77struct st_mysql_value;
78typedef int (*mysql_var_check_func)(void* thd,
79 struct st_mysql_sys_var *var,
80 void *save, struct st_mysql_value *value);
81typedef void (*mysql_var_update_func)(void* thd,
82 struct st_mysql_sys_var *var,
83 void *var_ptr, const void *save);
84struct st_mysql_plugin
85{
86 int type;
87 void *info;
88 const char *name;
89 const char *author;
90 const char *descr;
91 int license;
92 int (*init)(void *);
93 int (*deinit)(void *);
94 unsigned int version;
95 struct st_mysql_show_var *status_vars;
96 struct st_mysql_sys_var **system_vars;
97 void * __reserved1;
98};
99#include "plugin_ftparser.h"
100#include "plugin.h"
101enum enum_ftparser_mode
102{
103 MYSQL_FTPARSER_SIMPLE_MODE= 0,
104 MYSQL_FTPARSER_WITH_STOPWORDS= 1,
105 MYSQL_FTPARSER_FULL_BOOLEAN_INFO= 2
106};
107enum enum_ft_token_type
108{
109 FT_TOKEN_EOF= 0,
110 FT_TOKEN_WORD= 1,
111 FT_TOKEN_LEFT_PAREN= 2,
112 FT_TOKEN_RIGHT_PAREN= 3,
113 FT_TOKEN_STOPWORD= 4
114};
115typedef struct st_mysql_ftparser_boolean_info
116{
117 enum enum_ft_token_type type;
118 int yesno;
119 int weight_adjust;
120 char wasign;
121 char trunc;
122 char prev;
123 char *quot;
124} MYSQL_FTPARSER_BOOLEAN_INFO;
125typedef struct st_mysql_ftparser_param
126{
127 int (*mysql_parse)(struct st_mysql_ftparser_param *,
128 char *doc, int doc_len);
129 int (*mysql_add_word)(struct st_mysql_ftparser_param *,
130 char *word, int word_len,
131 MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info);
132 void *ftparser_state;
133 void *mysql_ftparam;
134 struct charset_info_st *cs;
135 char *doc;
136 int length;
137 int flags;
138 enum enum_ftparser_mode mode;
139} MYSQL_FTPARSER_PARAM;
140struct st_mysql_ftparser
141{
142 int interface_version;
143 int (*parse)(MYSQL_FTPARSER_PARAM *param);
144 int (*init)(MYSQL_FTPARSER_PARAM *param);
145 int (*deinit)(MYSQL_FTPARSER_PARAM *param);
146};
147#include "plugin_query_rewrite.h"
148struct st_mysql_daemon
149{
150 int interface_version;
151};
152struct st_mysql_information_schema
153{
154 int interface_version;
155};
156struct st_mysql_storage_engine
157{
158 int interface_version;
159};
160struct handlerton;
161 struct Mysql_replication {
162 int interface_version;
163 };
164struct st_mysql_value
165{
166 int (*value_type)(struct st_mysql_value *);
167 const char *(*val_str)(struct st_mysql_value *, char *buffer, int *length);
168 int (*val_real)(struct st_mysql_value *, double *realbuf);
169 int (*val_int)(struct st_mysql_value *, long long *intbuf);
170 int (*is_unsigned)(struct st_mysql_value *);
171};
172int thd_in_lock_tables(const void* thd);
173int thd_tablespace_op(const void* thd);
174long long thd_test_options(const void* thd, long long test_options);
175int thd_sql_command(const void* thd);
176const char *thd_proc_info(void* thd, const char *info);
177void **thd_ha_data(const void* thd, const struct handlerton *hton);
178void thd_storage_lock_wait(void* thd, long long value);
179int thd_tx_isolation(const void* thd);
180char *thd_security_context(void* thd, char *buffer, unsigned int length,
181 unsigned int max_query_len);
182void thd_inc_row_count(void* thd);
183int mysql_tmpfile(const char *prefix);
184int thd_killed(const void* thd);
185unsigned long thd_get_thread_id(const void* thd);
186void thd_get_xid(const void* thd, MYSQL_XID *xid);
187void mysql_query_cache_invalidate4(void* thd,
188 const char *key, unsigned int key_length,
189 int using_trx);
190void *thd_get_ha_data(const void* thd, const struct handlerton *hton);
191void thd_set_ha_data(void* thd, const struct handlerton *hton,
192 const void *ha_data);
193struct st_mysql_query_rewrite
194{
195 int interface_version;
196 char* (*rewrite_query)(const char* schema, size_t schema_len, const char* query, size_t orig_query_len, size_t* rewritten_query_len);
197 void (*free_rewritten_query)(char* query);
198};
0199
=== removed file 'include/probes_mysql_nodtrace.h'
--- include/probes_mysql_nodtrace.h 2010-03-01 00:06:27 +0000
+++ include/probes_mysql_nodtrace.h 1970-01-01 00:00:00 +0000
@@ -1,129 +0,0 @@
1/*
2 * Generated by dheadgen(1).
3 */
4
5#ifndef _PROBES_MYSQL_D
6#define _PROBES_MYSQL_D
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#define MYSQL_CONNECTION_START(arg0, arg1, arg2)
13#define MYSQL_CONNECTION_START_ENABLED() (0)
14#define MYSQL_CONNECTION_DONE(arg0, arg1)
15#define MYSQL_CONNECTION_DONE_ENABLED() (0)
16#define MYSQL_COMMAND_START(arg0, arg1, arg2, arg3)
17#define MYSQL_COMMAND_START_ENABLED() (0)
18#define MYSQL_COMMAND_DONE(arg0)
19#define MYSQL_COMMAND_DONE_ENABLED() (0)
20#define MYSQL_QUERY_START(arg0, arg1, arg2, arg3, arg4)
21#define MYSQL_QUERY_START_ENABLED() (0)
22#define MYSQL_QUERY_DONE(arg0)
23#define MYSQL_QUERY_DONE_ENABLED() (0)
24#define MYSQL_QUERY_PARSE_START(arg0)
25#define MYSQL_QUERY_PARSE_START_ENABLED() (0)
26#define MYSQL_QUERY_PARSE_DONE(arg0)
27#define MYSQL_QUERY_PARSE_DONE_ENABLED() (0)
28#define MYSQL_QUERY_CACHE_HIT(arg0, arg1)
29#define MYSQL_QUERY_CACHE_HIT_ENABLED() (0)
30#define MYSQL_QUERY_CACHE_MISS(arg0)
31#define MYSQL_QUERY_CACHE_MISS_ENABLED() (0)
32#define MYSQL_QUERY_EXEC_START(arg0, arg1, arg2, arg3, arg4, arg5)
33#define MYSQL_QUERY_EXEC_START_ENABLED() (0)
34#define MYSQL_QUERY_EXEC_DONE(arg0)
35#define MYSQL_QUERY_EXEC_DONE_ENABLED() (0)
36#define MYSQL_INSERT_ROW_START(arg0, arg1)
37#define MYSQL_INSERT_ROW_START_ENABLED() (0)
38#define MYSQL_INSERT_ROW_DONE(arg0)
39#define MYSQL_INSERT_ROW_DONE_ENABLED() (0)
40#define MYSQL_UPDATE_ROW_START(arg0, arg1)
41#define MYSQL_UPDATE_ROW_START_ENABLED() (0)
42#define MYSQL_UPDATE_ROW_DONE(arg0)
43#define MYSQL_UPDATE_ROW_DONE_ENABLED() (0)
44#define MYSQL_DELETE_ROW_START(arg0, arg1)
45#define MYSQL_DELETE_ROW_START_ENABLED() (0)
46#define MYSQL_DELETE_ROW_DONE(arg0)
47#define MYSQL_DELETE_ROW_DONE_ENABLED() (0)
48#define MYSQL_READ_ROW_START(arg0, arg1, arg2)
49#define MYSQL_READ_ROW_START_ENABLED() (0)
50#define MYSQL_READ_ROW_DONE(arg0)
51#define MYSQL_READ_ROW_DONE_ENABLED() (0)
52#define MYSQL_INDEX_READ_ROW_START(arg0, arg1)
53#define MYSQL_INDEX_READ_ROW_START_ENABLED() (0)
54#define MYSQL_INDEX_READ_ROW_DONE(arg0)
55#define MYSQL_INDEX_READ_ROW_DONE_ENABLED() (0)
56#define MYSQL_HANDLER_RDLOCK_START(arg0, arg1)
57#define MYSQL_HANDLER_RDLOCK_START_ENABLED() (0)
58#define MYSQL_HANDLER_WRLOCK_START(arg0, arg1)
59#define MYSQL_HANDLER_WRLOCK_START_ENABLED() (0)
60#define MYSQL_HANDLER_UNLOCK_START(arg0, arg1)
61#define MYSQL_HANDLER_UNLOCK_START_ENABLED() (0)
62#define MYSQL_HANDLER_RDLOCK_DONE(arg0)
63#define MYSQL_HANDLER_RDLOCK_DONE_ENABLED() (0)
64#define MYSQL_HANDLER_WRLOCK_DONE(arg0)
65#define MYSQL_HANDLER_WRLOCK_DONE_ENABLED() (0)
66#define MYSQL_HANDLER_UNLOCK_DONE(arg0)
67#define MYSQL_HANDLER_UNLOCK_DONE_ENABLED() (0)
68#define MYSQL_FILESORT_START(arg0, arg1)
69#define MYSQL_FILESORT_START_ENABLED() (0)
70#define MYSQL_FILESORT_DONE(arg0, arg1)
71#define MYSQL_FILESORT_DONE_ENABLED() (0)
72#define MYSQL_SELECT_START(arg0)
73#define MYSQL_SELECT_START_ENABLED() (0)
74#define MYSQL_SELECT_DONE(arg0, arg1)
75#define MYSQL_SELECT_DONE_ENABLED() (0)
76#define MYSQL_INSERT_START(arg0)
77#define MYSQL_INSERT_START_ENABLED() (0)
78#define MYSQL_INSERT_DONE(arg0, arg1)
79#define MYSQL_INSERT_DONE_ENABLED() (0)
80#define MYSQL_INSERT_SELECT_START(arg0)
81#define MYSQL_INSERT_SELECT_START_ENABLED() (0)
82#define MYSQL_INSERT_SELECT_DONE(arg0, arg1)
83#define MYSQL_INSERT_SELECT_DONE_ENABLED() (0)
84#define MYSQL_UPDATE_START(arg0)
85#define MYSQL_UPDATE_START_ENABLED() (0)
86#define MYSQL_UPDATE_DONE(arg0, arg1, arg2)
87#define MYSQL_UPDATE_DONE_ENABLED() (0)
88#define MYSQL_MULTI_UPDATE_START(arg0)
89#define MYSQL_MULTI_UPDATE_START_ENABLED() (0)
90#define MYSQL_MULTI_UPDATE_DONE(arg0, arg1, arg2)
91#define MYSQL_MULTI_UPDATE_DONE_ENABLED() (0)
92#define MYSQL_DELETE_START(arg0)
93#define MYSQL_DELETE_START_ENABLED() (0)
94#define MYSQL_DELETE_DONE(arg0, arg1)
95#define MYSQL_DELETE_DONE_ENABLED() (0)
96#define MYSQL_MULTI_DELETE_START(arg0)
97#define MYSQL_MULTI_DELETE_START_ENABLED() (0)
98#define MYSQL_MULTI_DELETE_DONE(arg0, arg1)
99#define MYSQL_MULTI_DELETE_DONE_ENABLED() (0)
100#define MYSQL_NET_READ_START()
101#define MYSQL_NET_READ_START_ENABLED() (0)
102#define MYSQL_NET_READ_DONE(arg0, arg1)
103#define MYSQL_NET_READ_DONE_ENABLED() (0)
104#define MYSQL_NET_WRITE_START(arg0)
105#define MYSQL_NET_WRITE_START_ENABLED() (0)
106#define MYSQL_NET_WRITE_DONE(arg0)
107#define MYSQL_NET_WRITE_DONE_ENABLED() (0)
108#define MYSQL_KEYCACHE_READ_START(arg0, arg1, arg2, arg3)
109#define MYSQL_KEYCACHE_READ_START_ENABLED() (0)
110#define MYSQL_KEYCACHE_READ_BLOCK(arg0)
111#define MYSQL_KEYCACHE_READ_BLOCK_ENABLED() (0)
112#define MYSQL_KEYCACHE_READ_HIT()
113#define MYSQL_KEYCACHE_READ_HIT_ENABLED() (0)
114#define MYSQL_KEYCACHE_READ_MISS()
115#define MYSQL_KEYCACHE_READ_MISS_ENABLED() (0)
116#define MYSQL_KEYCACHE_READ_DONE(arg0, arg1)
117#define MYSQL_KEYCACHE_READ_DONE_ENABLED() (0)
118#define MYSQL_KEYCACHE_WRITE_START(arg0, arg1, arg2, arg3)
119#define MYSQL_KEYCACHE_WRITE_START_ENABLED() (0)
120#define MYSQL_KEYCACHE_WRITE_BLOCK(arg0)
121#define MYSQL_KEYCACHE_WRITE_BLOCK_ENABLED() (0)
122#define MYSQL_KEYCACHE_WRITE_DONE(arg0, arg1)
123#define MYSQL_KEYCACHE_WRITE_DONE_ENABLED() (0)
124
125#ifdef __cplusplus
126}
127#endif
128
129#endif /* _PROBES_MYSQL_D */
1300
=== added directory 'plugin/rewrite_lower'
=== added file 'plugin/rewrite_lower/CMakeLists.txt'
--- plugin/rewrite_lower/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ plugin/rewrite_lower/CMakeLists.txt 2010-10-15 16:16:49 +0000
@@ -0,0 +1,17 @@
1# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15
16MYSQL_ADD_PLUGIN(rewrite_lower rewrite_lower.cc
17 MODULE_ONLY MODULE_OUTPUT_NAME "rewrite_lower")
018
=== added file 'plugin/rewrite_lower/Makefile.am'
--- plugin/rewrite_lower/Makefile.am 1970-01-01 00:00:00 +0000
+++ plugin/rewrite_lower/Makefile.am 2010-10-15 16:16:49 +0000
@@ -0,0 +1,32 @@
1# Copyright (C) 2006 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15
16## Makefile.am for query rewrite plugin that converts a query to lower case
17
18pkgplugindir = $(pkglibdir)/plugin
19INCLUDES = -I$(top_srcdir)/include \
20 -I$(top_srcdir)/sql \
21 -I$(top_srcdir)/regex \
22 -I$(srcdir)
23
24#noinst_HEADERS = rewrite_lower.h
25
26pkgplugin_LTLIBRARIES = rewrite_lower.la
27rewrite_lower_la_LDFLAGS = -module -rpath $(pkgplugindir) -L$(top_builddir)/libservices -lmysqlservices -lstdc++
28rewrite_lower_la_CXXFLAGS= $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN
29rewrite_lower_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
30rewrite_lower_la_SOURCES = rewrite_lower.cc
31
32EXTRA_DIST= plugin.in CMakeLists.txt
033
=== added file 'plugin/rewrite_lower/plug.in'
--- plugin/rewrite_lower/plug.in 1970-01-01 00:00:00 +0000
+++ plugin/rewrite_lower/plug.in 2010-10-15 16:16:49 +0000
@@ -0,0 +1,4 @@
1MYSQL_PLUGIN(rewrite_lower,[Convert query to lower-case Query Rewriting Plugin],
2 [Example query rewriting plugin.])
3MYSQL_PLUGIN_DYNAMIC(rewrite_lower, [rewrite_lower.la])
4MYSQL_PLUGIN_STATIC(rewrite_lower, [librewritelower.a])
05
=== added file 'plugin/rewrite_lower/rewrite_lower.cc'
--- plugin/rewrite_lower/rewrite_lower.cc 1970-01-01 00:00:00 +0000
+++ plugin/rewrite_lower/rewrite_lower.cc 2010-10-15 16:16:49 +0000
@@ -0,0 +1,84 @@
1/* Copyright (C) 2010 Akiban Technologies
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15
16#include <ctype.h>
17#include <string.h>
18
19#include <mysql/plugin.h>
20#include <mysql/plugin_query_rewrite.h>
21
22using namespace std;
23
24static char* rewrite_lower(const char*,
25 size_t,
26 const char* query,
27 size_t original_query_len,
28 size_t* rewritten_query_len)
29{
30 char* rewritten_query= new char[original_query_len];
31 memcpy(rewritten_query, query, original_query_len);
32 while (*rewritten_query++ = tolower(*rewritten_query));
33 *rewritten_query_len= original_query_len;
34 return (rewritten_query - (original_query_len + 1));
35}
36
37
38static void free_rewritten_query(char* query)
39{
40 delete [] query;
41}
42
43
44static void null_parse_rewrite(MYSQL_THD, MYSQL_LEXPTR)
45{
46}
47
48
49static int rewrite_lower_plugin_init(void *)
50{
51 return 0;
52}
53
54static int rewrite_lower_plugin_deinit(void *)
55{
56 return 0;
57}
58
59static struct st_mysql_query_rewrite rewrite_lower_descriptor= {
60 MYSQL_QUERY_REWRITE_INTERFACE_VERSION, /* interface version */
61 rewrite_lower, /* rewrite function */
62 free_rewritten_query, /* free allocated memory for rewritten query */
63 null_parse_rewrite /* rewrite the parse tree (do nothing) */
64};
65
66/*
67 Plugin library descriptor
68*/
69mysql_declare_plugin(rewrite_lower)
70{
71 MYSQL_QUERY_REWRITE_PLUGIN,
72 &rewrite_lower_descriptor,
73 "rewrite_lower",
74 "Padraig O'Sullivan",
75 "Simple example query rewriting plugin",
76 PLUGIN_LICENSE_GPL,
77 rewrite_lower_plugin_init, /* Plugin Init */
78 rewrite_lower_plugin_deinit, /* Plugin Deinit */
79 0x0100 /* 1.0 */,
80 NULL, /* status variables */
81 NULL, /* system variables */
82 NULL /* config options */
83}
84mysql_declare_plugin_end;
085
=== modified file 'sql/CMakeLists.txt'
--- sql/CMakeLists.txt 2010-09-28 15:30:47 +0000
+++ sql/CMakeLists.txt 2010-10-15 16:16:49 +0000
@@ -67,7 +67,7 @@
67 event_queue.cc event_db_repository.cc 67 event_queue.cc event_db_repository.cc
68 sql_tablespace.cc events.cc ../sql-common/my_user.c 68 sql_tablespace.cc events.cc ../sql-common/my_user.c
69 partition_info.cc sql_locale.cc69 partition_info.cc sql_locale.cc
70 sql_servers.cc sql_audit.cc70 sql_servers.cc sql_audit.cc sql_query_rewrite.cc
71 sql_connect.cc scheduler.cc 71 sql_connect.cc scheduler.cc
72 sql_profile.cc event_parse_data.cc72 sql_profile.cc event_parse_data.cc
73 sql_bootstrap.cc73 sql_bootstrap.cc
7474
=== modified file 'sql/Makefile.am'
--- sql/Makefile.am 2010-08-20 09:15:16 +0000
+++ sql/Makefile.am 2010-10-15 16:16:49 +0000
@@ -130,7 +130,7 @@
130 sql_plugin.h authors.h event_parse_data.h \130 sql_plugin.h authors.h event_parse_data.h \
131 event_data_objects.h event_scheduler.h \131 event_data_objects.h event_scheduler.h \
132 sql_partition.h partition_info.h partition_element.h \132 sql_partition.h partition_info.h partition_element.h \
133 sql_audit.h sql_alter.h sql_partition_admin.h \133 sql_audit.h sql_query_rewrite.h sql_alter.h sql_partition_admin.h \
134 contributors.h sql_servers.h sql_signal.h records.h \134 contributors.h sql_servers.h sql_signal.h records.h \
135 sql_prepare.h rpl_handler.h replication.h mdl.h \135 sql_prepare.h rpl_handler.h replication.h mdl.h \
136 sql_cmd.h \136 sql_cmd.h \
@@ -176,7 +176,7 @@
176 sql_plugin.cc \176 sql_plugin.cc \
177 sql_builtin.cc sql_tablespace.cc partition_info.cc \177 sql_builtin.cc sql_tablespace.cc partition_info.cc \
178 sql_servers.cc event_parse_data.cc sql_signal.cc \178 sql_servers.cc event_parse_data.cc sql_signal.cc \
179 mdl.cc transaction.cc sql_audit.cc \179 mdl.cc transaction.cc sql_audit.cc sql_query_rewrite.cc \
180 sha2.cc \180 sha2.cc \
181 sql_alter.cc \181 sql_alter.cc \
182 sql_partition_admin.cc182 sql_partition_admin.cc
183183
=== modified file 'sql/sql_parse.cc'
--- sql/sql_parse.cc 2010-09-01 22:59:33 +0000
+++ sql/sql_parse.cc 2010-10-15 16:16:49 +0000
@@ -99,6 +99,7 @@
99#include "probes_mysql.h"99#include "probes_mysql.h"
100#include "set_var.h"100#include "set_var.h"
101#include "sql_bootstrap.h"101#include "sql_bootstrap.h"
102#include "sql_query_rewrite.h"
102103
103#define FLAGSTR(V,F) ((V)&(F)?#F" ":"")104#define FLAGSTR(V,F) ((V)&(F)?#F" ":"")
104105
@@ -556,6 +557,7 @@
556 mode we have only one thread.557 mode we have only one thread.
557 */558 */
558 thd->set_time();559 thd->set_time();
560 mysql_rewrite_raw_query(thd);
559 Parser_state parser_state;561 Parser_state parser_state;
560 if (parser_state.init(thd, thd->query(), length))562 if (parser_state.init(thd, thd->query(), length))
561 {563 {
@@ -1118,6 +1120,7 @@
1118 char *packet_end= thd->query() + thd->query_length();1120 char *packet_end= thd->query() + thd->query_length();
1119 /* 'b' stands for 'buffer' parameter', special for 'my_snprintf' */1121 /* 'b' stands for 'buffer' parameter', special for 'my_snprintf' */
11201122
1123 mysql_rewrite_raw_query(thd);
1121 general_log_write(thd, command, thd->query(), thd->query_length());1124 general_log_write(thd, command, thd->query(), thd->query_length());
1122 DBUG_PRINT("query",("%-.4096s",thd->query()));1125 DBUG_PRINT("query",("%-.4096s",thd->query()));
1123#if defined(ENABLED_PROFILING)1126#if defined(ENABLED_PROFILING)
@@ -5559,6 +5562,7 @@
5559 {5562 {
5560 if (! thd->is_error())5563 if (! thd->is_error())
5561 {5564 {
5565 mysql_rewrite_parse_tree(thd);
5562 const char *found_semicolon= parser_state->m_lip.found_semicolon;5566 const char *found_semicolon= parser_state->m_lip.found_semicolon;
5563 /*5567 /*
5564 Binlog logs a string starting from thd->query and having length5568 Binlog logs a string starting from thd->query and having length
55655569
=== modified file 'sql/sql_plugin.cc'
--- sql/sql_plugin.cc 2010-09-21 21:27:43 +0000
+++ sql/sql_plugin.cc 2010-10-15 16:16:49 +0000
@@ -64,6 +64,7 @@
64 { C_STRING_WITH_LEN("DAEMON") },64 { C_STRING_WITH_LEN("DAEMON") },
65 { C_STRING_WITH_LEN("INFORMATION SCHEMA") },65 { C_STRING_WITH_LEN("INFORMATION SCHEMA") },
66 { C_STRING_WITH_LEN("AUDIT") },66 { C_STRING_WITH_LEN("AUDIT") },
67 { C_STRING_WITH_LEN("QUERY REWRITE") },
67 { C_STRING_WITH_LEN("REPLICATION") },68 { C_STRING_WITH_LEN("REPLICATION") },
68};69};
6970
@@ -73,6 +74,9 @@
73extern int initialize_audit_plugin(st_plugin_int *plugin);74extern int initialize_audit_plugin(st_plugin_int *plugin);
74extern int finalize_audit_plugin(st_plugin_int *plugin);75extern int finalize_audit_plugin(st_plugin_int *plugin);
7576
77extern int initialize_query_rewrite_plugin(st_plugin_int *plugin);
78extern int finalize_query_rewrite_plugin(st_plugin_int *plugin);
79
76/*80/*
77 The number of elements in both plugin_type_initialize and81 The number of elements in both plugin_type_initialize and
78 plugin_type_deinitialize should equal to the number of plugins82 plugin_type_deinitialize should equal to the number of plugins
@@ -81,13 +85,13 @@
81plugin_type_init plugin_type_initialize[MYSQL_MAX_PLUGIN_TYPE_NUM]=85plugin_type_init plugin_type_initialize[MYSQL_MAX_PLUGIN_TYPE_NUM]=
82{86{
83 0,ha_initialize_handlerton,0,0,initialize_schema_table,87 0,ha_initialize_handlerton,0,0,initialize_schema_table,
84 initialize_audit_plugin88 initialize_audit_plugin,initialize_query_rewrite_plugin
85};89};
8690
87plugin_type_init plugin_type_deinitialize[MYSQL_MAX_PLUGIN_TYPE_NUM]=91plugin_type_init plugin_type_deinitialize[MYSQL_MAX_PLUGIN_TYPE_NUM]=
88{92{
89 0,ha_finalize_handlerton,0,0,finalize_schema_table,93 0,ha_finalize_handlerton,0,0,finalize_schema_table,
90 finalize_audit_plugin94 finalize_audit_plugin,finalize_query_rewrite_plugin
91};95};
9296
93#ifdef HAVE_DLOPEN97#ifdef HAVE_DLOPEN
@@ -110,6 +114,7 @@
110 MYSQL_DAEMON_INTERFACE_VERSION,114 MYSQL_DAEMON_INTERFACE_VERSION,
111 MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION,115 MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION,
112 MYSQL_AUDIT_INTERFACE_VERSION,116 MYSQL_AUDIT_INTERFACE_VERSION,
117 MYSQL_QUERY_REWRITE_INTERFACE_VERSION,
113 MYSQL_REPLICATION_INTERFACE_VERSION118 MYSQL_REPLICATION_INTERFACE_VERSION
114};119};
115static int cur_plugin_info_interface_version[MYSQL_MAX_PLUGIN_TYPE_NUM]=120static int cur_plugin_info_interface_version[MYSQL_MAX_PLUGIN_TYPE_NUM]=
@@ -120,6 +125,7 @@
120 MYSQL_DAEMON_INTERFACE_VERSION,125 MYSQL_DAEMON_INTERFACE_VERSION,
121 MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION,126 MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION,
122 MYSQL_AUDIT_INTERFACE_VERSION,127 MYSQL_AUDIT_INTERFACE_VERSION,
128 MYSQL_QUERY_REWRITE_INTERFACE_VERSION,
123 MYSQL_REPLICATION_INTERFACE_VERSION129 MYSQL_REPLICATION_INTERFACE_VERSION
124};130};
125131
126132
=== added file 'sql/sql_query_rewrite.cc'
--- sql/sql_query_rewrite.cc 1970-01-01 00:00:00 +0000
+++ sql/sql_query_rewrite.cc 2010-10-15 16:16:49 +0000
@@ -0,0 +1,167 @@
1/* Copyright (c) 2010, Akiban Technologies. All rights reserved.
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 Foundation,
14 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
15
16#include "sql_priv.h"
17#include "sql_parse.h"
18#include "sql_query_rewrite.h"
19
20extern int initialize_query_rewrite_plugin(st_plugin_int *plugin);
21extern int finalize_query_rewrite_plugin(st_plugin_int *plugin);
22
23#ifndef EMBEDDED_LIBRARY
24
25/**
26 Rewrites a query by invoking the plugin's query_rewrite method.
27
28 @param[in] thd
29 @param[in] plugin
30 @param[in] arg
31
32 @retval FALSE always
33*/
34static my_bool query_text_rewrite(THD *thd,
35 plugin_ref plugin,
36 void *)
37{
38 st_mysql_query_rewrite *data= plugin_data(plugin, struct st_mysql_query_rewrite *);
39
40 /* rewrite the query */
41 if (data)
42 {
43 size_t rewritten_query_len= 0;
44 char *rewritten_query= data->rewrite_query(thd->db, thd->db_length, thd->query(), thd->query_length(), &rewritten_query_len);
45 if (rewritten_query != NULL && rewritten_query_len > 0)
46 {
47 alloc_query(thd, rewritten_query, rewritten_query_len);
48 data->free_rewritten_query(rewritten_query);
49 }
50 }
51
52 return 0;
53}
54
55
56/**
57 Rewrites a query by invoking the plugin's rewrite_parse_tree method.
58
59 @param[in] thd
60 @param[in] plugin
61 @param[in] arg
62
63 @retval FALSE always
64*/
65static my_bool parse_tree_rewrite(THD *thd,
66 plugin_ref plugin,
67 void *)
68{
69 st_mysql_query_rewrite *data= plugin_data(plugin, struct st_mysql_query_rewrite *);
70
71 /* rewrite the parse tree */
72 if (data)
73 {
74 data->rewrite_parse_tree(thd, thd->lex);
75 }
76
77 return 0;
78}
79
80
81void mysql_rewrite_raw_query(THD *thd)
82{
83 plugin_foreach(thd,
84 query_text_rewrite,
85 MYSQL_QUERY_REWRITE_PLUGIN,
86 NULL);
87}
88
89
90void mysql_rewrite_parse_tree(THD *thd)
91{
92 plugin_foreach(thd,
93 parse_tree_rewrite,
94 MYSQL_QUERY_REWRITE_PLUGIN,
95 NULL);
96}
97
98/**
99 Initialize a query rewrite plug-in
100
101 @param[in] plugin
102
103 @retval FALSE OK
104 @retval TRUE There was an error.
105*/
106int initialize_query_rewrite_plugin(st_plugin_int *plugin)
107{
108 if (plugin->plugin->init && plugin->plugin->init(NULL))
109 {
110 sql_print_error("Plugin '%s' init function returned error.",
111 plugin->name.str);
112 return 1;
113 }
114
115 /* Make the interface info more easily accessible */
116 plugin->data= plugin->plugin->info;
117
118 return 0;
119}
120
121
122/**
123 Finalize a query rewrite plug-in
124
125 @param[in] plugin
126
127 @retval FALSE OK
128 @retval TRUE There was an error.
129*/
130int finalize_query_rewrite_plugin(st_plugin_int *plugin)
131{
132 if (plugin->plugin->deinit && plugin->plugin->deinit(NULL))
133 {
134 DBUG_PRINT("warning", ("Plugin '%s' deinit function returned error.",
135 plugin->name.str));
136 DBUG_EXECUTE("finalize_query_rewrite_plugin", return 1; );
137 }
138
139 plugin->data= NULL;
140 return 0;
141}
142
143#else /* EMBEDDED_LIBRARY */
144
145
146void mysql_rewrite_raw_query(THD *thd)
147{
148}
149
150
151void mysql_rewrite_parse_tree(THD *thd)
152{
153}
154
155
156int initialize_query_rewrite_plugin(st_plugin_int *plugin)
157{
158 return 1;
159}
160
161
162int finalize_query_rewrite_plugin(st_plugin_int *plugin)
163{
164 return 1;
165}
166
167#endif /* EMBEDDED_LIBRARY */
0168
=== added file 'sql/sql_query_rewrite.h'
--- sql/sql_query_rewrite.h 1970-01-01 00:00:00 +0000
+++ sql/sql_query_rewrite.h 2010-10-15 16:16:49 +0000
@@ -0,0 +1,36 @@
1#ifndef SQL_QUERY_REWRITE_INCLUDED
2#define SQL_QUERY_REWRITE_INCLUDED
3
4/* Copyright (c) 2010, Akiban Technologies. All rights reserved.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; version 2 of the License.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software Foundation,
17 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
18
19
20#include <mysql/plugin_query_rewrite.h>
21#include "sql_class.h"
22
23/**
24 Call query rewrite plugins on raw query text
25 @param[in] thd thread with the query to be rewritten
26 */
27void mysql_rewrite_raw_query(THD *thd);
28
29
30/**
31 Call query rewrite plugins on the parse tree
32 @param[in] thd thread with the parse tree to be rewritten
33 */
34void mysql_rewrite_parse_tree(THD *thd);
35
36#endif /* SQL_QUERY_REWRITE_INCLUDED */

Subscribers

People subscribed via source and target branches

to status/vote changes: