]> git.pld-linux.org Git - packages/mysql.git/blame - innodb_show_sys_tables.patch
- rel 2; update percona patches
[packages/mysql.git] / innodb_show_sys_tables.patch
CommitLineData
b4e1fa2c
AM
1# name : innodb_show_sys_tables.patch
2# introduced : 13?
3# maintainer : Yasufumi
4# (It is revived from mysql-5.5.6-rc)
5#!!! notice !!!
6# Any small change to this file in the main branch
7# should be done or reviewed by the maintainer!
d8778560
AM
8diff -ruN a/storage/innobase/dict/dict0load.c b/storage/innobase/dict/dict0load.c
9--- a/storage/innobase/dict/dict0load.c 2011-01-20 07:37:08.000000000 +0900
10+++ b/storage/innobase/dict/dict0load.c 2011-02-14 18:59:40.774162959 +0900
11@@ -437,7 +437,7 @@
12
13 }
14
15-#ifdef FOREIGN_NOT_USED
16+//#ifdef FOREIGN_NOT_USED
17 /********************************************************************//**
18 This function parses a SYS_FOREIGN record and populate a dict_foreign_t
19 structure with the information from the record. For detail information
20@@ -513,9 +513,9 @@
21
22 return(NULL);
23 }
24-#endif /* FOREIGN_NOT_USED */
25+//#endif /* FOREIGN_NOT_USED */
26
27-#ifdef FOREIGN_NOT_USED
28+//#ifdef FOREIGN_NOT_USED
29 /********************************************************************//**
30 This function parses a SYS_FOREIGN_COLS record and extract necessary
31 information from the record and return to caller.
32@@ -579,7 +579,7 @@
33
34 return(NULL);
35 }
36-#endif /* FOREIGN_NOT_USED */
37+//#endif /* FOREIGN_NOT_USED */
38
39 /********************************************************************//**
40 Determine the flags of a table described in SYS_TABLES.
b4e1fa2c
AM
41diff -ruN a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
42--- a/storage/innobase/handler/ha_innodb.cc 2010-12-03 15:53:54.615040167 +0900
43+++ b/storage/innobase/handler/ha_innodb.cc 2010-12-03 16:07:26.851357007 +0900
adf0fb13 44@@ -11772,7 +11772,14 @@
b4e1fa2c
AM
45 i_s_innodb_cmp,
46 i_s_innodb_cmp_reset,
47 i_s_innodb_cmpmem,
48-i_s_innodb_cmpmem_reset
49+i_s_innodb_cmpmem_reset,
50+i_s_innodb_sys_tables,
51+i_s_innodb_sys_tablestats,
52+i_s_innodb_sys_indexes,
53+i_s_innodb_sys_columns,
54+i_s_innodb_sys_fields,
55+i_s_innodb_sys_foreign,
56+i_s_innodb_sys_foreign_cols
57 mysql_declare_plugin_end;
58
59 /** @brief Initialize the default value of innodb_commit_concurrency.
60diff -ruN a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc
61--- a/storage/innobase/handler/i_s.cc 2010-12-03 15:49:59.207956807 +0900
62+++ b/storage/innobase/handler/i_s.cc 2010-12-03 17:10:02.719210529 +0900
63@@ -36,9 +36,11 @@
64 #include <mysql/innodb_priv.h>
65
66 extern "C" {
67+#include "btr0pcur.h" /* for file sys_tables related info. */
68 #include "btr0types.h"
69 #include "buf0buddy.h" /* for i_s_cmpmem */
70 #include "buf0buf.h" /* for buf_pool and PAGE_ZIP_MIN_SIZE */
71+#include "dict0load.h" /* for file sys_tables related info. */
72 #include "dict0mem.h"
73 #include "dict0types.h"
74 #include "ha_prototypes.h" /* for innobase_convert_name() */
adf0fb13 75@@ -1784,6 +1786,1675 @@
b4e1fa2c
AM
76 DBUG_RETURN(0);
77 }
78
79+/* Fields of the dynamic table INFORMATION_SCHEMA.SYS_TABLES */
80+static ST_FIELD_INFO innodb_sys_tables_fields_info[] =
81+{
82+#define SYS_TABLE_ID 0
83+ {STRUCT_FLD(field_name, "TABLE_ID"),
84+ STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
85+ STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
86+ STRUCT_FLD(value, 0),
87+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
88+ STRUCT_FLD(old_name, ""),
89+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
90+
91+#define SYS_TABLE_SCHEMA 1
92+ {STRUCT_FLD(field_name, "SCHEMA"),
93+ STRUCT_FLD(field_length, NAME_LEN + 1),
94+ STRUCT_FLD(field_type, MYSQL_TYPE_STRING),
95+ STRUCT_FLD(value, 0),
96+ STRUCT_FLD(field_flags, 0),
97+ STRUCT_FLD(old_name, ""),
98+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
99+
100+#define SYS_TABLE_NAME 2
101+ {STRUCT_FLD(field_name, "NAME"),
102+ STRUCT_FLD(field_length, NAME_LEN + 1),
103+ STRUCT_FLD(field_type, MYSQL_TYPE_STRING),
104+ STRUCT_FLD(value, 0),
105+ STRUCT_FLD(field_flags, 0),
106+ STRUCT_FLD(old_name, ""),
107+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
108+
109+#define SYS_TABLE_FLAG 3
110+ {STRUCT_FLD(field_name, "FLAG"),
111+ STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS),
112+ STRUCT_FLD(field_type, MYSQL_TYPE_LONG),
113+ STRUCT_FLD(value, 0),
114+ STRUCT_FLD(field_flags, 0),
115+ STRUCT_FLD(old_name, ""),
116+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
117+
118+#define SYS_TABLE_NUM_COLUMN 4
119+ {STRUCT_FLD(field_name, "N_COLS"),
120+ STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS),
121+ STRUCT_FLD(field_type, MYSQL_TYPE_LONG),
122+ STRUCT_FLD(value, 0),
123+ STRUCT_FLD(field_flags, 0),
124+ STRUCT_FLD(old_name, ""),
125+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
126+
127+#define SYS_TABLE_SPACE 5
128+ {STRUCT_FLD(field_name, "SPACE"),
129+ STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS),
130+ STRUCT_FLD(field_type, MYSQL_TYPE_LONG),
131+ STRUCT_FLD(value, 0),
132+ STRUCT_FLD(field_flags, 0),
133+ STRUCT_FLD(old_name, ""),
134+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
135+
136+ END_OF_ST_FIELD_INFO
137+};
138+
139+/**********************************************************************//**
140+Populate information_schema.innodb_sys_tables table with information
141+from SYS_TABLES.
142+@return 0 on success */
143+static
144+int
145+i_s_dict_fill_sys_tables(
146+/*=====================*/
147+ THD* thd, /*!< in: thread */
148+ dict_table_t* table, /*!< in: table */
149+ TABLE* table_to_fill) /*!< in/out: fill this table */
150+{
151+ Field** fields;
152+ char buf[NAME_LEN * 2 + 2];
153+ char* ptr;
154+
155+ DBUG_ENTER("i_s_dict_fill_sys_tables");
156+
157+ fields = table_to_fill->field;
158+
159+ OK(fields[SYS_TABLE_ID]->store(longlong(table->id), TRUE));
160+
161+ strncpy(buf, table->name, NAME_LEN * 2 + 2);
162+ ptr = strchr(buf, '/');
163+ if (ptr) {
164+ *ptr = '\0';
165+ ++ptr;
166+
167+ OK(field_store_string(fields[SYS_TABLE_SCHEMA], buf));
168+ OK(field_store_string(fields[SYS_TABLE_NAME], ptr));
169+ } else {
170+ fields[SYS_TABLE_SCHEMA]->set_null();
171+ OK(field_store_string(fields[SYS_TABLE_NAME], buf));
172+ }
173+
174+ OK(fields[SYS_TABLE_FLAG]->store(table->flags));
175+
176+ OK(fields[SYS_TABLE_NUM_COLUMN]->store(table->n_cols));
177+
178+ OK(fields[SYS_TABLE_SPACE]->store(table->space));
179+
180+ OK(schema_table_store_record(thd, table_to_fill));
181+
182+ DBUG_RETURN(0);
183+}
184+/*******************************************************************//**
185+Function to go through each record in SYS_TABLES table, and fill the
186+information_schema.innodb_sys_tables table with related table information
187+@return 0 on success */
188+static
189+int
190+i_s_sys_tables_fill_table(
191+/*======================*/
192+ THD* thd, /*!< in: thread */
193+ TABLE_LIST* tables, /*!< in/out: tables to fill */
194+ COND* cond) /*!< in: condition (not used) */
195+{
196+ btr_pcur_t pcur;
197+ const rec_t* rec;
198+ mem_heap_t* heap;
199+ mtr_t mtr;
200+
201+ DBUG_ENTER("i_s_sys_tables_fill_table");
202+
203+ /* deny access to non-superusers */
204+ if (check_global_access(thd, PROCESS_ACL)) {
205+
206+ DBUG_RETURN(0);
207+ }
208+
209+ heap = mem_heap_create(1000);
210+ mutex_enter(&(dict_sys->mutex));
211+ mtr_start(&mtr);
212+
213+ rec = dict_startscan_system(&pcur, &mtr, SYS_TABLES);
214+
215+ while (rec) {
216+ const char* err_msg;
217+ dict_table_t* table_rec;
218+
219+ /* Create and populate a dict_table_t structure with
220+ information from SYS_TABLES row */
221+ err_msg = dict_process_sys_tables_rec(
222+ heap, rec, &table_rec, DICT_TABLE_LOAD_FROM_RECORD);
223+
224+ mtr_commit(&mtr);
225+ mutex_exit(&dict_sys->mutex);
226+
227+ if (!err_msg) {
228+ i_s_dict_fill_sys_tables(thd, table_rec, tables->table);
229+ } else {
230+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
231+ ER_CANT_FIND_SYSTEM_REC,
232+ err_msg);
233+ }
234+
235+ /* Since dict_process_sys_tables_rec() is called with
236+ DICT_TABLE_LOAD_FROM_RECORD, the table_rec is created in
237+ dict_process_sys_tables_rec(), we will need to free it */
238+ if (table_rec) {
239+ dict_mem_table_free(table_rec);
240+ }
241+
242+ mem_heap_empty(heap);
243+
244+ /* Get the next record */
245+ mutex_enter(&dict_sys->mutex);
246+ mtr_start(&mtr);
247+ rec = dict_getnext_system(&pcur, &mtr);
248+ }
249+
250+ mtr_commit(&mtr);
251+ mutex_exit(&dict_sys->mutex);
252+ mem_heap_free(heap);
253+
254+ DBUG_RETURN(0);
255+}
256+
257+/*******************************************************************//**
258+Bind the dynamic table INFORMATION_SCHEMA.innodb_sys_tables
259+@return 0 on success */
260+static
261+int
262+innodb_sys_tables_init(
263+/*===================*/
264+ void* p) /*!< in/out: table schema object */
265+{
266+ ST_SCHEMA_TABLE* schema;
267+
268+ DBUG_ENTER("innodb_sys_tables_init");
269+
270+ schema = (ST_SCHEMA_TABLE*) p;
271+
272+ schema->fields_info = innodb_sys_tables_fields_info;
273+ schema->fill_table = i_s_sys_tables_fill_table;
274+
275+ DBUG_RETURN(0);
276+}
277+
278+UNIV_INTERN struct st_mysql_plugin i_s_innodb_sys_tables =
279+{
280+ /* the plugin type (a MYSQL_XXX_PLUGIN value) */
281+ /* int */
282+ STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN),
283+
284+ /* pointer to type-specific plugin descriptor */
285+ /* void* */
286+ STRUCT_FLD(info, &i_s_info),
287+
288+ /* plugin name */
289+ /* const char* */
290+ STRUCT_FLD(name, "INNODB_SYS_TABLES"),
291+
292+ /* plugin author (for SHOW PLUGINS) */
293+ /* const char* */
adf0fb13 294+ STRUCT_FLD(author, "Percona"),
b4e1fa2c
AM
295+
296+ /* general descriptive text (for SHOW PLUGINS) */
297+ /* const char* */
298+ STRUCT_FLD(descr, "InnoDB SYS_TABLES"),
299+
300+ /* the plugin license (PLUGIN_LICENSE_XXX) */
301+ /* int */
302+ STRUCT_FLD(license, PLUGIN_LICENSE_GPL),
303+
304+ /* the function to invoke when plugin is loaded */
305+ /* int (*)(void*); */
306+ STRUCT_FLD(init, innodb_sys_tables_init),
307+
308+ /* the function to invoke when plugin is unloaded */
309+ /* int (*)(void*); */
310+ STRUCT_FLD(deinit, i_s_common_deinit),
311+
312+ /* plugin version (for SHOW PLUGINS) */
313+ /* unsigned int */
314+ STRUCT_FLD(version, INNODB_VERSION_SHORT),
315+
316+ /* struct st_mysql_show_var* */
317+ STRUCT_FLD(status_vars, NULL),
318+
319+ /* struct st_mysql_sys_var** */
320+ STRUCT_FLD(system_vars, NULL),
321+
322+ /* reserved for dependency checking */
323+ /* void* */
324+ STRUCT_FLD(__reserved1, NULL)
325+};
326+
327+/* Fields of the dynamic table INFORMATION_SCHEMA.SYS_TABLESTATS */
328+static ST_FIELD_INFO innodb_sys_tablestats_fields_info[] =
329+{
330+#define SYS_TABLESTATS_ID 0
331+ {STRUCT_FLD(field_name, "TABLE_ID"),
332+ STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
333+ STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
334+ STRUCT_FLD(value, 0),
335+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
336+ STRUCT_FLD(old_name, ""),
337+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
338+
339+#define SYS_TABLESTATS_SCHEMA 1
340+ {STRUCT_FLD(field_name, "SCHEMA"),
341+ STRUCT_FLD(field_length, NAME_LEN + 1),
342+ STRUCT_FLD(field_type, MYSQL_TYPE_STRING),
343+ STRUCT_FLD(value, 0),
344+ STRUCT_FLD(field_flags, 0),
345+ STRUCT_FLD(old_name, ""),
346+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
347+
348+#define SYS_TABLESTATS_NAME 2
349+ {STRUCT_FLD(field_name, "NAME"),
350+ STRUCT_FLD(field_length, NAME_LEN + 1),
351+ STRUCT_FLD(field_type, MYSQL_TYPE_STRING),
352+ STRUCT_FLD(value, 0),
353+ STRUCT_FLD(field_flags, 0),
354+ STRUCT_FLD(old_name, ""),
355+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
356+
357+#define SYS_TABLESTATS_INIT 3
358+ {STRUCT_FLD(field_name, "STATS_INITIALIZED"),
359+ STRUCT_FLD(field_length, NAME_LEN + 1),
360+ STRUCT_FLD(field_type, MYSQL_TYPE_STRING),
361+ STRUCT_FLD(value, 0),
362+ STRUCT_FLD(field_flags, 0),
363+ STRUCT_FLD(old_name, ""),
364+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
365+
366+#define SYS_TABLESTATS_NROW 4
367+ {STRUCT_FLD(field_name, "NUM_ROWS"),
368+ STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
369+ STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
370+ STRUCT_FLD(value, 0),
371+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
372+ STRUCT_FLD(old_name, ""),
373+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
374+
375+#define SYS_TABLESTATS_CLUST_SIZE 5
376+ {STRUCT_FLD(field_name, "CLUST_INDEX_SIZE"),
377+ STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
378+ STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
379+ STRUCT_FLD(value, 0),
380+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
381+ STRUCT_FLD(old_name, ""),
382+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
383+
384+#define SYS_TABLESTATS_INDEX_SIZE 6
385+ {STRUCT_FLD(field_name, "OTHER_INDEX_SIZE"),
386+ STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
387+ STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
388+ STRUCT_FLD(value, 0),
389+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
390+ STRUCT_FLD(old_name, ""),
391+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
392+
393+#define SYS_TABLESTATS_MODIFIED 7
394+ {STRUCT_FLD(field_name, "MODIFIED_COUNTER"),
395+ STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
396+ STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
397+ STRUCT_FLD(value, 0),
398+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
399+ STRUCT_FLD(old_name, ""),
400+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
401+
402+#define SYS_TABLESTATS_AUTONINC 8
403+ {STRUCT_FLD(field_name, "AUTOINC"),
404+ STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
405+ STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
406+ STRUCT_FLD(value, 0),
407+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
408+ STRUCT_FLD(old_name, ""),
409+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
410+
411+#define SYS_TABLESTATS_MYSQL_OPEN_HANDLE 9
412+ {STRUCT_FLD(field_name, "MYSQL_HANDLES_OPENED"),
413+ STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS),
414+ STRUCT_FLD(field_type, MYSQL_TYPE_LONG),
415+ STRUCT_FLD(value, 0),
416+ STRUCT_FLD(field_flags, 0),
417+ STRUCT_FLD(old_name, ""),
418+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
419+
420+ END_OF_ST_FIELD_INFO
421+};
422+
423+/**********************************************************************//**
424+Populate information_schema.innodb_sys_tablestats table with information
425+from SYS_TABLES.
426+@return 0 on success */
427+static
428+int
429+i_s_dict_fill_sys_tablestats(
430+/*=========================*/
431+ THD* thd, /*!< in: thread */
432+ dict_table_t* table, /*!< in: table */
433+ TABLE* table_to_fill) /*!< in/out: fill this table */
434+{
435+ Field** fields;
436+ char buf[NAME_LEN * 2 + 2];
437+ char* ptr;
438+
439+ DBUG_ENTER("i_s_dict_fill_sys_tablestats");
440+
441+ fields = table_to_fill->field;
442+
443+ OK(fields[SYS_TABLESTATS_ID]->store(longlong(table->id), TRUE));
444+
445+ strncpy(buf, table->name, NAME_LEN * 2 + 2);
446+ ptr = strchr(buf, '/');
447+ if (ptr) {
448+ *ptr = '\0';
449+ ++ptr;
450+
451+ OK(field_store_string(fields[SYS_TABLESTATS_SCHEMA], buf));
452+ OK(field_store_string(fields[SYS_TABLESTATS_NAME], ptr));
453+ } else {
454+ fields[SYS_TABLESTATS_SCHEMA]->set_null();
455+ OK(field_store_string(fields[SYS_TABLESTATS_NAME], buf));
456+ }
457+
458+ if (table->stat_initialized) {
459+ OK(field_store_string(fields[SYS_TABLESTATS_INIT],
460+ "Initialized"));
461+ } else {
462+ OK(field_store_string(fields[SYS_TABLESTATS_INIT],
463+ "Uninitialized"));
464+ }
465+
466+ OK(fields[SYS_TABLESTATS_NROW]->store(table->stat_n_rows, TRUE));
467+
468+ OK(fields[SYS_TABLESTATS_CLUST_SIZE]->store(
469+ table->stat_clustered_index_size));
470+
471+ OK(fields[SYS_TABLESTATS_INDEX_SIZE]->store(
472+ table->stat_sum_of_other_index_sizes));
473+
474+ OK(fields[SYS_TABLESTATS_MODIFIED]->store(
475+ table->stat_modified_counter));
476+
477+ OK(fields[SYS_TABLESTATS_AUTONINC]->store(table->autoinc, TRUE));
478+
479+ OK(fields[SYS_TABLESTATS_MYSQL_OPEN_HANDLE]->store(
480+ table->n_mysql_handles_opened));
481+
482+ OK(schema_table_store_record(thd, table_to_fill));
483+
484+ DBUG_RETURN(0);
485+}
486+/*******************************************************************//**
487+Function to go through each record in SYS_TABLES table, and fill the
488+information_schema.innodb_sys_tablestats table with table statistics
489+related information
490+@return 0 on success */
491+static
492+int
493+i_s_sys_tables_fill_table_stats(
494+/*============================*/
495+ THD* thd, /*!< in: thread */
496+ TABLE_LIST* tables, /*!< in/out: tables to fill */
497+ COND* cond) /*!< in: condition (not used) */
498+{
499+ btr_pcur_t pcur;
500+ const rec_t* rec;
501+ mem_heap_t* heap;
502+ mtr_t mtr;
503+
504+ DBUG_ENTER("i_s_sys_tables_fill_table_stats");
505+
506+ /* deny access to non-superusers */
507+ if (check_global_access(thd, PROCESS_ACL)) {
508+
509+ DBUG_RETURN(0);
510+ }
511+
512+ heap = mem_heap_create(1000);
513+ mutex_enter(&dict_sys->mutex);
514+ mtr_start(&mtr);
515+
516+ rec = dict_startscan_system(&pcur, &mtr, SYS_TABLES);
517+
518+ while (rec) {
519+ const char* err_msg;
520+ dict_table_t* table_rec;
521+
522+ /* Fetch the dict_table_t structure corresponding to
523+ this SYS_TABLES record */
524+ err_msg = dict_process_sys_tables_rec(
525+ heap, rec, &table_rec, DICT_TABLE_LOAD_FROM_CACHE);
526+
527+ mtr_commit(&mtr);
528+ mutex_exit(&dict_sys->mutex);
529+
530+ if (!err_msg) {
531+ i_s_dict_fill_sys_tablestats(thd, table_rec,
532+ tables->table);
533+ } else {
534+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
535+ ER_CANT_FIND_SYSTEM_REC,
536+ err_msg);
537+ }
538+
539+ mem_heap_empty(heap);
540+
541+ /* Get the next record */
542+ mutex_enter(&dict_sys->mutex);
543+ mtr_start(&mtr);
544+ rec = dict_getnext_system(&pcur, &mtr);
545+ }
546+
547+ mtr_commit(&mtr);
548+ mutex_exit(&dict_sys->mutex);
549+ mem_heap_free(heap);
550+
551+ DBUG_RETURN(0);
552+}
553+
554+/*******************************************************************//**
555+Bind the dynamic table INFORMATION_SCHEMA.innodb_sys_tablestats
556+@return 0 on success */
557+static
558+int
559+innodb_sys_tablestats_init(
560+/*=======================*/
561+ void* p) /*!< in/out: table schema object */
562+{
563+ ST_SCHEMA_TABLE* schema;
564+
565+ DBUG_ENTER("innodb_sys_tablestats_init");
566+
567+ schema = (ST_SCHEMA_TABLE*) p;
568+
569+ schema->fields_info = innodb_sys_tablestats_fields_info;
570+ schema->fill_table = i_s_sys_tables_fill_table_stats;
571+
572+ DBUG_RETURN(0);
573+}
574+
575+UNIV_INTERN struct st_mysql_plugin i_s_innodb_sys_tablestats =
576+{
577+ /* the plugin type (a MYSQL_XXX_PLUGIN value) */
578+ /* int */
579+ STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN),
580+
581+ /* pointer to type-specific plugin descriptor */
582+ /* void* */
583+ STRUCT_FLD(info, &i_s_info),
584+
585+ /* plugin name */
586+ /* const char* */
587+ STRUCT_FLD(name, "INNODB_SYS_TABLESTATS"),
588+
589+ /* plugin author (for SHOW PLUGINS) */
590+ /* const char* */
adf0fb13 591+ STRUCT_FLD(author, "Percona"),
b4e1fa2c
AM
592+
593+ /* general descriptive text (for SHOW PLUGINS) */
594+ /* const char* */
595+ STRUCT_FLD(descr, "InnoDB SYS_TABLESTATS"),
596+
597+ /* the plugin license (PLUGIN_LICENSE_XXX) */
598+ /* int */
599+ STRUCT_FLD(license, PLUGIN_LICENSE_GPL),
600+
601+ /* the function to invoke when plugin is loaded */
602+ /* int (*)(void*); */
603+ STRUCT_FLD(init, innodb_sys_tablestats_init),
604+
605+ /* the function to invoke when plugin is unloaded */
606+ /* int (*)(void*); */
607+ STRUCT_FLD(deinit, i_s_common_deinit),
608+
609+ /* plugin version (for SHOW PLUGINS) */
610+ /* unsigned int */
611+ STRUCT_FLD(version, INNODB_VERSION_SHORT),
612+
613+ /* struct st_mysql_show_var* */
614+ STRUCT_FLD(status_vars, NULL),
615+
616+ /* struct st_mysql_sys_var** */
617+ STRUCT_FLD(system_vars, NULL),
618+
619+ /* reserved for dependency checking */
620+ /* void* */
621+ STRUCT_FLD(__reserved1, NULL)
622+};
623+
624+/* Fields of the dynamic table INFORMATION_SCHEMA.SYS_INDEXES */
625+static ST_FIELD_INFO innodb_sysindex_fields_info[] =
626+{
627+#define SYS_INDEX_ID 0
628+ {STRUCT_FLD(field_name, "INDEX_ID"),
629+ STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
630+ STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
631+ STRUCT_FLD(value, 0),
632+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
633+ STRUCT_FLD(old_name, ""),
634+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
635+
636+#define SYS_INDEX_NAME 1
637+ {STRUCT_FLD(field_name, "NAME"),
638+ STRUCT_FLD(field_length, NAME_LEN + 1),
639+ STRUCT_FLD(field_type, MYSQL_TYPE_STRING),
640+ STRUCT_FLD(value, 0),
641+ STRUCT_FLD(field_flags, 0),
642+ STRUCT_FLD(old_name, ""),
643+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
644+
645+#define SYS_INDEX_TABLE_ID 2
646+ {STRUCT_FLD(field_name, "TABLE_ID"),
647+ STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
648+ STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
649+ STRUCT_FLD(value, 0),
650+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
651+ STRUCT_FLD(old_name, ""),
652+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
653+
654+#define SYS_INDEX_TYPE 3
655+ {STRUCT_FLD(field_name, "TYPE"),
656+ STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS),
657+ STRUCT_FLD(field_type, MYSQL_TYPE_LONG),
658+ STRUCT_FLD(value, 0),
659+ STRUCT_FLD(field_flags, 0),
660+ STRUCT_FLD(old_name, ""),
661+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
662+
663+#define SYS_INDEX_NUM_FIELDS 4
664+ {STRUCT_FLD(field_name, "N_FIELDS"),
665+ STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS),
666+ STRUCT_FLD(field_type, MYSQL_TYPE_LONG),
667+ STRUCT_FLD(value, 0),
668+ STRUCT_FLD(field_flags, 0),
669+ STRUCT_FLD(old_name, ""),
670+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
671+
672+#define SYS_INDEX_PAGE_NO 5
673+ {STRUCT_FLD(field_name, "PAGE_NO"),
674+ STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS),
675+ STRUCT_FLD(field_type, MYSQL_TYPE_LONG),
676+ STRUCT_FLD(value, 0),
677+ STRUCT_FLD(field_flags, 0),
678+ STRUCT_FLD(old_name, ""),
679+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
680+
681+#define SYS_INDEX_SPACE 6
682+ {STRUCT_FLD(field_name, "SPACE"),
683+ STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS),
684+ STRUCT_FLD(field_type, MYSQL_TYPE_LONG),
685+ STRUCT_FLD(value, 0),
686+ STRUCT_FLD(field_flags, 0),
687+ STRUCT_FLD(old_name, ""),
688+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
689+
690+ END_OF_ST_FIELD_INFO
691+};
692+
693+/**********************************************************************//**
694+Function to populate the information_schema.innodb_sys_indexes table with
695+collected index information
696+@return 0 on success */
697+static
698+int
699+i_s_dict_fill_sys_indexes(
700+/*======================*/
701+ THD* thd, /*!< in: thread */
702+ table_id_t table_id, /*!< in: table id */
703+ dict_index_t* index, /*!< in: populated dict_index_t
704+ struct with index info */
705+ TABLE* table_to_fill) /*!< in/out: fill this table */
706+{
707+ Field** fields;
708+
709+ DBUG_ENTER("i_s_dict_fill_sys_indexes");
710+
711+ fields = table_to_fill->field;
712+
713+ OK(fields[SYS_INDEX_ID]->store(longlong(index->id), TRUE));
714+
715+ OK(field_store_string(fields[SYS_INDEX_NAME], index->name));
716+
717+ OK(fields[SYS_INDEX_TABLE_ID]->store(longlong(table_id), TRUE));
718+
719+ OK(fields[SYS_INDEX_TYPE]->store(index->type));
720+
721+ OK(fields[SYS_INDEX_NUM_FIELDS]->store(index->n_fields));
722+
723+ OK(fields[SYS_INDEX_PAGE_NO]->store(index->page));
724+
725+ OK(fields[SYS_INDEX_SPACE]->store(index->space));
726+
727+ OK(schema_table_store_record(thd, table_to_fill));
728+
729+ DBUG_RETURN(0);
730+}
731+/*******************************************************************//**
732+Function to go through each record in SYS_INDEXES table, and fill the
733+information_schema.innodb_sys_indexes table with related index information
734+@return 0 on success */
735+static
736+int
737+i_s_sys_indexes_fill_table(
738+/*=======================*/
739+ THD* thd, /*!< in: thread */
740+ TABLE_LIST* tables, /*!< in/out: tables to fill */
741+ COND* cond) /*!< in: condition (not used) */
742+{
743+ btr_pcur_t pcur;
744+ const rec_t* rec;
745+ mem_heap_t* heap;
746+ mtr_t mtr;
747+
748+ DBUG_ENTER("i_s_sys_indexes_fill_table");
749+
750+ /* deny access to non-superusers */
751+ if (check_global_access(thd, PROCESS_ACL)) {
752+
753+ DBUG_RETURN(0);
754+ }
755+
756+ heap = mem_heap_create(1000);
757+ mutex_enter(&dict_sys->mutex);
758+ mtr_start(&mtr);
759+
760+ /* Start scan the SYS_INDEXES table */
761+ rec = dict_startscan_system(&pcur, &mtr, SYS_INDEXES);
762+
763+ /* Process each record in the table */
764+ while (rec) {
765+ const char* err_msg;;
766+ table_id_t table_id;
767+ dict_index_t index_rec;
768+
769+ /* Populate a dict_index_t structure with information from
770+ a SYS_INDEXES row */
771+ err_msg = dict_process_sys_indexes_rec(heap, rec, &index_rec,
772+ &table_id);
773+
774+ mtr_commit(&mtr);
775+ mutex_exit(&dict_sys->mutex);
776+
777+ if (!err_msg) {
778+ i_s_dict_fill_sys_indexes(thd, table_id, &index_rec,
779+ tables->table);
780+ } else {
781+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
782+ ER_CANT_FIND_SYSTEM_REC,
783+ err_msg);
784+ }
785+
786+ mem_heap_empty(heap);
787+
788+ /* Get the next record */
789+ mutex_enter(&dict_sys->mutex);
790+ mtr_start(&mtr);
791+ rec = dict_getnext_system(&pcur, &mtr);
792+ }
793+
794+ mtr_commit(&mtr);
795+ mutex_exit(&dict_sys->mutex);
796+ mem_heap_free(heap);
797+
798+ DBUG_RETURN(0);
799+}
800+/*******************************************************************//**
801+Bind the dynamic table INFORMATION_SCHEMA.innodb_sys_indexes
802+@return 0 on success */
803+static
804+int
805+innodb_sys_indexes_init(
806+/*====================*/
807+ void* p) /*!< in/out: table schema object */
808+{
809+ ST_SCHEMA_TABLE* schema;
810+
811+ DBUG_ENTER("innodb_sys_index_init");
812+
813+ schema = (ST_SCHEMA_TABLE*) p;
814+
815+ schema->fields_info = innodb_sysindex_fields_info;
816+ schema->fill_table = i_s_sys_indexes_fill_table;
817+
818+ DBUG_RETURN(0);
819+}
820+
821+UNIV_INTERN struct st_mysql_plugin i_s_innodb_sys_indexes =
822+{
823+ /* the plugin type (a MYSQL_XXX_PLUGIN value) */
824+ /* int */
825+ STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN),
826+
827+ /* pointer to type-specific plugin descriptor */
828+ /* void* */
829+ STRUCT_FLD(info, &i_s_info),
830+
831+ /* plugin name */
832+ /* const char* */
833+ STRUCT_FLD(name, "INNODB_SYS_INDEXES"),
834+
835+ /* plugin author (for SHOW PLUGINS) */
836+ /* const char* */
adf0fb13 837+ STRUCT_FLD(author, "Percona"),
b4e1fa2c
AM
838+
839+ /* general descriptive text (for SHOW PLUGINS) */
840+ /* const char* */
841+ STRUCT_FLD(descr, "InnoDB SYS_INDEXES"),
842+
843+ /* the plugin license (PLUGIN_LICENSE_XXX) */
844+ /* int */
845+ STRUCT_FLD(license, PLUGIN_LICENSE_GPL),
846+
847+ /* the function to invoke when plugin is loaded */
848+ /* int (*)(void*); */
849+ STRUCT_FLD(init, innodb_sys_indexes_init),
850+
851+ /* the function to invoke when plugin is unloaded */
852+ /* int (*)(void*); */
853+ STRUCT_FLD(deinit, i_s_common_deinit),
854+
855+ /* plugin version (for SHOW PLUGINS) */
856+ /* unsigned int */
857+ STRUCT_FLD(version, INNODB_VERSION_SHORT),
858+
859+ /* struct st_mysql_show_var* */
860+ STRUCT_FLD(status_vars, NULL),
861+
862+ /* struct st_mysql_sys_var** */
863+ STRUCT_FLD(system_vars, NULL),
864+
865+ /* reserved for dependency checking */
866+ /* void* */
867+ STRUCT_FLD(__reserved1, NULL)
868+};
869+
870+/* Fields of the dynamic table INFORMATION_SCHEMA.SYS_COLUMNS */
871+static ST_FIELD_INFO innodb_sys_columns_fields_info[] =
872+{
873+#define SYS_COLUMN_TABLE_ID 0
874+ {STRUCT_FLD(field_name, "TABLE_ID"),
875+ STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
876+ STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
877+ STRUCT_FLD(value, 0),
878+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
879+ STRUCT_FLD(old_name, ""),
880+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
881+
882+#define SYS_COLUMN_NAME 1
883+ {STRUCT_FLD(field_name, "NAME"),
884+ STRUCT_FLD(field_length, NAME_LEN + 1),
885+ STRUCT_FLD(field_type, MYSQL_TYPE_STRING),
886+ STRUCT_FLD(value, 0),
887+ STRUCT_FLD(field_flags, 0),
888+ STRUCT_FLD(old_name, ""),
889+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
890+
891+#define SYS_COLUMN_POSITION 2
892+ {STRUCT_FLD(field_name, "POS"),
893+ STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
894+ STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
895+ STRUCT_FLD(value, 0),
896+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
897+ STRUCT_FLD(old_name, ""),
898+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
899+
900+#define SYS_COLUMN_MTYPE 3
901+ {STRUCT_FLD(field_name, "MTYPE"),
902+ STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS),
903+ STRUCT_FLD(field_type, MYSQL_TYPE_LONG),
904+ STRUCT_FLD(value, 0),
905+ STRUCT_FLD(field_flags, 0),
906+ STRUCT_FLD(old_name, ""),
907+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
908+
909+#define SYS_COLUMN__PRTYPE 4
910+ {STRUCT_FLD(field_name, "PRTYPE"),
911+ STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS),
912+ STRUCT_FLD(field_type, MYSQL_TYPE_LONG),
913+ STRUCT_FLD(value, 0),
914+ STRUCT_FLD(field_flags, 0),
915+ STRUCT_FLD(old_name, ""),
916+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
917+
918+#define SYS_COLUMN_COLUMN_LEN 5
919+ {STRUCT_FLD(field_name, "LEN"),
920+ STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS),
921+ STRUCT_FLD(field_type, MYSQL_TYPE_LONG),
922+ STRUCT_FLD(value, 0),
923+ STRUCT_FLD(field_flags, 0),
924+ STRUCT_FLD(old_name, ""),
925+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
926+
927+ END_OF_ST_FIELD_INFO
928+};
929+
930+/**********************************************************************//**
931+Function to populate the information_schema.innodb_sys_columns with
932+related column information
933+@return 0 on success */
934+static
935+int
936+i_s_dict_fill_sys_columns(
937+/*======================*/
938+ THD* thd, /*!< in: thread */
939+ table_id_t table_id, /*!< in: table ID */
940+ const char* col_name, /*!< in: column name */
941+ dict_col_t* column, /*!< in: dict_col_t struct holding
942+ more column information */
943+ TABLE* table_to_fill) /*!< in/out: fill this table */
944+{
945+ Field** fields;
946+
947+ DBUG_ENTER("i_s_dict_fill_sys_columns");
948+
949+ fields = table_to_fill->field;
950+
951+ OK(fields[SYS_COLUMN_TABLE_ID]->store(longlong(table_id), TRUE));
952+
953+ OK(field_store_string(fields[SYS_COLUMN_NAME], col_name));
954+
955+ OK(fields[SYS_COLUMN_POSITION]->store(column->ind));
956+
957+ OK(fields[SYS_COLUMN_MTYPE]->store(column->mtype));
958+
959+ OK(fields[SYS_COLUMN__PRTYPE]->store(column->prtype));
960+
961+ OK(fields[SYS_COLUMN_COLUMN_LEN]->store(column->len));
962+
963+ OK(schema_table_store_record(thd, table_to_fill));
964+
965+ DBUG_RETURN(0);
966+}
967+/*******************************************************************//**
968+Function to fill information_schema.innodb_sys_columns with information
969+collected by scanning SYS_COLUMNS table.
970+@return 0 on success */
971+static
972+int
973+i_s_sys_columns_fill_table(
974+/*=======================*/
975+ THD* thd, /*!< in: thread */
976+ TABLE_LIST* tables, /*!< in/out: tables to fill */
977+ COND* cond) /*!< in: condition (not used) */
978+{
979+ btr_pcur_t pcur;
980+ const rec_t* rec;
981+ const char* col_name;
982+ mem_heap_t* heap;
983+ mtr_t mtr;
984+
985+ DBUG_ENTER("i_s_sys_columns_fill_table");
986+
987+ /* deny access to non-superusers */
988+ if (check_global_access(thd, PROCESS_ACL)) {
989+
990+ DBUG_RETURN(0);
991+ }
992+
993+ heap = mem_heap_create(1000);
994+ mutex_enter(&dict_sys->mutex);
995+ mtr_start(&mtr);
996+
997+ rec = dict_startscan_system(&pcur, &mtr, SYS_COLUMNS);
998+
999+ while (rec) {
1000+ const char* err_msg;
1001+ dict_col_t column_rec;
1002+ table_id_t table_id;
1003+
1004+ /* populate a dict_col_t structure with information from
1005+ a SYS_COLUMNS row */
1006+ err_msg = dict_process_sys_columns_rec(heap, rec, &column_rec,
1007+ &table_id, &col_name);
1008+
1009+ mtr_commit(&mtr);
1010+ mutex_exit(&dict_sys->mutex);
1011+
1012+ if (!err_msg) {
1013+ i_s_dict_fill_sys_columns(thd, table_id, col_name,
1014+ &column_rec,
1015+ tables->table);
1016+ } else {
1017+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
1018+ ER_CANT_FIND_SYSTEM_REC,
1019+ err_msg);
1020+ }
1021+
1022+ mem_heap_empty(heap);
1023+
1024+ /* Get the next record */
1025+ mutex_enter(&dict_sys->mutex);
1026+ mtr_start(&mtr);
1027+ rec = dict_getnext_system(&pcur, &mtr);
1028+ }
1029+
1030+ mtr_commit(&mtr);
1031+ mutex_exit(&dict_sys->mutex);
1032+ mem_heap_free(heap);
1033+
1034+ DBUG_RETURN(0);
1035+}
1036+/*******************************************************************//**
1037+Bind the dynamic table INFORMATION_SCHEMA.innodb_sys_columns
1038+@return 0 on success */
1039+static
1040+int
1041+innodb_sys_columns_init(
1042+/*====================*/
1043+ void* p) /*!< in/out: table schema object */
1044+{
1045+ ST_SCHEMA_TABLE* schema;
1046+
1047+ DBUG_ENTER("innodb_sys_columns_init");
1048+
1049+ schema = (ST_SCHEMA_TABLE*) p;
1050+
1051+ schema->fields_info = innodb_sys_columns_fields_info;
1052+ schema->fill_table = i_s_sys_columns_fill_table;
1053+
1054+ DBUG_RETURN(0);
1055+}
1056+
1057+UNIV_INTERN struct st_mysql_plugin i_s_innodb_sys_columns =
1058+{
1059+ /* the plugin type (a MYSQL_XXX_PLUGIN value) */
1060+ /* int */
1061+ STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN),
1062+
1063+ /* pointer to type-specific plugin descriptor */
1064+ /* void* */
1065+ STRUCT_FLD(info, &i_s_info),
1066+
1067+ /* plugin name */
1068+ /* const char* */
1069+ STRUCT_FLD(name, "INNODB_SYS_COLUMNS"),
1070+
1071+ /* plugin author (for SHOW PLUGINS) */
1072+ /* const char* */
adf0fb13 1073+ STRUCT_FLD(author, "Percona"),
b4e1fa2c
AM
1074+
1075+ /* general descriptive text (for SHOW PLUGINS) */
1076+ /* const char* */
1077+ STRUCT_FLD(descr, "InnoDB SYS_COLUMNS"),
1078+
1079+ /* the plugin license (PLUGIN_LICENSE_XXX) */
1080+ /* int */
1081+ STRUCT_FLD(license, PLUGIN_LICENSE_GPL),
1082+
1083+ /* the function to invoke when plugin is loaded */
1084+ /* int (*)(void*); */
1085+ STRUCT_FLD(init, innodb_sys_columns_init),
1086+
1087+ /* the function to invoke when plugin is unloaded */
1088+ /* int (*)(void*); */
1089+ STRUCT_FLD(deinit, i_s_common_deinit),
1090+
1091+ /* plugin version (for SHOW PLUGINS) */
1092+ /* unsigned int */
1093+ STRUCT_FLD(version, INNODB_VERSION_SHORT),
1094+
1095+ /* struct st_mysql_show_var* */
1096+ STRUCT_FLD(status_vars, NULL),
1097+
1098+ /* struct st_mysql_sys_var** */
1099+ STRUCT_FLD(system_vars, NULL),
1100+
1101+ /* reserved for dependency checking */
1102+ /* void* */
1103+ STRUCT_FLD(__reserved1, NULL)
1104+};
1105+/* Fields of the dynamic table INFORMATION_SCHEMA.innodb_sys_fields */
1106+static ST_FIELD_INFO innodb_sys_fields_fields_info[] =
1107+{
1108+#define SYS_FIELD_INDEX_ID 0
1109+ {STRUCT_FLD(field_name, "INDEX_ID"),
1110+ STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
1111+ STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
1112+ STRUCT_FLD(value, 0),
1113+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
1114+ STRUCT_FLD(old_name, ""),
1115+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
1116+
1117+#define SYS_FIELD_NAME 1
1118+ {STRUCT_FLD(field_name, "NAME"),
1119+ STRUCT_FLD(field_length, NAME_LEN + 1),
1120+ STRUCT_FLD(field_type, MYSQL_TYPE_STRING),
1121+ STRUCT_FLD(value, 0),
1122+ STRUCT_FLD(field_flags, 0),
1123+ STRUCT_FLD(old_name, ""),
1124+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
1125+
1126+#define SYS_FIELD_POS 2
1127+ {STRUCT_FLD(field_name, "POS"),
1128+ STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS),
1129+ STRUCT_FLD(field_type, MYSQL_TYPE_LONG),
1130+ STRUCT_FLD(value, 0),
1131+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
1132+ STRUCT_FLD(old_name, ""),
1133+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
1134+
1135+ END_OF_ST_FIELD_INFO
1136+};
1137+
1138+/**********************************************************************//**
1139+Function to fill information_schema.innodb_sys_fields with information
1140+collected by scanning SYS_FIELDS table.
1141+@return 0 on success */
1142+static
1143+int
1144+i_s_dict_fill_sys_fields(
1145+/*=====================*/
1146+ THD* thd, /*!< in: thread */
1147+ index_id_t index_id, /*!< in: index id for the field */
1148+ dict_field_t* field, /*!< in: table */
1149+ ulint pos, /*!< in: Field position */
1150+ TABLE* table_to_fill) /*!< in/out: fill this table */
1151+{
1152+ Field** fields;
1153+
1154+ DBUG_ENTER("i_s_dict_fill_sys_fields");
1155+
1156+ fields = table_to_fill->field;
1157+
1158+ OK(fields[SYS_FIELD_INDEX_ID]->store(longlong(index_id), TRUE));
1159+
1160+ OK(field_store_string(fields[SYS_FIELD_NAME], field->name));
1161+
1162+ OK(fields[SYS_FIELD_POS]->store(pos));
1163+
1164+ OK(schema_table_store_record(thd, table_to_fill));
1165+
1166+ DBUG_RETURN(0);
1167+}
1168+/*******************************************************************//**
1169+Function to go through each record in SYS_FIELDS table, and fill the
1170+information_schema.innodb_sys_fields table with related index field
1171+information
1172+@return 0 on success */
1173+static
1174+int
1175+i_s_sys_fields_fill_table(
1176+/*======================*/
1177+ THD* thd, /*!< in: thread */
1178+ TABLE_LIST* tables, /*!< in/out: tables to fill */
1179+ COND* cond) /*!< in: condition (not used) */
1180+{
1181+ btr_pcur_t pcur;
1182+ const rec_t* rec;
1183+ mem_heap_t* heap;
1184+ index_id_t last_id;
1185+ mtr_t mtr;
1186+
1187+ DBUG_ENTER("i_s_sys_fields_fill_table");
1188+
1189+ /* deny access to non-superusers */
1190+ if (check_global_access(thd, PROCESS_ACL)) {
1191+
1192+ DBUG_RETURN(0);
1193+ }
1194+
1195+ heap = mem_heap_create(1000);
1196+ mutex_enter(&dict_sys->mutex);
1197+ mtr_start(&mtr);
1198+
1199+ /* will save last index id so that we know whether we move to
1200+ the next index. This is used to calculate prefix length */
1201+ last_id = 0;
1202+
1203+ rec = dict_startscan_system(&pcur, &mtr, SYS_FIELDS);
1204+
1205+ while (rec) {
1206+ ulint pos;
1207+ const char* err_msg;
1208+ index_id_t index_id;
1209+ dict_field_t field_rec;
1210+
1211+ /* Populate a dict_field_t structure with information from
1212+ a SYS_FIELDS row */
1213+ err_msg = dict_process_sys_fields_rec(heap, rec, &field_rec,
1214+ &pos, &index_id, last_id);
1215+
1216+ mtr_commit(&mtr);
1217+ mutex_exit(&dict_sys->mutex);
1218+
1219+ if (!err_msg) {
1220+ i_s_dict_fill_sys_fields(thd, index_id, &field_rec,
1221+ pos, tables->table);
1222+ last_id = index_id;
1223+ } else {
1224+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
1225+ ER_CANT_FIND_SYSTEM_REC,
1226+ err_msg);
1227+ }
1228+
1229+ mem_heap_empty(heap);
1230+
1231+ /* Get the next record */
1232+ mutex_enter(&dict_sys->mutex);
1233+ mtr_start(&mtr);
1234+ rec = dict_getnext_system(&pcur, &mtr);
1235+ }
1236+
1237+ mtr_commit(&mtr);
1238+ mutex_exit(&dict_sys->mutex);
1239+ mem_heap_free(heap);
1240+
1241+ DBUG_RETURN(0);
1242+}
1243+/*******************************************************************//**
1244+Bind the dynamic table INFORMATION_SCHEMA.innodb_sys_fields
1245+@return 0 on success */
1246+static
1247+int
1248+innodb_sys_fields_init(
1249+/*===================*/
1250+ void* p) /*!< in/out: table schema object */
1251+{
1252+ ST_SCHEMA_TABLE* schema;
1253+
1254+ DBUG_ENTER("innodb_sys_field_init");
1255+
1256+ schema = (ST_SCHEMA_TABLE*) p;
1257+
1258+ schema->fields_info = innodb_sys_fields_fields_info;
1259+ schema->fill_table = i_s_sys_fields_fill_table;
1260+
1261+ DBUG_RETURN(0);
1262+}
1263+
1264+UNIV_INTERN struct st_mysql_plugin i_s_innodb_sys_fields =
1265+{
1266+ /* the plugin type (a MYSQL_XXX_PLUGIN value) */
1267+ /* int */
1268+ STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN),
1269+
1270+ /* pointer to type-specific plugin descriptor */
1271+ /* void* */
1272+ STRUCT_FLD(info, &i_s_info),
1273+
1274+ /* plugin name */
1275+ /* const char* */
1276+ STRUCT_FLD(name, "INNODB_SYS_FIELDS"),
1277+
1278+ /* plugin author (for SHOW PLUGINS) */
1279+ /* const char* */
adf0fb13 1280+ STRUCT_FLD(author, "Percona"),
b4e1fa2c
AM
1281+
1282+ /* general descriptive text (for SHOW PLUGINS) */
1283+ /* const char* */
1284+ STRUCT_FLD(descr, "InnoDB SYS_FIELDS"),
1285+
1286+ /* the plugin license (PLUGIN_LICENSE_XXX) */
1287+ /* int */
1288+ STRUCT_FLD(license, PLUGIN_LICENSE_GPL),
1289+
1290+ /* the function to invoke when plugin is loaded */
1291+ /* int (*)(void*); */
1292+ STRUCT_FLD(init, innodb_sys_fields_init),
1293+
1294+ /* the function to invoke when plugin is unloaded */
1295+ /* int (*)(void*); */
1296+ STRUCT_FLD(deinit, i_s_common_deinit),
1297+
1298+ /* plugin version (for SHOW PLUGINS) */
1299+ /* unsigned int */
1300+ STRUCT_FLD(version, INNODB_VERSION_SHORT),
1301+
1302+ /* struct st_mysql_show_var* */
1303+ STRUCT_FLD(status_vars, NULL),
1304+
1305+ /* struct st_mysql_sys_var** */
1306+ STRUCT_FLD(system_vars, NULL),
1307+
1308+ /* reserved for dependency checking */
1309+ /* void* */
1310+ STRUCT_FLD(__reserved1, NULL)
1311+};
1312+
1313+/* Fields of the dynamic table INFORMATION_SCHEMA.innodb_sys_foreign */
1314+static ST_FIELD_INFO innodb_sys_foreign_fields_info[] =
1315+{
1316+#define SYS_FOREIGN_ID 0
1317+ {STRUCT_FLD(field_name, "ID"),
1318+ STRUCT_FLD(field_length, NAME_LEN + 1),
1319+ STRUCT_FLD(field_type, MYSQL_TYPE_STRING),
1320+ STRUCT_FLD(value, 0),
1321+ STRUCT_FLD(field_flags, 0),
1322+ STRUCT_FLD(old_name, ""),
1323+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
1324+
1325+#define SYS_FOREIGN_FOR_NAME 1
1326+ {STRUCT_FLD(field_name, "FOR_NAME"),
1327+ STRUCT_FLD(field_length, NAME_LEN + 1),
1328+ STRUCT_FLD(field_type, MYSQL_TYPE_STRING),
1329+ STRUCT_FLD(value, 0),
1330+ STRUCT_FLD(field_flags, 0),
1331+ STRUCT_FLD(old_name, ""),
1332+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
1333+
1334+#define SYS_FOREIGN_REF_NAME 2
1335+ {STRUCT_FLD(field_name, "REF_NAME"),
1336+ STRUCT_FLD(field_length, NAME_LEN + 1),
1337+ STRUCT_FLD(field_type, MYSQL_TYPE_STRING),
1338+ STRUCT_FLD(value, 0),
1339+ STRUCT_FLD(field_flags, 0),
1340+ STRUCT_FLD(old_name, ""),
1341+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
1342+
1343+#define SYS_FOREIGN_NUM_COL 3
1344+ {STRUCT_FLD(field_name, "N_COLS"),
1345+ STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS),
1346+ STRUCT_FLD(field_type, MYSQL_TYPE_LONG),
1347+ STRUCT_FLD(value, 0),
1348+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
1349+ STRUCT_FLD(old_name, ""),
1350+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
1351+
1352+#define SYS_FOREIGN_TYPE 4
1353+ {STRUCT_FLD(field_name, "TYPE"),
1354+ STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS),
1355+ STRUCT_FLD(field_type, MYSQL_TYPE_LONG),
1356+ STRUCT_FLD(value, 0),
1357+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
1358+ STRUCT_FLD(old_name, ""),
1359+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
1360+
1361+ END_OF_ST_FIELD_INFO
1362+};
1363+
1364+/**********************************************************************//**
1365+Function to fill information_schema.innodb_sys_foreign with information
1366+collected by scanning SYS_FOREIGN table.
1367+@return 0 on success */
1368+static
1369+int
1370+i_s_dict_fill_sys_foreign(
1371+/*======================*/
1372+ THD* thd, /*!< in: thread */
1373+ dict_foreign_t* foreign, /*!< in: table */
1374+ TABLE* table_to_fill) /*!< in/out: fill this table */
1375+{
1376+ Field** fields;
1377+
1378+ DBUG_ENTER("i_s_dict_fill_sys_foreign");
1379+
1380+ fields = table_to_fill->field;
1381+
1382+ OK(field_store_string(fields[SYS_FOREIGN_ID], foreign->id));
1383+
1384+ OK(field_store_string(fields[SYS_FOREIGN_FOR_NAME],
1385+ foreign->foreign_table_name));
1386+
1387+ OK(field_store_string(fields[SYS_FOREIGN_REF_NAME],
1388+ foreign->referenced_table_name));
1389+
1390+ OK(fields[SYS_FOREIGN_NUM_COL]->store(foreign->n_fields));
1391+
1392+ OK(fields[SYS_FOREIGN_TYPE]->store(foreign->type));
1393+
1394+ OK(schema_table_store_record(thd, table_to_fill));
1395+
1396+ DBUG_RETURN(0);
1397+}
1398+/*******************************************************************//**
1399+Function to populate INFORMATION_SCHEMA.innodb_sys_foreign table. Loop
1400+through each record in SYS_FOREIGN, and extract the foreign key
1401+information.
1402+@return 0 on success */
1403+static
1404+int
1405+i_s_sys_foreign_fill_table(
1406+/*=======================*/
1407+ THD* thd, /*!< in: thread */
1408+ TABLE_LIST* tables, /*!< in/out: tables to fill */
1409+ COND* cond) /*!< in: condition (not used) */
1410+{
1411+ btr_pcur_t pcur;
1412+ const rec_t* rec;
1413+ mem_heap_t* heap;
1414+ mtr_t mtr;
1415+
1416+ DBUG_ENTER("i_s_sys_foreign_fill_table");
1417+
1418+ /* deny access to non-superusers */
1419+ if (check_global_access(thd, PROCESS_ACL)) {
1420+
1421+ DBUG_RETURN(0);
1422+ }
1423+
1424+ heap = mem_heap_create(1000);
1425+ mutex_enter(&dict_sys->mutex);
1426+ mtr_start(&mtr);
1427+
1428+ rec = dict_startscan_system(&pcur, &mtr, SYS_FOREIGN);
1429+
1430+ while (rec) {
1431+ const char* err_msg;
1432+ dict_foreign_t foreign_rec;
1433+
1434+ /* Populate a dict_foreign_t structure with information from
1435+ a SYS_FOREIGN row */
1436+ err_msg = dict_process_sys_foreign_rec(heap, rec, &foreign_rec);
1437+
1438+ mtr_commit(&mtr);
1439+ mutex_exit(&dict_sys->mutex);
1440+
1441+ if (!err_msg) {
1442+ i_s_dict_fill_sys_foreign(thd, &foreign_rec,
1443+ tables->table);
1444+ } else {
1445+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
1446+ ER_CANT_FIND_SYSTEM_REC,
1447+ err_msg);
1448+ }
1449+
1450+ mem_heap_empty(heap);
1451+
1452+ /* Get the next record */
1453+ mtr_start(&mtr);
1454+ mutex_enter(&dict_sys->mutex);
1455+ rec = dict_getnext_system(&pcur, &mtr);
1456+ }
1457+
1458+ mtr_commit(&mtr);
1459+ mutex_exit(&dict_sys->mutex);
1460+ mem_heap_free(heap);
1461+
1462+ DBUG_RETURN(0);
1463+}
1464+/*******************************************************************//**
1465+Bind the dynamic table INFORMATION_SCHEMA.innodb_sys_foreign
1466+@return 0 on success */
1467+static
1468+int
1469+innodb_sys_foreign_init(
1470+/*====================*/
1471+ void* p) /*!< in/out: table schema object */
1472+{
1473+ ST_SCHEMA_TABLE* schema;
1474+
1475+ DBUG_ENTER("innodb_sys_foreign_init");
1476+
1477+ schema = (ST_SCHEMA_TABLE*) p;
1478+
1479+ schema->fields_info = innodb_sys_foreign_fields_info;
1480+ schema->fill_table = i_s_sys_foreign_fill_table;
1481+
1482+ DBUG_RETURN(0);
1483+}
1484+
1485+UNIV_INTERN struct st_mysql_plugin i_s_innodb_sys_foreign =
1486+{
1487+ /* the plugin type (a MYSQL_XXX_PLUGIN value) */
1488+ /* int */
1489+ STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN),
1490+
1491+ /* pointer to type-specific plugin descriptor */
1492+ /* void* */
1493+ STRUCT_FLD(info, &i_s_info),
1494+
1495+ /* plugin name */
1496+ /* const char* */
1497+ STRUCT_FLD(name, "INNODB_SYS_FOREIGN"),
1498+
1499+ /* plugin author (for SHOW PLUGINS) */
1500+ /* const char* */
adf0fb13 1501+ STRUCT_FLD(author, "Percona"),
b4e1fa2c
AM
1502+
1503+ /* general descriptive text (for SHOW PLUGINS) */
1504+ /* const char* */
1505+ STRUCT_FLD(descr, "InnoDB SYS_FOREIGN"),
1506+
1507+ /* the plugin license (PLUGIN_LICENSE_XXX) */
1508+ /* int */
1509+ STRUCT_FLD(license, PLUGIN_LICENSE_GPL),
1510+
1511+ /* the function to invoke when plugin is loaded */
1512+ /* int (*)(void*); */
1513+ STRUCT_FLD(init, innodb_sys_foreign_init),
1514+
1515+ /* the function to invoke when plugin is unloaded */
1516+ /* int (*)(void*); */
1517+ STRUCT_FLD(deinit, i_s_common_deinit),
1518+
1519+ /* plugin version (for SHOW PLUGINS) */
1520+ /* unsigned int */
1521+ STRUCT_FLD(version, INNODB_VERSION_SHORT),
1522+
1523+ /* struct st_mysql_show_var* */
1524+ STRUCT_FLD(status_vars, NULL),
1525+
1526+ /* struct st_mysql_sys_var** */
1527+ STRUCT_FLD(system_vars, NULL),
1528+
1529+ /* reserved for dependency checking */
1530+ /* void* */
1531+ STRUCT_FLD(__reserved1, NULL)
1532+};
1533+/* Fields of the dynamic table INFORMATION_SCHEMA.innodb_sys_foreign_cols */
1534+static ST_FIELD_INFO innodb_sys_foreign_cols_fields_info[] =
1535+{
1536+#define SYS_FOREIGN_COL_ID 0
1537+ {STRUCT_FLD(field_name, "ID"),
1538+ STRUCT_FLD(field_length, NAME_LEN + 1),
1539+ STRUCT_FLD(field_type, MYSQL_TYPE_STRING),
1540+ STRUCT_FLD(value, 0),
1541+ STRUCT_FLD(field_flags, 0),
1542+ STRUCT_FLD(old_name, ""),
1543+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
1544+
1545+#define SYS_FOREIGN_COL_FOR_NAME 1
1546+ {STRUCT_FLD(field_name, "FOR_COL_NAME"),
1547+ STRUCT_FLD(field_length, NAME_LEN + 1),
1548+ STRUCT_FLD(field_type, MYSQL_TYPE_STRING),
1549+ STRUCT_FLD(value, 0),
1550+ STRUCT_FLD(field_flags, 0),
1551+ STRUCT_FLD(old_name, ""),
1552+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
1553+
1554+#define SYS_FOREIGN_COL_REF_NAME 2
1555+ {STRUCT_FLD(field_name, "REF_COL_NAME"),
1556+ STRUCT_FLD(field_length, NAME_LEN + 1),
1557+ STRUCT_FLD(field_type, MYSQL_TYPE_STRING),
1558+ STRUCT_FLD(value, 0),
1559+ STRUCT_FLD(field_flags, 0),
1560+ STRUCT_FLD(old_name, ""),
1561+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
1562+
1563+#define SYS_FOREIGN_COL_POS 3
1564+ {STRUCT_FLD(field_name, "POS"),
1565+ STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS),
1566+ STRUCT_FLD(field_type, MYSQL_TYPE_LONG),
1567+ STRUCT_FLD(value, 0),
1568+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
1569+ STRUCT_FLD(old_name, ""),
1570+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
1571+
1572+ END_OF_ST_FIELD_INFO
1573+};
1574+
1575+/**********************************************************************//**
1576+Function to fill information_schema.innodb_sys_foreign_cols with information
1577+collected by scanning SYS_FOREIGN_COLS table.
1578+@return 0 on success */
1579+static
1580+int
1581+i_s_dict_fill_sys_foreign_cols(
1582+/*==========================*/
1583+ THD* thd, /*!< in: thread */
1584+ const char* name, /*!< in: foreign key constraint name */
1585+ const char* for_col_name, /*!< in: referencing column name*/
1586+ const char* ref_col_name, /*!< in: referenced column
1587+ name */
1588+ ulint pos, /*!< in: column position */
1589+ TABLE* table_to_fill) /*!< in/out: fill this table */
1590+{
1591+ Field** fields;
1592+
1593+ DBUG_ENTER("i_s_dict_fill_sys_foreign_cols");
1594+
1595+ fields = table_to_fill->field;
1596+
1597+ OK(field_store_string(fields[SYS_FOREIGN_COL_ID], name));
1598+
1599+ OK(field_store_string(fields[SYS_FOREIGN_COL_FOR_NAME], for_col_name));
1600+
1601+ OK(field_store_string(fields[SYS_FOREIGN_COL_REF_NAME], ref_col_name));
1602+
1603+ OK(fields[SYS_FOREIGN_COL_POS]->store(pos));
1604+
1605+ OK(schema_table_store_record(thd, table_to_fill));
1606+
1607+ DBUG_RETURN(0);
1608+}
1609+/*******************************************************************//**
1610+Function to populate INFORMATION_SCHEMA.innodb_sys_foreign_cols table. Loop
1611+through each record in SYS_FOREIGN_COLS, and extract the foreign key column
1612+information and fill the INFORMATION_SCHEMA.innodb_sys_foreign_cols table.
1613+@return 0 on success */
1614+static
1615+int
1616+i_s_sys_foreign_cols_fill_table(
1617+/*============================*/
1618+ THD* thd, /*!< in: thread */
1619+ TABLE_LIST* tables, /*!< in/out: tables to fill */
1620+ COND* cond) /*!< in: condition (not used) */
1621+{
1622+ btr_pcur_t pcur;
1623+ const rec_t* rec;
1624+ mem_heap_t* heap;
1625+ mtr_t mtr;
1626+
1627+ DBUG_ENTER("i_s_sys_foreign_cols_fill_table");
1628+
1629+ /* deny access to non-superusers */
1630+ if (check_global_access(thd, PROCESS_ACL)) {
1631+ DBUG_RETURN(0);
1632+ }
1633+
1634+ heap = mem_heap_create(1000);
1635+ mutex_enter(&dict_sys->mutex);
1636+ mtr_start(&mtr);
1637+
1638+ rec = dict_startscan_system(&pcur, &mtr, SYS_FOREIGN_COLS);
1639+
1640+ while (rec) {
1641+ const char* err_msg;
1642+ const char* name;
1643+ const char* for_col_name;
1644+ const char* ref_col_name;
1645+ ulint pos;
1646+
1647+ /* Extract necessary information from a SYS_FOREIGN_COLS row */
1648+ err_msg = dict_process_sys_foreign_col_rec(
1649+ heap, rec, &name, &for_col_name, &ref_col_name, &pos);
1650+
1651+ mtr_commit(&mtr);
1652+ mutex_exit(&dict_sys->mutex);
1653+
1654+ if (!err_msg) {
1655+ i_s_dict_fill_sys_foreign_cols(
1656+ thd, name, for_col_name, ref_col_name, pos,
1657+ tables->table);
1658+ } else {
1659+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
1660+ ER_CANT_FIND_SYSTEM_REC,
1661+ err_msg);
1662+ }
1663+
1664+ mem_heap_empty(heap);
1665+
1666+ /* Get the next record */
1667+ mutex_enter(&dict_sys->mutex);
1668+ mtr_start(&mtr);
1669+ rec = dict_getnext_system(&pcur, &mtr);
1670+ }
1671+
1672+ mtr_commit(&mtr);
1673+ mutex_exit(&dict_sys->mutex);
1674+ mem_heap_free(heap);
1675+
1676+ DBUG_RETURN(0);
1677+}
1678+/*******************************************************************//**
1679+Bind the dynamic table INFORMATION_SCHEMA.innodb_sys_foreign_cols
1680+@return 0 on success */
1681+static
1682+int
1683+innodb_sys_foreign_cols_init(
1684+/*========================*/
1685+ void* p) /*!< in/out: table schema object */
1686+{
1687+ ST_SCHEMA_TABLE* schema;
1688+
1689+ DBUG_ENTER("innodb_sys_foreign_cols_init");
1690+
1691+ schema = (ST_SCHEMA_TABLE*) p;
1692+
1693+ schema->fields_info = innodb_sys_foreign_cols_fields_info;
1694+ schema->fill_table = i_s_sys_foreign_cols_fill_table;
1695+
1696+ DBUG_RETURN(0);
1697+}
1698+
1699+UNIV_INTERN struct st_mysql_plugin i_s_innodb_sys_foreign_cols =
1700+{
1701+ /* the plugin type (a MYSQL_XXX_PLUGIN value) */
1702+ /* int */
1703+ STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN),
1704+
1705+ /* pointer to type-specific plugin descriptor */
1706+ /* void* */
1707+ STRUCT_FLD(info, &i_s_info),
1708+
1709+ /* plugin name */
1710+ /* const char* */
1711+ STRUCT_FLD(name, "INNODB_SYS_FOREIGN_COLS"),
1712+
1713+ /* plugin author (for SHOW PLUGINS) */
1714+ /* const char* */
adf0fb13 1715+ STRUCT_FLD(author, "Percona"),
b4e1fa2c
AM
1716+
1717+ /* general descriptive text (for SHOW PLUGINS) */
1718+ /* const char* */
1719+ STRUCT_FLD(descr, "InnoDB SYS_FOREIGN_COLS"),
1720+
1721+ /* the plugin license (PLUGIN_LICENSE_XXX) */
1722+ /* int */
1723+ STRUCT_FLD(license, PLUGIN_LICENSE_GPL),
1724+
1725+ /* the function to invoke when plugin is loaded */
1726+ /* int (*)(void*); */
1727+ STRUCT_FLD(init, innodb_sys_foreign_cols_init),
1728+
1729+ /* the function to invoke when plugin is unloaded */
1730+ /* int (*)(void*); */
1731+ STRUCT_FLD(deinit, i_s_common_deinit),
1732+
1733+ /* plugin version (for SHOW PLUGINS) */
1734+ /* unsigned int */
1735+ STRUCT_FLD(version, INNODB_VERSION_SHORT),
1736+
1737+ /* struct st_mysql_show_var* */
1738+ STRUCT_FLD(status_vars, NULL),
1739+
1740+ /* struct st_mysql_sys_var** */
1741+ STRUCT_FLD(system_vars, NULL),
1742+
1743+ /* reserved for dependency checking */
1744+ /* void* */
1745+ STRUCT_FLD(__reserved1, NULL)
1746+};
1747+
1748 /***********************************************************************
1749 */
1750 static ST_FIELD_INFO i_s_innodb_rseg_fields_info[] =
1751diff -ruN a/storage/innobase/handler/i_s.h b/storage/innobase/handler/i_s.h
1752--- a/storage/innobase/handler/i_s.h 2010-12-03 15:37:45.540456499 +0900
1753+++ b/storage/innobase/handler/i_s.h 2010-12-03 16:08:57.596941207 +0900
adf0fb13 1754@@ -35,6 +35,13 @@
b4e1fa2c
AM
1755 extern struct st_mysql_plugin i_s_innodb_cmp_reset;
1756 extern struct st_mysql_plugin i_s_innodb_cmpmem;
1757 extern struct st_mysql_plugin i_s_innodb_cmpmem_reset;
1758+extern struct st_mysql_plugin i_s_innodb_sys_tables;
1759+extern struct st_mysql_plugin i_s_innodb_sys_tablestats;
1760+extern struct st_mysql_plugin i_s_innodb_sys_indexes;
1761+extern struct st_mysql_plugin i_s_innodb_sys_columns;
1762+extern struct st_mysql_plugin i_s_innodb_sys_fields;
1763+extern struct st_mysql_plugin i_s_innodb_sys_foreign;
1764+extern struct st_mysql_plugin i_s_innodb_sys_foreign_cols;
1765 extern struct st_mysql_plugin i_s_innodb_rseg;
1766
1767 #endif /* i_s_h */
This page took 0.415438 seconds and 4 git commands to generate.