]> git.pld-linux.org Git - packages/mysql.git/blame - innodb_admin_command_base.patch
move status action to status function
[packages/mysql.git] / innodb_admin_command_base.patch
CommitLineData
b4e1fa2c
AM
1# name : innodb_admin_command_base.patch
2# introduced : 11 or before
3# maintainer : Yasufumi
4#
5#!!! notice !!!
6# Any small change to this file in the main branch
7# should be done or reviewed by the maintainer!
db82db79
AM
8--- a/storage/innobase/handler/ha_innodb.cc
9+++ b/storage/innobase/handler/ha_innodb.cc
29ffd636 10@@ -12041,7 +12041,8 @@
b4e1fa2c
AM
11 i_s_innodb_sys_foreign_cols,
12 i_s_innodb_sys_stats,
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;
18
19 /** @brief Initialize the default value of innodb_commit_concurrency.
db82db79
AM
20--- a/storage/innobase/handler/i_s.cc
21+++ b/storage/innobase/handler/i_s.cc
13ceb006
AM
22@@ -4243,3 +4243,140 @@
23 STRUCT_FLD(__reserved1, NULL),
24 STRUCT_FLD(flags, 0UL)
b4e1fa2c
AM
25 };
26+
27+/***********************************************************************
28+*/
29+static ST_FIELD_INFO i_s_innodb_admin_command_info[] =
30+{
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)},
38+
39+ END_OF_ST_FIELD_INFO
40+};
41+
42+#ifndef INNODB_COMPATIBILITY_HOOKS
43+#error InnoDB needs MySQL to be built with #define INNODB_COMPATIBILITY_HOOKS
44+#endif
45+
46+extern "C" {
47+char **thd_query(MYSQL_THD thd);
48+}
49+
50+static
51+int
52+i_s_innodb_admin_command_fill(
53+/*==========================*/
54+ THD* thd,
55+ TABLE_LIST* tables,
56+ COND* cond)
57+{
58+ TABLE* i_s_table = (TABLE *) tables->table;
59+ char** query_str;
60+ char* ptr;
61+ char quote = '\0';
62+ const char* command_head = "XTRA_";
63+
64+ DBUG_ENTER("i_s_innodb_admin_command_fill");
65+
66+ /* deny access to non-superusers */
67+ if (check_global_access(thd, PROCESS_ACL)) {
68+ DBUG_RETURN(0);
69+ }
70+
71+ if(thd_sql_command(thd) != SQLCOM_SELECT) {
72+ field_store_string(i_s_table->field[0],
73+ "SELECT command is only accepted.");
74+ goto end_func;
75+ }
76+
77+ query_str = thd_query(thd);
78+ ptr = *query_str;
79+
80+ for (; *ptr; ptr++) {
81+ if (*ptr == quote) {
82+ quote = '\0';
83+ } else if (quote) {
84+ } else if (*ptr == '`' || *ptr == '"') {
85+ quote = *ptr;
86+ } else {
87+ long i;
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]))) {
92+ goto nomatch;
93+ }
94+ }
95+ break;
96+nomatch:
97+ ;
98+ }
99+ }
100+
101+ if (!*ptr) {
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.");
105+ goto end_func;
106+ }
107+
108+ if (!strncasecmp("XTRA_HELLO", ptr, 10)) {
109+ /* This is example command XTRA_HELLO */
110+
111+ ut_print_timestamp(stderr);
112+ fprintf(stderr, " InnoDB: administration command test for XtraDB"
113+ " 'XTRA_HELLO' was detected.\n");
114+
115+ field_store_string(i_s_table->field[0],
116+ "Hello!");
117+ goto end_func;
118+ }
119+
120+ field_store_string(i_s_table->field[0],
121+ "Undefined XTRA_* command.");
122+ goto end_func;
123+
124+end_func:
125+ if (schema_table_store_record(thd, i_s_table)) {
126+ DBUG_RETURN(1);
127+ } else {
128+ DBUG_RETURN(0);
129+ }
130+}
131+
132+static
133+int
134+i_s_innodb_admin_command_init(
135+/*==========================*/
136+ void* p)
137+{
138+ DBUG_ENTER("i_s_innodb_admin_command_init");
139+ ST_SCHEMA_TABLE* schema = (ST_SCHEMA_TABLE*) p;
140+
141+ schema->fields_info = i_s_innodb_admin_command_info;
142+ schema->fill_table = i_s_innodb_admin_command_fill;
143+
144+ DBUG_RETURN(0);
145+}
146+
147+UNIV_INTERN struct st_mysql_plugin i_s_innodb_admin_command =
148+{
149+ STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN),
150+ STRUCT_FLD(info, &i_s_info),
151+ STRUCT_FLD(name, "XTRADB_ADMIN_COMMAND"),
adf0fb13 152+ STRUCT_FLD(author, "Percona"),
b4e1fa2c
AM
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),
13ceb006
AM
160+ STRUCT_FLD(__reserved1, NULL),
161+ STRUCT_FLD(flags, 0UL)
b4e1fa2c 162+};
db82db79
AM
163--- a/storage/innobase/handler/i_s.h
164+++ b/storage/innobase/handler/i_s.h
adf0fb13 165@@ -46,5 +46,6 @@
b4e1fa2c
AM
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;
170
171 #endif /* i_s_h */
48b678b4
AM
172--- /dev/null
173+++ b/mysql-test/r/percona_xtradb_admin_command.result
174@@ -0,0 +1,6 @@
175+select * from information_schema.XTRADB_ADMIN_COMMAND;
176+result_message
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*/;
179+result_message
180+Hello!
181--- /dev/null
182+++ b/mysql-test/t/percona_xtradb_admin_command.test
183@@ -0,0 +1,3 @@
184+--source include/have_innodb.inc
185+select * from information_schema.XTRADB_ADMIN_COMMAND;
186+select * from information_schema.XTRADB_ADMIN_COMMAND /*!XTRA_HELLO*/;
734d6226
AM
187--- a/mysql-test/r/mysqld--help-notwin.result
188+++ b/mysql-test/r/mysqld--help-notwin.result
1bfc1981 189@@ -733,6 +733,10 @@
734d6226
AM
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
196+ fails to load).
197
198 Variables (--variable-name=value)
199 abort-slave-event-count 0
1bfc1981 200@@ -958,6 +962,7 @@
734d6226
AM
201 updatable-views-with-limit YES
202 verbose TRUE
203 wait-timeout 28800
204+xtradb-admin-command ON
205
206 To see what values a running MySQL server is using, type
207 'mysqladmin variables' instead of 'mysqld --verbose --help'.
This page took 0.351534 seconds and 4 git commands to generate.