1 # name : innodb_admin_command_base.patch
2 # introduced : 11 or before
3 # maintainer : Yasufumi
6 # Any small change to this file in the main branch
7 # should be done or reviewed by the maintainer!
8 diff -ruN a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
9 --- a/storage/innobase/handler/ha_innodb.cc 2010-12-03 17:32:15.624039043 +0900
10 +++ b/storage/innobase/handler/ha_innodb.cc 2010-12-03 17:32:35.424957827 +0900
11 @@ -11833,7 +11833,8 @@
12 i_s_innodb_sys_foreign_cols,
14 i_s_innodb_table_stats,
15 -i_s_innodb_index_stats
16 +i_s_innodb_index_stats,
17 +i_s_innodb_admin_command
18 mysql_declare_plugin_end;
20 /** @brief Initialize the default value of innodb_commit_concurrency.
21 diff -ruN a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc
22 --- a/storage/innobase/handler/i_s.cc 2010-12-03 17:30:16.299955549 +0900
23 +++ b/storage/innobase/handler/i_s.cc 2010-12-03 17:32:35.425989972 +0900
24 @@ -4161,3 +4161,139 @@
25 STRUCT_FLD(system_vars, NULL),
26 STRUCT_FLD(__reserved1, NULL)
29 +/***********************************************************************
31 +static ST_FIELD_INFO i_s_innodb_admin_command_info[] =
33 + {STRUCT_FLD(field_name, "result_message"),
34 + STRUCT_FLD(field_length, 1024),
35 + STRUCT_FLD(field_type, MYSQL_TYPE_STRING),
36 + STRUCT_FLD(value, 0),
37 + STRUCT_FLD(field_flags, 0),
38 + STRUCT_FLD(old_name, ""),
39 + STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
41 + END_OF_ST_FIELD_INFO
44 +#ifndef INNODB_COMPATIBILITY_HOOKS
45 +#error InnoDB needs MySQL to be built with #define INNODB_COMPATIBILITY_HOOKS
49 +char **thd_query(MYSQL_THD thd);
54 +i_s_innodb_admin_command_fill(
55 +/*==========================*/
60 + TABLE* i_s_table = (TABLE *) tables->table;
64 + const char* command_head = "XTRA_";
66 + DBUG_ENTER("i_s_innodb_admin_command_fill");
68 + /* deny access to non-superusers */
69 + if (check_global_access(thd, PROCESS_ACL)) {
73 + if(thd_sql_command(thd) != SQLCOM_SELECT) {
74 + field_store_string(i_s_table->field[0],
75 + "SELECT command is only accepted.");
79 + query_str = thd_query(thd);
82 + for (; *ptr; ptr++) {
83 + if (*ptr == quote) {
86 + } else if (*ptr == '`' || *ptr == '"') {
90 + for (i = 0; command_head[i]; i++) {
91 + if (toupper((int)(unsigned char)(ptr[i]))
92 + != toupper((int)(unsigned char)
93 + (command_head[i]))) {
104 + field_store_string(i_s_table->field[0],
105 + "No XTRA_* command in the SQL statement."
106 + " Please add /*!XTRA_xxxx*/ to the SQL.");
110 + if (!strncasecmp("XTRA_HELLO", ptr, 10)) {
111 + /* This is example command XTRA_HELLO */
113 + ut_print_timestamp(stderr);
114 + fprintf(stderr, " InnoDB: administration command test for XtraDB"
115 + " 'XTRA_HELLO' was detected.\n");
117 + field_store_string(i_s_table->field[0],
122 + field_store_string(i_s_table->field[0],
123 + "Undefined XTRA_* command.");
127 + if (schema_table_store_record(thd, i_s_table)) {
136 +i_s_innodb_admin_command_init(
137 +/*==========================*/
140 + DBUG_ENTER("i_s_innodb_admin_command_init");
141 + ST_SCHEMA_TABLE* schema = (ST_SCHEMA_TABLE*) p;
143 + schema->fields_info = i_s_innodb_admin_command_info;
144 + schema->fill_table = i_s_innodb_admin_command_fill;
149 +UNIV_INTERN struct st_mysql_plugin i_s_innodb_admin_command =
151 + STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN),
152 + STRUCT_FLD(info, &i_s_info),
153 + STRUCT_FLD(name, "XTRADB_ADMIN_COMMAND"),
154 + STRUCT_FLD(author, plugin_author),
155 + STRUCT_FLD(descr, "XtraDB specific command acceptor"),
156 + STRUCT_FLD(license, PLUGIN_LICENSE_GPL),
157 + STRUCT_FLD(init, i_s_innodb_admin_command_init),
158 + STRUCT_FLD(deinit, i_s_common_deinit),
159 + STRUCT_FLD(version, 0x0100 /* 1.0 */),
160 + STRUCT_FLD(status_vars, NULL),
161 + STRUCT_FLD(system_vars, NULL),
162 + STRUCT_FLD(__reserved1, NULL)
164 diff -ruN a/storage/innobase/handler/i_s.h b/storage/innobase/handler/i_s.h
165 --- a/storage/innobase/handler/i_s.h 2010-12-03 17:30:16.301987692 +0900
166 +++ b/storage/innobase/handler/i_s.h 2010-12-03 17:32:35.426954555 +0900
168 extern struct st_mysql_plugin i_s_innodb_sys_stats;
169 extern struct st_mysql_plugin i_s_innodb_table_stats;
170 extern struct st_mysql_plugin i_s_innodb_index_stats;
171 +extern struct st_mysql_plugin i_s_innodb_admin_command;