]> git.pld-linux.org Git - packages/mysql.git/blame - innodb_admin_command_base.patch
- disable response-time-distribution patch on arch which has no atomic builtins even...
[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!
8diff -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
11822e22 11@@ -11839,7 +11839,8 @@
b4e1fa2c
AM
12 i_s_innodb_sys_foreign_cols,
13 i_s_innodb_sys_stats,
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;
19
20 /** @brief Initialize the default value of innodb_commit_concurrency.
21diff -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
11822e22 24@@ -4179,3 +4179,139 @@
b4e1fa2c
AM
25 STRUCT_FLD(system_vars, NULL),
26 STRUCT_FLD(__reserved1, NULL)
27 };
28+
29+/***********************************************************************
30+*/
31+static ST_FIELD_INFO i_s_innodb_admin_command_info[] =
32+{
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)},
40+
41+ END_OF_ST_FIELD_INFO
42+};
43+
44+#ifndef INNODB_COMPATIBILITY_HOOKS
45+#error InnoDB needs MySQL to be built with #define INNODB_COMPATIBILITY_HOOKS
46+#endif
47+
48+extern "C" {
49+char **thd_query(MYSQL_THD thd);
50+}
51+
52+static
53+int
54+i_s_innodb_admin_command_fill(
55+/*==========================*/
56+ THD* thd,
57+ TABLE_LIST* tables,
58+ COND* cond)
59+{
60+ TABLE* i_s_table = (TABLE *) tables->table;
61+ char** query_str;
62+ char* ptr;
63+ char quote = '\0';
64+ const char* command_head = "XTRA_";
65+
66+ DBUG_ENTER("i_s_innodb_admin_command_fill");
67+
68+ /* deny access to non-superusers */
69+ if (check_global_access(thd, PROCESS_ACL)) {
70+ DBUG_RETURN(0);
71+ }
72+
73+ if(thd_sql_command(thd) != SQLCOM_SELECT) {
74+ field_store_string(i_s_table->field[0],
75+ "SELECT command is only accepted.");
76+ goto end_func;
77+ }
78+
79+ query_str = thd_query(thd);
80+ ptr = *query_str;
81+
82+ for (; *ptr; ptr++) {
83+ if (*ptr == quote) {
84+ quote = '\0';
85+ } else if (quote) {
86+ } else if (*ptr == '`' || *ptr == '"') {
87+ quote = *ptr;
88+ } else {
89+ long i;
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]))) {
94+ goto nomatch;
95+ }
96+ }
97+ break;
98+nomatch:
99+ ;
100+ }
101+ }
102+
103+ if (!*ptr) {
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.");
107+ goto end_func;
108+ }
109+
110+ if (!strncasecmp("XTRA_HELLO", ptr, 10)) {
111+ /* This is example command XTRA_HELLO */
112+
113+ ut_print_timestamp(stderr);
114+ fprintf(stderr, " InnoDB: administration command test for XtraDB"
115+ " 'XTRA_HELLO' was detected.\n");
116+
117+ field_store_string(i_s_table->field[0],
118+ "Hello!");
119+ goto end_func;
120+ }
121+
122+ field_store_string(i_s_table->field[0],
123+ "Undefined XTRA_* command.");
124+ goto end_func;
125+
126+end_func:
127+ if (schema_table_store_record(thd, i_s_table)) {
128+ DBUG_RETURN(1);
129+ } else {
130+ DBUG_RETURN(0);
131+ }
132+}
133+
134+static
135+int
136+i_s_innodb_admin_command_init(
137+/*==========================*/
138+ void* p)
139+{
140+ DBUG_ENTER("i_s_innodb_admin_command_init");
141+ ST_SCHEMA_TABLE* schema = (ST_SCHEMA_TABLE*) p;
142+
143+ schema->fields_info = i_s_innodb_admin_command_info;
144+ schema->fill_table = i_s_innodb_admin_command_fill;
145+
146+ DBUG_RETURN(0);
147+}
148+
149+UNIV_INTERN struct st_mysql_plugin i_s_innodb_admin_command =
150+{
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)
163+};
164diff -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
167@@ -44,5 +44,6 @@
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;
172
173 #endif /* i_s_h */
This page took 0.963096 seconds and 4 git commands to generate.