~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/handler/i_s.cc

Monty fixes pluss a few from me for charset.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************************
 
2
 
 
3
Copyright (c) 2007, 2009, Innobase Oy. All Rights Reserved.
 
4
 
 
5
This program is free software; you can redistribute it and/or modify it under
 
6
the terms of the GNU General Public License as published by the Free Software
 
7
Foundation; version 2 of the License.
 
8
 
 
9
This program is distributed in the hope that it will be useful, but WITHOUT
 
10
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 
11
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 
12
 
 
13
You should have received a copy of the GNU General Public License along with
 
14
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 
15
Place, Suite 330, Boston, MA 02111-1307 USA
 
16
 
 
17
*****************************************************************************/
 
18
 
 
19
/******************************************************
 
20
InnoDB INFORMATION SCHEMA tables interface to MySQL.
 
21
 
 
22
Created July 18, 2007 Vasil Dimov
 
23
*******************************************************/
 
24
 
 
25
#include <drizzled/server_includes.h>
 
26
#include <drizzled/error.h>
 
27
#include <mystrings/m_ctype.h>
 
28
#include <mysys/my_sys.h>
 
29
#include <mysys/hash.h>
 
30
#include <mysys/mysys_err.h>
 
31
#include <drizzled/plugin.h>
 
32
#include <drizzled/field.h>
 
33
#include <drizzled/table.h>
 
34
#include <drizzled/info_schema.h>
 
35
 
 
36
#include "i_s.h"
 
37
 
 
38
 
 
39
extern "C" {
 
40
#include "trx0i_s.h"
 
41
#include "trx0trx.h" /* for TRX_QUE_STATE_STR_MAX_LEN */
 
42
#include "buf0buddy.h" /* for i_s_cmpmem */
 
43
#include "buf0buf.h" /* for buf_pool and PAGE_ZIP_MIN_SIZE */
 
44
#include "ha_prototypes.h" /* for innobase_convert_name() */
 
45
#include "srv0start.h" /* for srv_was_started */
 
46
}
 
47
#include "handler0vars.h"
 
48
 
 
49
static const char plugin_author[] = "Innobase Oy";
 
50
 
 
51
#define OK(expr)                \
 
52
        if ((expr) != 0) {      \
 
53
                return(1);      \
 
54
        }
 
55
 
 
56
#define RETURN_IF_INNODB_NOT_STARTED(plugin_name)                       \
 
57
do {                                                                    \
 
58
        if (!srv_was_started) {                                         \
 
59
                push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,    \
 
60
                                    ER_CANT_FIND_SYSTEM_REC,            \
 
61
                                    "InnoDB: SELECTing from "           \
 
62
                                    "INFORMATION_SCHEMA.%s but "        \
 
63
                                    "the InnoDB storage engine "        \
 
64
                                    "is not installed", plugin_name);   \
 
65
                return(0);                                              \
 
66
        }                                                               \
 
67
} while (0)
 
68
 
 
69
#define STRUCT_FLD(name, value) value
 
70
 
 
71
InfoSchemaTable *innodb_trx_schema_table= NULL;
 
72
InfoSchemaTable *innodb_locks_schema_table= NULL;
 
73
InfoSchemaTable *innodb_lock_waits_schema_table= NULL;
 
74
InfoSchemaTable *innodb_cmp_schema_table= NULL;
 
75
InfoSchemaTable *innodb_cmp_reset_schema_table= NULL;
 
76
InfoSchemaTable *innodb_cmpmem_schema_table= NULL;
 
77
InfoSchemaTable *innodb_cmpmem_reset_schema_table= NULL;
 
78
 
 
79
static TrxISMethods trx_methods;
 
80
static CmpISMethods cmp_methods;
 
81
static CmpResetISMethods cmp_reset_methods;
 
82
static CmpmemISMethods cmpmem_methods;
 
83
static CmpmemResetISMethods cmpmem_reset_methods;
 
84
 
 
85
/*
 
86
Use the following types mapping:
 
87
 
 
88
C type  ST_FIELD_INFO::field_type
 
89
---------------------------------
 
90
long                    DRIZZLE_TYPE_LONGLONG
 
91
(field_length=MY_INT64_NUM_DECIMAL_DIGITS)
 
92
 
 
93
long unsigned           DRIZZLE_TYPE_LONGLONG
 
94
(field_length=MY_INT64_NUM_DECIMAL_DIGITS, field_flags=MY_I_S_UNSIGNED)
 
95
 
 
96
char*                   DRIZZLE_TYPE_STRING
 
97
(field_length=n)
 
98
 
 
99
float                   DRIZZLE_TYPE_FLOAT
 
100
(field_length=0 is ignored)
 
101
 
 
102
void*                   DRIZZLE_TYPE_LONGLONG
 
103
(field_length=MY_INT64_NUM_DECIMAL_DIGITS, field_flags=MY_I_S_UNSIGNED)
 
104
 
 
105
boolean (if else)       DRIZZLE_TYPE_LONG
 
106
(field_length=1)
 
107
 
 
108
time_t                  DRIZZLE_TYPE_DATETIME
 
109
(field_length=0 ignored)
 
110
---------------------------------
 
111
*/
 
112
 
 
113
/* XXX these are defined in mysql_priv.h inside #ifdef DRIZZLE_SERVER */
 
114
bool schema_table_store_record(Session *session, Table *table);
 
115
void localtime_to_TIME(DRIZZLE_TIME *to, struct tm *from);
 
116
 
 
117
/***********************************************************************
 
118
Unbind a dynamic INFORMATION_SCHEMA table. */
 
119
 
 
120
/***********************************************************************
 
121
Auxiliary function to store time_t value in DRIZZLE_TYPE_DATETIME
 
122
field. */
 
123
static
 
124
int
 
125
field_store_time_t(
 
126
/*===============*/
 
127
                        /* out: 0 on success */
 
128
        Field*  field,  /* in/out: target field for storage */
 
129
        time_t  time)   /* in: value to store */
 
130
{
 
131
        DRIZZLE_TIME    my_time;
 
132
        struct tm       tm_time;
 
133
 
 
134
#if 0
 
135
        /* use this if you are sure that `variables' and `time_zone'
 
136
        are always initialized */
 
137
        session->variables.time_zone->gmt_sec_to_TIME(
 
138
                &my_time, (time_t) time);
 
139
#else
 
140
        localtime_r(&time, &tm_time);
 
141
        localtime_to_TIME(&my_time, &tm_time);
 
142
        my_time.time_type = DRIZZLE_TIMESTAMP_DATETIME;
 
143
#endif
 
144
 
 
145
        return(field->store_time(&my_time, DRIZZLE_TIMESTAMP_DATETIME));
 
146
}
 
147
 
 
148
/***********************************************************************
 
149
Auxiliary function to store char* value in DRIZZLE_TYPE_STRING field. */
 
150
static
 
151
int
 
152
field_store_string(
 
153
/*===============*/
 
154
                                /* out: 0 on success */
 
155
        Field*          field,  /* in/out: target field for storage */
 
156
        const char*     str)    /* in: NUL-terminated utf-8 string,
 
157
                                or NULL */
 
158
{
 
159
        int     ret;
 
160
 
 
161
        if (str != NULL) {
 
162
 
 
163
                ret = field->store(str, strlen(str),
 
164
                                   system_charset_info);
 
165
                field->set_notnull();
 
166
        } else {
 
167
 
 
168
                ret = 0; /* success */
 
169
                field->set_null();
 
170
        }
 
171
 
 
172
        return(ret);
 
173
}
 
174
 
 
175
/***********************************************************************
 
176
Auxiliary function to store ulint value in DRIZZLE_TYPE_LONGLONG field.
 
177
If the value is ULINT_UNDEFINED then the field it set to NULL. */
 
178
static
 
179
int
 
180
field_store_ulint(
 
181
/*==============*/
 
182
                        /* out: 0 on success */
 
183
        Field*  field,  /* in/out: target field for storage */
 
184
        ulint   n)      /* in: value to store */
 
185
{
 
186
        int     ret;
 
187
 
 
188
        if (n != ULINT_UNDEFINED) {
 
189
 
 
190
                ret = field->store(n);
 
191
                field->set_notnull();
 
192
        } else {
 
193
 
 
194
                ret = 0; /* success */
 
195
                field->set_null();
 
196
        }
 
197
 
 
198
        return(ret);
 
199
}
 
200
 
 
201
/* Fields of the dynamic table INFORMATION_SCHEMA.innodb_trx */
 
202
static ColumnInfo       innodb_trx_fields_info[] =
 
203
{
 
204
#define IDX_TRX_ID              0
 
205
        ColumnInfo("trx_id",
 
206
                  TRX_ID_MAX_LEN + 1,
 
207
                  DRIZZLE_TYPE_VARCHAR,
 
208
                  0,
 
209
                  0,
 
210
                  "",
 
211
                  SKIP_OPEN_TABLE),
 
212
 
 
213
#define IDX_TRX_STATE           1
 
214
        ColumnInfo("trx_state",
 
215
                  TRX_QUE_STATE_STR_MAX_LEN + 1,
 
216
                  DRIZZLE_TYPE_VARCHAR,
 
217
                  0,
 
218
                  0,
 
219
                  "",
 
220
                  SKIP_OPEN_TABLE),
 
221
 
 
222
#define IDX_TRX_STARTED         2
 
223
        ColumnInfo("trx_started",
 
224
                  0,
 
225
                  DRIZZLE_TYPE_DATETIME,
 
226
                  0,
 
227
                  0,
 
228
                  "",
 
229
                  SKIP_OPEN_TABLE),
 
230
 
 
231
#define IDX_TRX_REQUESTED_LOCK_ID       3
 
232
        ColumnInfo("trx_requested_lock_id",
 
233
                  TRX_I_S_LOCK_ID_MAX_LEN + 1,
 
234
                  DRIZZLE_TYPE_VARCHAR,
 
235
                  0,
 
236
                  MY_I_S_MAYBE_NULL,
 
237
                  "",
 
238
                  SKIP_OPEN_TABLE),
 
239
 
 
240
#define IDX_TRX_WAIT_STARTED    4
 
241
        ColumnInfo("trx_wait_started",
 
242
                  0,
 
243
                  DRIZZLE_TYPE_DATETIME,
 
244
                  0,
 
245
                  MY_I_S_MAYBE_NULL,
 
246
                  "",
 
247
                  SKIP_OPEN_TABLE),
 
248
 
 
249
#define IDX_TRX_WEIGHT          5
 
250
        ColumnInfo("trx_weight",
 
251
                  MY_INT64_NUM_DECIMAL_DIGITS,
 
252
                  DRIZZLE_TYPE_LONGLONG,
 
253
                  0,
 
254
                  MY_I_S_UNSIGNED,
 
255
                  "",
 
256
                  SKIP_OPEN_TABLE),
 
257
 
 
258
#define IDX_TRX_DRIZZLE_THREAD_ID       6
 
259
        ColumnInfo("trx_mysql_thread_id",
 
260
                  MY_INT64_NUM_DECIMAL_DIGITS,
 
261
                  DRIZZLE_TYPE_LONGLONG,
 
262
                  0,
 
263
                  MY_I_S_UNSIGNED,
 
264
                  "",
 
265
                  SKIP_OPEN_TABLE),
 
266
 
 
267
#define IDX_TRX_QUERY           7
 
268
        ColumnInfo("trx_query",
 
269
                  TRX_I_S_TRX_QUERY_MAX_LEN,
 
270
                  DRIZZLE_TYPE_VARCHAR,
 
271
                  0,
 
272
                  MY_I_S_MAYBE_NULL,
 
273
                  "",
 
274
                  SKIP_OPEN_TABLE),
 
275
 
 
276
        ColumnInfo()
 
277
};
 
278
 
 
279
/***********************************************************************
 
280
Read data from cache buffer and fill the INFORMATION_SCHEMA.innodb_trx
 
281
table with it. */
 
282
static
 
283
int
 
284
fill_innodb_trx_from_cache(
 
285
/*=======================*/
 
286
                                        /* out: 0 on success */
 
287
        trx_i_s_cache_t*        cache,  /* in: cache to read from */
 
288
        Session*                        session,        /* in: used to call
 
289
                                        schema_table_store_record() */
 
290
        Table*                  table)  /* in/out: fill this table */
 
291
{
 
292
        Field** fields;
 
293
        ulint   rows_num;
 
294
        char    lock_id[TRX_I_S_LOCK_ID_MAX_LEN + 1];
 
295
        ulint   i;
 
296
 
 
297
        fields = table->field;
 
298
 
 
299
        rows_num = trx_i_s_cache_get_rows_used(cache,
 
300
                                               I_S_INNODB_TRX);
 
301
 
 
302
        for (i = 0; i < rows_num; i++) {
 
303
 
 
304
                i_s_trx_row_t*  row;
 
305
                char            trx_id[TRX_ID_MAX_LEN + 1];
 
306
 
 
307
                row = (i_s_trx_row_t*)
 
308
                        trx_i_s_cache_get_nth_row(
 
309
                                cache, I_S_INNODB_TRX, i);
 
310
 
 
311
                /* trx_id */
 
312
                ut_snprintf(trx_id, sizeof(trx_id), TRX_ID_FMT, row->trx_id);
 
313
                OK(field_store_string(fields[IDX_TRX_ID], trx_id));
 
314
 
 
315
                /* trx_state */
 
316
                OK(field_store_string(fields[IDX_TRX_STATE],
 
317
                                      row->trx_state));
 
318
 
 
319
                /* trx_started */
 
320
                OK(field_store_time_t(fields[IDX_TRX_STARTED],
 
321
                                      (time_t) row->trx_started));
 
322
 
 
323
                /* trx_requested_lock_id */
 
324
                /* trx_wait_started */
 
325
                if (row->trx_wait_started != 0) {
 
326
 
 
327
                        OK(field_store_string(
 
328
                                   fields[IDX_TRX_REQUESTED_LOCK_ID],
 
329
                                   trx_i_s_create_lock_id(
 
330
                                           row->requested_lock_row,
 
331
                                           lock_id, sizeof(lock_id))));
 
332
                        /* field_store_string() sets it no notnull */
 
333
 
 
334
                        OK(field_store_time_t(
 
335
                                   fields[IDX_TRX_WAIT_STARTED],
 
336
                                   (time_t) row->trx_wait_started));
 
337
                        fields[IDX_TRX_WAIT_STARTED]->set_notnull();
 
338
                } else {
 
339
 
 
340
                        fields[IDX_TRX_REQUESTED_LOCK_ID]->set_null();
 
341
                        fields[IDX_TRX_WAIT_STARTED]->set_null();
 
342
                }
 
343
 
 
344
                /* trx_weight */
 
345
                OK(fields[IDX_TRX_WEIGHT]->store((int64_t) row->trx_weight,
 
346
                                                 true));
 
347
 
 
348
                /* trx_mysql_thread_id */
 
349
                OK(fields[IDX_TRX_DRIZZLE_THREAD_ID]->store(
 
350
                           row->trx_mysql_thread_id));
 
351
 
 
352
                /* trx_query */
 
353
                OK(field_store_string(fields[IDX_TRX_QUERY],
 
354
                                      row->trx_query));
 
355
 
 
356
                OK(schema_table_store_record(session, table));
 
357
        }
 
358
 
 
359
        return(0);
 
360
}
 
361
 
 
362
/***********************************************************************
 
363
Bind the dynamic table INFORMATION_SCHEMA.innodb_trx */
 
364
int
 
365
innodb_trx_init(
 
366
/*============*/
 
367
                        /* out: 0 on success */
 
368
        )       /* in/out: table schema object */
 
369
{
 
370
        if ((innodb_trx_schema_table= new InfoSchemaTable) == NULL)
 
371
                return(1);
 
372
 
 
373
        innodb_trx_schema_table->setColumnInfo(innodb_trx_fields_info);
 
374
        innodb_trx_schema_table->setInfoSchemaMethods(&trx_methods);
 
375
        innodb_trx_schema_table->setTableName("INNODB_TRX");
 
376
 
 
377
        return(0);
 
378
}
 
379
 
 
380
 
 
381
/* Fields of the dynamic table INFORMATION_SCHEMA.innodb_locks */
 
382
static ColumnInfo innodb_locks_fields_info[] =
 
383
{
 
384
#define IDX_LOCK_ID             0
 
385
        ColumnInfo("lock_id",
 
386
                  TRX_I_S_LOCK_ID_MAX_LEN + 1,
 
387
                  DRIZZLE_TYPE_VARCHAR,
 
388
                  0,
 
389
                  0,
 
390
                  "",
 
391
                  SKIP_OPEN_TABLE),
 
392
 
 
393
#define IDX_LOCK_TRX_ID         1
 
394
        ColumnInfo("lock_trx_id",
 
395
                  TRX_ID_MAX_LEN + 1,
 
396
                  DRIZZLE_TYPE_VARCHAR,
 
397
                  0,
 
398
                  0,
 
399
                  "",
 
400
                  SKIP_OPEN_TABLE),
 
401
 
 
402
#define IDX_LOCK_MODE           2
 
403
        ColumnInfo("lock_mode",
 
404
         /* S[,GAP] X[,GAP] IS[,GAP] IX[,GAP] AUTO_INC UNKNOWN */
 
405
                  32,
 
406
                  DRIZZLE_TYPE_VARCHAR,
 
407
                  0,
 
408
                  0,
 
409
                  "",
 
410
                  SKIP_OPEN_TABLE),
 
411
 
 
412
#define IDX_LOCK_TYPE           3
 
413
        ColumnInfo("lock_type",
 
414
                  32, /* RECORD|TABLE|UNKNOWN */
 
415
                  DRIZZLE_TYPE_VARCHAR,
 
416
                  0,
 
417
                  0,
 
418
                  "",
 
419
                  SKIP_OPEN_TABLE),
 
420
 
 
421
#define IDX_LOCK_TABLE          4
 
422
        ColumnInfo("lock_table",
 
423
                  1024,
 
424
                  DRIZZLE_TYPE_VARCHAR,
 
425
                  0,
 
426
                  0,
 
427
                  "",
 
428
                  SKIP_OPEN_TABLE),
 
429
 
 
430
#define IDX_LOCK_INDEX          5
 
431
        ColumnInfo("lock_index",
 
432
                  1024,
 
433
                  DRIZZLE_TYPE_VARCHAR,
 
434
                  0,
 
435
                  MY_I_S_MAYBE_NULL,
 
436
                  "",
 
437
                  SKIP_OPEN_TABLE),
 
438
 
 
439
#define IDX_LOCK_SPACE          6
 
440
        ColumnInfo("lock_space",
 
441
                  MY_INT64_NUM_DECIMAL_DIGITS,
 
442
                  DRIZZLE_TYPE_LONGLONG,
 
443
                  0,
 
444
                  MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL,
 
445
                  "",
 
446
                  SKIP_OPEN_TABLE),
 
447
 
 
448
#define IDX_LOCK_PAGE           7
 
449
        ColumnInfo("lock_page",
 
450
                  MY_INT64_NUM_DECIMAL_DIGITS,
 
451
                  DRIZZLE_TYPE_LONGLONG,
 
452
                  0,
 
453
                  MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL,
 
454
                  "",
 
455
                  SKIP_OPEN_TABLE),
 
456
 
 
457
#define IDX_LOCK_REC            8
 
458
        ColumnInfo("lock_rec",
 
459
                  MY_INT64_NUM_DECIMAL_DIGITS,
 
460
                  DRIZZLE_TYPE_LONGLONG,
 
461
                  0,
 
462
                  MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL,
 
463
                  "",
 
464
                  SKIP_OPEN_TABLE),
 
465
 
 
466
#define IDX_LOCK_DATA           9
 
467
        ColumnInfo("lock_data",
 
468
                  TRX_I_S_LOCK_DATA_MAX_LEN,
 
469
                  DRIZZLE_TYPE_VARCHAR,
 
470
                  0,
 
471
                  MY_I_S_MAYBE_NULL,
 
472
                  "",
 
473
                  SKIP_OPEN_TABLE),
 
474
 
 
475
        ColumnInfo()
 
476
};
 
477
 
 
478
/***********************************************************************
 
479
Read data from cache buffer and fill the INFORMATION_SCHEMA.innodb_locks
 
480
table with it. */
 
481
static
 
482
int
 
483
fill_innodb_locks_from_cache(
 
484
/*=========================*/
 
485
                                        /* out: 0 on success */
 
486
        trx_i_s_cache_t*        cache,  /* in: cache to read from */
 
487
        Session*                        session,        /* in: MySQL client connection */
 
488
        Table*                  table)  /* in/out: fill this table */
 
489
{
 
490
        Field** fields;
 
491
        ulint   rows_num;
 
492
        char    lock_id[TRX_I_S_LOCK_ID_MAX_LEN + 1];
 
493
        ulint   i;
 
494
 
 
495
        fields = table->field;
 
496
 
 
497
        rows_num = trx_i_s_cache_get_rows_used(cache,
 
498
                                               I_S_INNODB_LOCKS);
 
499
 
 
500
        for (i = 0; i < rows_num; i++) {
 
501
 
 
502
                i_s_locks_row_t*        row;
 
503
 
 
504
                /* note that the decoded database or table name is
 
505
                never expected to be longer than NAME_LEN;
 
506
                NAME_LEN for database name
 
507
                2 for surrounding quotes around database name
 
508
                NAME_LEN for table name
 
509
                2 for surrounding quotes around table name
 
510
                1 for the separating dot (.)
 
511
                9 for the #mysql50# prefix */
 
512
                char                    buf[2 * NAME_LEN + 14];
 
513
                const char*             bufend;
 
514
 
 
515
                char                    lock_trx_id[TRX_ID_MAX_LEN + 1];
 
516
 
 
517
                row = (i_s_locks_row_t*)
 
518
                        trx_i_s_cache_get_nth_row(
 
519
                                cache, I_S_INNODB_LOCKS, i);
 
520
 
 
521
                /* lock_id */
 
522
                trx_i_s_create_lock_id(row, lock_id, sizeof(lock_id));
 
523
                OK(field_store_string(fields[IDX_LOCK_ID],
 
524
                                      lock_id));
 
525
 
 
526
                /* lock_trx_id */
 
527
                ut_snprintf(lock_trx_id, sizeof(lock_trx_id),
 
528
                            TRX_ID_FMT, row->lock_trx_id);
 
529
                OK(field_store_string(fields[IDX_LOCK_TRX_ID], lock_trx_id));
 
530
 
 
531
                /* lock_mode */
 
532
                OK(field_store_string(fields[IDX_LOCK_MODE],
 
533
                                      row->lock_mode));
 
534
 
 
535
                /* lock_type */
 
536
                OK(field_store_string(fields[IDX_LOCK_TYPE],
 
537
                                      row->lock_type));
 
538
 
 
539
                /* lock_table */
 
540
                bufend = innobase_convert_name(buf, sizeof(buf),
 
541
                                               row->lock_table,
 
542
                                               strlen(row->lock_table),
 
543
                                               session, TRUE);
 
544
                OK(fields[IDX_LOCK_TABLE]->store(buf, bufend - buf,
 
545
                                                 system_charset_info));
 
546
 
 
547
                /* lock_index */
 
548
                if (row->lock_index != NULL) {
 
549
 
 
550
                        bufend = innobase_convert_name(buf, sizeof(buf),
 
551
                                                       row->lock_index,
 
552
                                                       strlen(row->lock_index),
 
553
                                                       session, FALSE);
 
554
                        OK(fields[IDX_LOCK_INDEX]->store(buf, bufend - buf,
 
555
                                                         system_charset_info));
 
556
                        fields[IDX_LOCK_INDEX]->set_notnull();
 
557
                } else {
 
558
 
 
559
                        fields[IDX_LOCK_INDEX]->set_null();
 
560
                }
 
561
 
 
562
                /* lock_space */
 
563
                OK(field_store_ulint(fields[IDX_LOCK_SPACE],
 
564
                                     row->lock_space));
 
565
 
 
566
                /* lock_page */
 
567
                OK(field_store_ulint(fields[IDX_LOCK_PAGE],
 
568
                                     row->lock_page));
 
569
 
 
570
                /* lock_rec */
 
571
                OK(field_store_ulint(fields[IDX_LOCK_REC],
 
572
                                     row->lock_rec));
 
573
 
 
574
                /* lock_data */
 
575
                OK(field_store_string(fields[IDX_LOCK_DATA],
 
576
                                      row->lock_data));
 
577
 
 
578
                OK(schema_table_store_record(session, table));
 
579
        }
 
580
 
 
581
        return(0);
 
582
}
 
583
 
 
584
/***********************************************************************
 
585
Bind the dynamic table INFORMATION_SCHEMA.innodb_locks */
 
586
int
 
587
innodb_locks_init(
 
588
/*==============*/
 
589
                        /* out: 0 on success */
 
590
        )       /* in/out: table schema object */
 
591
{
 
592
 
 
593
        if ((innodb_locks_schema_table= new InfoSchemaTable) == NULL)
 
594
                return(1);
 
595
 
 
596
        innodb_locks_schema_table->setColumnInfo(innodb_locks_fields_info);
 
597
        innodb_locks_schema_table->setInfoSchemaMethods(&trx_methods);
 
598
        innodb_locks_schema_table->setTableName("INNODB_LOCKS");
 
599
        return(0);
 
600
}
 
601
 
 
602
 
 
603
/* Fields of the dynamic table INFORMATION_SCHEMA.innodb_lock_waits */
 
604
static ColumnInfo innodb_lock_waits_fields_info[] =
 
605
{
 
606
#define IDX_REQUESTING_TRX_ID   0
 
607
        ColumnInfo("requesting_trx_id",
 
608
                  TRX_ID_MAX_LEN + 1,
 
609
                  DRIZZLE_TYPE_VARCHAR,
 
610
                  0,
 
611
                  0,
 
612
                  "",
 
613
                  SKIP_OPEN_TABLE),
 
614
 
 
615
#define IDX_REQUESTED_LOCK_ID   1
 
616
        ColumnInfo("requested_lock_id",
 
617
                  TRX_I_S_LOCK_ID_MAX_LEN + 1,
 
618
                  DRIZZLE_TYPE_VARCHAR,
 
619
                  0,
 
620
                  0,
 
621
                  "",
 
622
                  SKIP_OPEN_TABLE),
 
623
 
 
624
#define IDX_BLOCKING_TRX_ID     2
 
625
        ColumnInfo("blocking_trx_id",
 
626
                  TRX_ID_MAX_LEN + 1,
 
627
                  DRIZZLE_TYPE_VARCHAR,
 
628
                  0,
 
629
                  0,
 
630
                  "",
 
631
                  SKIP_OPEN_TABLE),
 
632
 
 
633
#define IDX_BLOCKING_LOCK_ID    3
 
634
        ColumnInfo("blocking_lock_id",
 
635
                  TRX_I_S_LOCK_ID_MAX_LEN + 1,
 
636
                  DRIZZLE_TYPE_VARCHAR,
 
637
                  0,
 
638
                  0,
 
639
                  "",
 
640
                  SKIP_OPEN_TABLE),
 
641
 
 
642
        ColumnInfo()
 
643
};
 
644
 
 
645
/***********************************************************************
 
646
Read data from cache buffer and fill the
 
647
INFORMATION_SCHEMA.innodb_lock_waits table with it. */
 
648
static
 
649
int
 
650
fill_innodb_lock_waits_from_cache(
 
651
/*==============================*/
 
652
                                        /* out: 0 on success */
 
653
        trx_i_s_cache_t*        cache,  /* in: cache to read from */
 
654
        Session*                        session,        /* in: used to call
 
655
                                        schema_table_store_record() */
 
656
        Table*                  table)  /* in/out: fill this table */
 
657
{
 
658
        Field** fields;
 
659
        ulint   rows_num;
 
660
        char    requested_lock_id[TRX_I_S_LOCK_ID_MAX_LEN + 1];
 
661
        char    blocking_lock_id[TRX_I_S_LOCK_ID_MAX_LEN + 1];
 
662
        ulint   i;
 
663
 
 
664
        fields = table->field;
 
665
 
 
666
        rows_num = trx_i_s_cache_get_rows_used(cache,
 
667
                                               I_S_INNODB_LOCK_WAITS);
 
668
 
 
669
        for (i = 0; i < rows_num; i++) {
 
670
 
 
671
                i_s_lock_waits_row_t*   row;
 
672
 
 
673
                char    requesting_trx_id[TRX_ID_MAX_LEN + 1];
 
674
                char    blocking_trx_id[TRX_ID_MAX_LEN + 1];
 
675
 
 
676
                row = (i_s_lock_waits_row_t*)
 
677
                        trx_i_s_cache_get_nth_row(
 
678
                                cache, I_S_INNODB_LOCK_WAITS, i);
 
679
 
 
680
                /* requesting_trx_id */
 
681
                ut_snprintf(requesting_trx_id, sizeof(requesting_trx_id),
 
682
                            TRX_ID_FMT, row->requested_lock_row->lock_trx_id);
 
683
                OK(field_store_string(fields[IDX_REQUESTING_TRX_ID],
 
684
                                      requesting_trx_id));
 
685
 
 
686
                /* requested_lock_id */
 
687
                OK(field_store_string(
 
688
                           fields[IDX_REQUESTED_LOCK_ID],
 
689
                           trx_i_s_create_lock_id(
 
690
                                   row->requested_lock_row,
 
691
                                   requested_lock_id,
 
692
                                   sizeof(requested_lock_id))));
 
693
 
 
694
                /* blocking_trx_id */
 
695
                ut_snprintf(blocking_trx_id, sizeof(blocking_trx_id),
 
696
                            TRX_ID_FMT, row->blocking_lock_row->lock_trx_id);
 
697
                OK(field_store_string(fields[IDX_BLOCKING_TRX_ID],
 
698
                                      blocking_trx_id));
 
699
 
 
700
                /* blocking_lock_id */
 
701
                OK(field_store_string(
 
702
                           fields[IDX_BLOCKING_LOCK_ID],
 
703
                           trx_i_s_create_lock_id(
 
704
                                   row->blocking_lock_row,
 
705
                                   blocking_lock_id,
 
706
                                   sizeof(blocking_lock_id))));
 
707
 
 
708
                OK(schema_table_store_record(session, table));
 
709
        }
 
710
 
 
711
        return(0);
 
712
}
 
713
 
 
714
/***********************************************************************
 
715
Bind the dynamic table INFORMATION_SCHEMA.innodb_lock_waits */
 
716
int
 
717
innodb_lock_waits_init(
 
718
/*===================*/
 
719
                        /* out: 0 on success */
 
720
        )
 
721
{
 
722
 
 
723
        if ((innodb_lock_waits_schema_table= new InfoSchemaTable) == NULL)
 
724
                return(1);
 
725
 
 
726
        innodb_lock_waits_schema_table->setColumnInfo(innodb_lock_waits_fields_info);
 
727
        innodb_lock_waits_schema_table->setInfoSchemaMethods(&trx_methods);
 
728
        innodb_lock_waits_schema_table->setTableName("INNODB_LOCK_WAITS");
 
729
 
 
730
 
 
731
        return(0);
 
732
}
 
733
 
 
734
 
 
735
/***********************************************************************
 
736
Common function to fill any of the dynamic tables:
 
737
INFORMATION_SCHEMA.innodb_trx
 
738
INFORMATION_SCHEMA.innodb_locks
 
739
INFORMATION_SCHEMA.innodb_lock_waits */
 
740
int
 
741
TrxISMethods::fillTable(
 
742
/*======================*/
 
743
                                /* out: 0 on success */
 
744
        Session*                session,        /* in: thread */
 
745
        TableList*      tables, /* in/out: tables to fill */
 
746
        COND*           )       /* in: condition (not used) */
 
747
{
 
748
        const char*             table_name;
 
749
        int                     ret;
 
750
        trx_i_s_cache_t*        cache;
 
751
 
 
752
        /* minimize the number of places where global variables are
 
753
        referenced */
 
754
        cache = trx_i_s_cache;
 
755
 
 
756
        /* which table we have to fill? */
 
757
        table_name = tables->schema_table_name;
 
758
        /* or table_name = tables->schema_table->table_name; */
 
759
 
 
760
        RETURN_IF_INNODB_NOT_STARTED(table_name);
 
761
 
 
762
        /* update the cache */
 
763
        trx_i_s_cache_start_write(cache);
 
764
        trx_i_s_possibly_fetch_data_into_cache(cache);
 
765
        trx_i_s_cache_end_write(cache);
 
766
 
 
767
        if (trx_i_s_cache_is_truncated(cache)) {
 
768
 
 
769
                /* XXX show warning to user if possible */
 
770
                fprintf(stderr, "Warning: data in %s truncated due to "
 
771
                        "memory limit of %d bytes\n", table_name,
 
772
                        TRX_I_S_MEM_LIMIT);
 
773
        }
 
774
 
 
775
        ret = 0;
 
776
 
 
777
        trx_i_s_cache_start_read(cache);
 
778
 
 
779
        if (innobase_strcasecmp(table_name, "innodb_trx") == 0) {
 
780
 
 
781
                if (fill_innodb_trx_from_cache(
 
782
                        cache, session, tables->table) != 0) {
 
783
 
 
784
                        ret = 1;
 
785
                }
 
786
 
 
787
        } else if (innobase_strcasecmp(table_name, "innodb_locks") == 0) {
 
788
 
 
789
                if (fill_innodb_locks_from_cache(
 
790
                        cache, session, tables->table) != 0) {
 
791
 
 
792
                        ret = 1;
 
793
                }
 
794
 
 
795
        } else if (innobase_strcasecmp(table_name, "innodb_lock_waits") == 0) {
 
796
 
 
797
                if (fill_innodb_lock_waits_from_cache(
 
798
                        cache, session, tables->table) != 0) {
 
799
 
 
800
                        ret = 1;
 
801
                }
 
802
 
 
803
        } else {
 
804
 
 
805
                /* huh! what happened!? */
 
806
                fprintf(stderr,
 
807
                        "InnoDB: trx_i_s_common_fill_table() was "
 
808
                        "called to fill unknown table: %s.\n"
 
809
                        "This function only knows how to fill "
 
810
                        "innodb_trx, innodb_locks and "
 
811
                        "innodb_lock_waits tables.\n", table_name);
 
812
 
 
813
                ret = 1;
 
814
        }
 
815
 
 
816
        trx_i_s_cache_end_read(cache);
 
817
 
 
818
#if 0
 
819
        return(ret);
 
820
#else
 
821
        /* if this function returns something else than 0 then a
 
822
        deadlock occurs between the mysqld server and mysql client,
 
823
        see http://bugs.mysql.com/29900 ; when that bug is resolved
 
824
        we can enable the return(ret) above */
 
825
        return(0);
 
826
#endif
 
827
}
 
828
 
 
829
/* Fields of the dynamic table information_schema.innodb_cmp. */
 
830
static ColumnInfo       i_s_cmp_fields_info[] =
 
831
{
 
832
        ColumnInfo("page_size",
 
833
                  5,
 
834
                  DRIZZLE_TYPE_LONG,
 
835
                  0,
 
836
                  0,
 
837
                  "Compressed Page Size",
 
838
                  SKIP_OPEN_TABLE),
 
839
 
 
840
        ColumnInfo("compress_ops",
 
841
                  MY_INT32_NUM_DECIMAL_DIGITS,
 
842
                  DRIZZLE_TYPE_LONG,
 
843
                  0,
 
844
                  0,
 
845
                  "Total Number of Compressions",
 
846
                  SKIP_OPEN_TABLE),
 
847
 
 
848
        ColumnInfo("compress_ops_ok",
 
849
                  MY_INT32_NUM_DECIMAL_DIGITS,
 
850
                  DRIZZLE_TYPE_LONG,
 
851
                  0,
 
852
                  0,
 
853
                  "Total Number of Successful Compressions",
 
854
                  SKIP_OPEN_TABLE),
 
855
 
 
856
        ColumnInfo("compress_time",
 
857
                  MY_INT32_NUM_DECIMAL_DIGITS,
 
858
                  DRIZZLE_TYPE_LONG,
 
859
                  0,
 
860
                  0,
 
861
                  "Total Duration of Compressions in Seconds",
 
862
                  SKIP_OPEN_TABLE),
 
863
 
 
864
        ColumnInfo("uncompress_ops",
 
865
                  MY_INT32_NUM_DECIMAL_DIGITS,
 
866
                  DRIZZLE_TYPE_LONG,
 
867
                  0,
 
868
                  0,
 
869
                  "Total Number of Decompressions",
 
870
                  SKIP_OPEN_TABLE),
 
871
 
 
872
        ColumnInfo("uncompress_time",
 
873
                  MY_INT32_NUM_DECIMAL_DIGITS,
 
874
                  DRIZZLE_TYPE_LONG,
 
875
                  0,
 
876
                  0,
 
877
                  "Total Duration of Decompressions in Seconds",
 
878
                  SKIP_OPEN_TABLE),
 
879
 
 
880
        ColumnInfo()
 
881
};
 
882
 
 
883
 
 
884
/***********************************************************************
 
885
Fill the dynamic table information_schema.innodb_cmp or
 
886
innodb_cmp_reset. */
 
887
static
 
888
int
 
889
i_s_cmp_fill_low(
 
890
/*=============*/
 
891
                                /* out: 0 on success, 1 on failure */
 
892
        Session*                session,        /* in: thread */
 
893
        TableList*      tables, /* in/out: tables to fill */
 
894
        COND*           ,       /* in: condition (ignored) */
 
895
        ibool           reset)  /* in: TRUE=reset cumulated counts */
 
896
{
 
897
        Table*  table   = (Table *) tables->table;
 
898
        int     status  = 0;
 
899
 
 
900
 
 
901
        RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name);
 
902
 
 
903
        for (uint i = 0; i < PAGE_ZIP_NUM_SSIZE - 1; i++) {
 
904
                page_zip_stat_t*        zip_stat = &page_zip_stat[i];
 
905
 
 
906
                table->field[0]->store(PAGE_ZIP_MIN_SIZE << i);
 
907
 
 
908
                /* The cumulated counts are not protected by any
 
909
                mutex.  Thus, some operation in page0zip.c could
 
910
                increment a counter between the time we read it and
 
911
                clear it.  We could introduce mutex protection, but it
 
912
                could cause a measureable performance hit in
 
913
                page0zip.c. */
 
914
                table->field[1]->store(zip_stat->compressed);
 
915
                table->field[2]->store(zip_stat->compressed_ok);
 
916
                table->field[3]->store(
 
917
                        (ulong) (zip_stat->compressed_usec / 1000000));
 
918
                table->field[4]->store(zip_stat->decompressed);
 
919
                table->field[5]->store(
 
920
                        (ulong) (zip_stat->decompressed_usec / 1000000));
 
921
 
 
922
                if (reset) {
 
923
                        memset(zip_stat, 0, sizeof *zip_stat);
 
924
                }
 
925
 
 
926
                if (schema_table_store_record(session, table)) {
 
927
                        status = 1;
 
928
                        break;
 
929
                }
 
930
        }
 
931
 
 
932
        return(status);
 
933
}
 
934
 
 
935
/***********************************************************************
 
936
Fill the dynamic table information_schema.innodb_cmp. */
 
937
int
 
938
CmpISMethods::fillTable(
 
939
/*=========*/
 
940
                                /* out: 0 on success, 1 on failure */
 
941
        Session*                session,        /* in: thread */
 
942
        TableList*      tables, /* in/out: tables to fill */
 
943
        COND*           cond)   /* in: condition (ignored) */
 
944
{
 
945
        return(i_s_cmp_fill_low(session, tables, cond, FALSE));
 
946
}
 
947
 
 
948
/***********************************************************************
 
949
Fill the dynamic table information_schema.innodb_cmp_reset. */
 
950
int
 
951
CmpResetISMethods::fillTable(
 
952
/*===============*/
 
953
                                /* out: 0 on success, 1 on failure */
 
954
        Session*                session,        /* in: thread */
 
955
        TableList*      tables, /* in/out: tables to fill */
 
956
        COND*           cond)   /* in: condition (ignored) */
 
957
{
 
958
        return(i_s_cmp_fill_low(session, tables, cond, TRUE));
 
959
}
 
960
 
 
961
 
 
962
/***********************************************************************
 
963
Bind the dynamic table information_schema.innodb_cmp. */
 
964
int
 
965
i_s_cmp_init(
 
966
/*=========*/
 
967
                        /* out: 0 on success */
 
968
        )
 
969
{
 
970
 
 
971
        if ((innodb_cmp_schema_table= new InfoSchemaTable) == NULL)
 
972
                return(1);
 
973
 
 
974
        innodb_cmp_schema_table->setColumnInfo(i_s_cmp_fields_info);
 
975
        innodb_cmp_schema_table->setInfoSchemaMethods(&cmp_methods);
 
976
        innodb_cmp_schema_table->setTableName("INNODB_CMP");
 
977
 
 
978
        return(0);
 
979
}
 
980
 
 
981
/***********************************************************************
 
982
Bind the dynamic table information_schema.innodb_cmp_reset. */
 
983
int
 
984
i_s_cmp_reset_init(
 
985
/*===============*/
 
986
                        /* out: 0 on success */
 
987
        )       /* in/out: table schema object */
 
988
{
 
989
 
 
990
        if ((innodb_cmp_reset_schema_table= new InfoSchemaTable) == NULL)
 
991
                return(1);
 
992
 
 
993
        innodb_cmp_reset_schema_table->setColumnInfo(i_s_cmp_fields_info);
 
994
        innodb_cmp_reset_schema_table->setInfoSchemaMethods(&cmp_reset_methods);
 
995
        innodb_cmp_reset_schema_table->setTableName("INNODB_CMP_RESET");
 
996
 
 
997
        return(0);
 
998
}
 
999
 
 
1000
 
 
1001
 
 
1002
/* Fields of the dynamic table information_schema.innodb_cmpmem. */
 
1003
static ColumnInfo       i_s_cmpmem_fields_info[] =
 
1004
{
 
1005
        ColumnInfo("page_size",
 
1006
                  5,
 
1007
                  DRIZZLE_TYPE_LONG,
 
1008
                  0,
 
1009
                  0,
 
1010
                  "Buddy Block Size",
 
1011
                  SKIP_OPEN_TABLE),
 
1012
 
 
1013
        ColumnInfo("pages_used",
 
1014
                  MY_INT32_NUM_DECIMAL_DIGITS,
 
1015
                  DRIZZLE_TYPE_LONG,
 
1016
                  0,
 
1017
                  0,
 
1018
                  "Currently in Use",
 
1019
                  SKIP_OPEN_TABLE),
 
1020
 
 
1021
        ColumnInfo("pages_free",
 
1022
                  MY_INT32_NUM_DECIMAL_DIGITS,
 
1023
                  DRIZZLE_TYPE_LONG,
 
1024
                  0,
 
1025
                  0,
 
1026
                  "Currently Available",
 
1027
                  SKIP_OPEN_TABLE),
 
1028
 
 
1029
        ColumnInfo("relocation_ops",
 
1030
                  MY_INT64_NUM_DECIMAL_DIGITS,
 
1031
                  DRIZZLE_TYPE_LONGLONG,
 
1032
                  0,
 
1033
                  0,
 
1034
                  "Total Number of Relocations",
 
1035
                  SKIP_OPEN_TABLE),
 
1036
 
 
1037
        ColumnInfo("relocation_time",
 
1038
                  MY_INT32_NUM_DECIMAL_DIGITS,
 
1039
                  DRIZZLE_TYPE_LONG,
 
1040
                  0,
 
1041
                  0,
 
1042
                  "Total Duration of Relocations, in Seconds",
 
1043
                  SKIP_OPEN_TABLE),
 
1044
 
 
1045
        ColumnInfo()
 
1046
};
 
1047
 
 
1048
/***********************************************************************
 
1049
Fill the dynamic table information_schema.innodb_cmpmem or
 
1050
innodb_cmpmem_reset. */
 
1051
static
 
1052
int
 
1053
i_s_cmpmem_fill_low(
 
1054
/*================*/
 
1055
                                /* out: 0 on success, 1 on failure */
 
1056
        Session*                session,        /* in: thread */
 
1057
        TableList*      tables, /* in/out: tables to fill */
 
1058
        COND*           ,       /* in: condition (ignored) */
 
1059
        ibool           reset)  /* in: TRUE=reset cumulated counts */
 
1060
{
 
1061
        Table*  table   = (Table *) tables->table;
 
1062
        int     status  = 0;
 
1063
 
 
1064
        RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name);
 
1065
 
 
1066
        buf_pool_mutex_enter();
 
1067
 
 
1068
        for (uint x = 0; x <= BUF_BUDDY_SIZES; x++) {
 
1069
                buf_buddy_stat_t*       buddy_stat = &buf_buddy_stat[x];
 
1070
 
 
1071
                table->field[0]->store(BUF_BUDDY_LOW << x);
 
1072
                table->field[1]->store(buddy_stat->used);
 
1073
                table->field[2]->store(UNIV_LIKELY(x < BUF_BUDDY_SIZES)
 
1074
                                       ? UT_LIST_GET_LEN(buf_pool->zip_free[x])
 
1075
                                       : 0);
 
1076
                table->field[3]->store((int64_t) buddy_stat->relocated, true);
 
1077
                table->field[4]->store(
 
1078
                        (ulong) (buddy_stat->relocated_usec / 1000000));
 
1079
 
 
1080
                if (reset) {
 
1081
                        /* This is protected by buf_pool_mutex. */
 
1082
                        buddy_stat->relocated = 0;
 
1083
                        buddy_stat->relocated_usec = 0;
 
1084
                }
 
1085
 
 
1086
                if (schema_table_store_record(session, table)) {
 
1087
                        status = 1;
 
1088
                        break;
 
1089
                }
 
1090
        }
 
1091
 
 
1092
        buf_pool_mutex_exit();
 
1093
        return(status);
 
1094
}
 
1095
 
 
1096
/***********************************************************************
 
1097
Fill the dynamic table information_schema.innodb_cmpmem. */
 
1098
int
 
1099
CmpmemISMethods::fillTable(
 
1100
/*============*/
 
1101
                                /* out: 0 on success, 1 on failure */
 
1102
        Session*                session,        /* in: thread */
 
1103
        TableList*      tables, /* in/out: tables to fill */
 
1104
        COND*           cond)   /* in: condition (ignored) */
 
1105
{
 
1106
        return(i_s_cmpmem_fill_low(session, tables, cond, FALSE));
 
1107
}
 
1108
 
 
1109
/***********************************************************************
 
1110
Fill the dynamic table information_schema.innodb_cmpmem_reset. */
 
1111
int
 
1112
CmpmemResetISMethods::fillTable(
 
1113
/*==================*/
 
1114
                                /* out: 0 on success, 1 on failure */
 
1115
        Session*                session,        /* in: thread */
 
1116
        TableList*      tables, /* in/out: tables to fill */
 
1117
        COND*           cond)   /* in: condition (ignored) */
 
1118
{
 
1119
        return(i_s_cmpmem_fill_low(session, tables, cond, TRUE));
 
1120
}
 
1121
 
 
1122
/***********************************************************************
 
1123
Bind the dynamic table information_schema.innodb_cmpmem. */
 
1124
int
 
1125
i_s_cmpmem_init(
 
1126
/*============*/
 
1127
                        /* out: 0 on success */
 
1128
        )
 
1129
{
 
1130
 
 
1131
        if ((innodb_cmpmem_schema_table= new InfoSchemaTable) == NULL)
 
1132
                return(1);
 
1133
 
 
1134
        innodb_cmpmem_schema_table->setColumnInfo(i_s_cmpmem_fields_info);
 
1135
        innodb_cmpmem_schema_table->setInfoSchemaMethods(&cmpmem_methods);
 
1136
        innodb_cmpmem_schema_table->setTableName("INNODB_CMPMEM");
 
1137
 
 
1138
        return(0);
 
1139
}
 
1140
 
 
1141
/***********************************************************************
 
1142
Bind the dynamic table information_schema.innodb_cmpmem_reset. */
 
1143
int
 
1144
i_s_cmpmem_reset_init(
 
1145
/*==================*/
 
1146
                        /* out: 0 on success */
 
1147
        )
 
1148
{
 
1149
        if ((innodb_cmpmem_reset_schema_table= new InfoSchemaTable) == NULL)
 
1150
                return(1);
 
1151
 
 
1152
        innodb_cmpmem_reset_schema_table->setColumnInfo(i_s_cmpmem_fields_info);
 
1153
        innodb_cmpmem_reset_schema_table->setInfoSchemaMethods(&cmpmem_reset_methods);
 
1154
        innodb_cmpmem_reset_schema_table->setTableName("INNODB_CMPMEM_RESET");
 
1155
 
 
1156
        return(0);
 
1157
}
 
1158
 
 
1159
 
 
1160
/***********************************************************************
 
1161
Unbind a dynamic INFORMATION_SCHEMA table. */
 
1162
int
 
1163
i_s_common_deinit(
 
1164
/*==============*/
 
1165
                        /* out: 0 on success */
 
1166
        PluginRegistry &registry)       /* in/out: table schema object */
 
1167
{
 
1168
        registry.remove(innodb_trx_schema_table);
 
1169
        registry.remove(innodb_locks_schema_table);
 
1170
        registry.remove(innodb_lock_waits_schema_table);
 
1171
        registry.remove(innodb_cmp_schema_table);
 
1172
        registry.remove(innodb_cmp_reset_schema_table);
 
1173
        registry.remove(innodb_cmpmem_schema_table);
 
1174
        registry.remove(innodb_cmpmem_reset_schema_table);
 
1175
 
 
1176
        delete innodb_trx_schema_table;
 
1177
        delete innodb_locks_schema_table;
 
1178
        delete innodb_lock_waits_schema_table;
 
1179
        delete innodb_cmp_schema_table;
 
1180
        delete innodb_cmp_reset_schema_table;
 
1181
        delete innodb_cmpmem_schema_table;
 
1182
        delete innodb_cmpmem_reset_schema_table;
 
1183
 
 
1184
        return(0);
 
1185
}