~percona-dev/percona-server/release-5.1.49-11

« back to all changes in this revision

Viewing changes to innodb_admin_command_base.patch

  • Committer: kinoyasu
  • Date: 2010-04-30 10:17:55 UTC
  • Revision ID: kinoyasu@gauntlet3-20100430101755-h27x25t4uax76lv4
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc
 
2
--- a/storage/innodb_plugin/handler/ha_innodb.cc        2010-04-30 14:35:00.000000000 +0900
 
3
+++ b/storage/innodb_plugin/handler/ha_innodb.cc        2010-04-30 14:36:22.000000000 +0900
 
4
@@ -11259,6 +11259,7 @@
 
5
 i_s_innodb_cmpmem_reset,
 
6
 i_s_innodb_table_stats,
 
7
 i_s_innodb_index_stats,
 
8
+i_s_innodb_admin_command,
 
9
 i_s_innodb_patches
 
10
 mysql_declare_plugin_end;
 
11
 
 
12
diff -ruN a/storage/innodb_plugin/handler/i_s.cc b/storage/innodb_plugin/handler/i_s.cc
 
13
--- a/storage/innodb_plugin/handler/i_s.cc      2010-04-30 10:49:58.000000000 +0900
 
14
+++ b/storage/innodb_plugin/handler/i_s.cc      2010-04-30 14:36:22.000000000 +0900
 
15
@@ -2997,3 +2997,140 @@
 
16
        STRUCT_FLD(system_vars, NULL),
 
17
        STRUCT_FLD(__reserved1, NULL)
 
18
 };
 
19
+
 
20
+/***********************************************************************
 
21
+*/
 
22
+static ST_FIELD_INFO   i_s_innodb_admin_command_info[] =
 
23
+{
 
24
+       {STRUCT_FLD(field_name,         "result_message"),
 
25
+        STRUCT_FLD(field_length,       1024),
 
26
+        STRUCT_FLD(field_type,         MYSQL_TYPE_STRING),
 
27
+        STRUCT_FLD(value,              0),
 
28
+        STRUCT_FLD(field_flags,        0),
 
29
+        STRUCT_FLD(old_name,           ""),
 
30
+        STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
 
31
+
 
32
+       END_OF_ST_FIELD_INFO
 
33
+};
 
34
+
 
35
+#ifndef INNODB_COMPATIBILITY_HOOKS
 
36
+#error InnoDB needs MySQL to be built with #define INNODB_COMPATIBILITY_HOOKS
 
37
+#endif
 
38
+
 
39
+extern "C" {
 
40
+char **thd_query(MYSQL_THD thd);
 
41
+}
 
42
+
 
43
+static
 
44
+int
 
45
+i_s_innodb_admin_command_fill(
 
46
+/*==========================*/
 
47
+       THD*            thd,
 
48
+       TABLE_LIST*     tables,
 
49
+       COND*           cond)
 
50
+{
 
51
+       TABLE*  i_s_table       = (TABLE *) tables->table;
 
52
+       CHARSET_INFO *cs= system_charset_info;
 
53
+       char**  query_str;
 
54
+       char*   ptr;
 
55
+       char    quote   = '\0';
 
56
+       char*   command_head = "XTRA_";
 
57
+
 
58
+       DBUG_ENTER("i_s_innodb_admin_command_fill");
 
59
+
 
60
+       /* deny access to non-superusers */
 
61
+       if (check_global_access(thd, PROCESS_ACL)) {
 
62
+               DBUG_RETURN(0);
 
63
+       }
 
64
+
 
65
+       if(thd_sql_command(thd) != SQLCOM_SELECT) {
 
66
+               field_store_string(i_s_table->field[0],
 
67
+                       "SELECT command is only accepted.");
 
68
+               goto end_func;
 
69
+       }
 
70
+
 
71
+       query_str = thd_query(thd);
 
72
+       ptr = *query_str;
 
73
+       
 
74
+       for (; *ptr; ptr++) {
 
75
+               if (*ptr == quote) {
 
76
+                       quote = '\0';
 
77
+               } else if (quote) {
 
78
+               } else if (*ptr == '`' || *ptr == '"') {
 
79
+                       quote = *ptr;
 
80
+               } else {
 
81
+                       long    i;
 
82
+                       for (i = 0; command_head[i]; i++) {
 
83
+                               if (toupper((int)(unsigned char)(ptr[i]))
 
84
+                                   != toupper((int)(unsigned char)
 
85
+                                     (command_head[i]))) {
 
86
+                                       goto nomatch;
 
87
+                               }
 
88
+                       }
 
89
+                       break;
 
90
+nomatch:
 
91
+                       ;
 
92
+               }
 
93
+       }
 
94
+
 
95
+       if (!*ptr) {
 
96
+               field_store_string(i_s_table->field[0],
 
97
+                       "No XTRA_* command in the SQL statement."
 
98
+                       " Please add /*!XTRA_xxxx*/ to the SQL.");
 
99
+               goto end_func;
 
100
+       }
 
101
+
 
102
+       if (!strncasecmp("XTRA_HELLO", ptr, 10)) {
 
103
+               /* This is example command XTRA_HELLO */
 
104
+
 
105
+               ut_print_timestamp(stderr);
 
106
+               fprintf(stderr, " InnoDB: administration command test for XtraDB"
 
107
+                               " 'XTRA_HELLO' was detected.\n");
 
108
+
 
109
+               field_store_string(i_s_table->field[0],
 
110
+                       "Hello!");
 
111
+               goto end_func;
 
112
+       }
 
113
+
 
114
+       field_store_string(i_s_table->field[0],
 
115
+               "Undefined XTRA_* command.");
 
116
+       goto end_func;
 
117
+
 
118
+end_func:
 
119
+       if (schema_table_store_record(thd, i_s_table)) {
 
120
+               DBUG_RETURN(1);
 
121
+       } else {
 
122
+               DBUG_RETURN(0);
 
123
+       }
 
124
+}
 
125
+
 
126
+static
 
127
+int
 
128
+i_s_innodb_admin_command_init(
 
129
+/*==========================*/
 
130
+       void*   p)
 
131
+{
 
132
+       DBUG_ENTER("i_s_innodb_admin_command_init");
 
133
+       ST_SCHEMA_TABLE* schema = (ST_SCHEMA_TABLE*) p;
 
134
+
 
135
+       schema->fields_info = i_s_innodb_admin_command_info;
 
136
+       schema->fill_table = i_s_innodb_admin_command_fill;
 
137
+
 
138
+       DBUG_RETURN(0);
 
139
+}
 
140
+
 
141
+UNIV_INTERN struct st_mysql_plugin     i_s_innodb_admin_command =
 
142
+{
 
143
+       STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN),
 
144
+       STRUCT_FLD(info, &i_s_info),
 
145
+       STRUCT_FLD(name, "XTRADB_ADMIN_COMMAND"),
 
146
+       STRUCT_FLD(author, plugin_author),
 
147
+       STRUCT_FLD(descr, "XtraDB specific command acceptor"),
 
148
+       STRUCT_FLD(license, PLUGIN_LICENSE_GPL),
 
149
+       STRUCT_FLD(init, i_s_innodb_admin_command_init),
 
150
+       STRUCT_FLD(deinit, i_s_common_deinit),
 
151
+       STRUCT_FLD(version, 0x0100 /* 1.0 */),
 
152
+       STRUCT_FLD(status_vars, NULL),
 
153
+       STRUCT_FLD(system_vars, NULL),
 
154
+       STRUCT_FLD(__reserved1, NULL)
 
155
+};
 
156
diff -ruN a/storage/innodb_plugin/handler/i_s.h b/storage/innodb_plugin/handler/i_s.h
 
157
--- a/storage/innodb_plugin/handler/i_s.h       2010-04-30 10:49:58.000000000 +0900
 
158
+++ b/storage/innodb_plugin/handler/i_s.h       2010-04-30 14:36:22.000000000 +0900
 
159
@@ -40,5 +40,6 @@
 
160
 extern struct st_mysql_plugin  i_s_innodb_rseg;
 
161
 extern struct st_mysql_plugin  i_s_innodb_table_stats;
 
162
 extern struct st_mysql_plugin  i_s_innodb_index_stats;
 
163
+extern struct st_mysql_plugin  i_s_innodb_admin_command;
 
164
 
 
165
 #endif /* i_s_h */
 
166
diff -ruN a/storage/innodb_plugin/handler/innodb_patch_info.h b/storage/innodb_plugin/handler/innodb_patch_info.h
 
167
--- a/storage/innodb_plugin/handler/innodb_patch_info.h 2010-04-30 14:35:00.000000000 +0900
 
168
+++ b/storage/innodb_plugin/handler/innodb_patch_info.h 2010-04-30 14:36:22.000000000 +0900
 
169
@@ -38,5 +38,6 @@
 
170
 {"innodb_stats","Additional features about InnoDB statistics/optimizer","","http://www.percona.com/docs/wiki/percona-xtradb"},
 
171
 {"innodb_recovery_patches","Bugfixes and adjustments about recovery process","","http://www.percona.com/docs/wiki/percona-xtradb"},
 
172
 {"innodb_purge_thread","Enable to use purge devoted thread","","http://www.percona.com/docs/wiki/percona-xtradb"},
 
173
+{"innodb_admin_command_base","XtraDB specific command interface through i_s","","http://www.percona.com/docs/wiki/percona-xtradb"},
 
174
 {NULL, NULL, NULL, NULL}
 
175
 };