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 --- a/storage/innobase/handler/ha_innodb.cc
9 +++ b/storage/innobase/handler/ha_innodb.cc
10 @@ -12041,7 +12041,8 @@
11 i_s_innodb_sys_foreign_cols,
13 i_s_innodb_table_stats,
14 -i_s_innodb_index_stats
15 +i_s_innodb_index_stats,
16 +i_s_innodb_admin_command
17 mysql_declare_plugin_end;
19 /** @brief Initialize the default value of innodb_commit_concurrency.
20 --- a/storage/innobase/handler/i_s.cc
21 +++ b/storage/innobase/handler/i_s.cc
22 @@ -4243,3 +4243,140 @@
23 STRUCT_FLD(__reserved1, NULL),
24 STRUCT_FLD(flags, 0UL)
27 +/***********************************************************************
29 +static ST_FIELD_INFO i_s_innodb_admin_command_info[] =
31 + {STRUCT_FLD(field_name, "result_message"),
32 + STRUCT_FLD(field_length, 1024),
33 + STRUCT_FLD(field_type, MYSQL_TYPE_STRING),
34 + STRUCT_FLD(value, 0),
35 + STRUCT_FLD(field_flags, 0),
36 + STRUCT_FLD(old_name, ""),
37 + STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
39 + END_OF_ST_FIELD_INFO
42 +#ifndef INNODB_COMPATIBILITY_HOOKS
43 +#error InnoDB needs MySQL to be built with #define INNODB_COMPATIBILITY_HOOKS
47 +char **thd_query(MYSQL_THD thd);
52 +i_s_innodb_admin_command_fill(
53 +/*==========================*/
58 + TABLE* i_s_table = (TABLE *) tables->table;
62 + const char* command_head = "XTRA_";
64 + DBUG_ENTER("i_s_innodb_admin_command_fill");
66 + /* deny access to non-superusers */
67 + if (check_global_access(thd, PROCESS_ACL)) {
71 + if(thd_sql_command(thd) != SQLCOM_SELECT) {
72 + field_store_string(i_s_table->field[0],
73 + "SELECT command is only accepted.");
77 + query_str = thd_query(thd);
80 + for (; *ptr; ptr++) {
81 + if (*ptr == quote) {
84 + } else if (*ptr == '`' || *ptr == '"') {
88 + for (i = 0; command_head[i]; i++) {
89 + if (toupper((int)(unsigned char)(ptr[i]))
90 + != toupper((int)(unsigned char)
91 + (command_head[i]))) {
102 + field_store_string(i_s_table->field[0],
103 + "No XTRA_* command in the SQL statement."
104 + " Please add /*!XTRA_xxxx*/ to the SQL.");
108 + if (!strncasecmp("XTRA_HELLO", ptr, 10)) {
109 + /* This is example command XTRA_HELLO */
111 + ut_print_timestamp(stderr);
112 + fprintf(stderr, " InnoDB: administration command test for XtraDB"
113 + " 'XTRA_HELLO' was detected.\n");
115 + field_store_string(i_s_table->field[0],
120 + field_store_string(i_s_table->field[0],
121 + "Undefined XTRA_* command.");
125 + if (schema_table_store_record(thd, i_s_table)) {
134 +i_s_innodb_admin_command_init(
135 +/*==========================*/
138 + DBUG_ENTER("i_s_innodb_admin_command_init");
139 + ST_SCHEMA_TABLE* schema = (ST_SCHEMA_TABLE*) p;
141 + schema->fields_info = i_s_innodb_admin_command_info;
142 + schema->fill_table = i_s_innodb_admin_command_fill;
147 +UNIV_INTERN struct st_mysql_plugin i_s_innodb_admin_command =
149 + STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN),
150 + STRUCT_FLD(info, &i_s_info),
151 + STRUCT_FLD(name, "XTRADB_ADMIN_COMMAND"),
152 + STRUCT_FLD(author, "Percona"),
153 + STRUCT_FLD(descr, "XtraDB specific command acceptor"),
154 + STRUCT_FLD(license, PLUGIN_LICENSE_GPL),
155 + STRUCT_FLD(init, i_s_innodb_admin_command_init),
156 + STRUCT_FLD(deinit, i_s_common_deinit),
157 + STRUCT_FLD(version, 0x0100 /* 1.0 */),
158 + STRUCT_FLD(status_vars, NULL),
159 + STRUCT_FLD(system_vars, NULL),
160 + STRUCT_FLD(__reserved1, NULL),
161 + STRUCT_FLD(flags, 0UL)
163 --- a/storage/innobase/handler/i_s.h
164 +++ b/storage/innobase/handler/i_s.h
166 extern struct st_mysql_plugin i_s_innodb_sys_stats;
167 extern struct st_mysql_plugin i_s_innodb_table_stats;
168 extern struct st_mysql_plugin i_s_innodb_index_stats;
169 +extern struct st_mysql_plugin i_s_innodb_admin_command;
173 +++ b/mysql-test/r/percona_xtradb_admin_command.result
175 +select * from information_schema.XTRADB_ADMIN_COMMAND;
177 +No XTRA_* command in the SQL statement. Please add /*!XTRA_xxxx*/ to the SQL.
178 +select * from information_schema.XTRADB_ADMIN_COMMAND /*!XTRA_HELLO*/;
182 +++ b/mysql-test/t/percona_xtradb_admin_command.test
184 +--source include/have_innodb.inc
185 +select * from information_schema.XTRADB_ADMIN_COMMAND;
186 +select * from information_schema.XTRADB_ADMIN_COMMAND /*!XTRA_HELLO*/;
187 --- a/mysql-test/r/mysqld--help-notwin.result
188 +++ b/mysql-test/r/mysqld--help-notwin.result
190 -V, --version Output version information and exit.
191 --wait-timeout=# The number of seconds the server waits for activity on a
192 connection before closing it
193 + --xtradb-admin-command[=name]
194 + Enable or disable XTRADB_ADMIN_COMMAND plugin. Possible
195 + values are ON, OFF, FORCE (don't start if the plugin
198 Variables (--variable-name=value)
199 abort-slave-event-count 0
201 updatable-views-with-limit YES
204 +xtradb-admin-command ON
206 To see what values a running MySQL server is using, type
207 'mysqladmin variables' instead of 'mysqld --verbose --help'.