~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Monty Taylor
  • Date: 2009-09-30 07:01:32 UTC
  • mto: This revision was merged to the branch mainline in revision 1184.
  • Revision ID: mordred@inaugust.com-20090930070132-b1ol1xu1rpajdddy
Small namespace cleanup.

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/plugin/info_schema_table.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
drizzled::plugin::InfoSchemaTable *innodb_trx_schema_table= NULL;
 
72
drizzled::plugin::InfoSchemaTable *innodb_locks_schema_table= NULL;
 
73
drizzled::plugin::InfoSchemaTable *innodb_lock_waits_schema_table= NULL;
 
74
drizzled::plugin::InfoSchemaTable *innodb_cmp_schema_table= NULL;
 
75
drizzled::plugin::InfoSchemaTable *innodb_cmp_reset_schema_table= NULL;
 
76
drizzled::plugin::InfoSchemaTable *innodb_cmpmem_schema_table= NULL;
 
77
drizzled::plugin::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 drizzled::plugin::ColumnInfo     innodb_trx_fields_info[] =
 
203
{
 
204
#define IDX_TRX_ID              0
 
205
        drizzled::plugin::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
        drizzled::plugin::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
        drizzled::plugin::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
        drizzled::plugin::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
        drizzled::plugin::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
        drizzled::plugin::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
        drizzled::plugin::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
        drizzled::plugin::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
        drizzled::plugin::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 drizzled::plugin::InfoSchemaTable("INNODB_TRX")) == NULL)
 
371
                return(1);
 
372
 
 
373
        innodb_trx_schema_table->setColumnInfo(innodb_trx_fields_info);
 
374
        innodb_trx_schema_table->setInfoSchemaMethods(&trx_methods);
 
375
 
 
376
        return(0);
 
377
}
 
378
 
 
379
 
 
380
/* Fields of the dynamic table INFORMATION_SCHEMA.innodb_locks */
 
381
static drizzled::plugin::ColumnInfo innodb_locks_fields_info[] =
 
382
{
 
383
#define IDX_LOCK_ID             0
 
384
        drizzled::plugin::ColumnInfo("lock_id",
 
385
                  TRX_I_S_LOCK_ID_MAX_LEN + 1,
 
386
                  DRIZZLE_TYPE_VARCHAR,
 
387
                  0,
 
388
                  0,
 
389
                  "",
 
390
                  SKIP_OPEN_TABLE),
 
391
 
 
392
#define IDX_LOCK_TRX_ID         1
 
393
        drizzled::plugin::ColumnInfo("lock_trx_id",
 
394
                  TRX_ID_MAX_LEN + 1,
 
395
                  DRIZZLE_TYPE_VARCHAR,
 
396
                  0,
 
397
                  0,
 
398
                  "",
 
399
                  SKIP_OPEN_TABLE),
 
400
 
 
401
#define IDX_LOCK_MODE           2
 
402
        drizzled::plugin::ColumnInfo("lock_mode",
 
403
         /* S[,GAP] X[,GAP] IS[,GAP] IX[,GAP] AUTO_INC UNKNOWN */
 
404
                  32,
 
405
                  DRIZZLE_TYPE_VARCHAR,
 
406
                  0,
 
407
                  0,
 
408
                  "",
 
409
                  SKIP_OPEN_TABLE),
 
410
 
 
411
#define IDX_LOCK_TYPE           3
 
412
        drizzled::plugin::ColumnInfo("lock_type",
 
413
                  32, /* RECORD|TABLE|UNKNOWN */
 
414
                  DRIZZLE_TYPE_VARCHAR,
 
415
                  0,
 
416
                  0,
 
417
                  "",
 
418
                  SKIP_OPEN_TABLE),
 
419
 
 
420
#define IDX_LOCK_TABLE          4
 
421
        drizzled::plugin::ColumnInfo("lock_table",
 
422
                  1024,
 
423
                  DRIZZLE_TYPE_VARCHAR,
 
424
                  0,
 
425
                  0,
 
426
                  "",
 
427
                  SKIP_OPEN_TABLE),
 
428
 
 
429
#define IDX_LOCK_INDEX          5
 
430
        drizzled::plugin::ColumnInfo("lock_index",
 
431
                  1024,
 
432
                  DRIZZLE_TYPE_VARCHAR,
 
433
                  0,
 
434
                  MY_I_S_MAYBE_NULL,
 
435
                  "",
 
436
                  SKIP_OPEN_TABLE),
 
437
 
 
438
#define IDX_LOCK_SPACE          6
 
439
        drizzled::plugin::ColumnInfo("lock_space",
 
440
                  MY_INT64_NUM_DECIMAL_DIGITS,
 
441
                  DRIZZLE_TYPE_LONGLONG,
 
442
                  0,
 
443
                  MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL,
 
444
                  "",
 
445
                  SKIP_OPEN_TABLE),
 
446
 
 
447
#define IDX_LOCK_PAGE           7
 
448
        drizzled::plugin::ColumnInfo("lock_page",
 
449
                  MY_INT64_NUM_DECIMAL_DIGITS,
 
450
                  DRIZZLE_TYPE_LONGLONG,
 
451
                  0,
 
452
                  MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL,
 
453
                  "",
 
454
                  SKIP_OPEN_TABLE),
 
455
 
 
456
#define IDX_LOCK_REC            8
 
457
        drizzled::plugin::ColumnInfo("lock_rec",
 
458
                  MY_INT64_NUM_DECIMAL_DIGITS,
 
459
                  DRIZZLE_TYPE_LONGLONG,
 
460
                  0,
 
461
                  MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL,
 
462
                  "",
 
463
                  SKIP_OPEN_TABLE),
 
464
 
 
465
#define IDX_LOCK_DATA           9
 
466
        drizzled::plugin::ColumnInfo("lock_data",
 
467
                  TRX_I_S_LOCK_DATA_MAX_LEN,
 
468
                  DRIZZLE_TYPE_VARCHAR,
 
469
                  0,
 
470
                  MY_I_S_MAYBE_NULL,
 
471
                  "",
 
472
                  SKIP_OPEN_TABLE),
 
473
 
 
474
        drizzled::plugin::ColumnInfo()
 
475
};
 
476
 
 
477
/***********************************************************************
 
478
Read data from cache buffer and fill the INFORMATION_SCHEMA.innodb_locks
 
479
table with it. */
 
480
static
 
481
int
 
482
fill_innodb_locks_from_cache(
 
483
/*=========================*/
 
484
                                        /* out: 0 on success */
 
485
        trx_i_s_cache_t*        cache,  /* in: cache to read from */
 
486
        Session*                        session,        /* in: MySQL client connection */
 
487
        Table*                  table)  /* in/out: fill this table */
 
488
{
 
489
        Field** fields;
 
490
        ulint   rows_num;
 
491
        char    lock_id[TRX_I_S_LOCK_ID_MAX_LEN + 1];
 
492
        ulint   i;
 
493
 
 
494
        fields = table->field;
 
495
 
 
496
        rows_num = trx_i_s_cache_get_rows_used(cache,
 
497
                                               I_S_INNODB_LOCKS);
 
498
 
 
499
        for (i = 0; i < rows_num; i++) {
 
500
 
 
501
                i_s_locks_row_t*        row;
 
502
 
 
503
                /* note that the decoded database or table name is
 
504
                never expected to be longer than NAME_LEN;
 
505
                NAME_LEN for database name
 
506
                2 for surrounding quotes around database name
 
507
                NAME_LEN for table name
 
508
                2 for surrounding quotes around table name
 
509
                1 for the separating dot (.)
 
510
                9 for the #mysql50# prefix */
 
511
                char                    buf[2 * NAME_LEN + 14];
 
512
                const char*             bufend;
 
513
 
 
514
                char                    lock_trx_id[TRX_ID_MAX_LEN + 1];
 
515
 
 
516
                row = (i_s_locks_row_t*)
 
517
                        trx_i_s_cache_get_nth_row(
 
518
                                cache, I_S_INNODB_LOCKS, i);
 
519
 
 
520
                /* lock_id */
 
521
                trx_i_s_create_lock_id(row, lock_id, sizeof(lock_id));
 
522
                OK(field_store_string(fields[IDX_LOCK_ID],
 
523
                                      lock_id));
 
524
 
 
525
                /* lock_trx_id */
 
526
                ut_snprintf(lock_trx_id, sizeof(lock_trx_id),
 
527
                            TRX_ID_FMT, row->lock_trx_id);
 
528
                OK(field_store_string(fields[IDX_LOCK_TRX_ID], lock_trx_id));
 
529
 
 
530
                /* lock_mode */
 
531
                OK(field_store_string(fields[IDX_LOCK_MODE],
 
532
                                      row->lock_mode));
 
533
 
 
534
                /* lock_type */
 
535
                OK(field_store_string(fields[IDX_LOCK_TYPE],
 
536
                                      row->lock_type));
 
537
 
 
538
                /* lock_table */
 
539
                bufend = innobase_convert_name(buf, sizeof(buf),
 
540
                                               row->lock_table,
 
541
                                               strlen(row->lock_table),
 
542
                                               session, TRUE);
 
543
                OK(fields[IDX_LOCK_TABLE]->store(buf, bufend - buf,
 
544
                                                 system_charset_info));
 
545
 
 
546
                /* lock_index */
 
547
                if (row->lock_index != NULL) {
 
548
 
 
549
                        bufend = innobase_convert_name(buf, sizeof(buf),
 
550
                                                       row->lock_index,
 
551
                                                       strlen(row->lock_index),
 
552
                                                       session, FALSE);
 
553
                        OK(fields[IDX_LOCK_INDEX]->store(buf, bufend - buf,
 
554
                                                         system_charset_info));
 
555
                        fields[IDX_LOCK_INDEX]->set_notnull();
 
556
                } else {
 
557
 
 
558
                        fields[IDX_LOCK_INDEX]->set_null();
 
559
                }
 
560
 
 
561
                /* lock_space */
 
562
                OK(field_store_ulint(fields[IDX_LOCK_SPACE],
 
563
                                     row->lock_space));
 
564
 
 
565
                /* lock_page */
 
566
                OK(field_store_ulint(fields[IDX_LOCK_PAGE],
 
567
                                     row->lock_page));
 
568
 
 
569
                /* lock_rec */
 
570
                OK(field_store_ulint(fields[IDX_LOCK_REC],
 
571
                                     row->lock_rec));
 
572
 
 
573
                /* lock_data */
 
574
                OK(field_store_string(fields[IDX_LOCK_DATA],
 
575
                                      row->lock_data));
 
576
 
 
577
                OK(schema_table_store_record(session, table));
 
578
        }
 
579
 
 
580
        return(0);
 
581
}
 
582
 
 
583
/***********************************************************************
 
584
Bind the dynamic table INFORMATION_SCHEMA.innodb_locks */
 
585
int
 
586
innodb_locks_init(
 
587
/*==============*/
 
588
                        /* out: 0 on success */
 
589
        )       /* in/out: table schema object */
 
590
{
 
591
 
 
592
        if ((innodb_locks_schema_table= new drizzled::plugin::InfoSchemaTable("INNODB_LOCKS")) == NULL)
 
593
                return(1);
 
594
 
 
595
        innodb_locks_schema_table->setColumnInfo(innodb_locks_fields_info);
 
596
        innodb_locks_schema_table->setInfoSchemaMethods(&trx_methods);
 
597
        return(0);
 
598
}
 
599
 
 
600
 
 
601
/* Fields of the dynamic table INFORMATION_SCHEMA.innodb_lock_waits */
 
602
static drizzled::plugin::ColumnInfo innodb_lock_waits_fields_info[] =
 
603
{
 
604
#define IDX_REQUESTING_TRX_ID   0
 
605
        drizzled::plugin::ColumnInfo("requesting_trx_id",
 
606
                  TRX_ID_MAX_LEN + 1,
 
607
                  DRIZZLE_TYPE_VARCHAR,
 
608
                  0,
 
609
                  0,
 
610
                  "",
 
611
                  SKIP_OPEN_TABLE),
 
612
 
 
613
#define IDX_REQUESTED_LOCK_ID   1
 
614
        drizzled::plugin::ColumnInfo("requested_lock_id",
 
615
                  TRX_I_S_LOCK_ID_MAX_LEN + 1,
 
616
                  DRIZZLE_TYPE_VARCHAR,
 
617
                  0,
 
618
                  0,
 
619
                  "",
 
620
                  SKIP_OPEN_TABLE),
 
621
 
 
622
#define IDX_BLOCKING_TRX_ID     2
 
623
        drizzled::plugin::ColumnInfo("blocking_trx_id",
 
624
                  TRX_ID_MAX_LEN + 1,
 
625
                  DRIZZLE_TYPE_VARCHAR,
 
626
                  0,
 
627
                  0,
 
628
                  "",
 
629
                  SKIP_OPEN_TABLE),
 
630
 
 
631
#define IDX_BLOCKING_LOCK_ID    3
 
632
        drizzled::plugin::ColumnInfo("blocking_lock_id",
 
633
                  TRX_I_S_LOCK_ID_MAX_LEN + 1,
 
634
                  DRIZZLE_TYPE_VARCHAR,
 
635
                  0,
 
636
                  0,
 
637
                  "",
 
638
                  SKIP_OPEN_TABLE),
 
639
 
 
640
        drizzled::plugin::ColumnInfo()
 
641
};
 
642
 
 
643
/***********************************************************************
 
644
Read data from cache buffer and fill the
 
645
INFORMATION_SCHEMA.innodb_lock_waits table with it. */
 
646
static
 
647
int
 
648
fill_innodb_lock_waits_from_cache(
 
649
/*==============================*/
 
650
                                        /* out: 0 on success */
 
651
        trx_i_s_cache_t*        cache,  /* in: cache to read from */
 
652
        Session*                        session,        /* in: used to call
 
653
                                        schema_table_store_record() */
 
654
        Table*                  table)  /* in/out: fill this table */
 
655
{
 
656
        Field** fields;
 
657
        ulint   rows_num;
 
658
        char    requested_lock_id[TRX_I_S_LOCK_ID_MAX_LEN + 1];
 
659
        char    blocking_lock_id[TRX_I_S_LOCK_ID_MAX_LEN + 1];
 
660
        ulint   i;
 
661
 
 
662
        fields = table->field;
 
663
 
 
664
        rows_num = trx_i_s_cache_get_rows_used(cache,
 
665
                                               I_S_INNODB_LOCK_WAITS);
 
666
 
 
667
        for (i = 0; i < rows_num; i++) {
 
668
 
 
669
                i_s_lock_waits_row_t*   row;
 
670
 
 
671
                char    requesting_trx_id[TRX_ID_MAX_LEN + 1];
 
672
                char    blocking_trx_id[TRX_ID_MAX_LEN + 1];
 
673
 
 
674
                row = (i_s_lock_waits_row_t*)
 
675
                        trx_i_s_cache_get_nth_row(
 
676
                                cache, I_S_INNODB_LOCK_WAITS, i);
 
677
 
 
678
                /* requesting_trx_id */
 
679
                ut_snprintf(requesting_trx_id, sizeof(requesting_trx_id),
 
680
                            TRX_ID_FMT, row->requested_lock_row->lock_trx_id);
 
681
                OK(field_store_string(fields[IDX_REQUESTING_TRX_ID],
 
682
                                      requesting_trx_id));
 
683
 
 
684
                /* requested_lock_id */
 
685
                OK(field_store_string(
 
686
                           fields[IDX_REQUESTED_LOCK_ID],
 
687
                           trx_i_s_create_lock_id(
 
688
                                   row->requested_lock_row,
 
689
                                   requested_lock_id,
 
690
                                   sizeof(requested_lock_id))));
 
691
 
 
692
                /* blocking_trx_id */
 
693
                ut_snprintf(blocking_trx_id, sizeof(blocking_trx_id),
 
694
                            TRX_ID_FMT, row->blocking_lock_row->lock_trx_id);
 
695
                OK(field_store_string(fields[IDX_BLOCKING_TRX_ID],
 
696
                                      blocking_trx_id));
 
697
 
 
698
                /* blocking_lock_id */
 
699
                OK(field_store_string(
 
700
                           fields[IDX_BLOCKING_LOCK_ID],
 
701
                           trx_i_s_create_lock_id(
 
702
                                   row->blocking_lock_row,
 
703
                                   blocking_lock_id,
 
704
                                   sizeof(blocking_lock_id))));
 
705
 
 
706
                OK(schema_table_store_record(session, table));
 
707
        }
 
708
 
 
709
        return(0);
 
710
}
 
711
 
 
712
/***********************************************************************
 
713
Bind the dynamic table INFORMATION_SCHEMA.innodb_lock_waits */
 
714
int
 
715
innodb_lock_waits_init(
 
716
/*===================*/
 
717
                        /* out: 0 on success */
 
718
        )
 
719
{
 
720
 
 
721
        if ((innodb_lock_waits_schema_table= new drizzled::plugin::InfoSchemaTable("INNODB_LOCK_WAITS")) == NULL)
 
722
                return(1);
 
723
 
 
724
        innodb_lock_waits_schema_table->setColumnInfo(innodb_lock_waits_fields_info);
 
725
        innodb_lock_waits_schema_table->setInfoSchemaMethods(&trx_methods);
 
726
 
 
727
 
 
728
        return(0);
 
729
}
 
730
 
 
731
 
 
732
/***********************************************************************
 
733
Common function to fill any of the dynamic tables:
 
734
INFORMATION_SCHEMA.innodb_trx
 
735
INFORMATION_SCHEMA.innodb_locks
 
736
INFORMATION_SCHEMA.innodb_lock_waits */
 
737
int
 
738
TrxISMethods::fillTable(
 
739
/*======================*/
 
740
                                /* out: 0 on success */
 
741
        Session*                session,        /* in: thread */
 
742
        TableList*      tables, /* in/out: tables to fill */
 
743
        COND*           )       /* in: condition (not used) */
 
744
{
 
745
        const char*             table_name;
 
746
        int                     ret;
 
747
        trx_i_s_cache_t*        cache;
 
748
 
 
749
        /* minimize the number of places where global variables are
 
750
        referenced */
 
751
        cache = trx_i_s_cache;
 
752
 
 
753
        /* which table we have to fill? */
 
754
        table_name = tables->schema_table_name;
 
755
        /* or table_name = tables->schema_table->table_name; */
 
756
 
 
757
        RETURN_IF_INNODB_NOT_STARTED(table_name);
 
758
 
 
759
        /* update the cache */
 
760
        trx_i_s_cache_start_write(cache);
 
761
        trx_i_s_possibly_fetch_data_into_cache(cache);
 
762
        trx_i_s_cache_end_write(cache);
 
763
 
 
764
        if (trx_i_s_cache_is_truncated(cache)) {
 
765
 
 
766
                /* XXX show warning to user if possible */
 
767
                fprintf(stderr, "Warning: data in %s truncated due to "
 
768
                        "memory limit of %d bytes\n", table_name,
 
769
                        TRX_I_S_MEM_LIMIT);
 
770
        }
 
771
 
 
772
        ret = 0;
 
773
 
 
774
        trx_i_s_cache_start_read(cache);
 
775
 
 
776
        if (innobase_strcasecmp(table_name, "innodb_trx") == 0) {
 
777
 
 
778
                if (fill_innodb_trx_from_cache(
 
779
                        cache, session, tables->table) != 0) {
 
780
 
 
781
                        ret = 1;
 
782
                }
 
783
 
 
784
        } else if (innobase_strcasecmp(table_name, "innodb_locks") == 0) {
 
785
 
 
786
                if (fill_innodb_locks_from_cache(
 
787
                        cache, session, tables->table) != 0) {
 
788
 
 
789
                        ret = 1;
 
790
                }
 
791
 
 
792
        } else if (innobase_strcasecmp(table_name, "innodb_lock_waits") == 0) {
 
793
 
 
794
                if (fill_innodb_lock_waits_from_cache(
 
795
                        cache, session, tables->table) != 0) {
 
796
 
 
797
                        ret = 1;
 
798
                }
 
799
 
 
800
        } else {
 
801
 
 
802
                /* huh! what happened!? */
 
803
                fprintf(stderr,
 
804
                        "InnoDB: trx_i_s_common_fill_table() was "
 
805
                        "called to fill unknown table: %s.\n"
 
806
                        "This function only knows how to fill "
 
807
                        "innodb_trx, innodb_locks and "
 
808
                        "innodb_lock_waits tables.\n", table_name);
 
809
 
 
810
                ret = 1;
 
811
        }
 
812
 
 
813
        trx_i_s_cache_end_read(cache);
 
814
 
 
815
#if 0
 
816
        return(ret);
 
817
#else
 
818
        /* if this function returns something else than 0 then a
 
819
        deadlock occurs between the mysqld server and mysql client,
 
820
        see http://bugs.mysql.com/29900 ; when that bug is resolved
 
821
        we can enable the return(ret) above */
 
822
        return(0);
 
823
#endif
 
824
}
 
825
 
 
826
/* Fields of the dynamic table information_schema.innodb_cmp. */
 
827
static drizzled::plugin::ColumnInfo     i_s_cmp_fields_info[] =
 
828
{
 
829
        drizzled::plugin::ColumnInfo("page_size",
 
830
                  5,
 
831
                  DRIZZLE_TYPE_LONG,
 
832
                  0,
 
833
                  0,
 
834
                  "Compressed Page Size",
 
835
                  SKIP_OPEN_TABLE),
 
836
 
 
837
        drizzled::plugin::ColumnInfo("compress_ops",
 
838
                  MY_INT32_NUM_DECIMAL_DIGITS,
 
839
                  DRIZZLE_TYPE_LONG,
 
840
                  0,
 
841
                  0,
 
842
                  "Total Number of Compressions",
 
843
                  SKIP_OPEN_TABLE),
 
844
 
 
845
        drizzled::plugin::ColumnInfo("compress_ops_ok",
 
846
                  MY_INT32_NUM_DECIMAL_DIGITS,
 
847
                  DRIZZLE_TYPE_LONG,
 
848
                  0,
 
849
                  0,
 
850
                  "Total Number of Successful Compressions",
 
851
                  SKIP_OPEN_TABLE),
 
852
 
 
853
        drizzled::plugin::ColumnInfo("compress_time",
 
854
                  MY_INT32_NUM_DECIMAL_DIGITS,
 
855
                  DRIZZLE_TYPE_LONG,
 
856
                  0,
 
857
                  0,
 
858
                  "Total Duration of Compressions in Seconds",
 
859
                  SKIP_OPEN_TABLE),
 
860
 
 
861
        drizzled::plugin::ColumnInfo("uncompress_ops",
 
862
                  MY_INT32_NUM_DECIMAL_DIGITS,
 
863
                  DRIZZLE_TYPE_LONG,
 
864
                  0,
 
865
                  0,
 
866
                  "Total Number of Decompressions",
 
867
                  SKIP_OPEN_TABLE),
 
868
 
 
869
        drizzled::plugin::ColumnInfo("uncompress_time",
 
870
                  MY_INT32_NUM_DECIMAL_DIGITS,
 
871
                  DRIZZLE_TYPE_LONG,
 
872
                  0,
 
873
                  0,
 
874
                  "Total Duration of Decompressions in Seconds",
 
875
                  SKIP_OPEN_TABLE),
 
876
 
 
877
        drizzled::plugin::ColumnInfo()
 
878
};
 
879
 
 
880
 
 
881
/***********************************************************************
 
882
Fill the dynamic table information_schema.innodb_cmp or
 
883
innodb_cmp_reset. */
 
884
static
 
885
int
 
886
i_s_cmp_fill_low(
 
887
/*=============*/
 
888
                                /* out: 0 on success, 1 on failure */
 
889
        Session*                session,        /* in: thread */
 
890
        TableList*      tables, /* in/out: tables to fill */
 
891
        COND*           ,       /* in: condition (ignored) */
 
892
        ibool           reset)  /* in: TRUE=reset cumulated counts */
 
893
{
 
894
        Table*  table   = (Table *) tables->table;
 
895
        int     status  = 0;
 
896
 
 
897
 
 
898
        RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name);
 
899
 
 
900
        for (uint i = 0; i < PAGE_ZIP_NUM_SSIZE - 1; i++) {
 
901
                page_zip_stat_t*        zip_stat = &page_zip_stat[i];
 
902
 
 
903
                table->field[0]->store(PAGE_ZIP_MIN_SIZE << i);
 
904
 
 
905
                /* The cumulated counts are not protected by any
 
906
                mutex.  Thus, some operation in page0zip.c could
 
907
                increment a counter between the time we read it and
 
908
                clear it.  We could introduce mutex protection, but it
 
909
                could cause a measureable performance hit in
 
910
                page0zip.c. */
 
911
                table->field[1]->store(zip_stat->compressed);
 
912
                table->field[2]->store(zip_stat->compressed_ok);
 
913
                table->field[3]->store(
 
914
                        (ulong) (zip_stat->compressed_usec / 1000000));
 
915
                table->field[4]->store(zip_stat->decompressed);
 
916
                table->field[5]->store(
 
917
                        (ulong) (zip_stat->decompressed_usec / 1000000));
 
918
 
 
919
                if (reset) {
 
920
                        memset(zip_stat, 0, sizeof *zip_stat);
 
921
                }
 
922
 
 
923
                if (schema_table_store_record(session, table)) {
 
924
                        status = 1;
 
925
                        break;
 
926
                }
 
927
        }
 
928
 
 
929
        return(status);
 
930
}
 
931
 
 
932
/***********************************************************************
 
933
Fill the dynamic table information_schema.innodb_cmp. */
 
934
int
 
935
CmpISMethods::fillTable(
 
936
/*=========*/
 
937
                                /* out: 0 on success, 1 on failure */
 
938
        Session*                session,        /* in: thread */
 
939
        TableList*      tables, /* in/out: tables to fill */
 
940
        COND*           cond)   /* in: condition (ignored) */
 
941
{
 
942
        return(i_s_cmp_fill_low(session, tables, cond, FALSE));
 
943
}
 
944
 
 
945
/***********************************************************************
 
946
Fill the dynamic table information_schema.innodb_cmp_reset. */
 
947
int
 
948
CmpResetISMethods::fillTable(
 
949
/*===============*/
 
950
                                /* out: 0 on success, 1 on failure */
 
951
        Session*                session,        /* in: thread */
 
952
        TableList*      tables, /* in/out: tables to fill */
 
953
        COND*           cond)   /* in: condition (ignored) */
 
954
{
 
955
        return(i_s_cmp_fill_low(session, tables, cond, TRUE));
 
956
}
 
957
 
 
958
 
 
959
/***********************************************************************
 
960
Bind the dynamic table information_schema.innodb_cmp. */
 
961
int
 
962
i_s_cmp_init(
 
963
/*=========*/
 
964
                        /* out: 0 on success */
 
965
        )
 
966
{
 
967
 
 
968
        if ((innodb_cmp_schema_table= new drizzled::plugin::InfoSchemaTable("INNODB_CMP")) == NULL)
 
969
                return(1);
 
970
 
 
971
        innodb_cmp_schema_table->setColumnInfo(i_s_cmp_fields_info);
 
972
        innodb_cmp_schema_table->setInfoSchemaMethods(&cmp_methods);
 
973
 
 
974
        return(0);
 
975
}
 
976
 
 
977
/***********************************************************************
 
978
Bind the dynamic table information_schema.innodb_cmp_reset. */
 
979
int
 
980
i_s_cmp_reset_init(
 
981
/*===============*/
 
982
                        /* out: 0 on success */
 
983
        )       /* in/out: table schema object */
 
984
{
 
985
 
 
986
        if ((innodb_cmp_reset_schema_table= new drizzled::plugin::InfoSchemaTable("INNODB_CMP_RESET")) == NULL)
 
987
                return(1);
 
988
 
 
989
        innodb_cmp_reset_schema_table->setColumnInfo(i_s_cmp_fields_info);
 
990
        innodb_cmp_reset_schema_table->setInfoSchemaMethods(&cmp_reset_methods);
 
991
 
 
992
        return(0);
 
993
}
 
994
 
 
995
 
 
996
 
 
997
/* Fields of the dynamic table information_schema.innodb_cmpmem. */
 
998
static drizzled::plugin::ColumnInfo     i_s_cmpmem_fields_info[] =
 
999
{
 
1000
        drizzled::plugin::ColumnInfo("page_size",
 
1001
                  5,
 
1002
                  DRIZZLE_TYPE_LONG,
 
1003
                  0,
 
1004
                  0,
 
1005
                  "Buddy Block Size",
 
1006
                  SKIP_OPEN_TABLE),
 
1007
 
 
1008
        drizzled::plugin::ColumnInfo("pages_used",
 
1009
                  MY_INT32_NUM_DECIMAL_DIGITS,
 
1010
                  DRIZZLE_TYPE_LONG,
 
1011
                  0,
 
1012
                  0,
 
1013
                  "Currently in Use",
 
1014
                  SKIP_OPEN_TABLE),
 
1015
 
 
1016
        drizzled::plugin::ColumnInfo("pages_free",
 
1017
                  MY_INT32_NUM_DECIMAL_DIGITS,
 
1018
                  DRIZZLE_TYPE_LONG,
 
1019
                  0,
 
1020
                  0,
 
1021
                  "Currently Available",
 
1022
                  SKIP_OPEN_TABLE),
 
1023
 
 
1024
        drizzled::plugin::ColumnInfo("relocation_ops",
 
1025
                  MY_INT64_NUM_DECIMAL_DIGITS,
 
1026
                  DRIZZLE_TYPE_LONGLONG,
 
1027
                  0,
 
1028
                  0,
 
1029
                  "Total Number of Relocations",
 
1030
                  SKIP_OPEN_TABLE),
 
1031
 
 
1032
        drizzled::plugin::ColumnInfo("relocation_time",
 
1033
                  MY_INT32_NUM_DECIMAL_DIGITS,
 
1034
                  DRIZZLE_TYPE_LONG,
 
1035
                  0,
 
1036
                  0,
 
1037
                  "Total Duration of Relocations, in Seconds",
 
1038
                  SKIP_OPEN_TABLE),
 
1039
 
 
1040
        drizzled::plugin::ColumnInfo()
 
1041
};
 
1042
 
 
1043
/***********************************************************************
 
1044
Fill the dynamic table information_schema.innodb_cmpmem or
 
1045
innodb_cmpmem_reset. */
 
1046
static
 
1047
int
 
1048
i_s_cmpmem_fill_low(
 
1049
/*================*/
 
1050
                                /* out: 0 on success, 1 on failure */
 
1051
        Session*                session,        /* in: thread */
 
1052
        TableList*      tables, /* in/out: tables to fill */
 
1053
        COND*           ,       /* in: condition (ignored) */
 
1054
        ibool           reset)  /* in: TRUE=reset cumulated counts */
 
1055
{
 
1056
        Table*  table   = (Table *) tables->table;
 
1057
        int     status  = 0;
 
1058
 
 
1059
        RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name);
 
1060
 
 
1061
        buf_pool_mutex_enter();
 
1062
 
 
1063
        for (uint x = 0; x <= BUF_BUDDY_SIZES; x++) {
 
1064
                buf_buddy_stat_t*       buddy_stat = &buf_buddy_stat[x];
 
1065
 
 
1066
                table->field[0]->store(BUF_BUDDY_LOW << x);
 
1067
                table->field[1]->store(buddy_stat->used);
 
1068
                table->field[2]->store(UNIV_LIKELY(x < BUF_BUDDY_SIZES)
 
1069
                                       ? UT_LIST_GET_LEN(buf_pool->zip_free[x])
 
1070
                                       : 0);
 
1071
                table->field[3]->store((int64_t) buddy_stat->relocated, true);
 
1072
                table->field[4]->store(
 
1073
                        (ulong) (buddy_stat->relocated_usec / 1000000));
 
1074
 
 
1075
                if (reset) {
 
1076
                        /* This is protected by buf_pool_mutex. */
 
1077
                        buddy_stat->relocated = 0;
 
1078
                        buddy_stat->relocated_usec = 0;
 
1079
                }
 
1080
 
 
1081
                if (schema_table_store_record(session, table)) {
 
1082
                        status = 1;
 
1083
                        break;
 
1084
                }
 
1085
        }
 
1086
 
 
1087
        buf_pool_mutex_exit();
 
1088
        return(status);
 
1089
}
 
1090
 
 
1091
/***********************************************************************
 
1092
Fill the dynamic table information_schema.innodb_cmpmem. */
 
1093
int
 
1094
CmpmemISMethods::fillTable(
 
1095
/*============*/
 
1096
                                /* out: 0 on success, 1 on failure */
 
1097
        Session*                session,        /* in: thread */
 
1098
        TableList*      tables, /* in/out: tables to fill */
 
1099
        COND*           cond)   /* in: condition (ignored) */
 
1100
{
 
1101
        return(i_s_cmpmem_fill_low(session, tables, cond, FALSE));
 
1102
}
 
1103
 
 
1104
/***********************************************************************
 
1105
Fill the dynamic table information_schema.innodb_cmpmem_reset. */
 
1106
int
 
1107
CmpmemResetISMethods::fillTable(
 
1108
/*==================*/
 
1109
                                /* out: 0 on success, 1 on failure */
 
1110
        Session*                session,        /* in: thread */
 
1111
        TableList*      tables, /* in/out: tables to fill */
 
1112
        COND*           cond)   /* in: condition (ignored) */
 
1113
{
 
1114
        return(i_s_cmpmem_fill_low(session, tables, cond, TRUE));
 
1115
}
 
1116
 
 
1117
/***********************************************************************
 
1118
Bind the dynamic table information_schema.innodb_cmpmem. */
 
1119
int
 
1120
i_s_cmpmem_init(
 
1121
/*============*/
 
1122
                        /* out: 0 on success */
 
1123
        )
 
1124
{
 
1125
 
 
1126
        if ((innodb_cmpmem_schema_table= new drizzled::plugin::InfoSchemaTable("INNODB_CMPMEM")) == NULL)
 
1127
                return(1);
 
1128
 
 
1129
        innodb_cmpmem_schema_table->setColumnInfo(i_s_cmpmem_fields_info);
 
1130
        innodb_cmpmem_schema_table->setInfoSchemaMethods(&cmpmem_methods);
 
1131
 
 
1132
        return(0);
 
1133
}
 
1134
 
 
1135
/***********************************************************************
 
1136
Bind the dynamic table information_schema.innodb_cmpmem_reset. */
 
1137
int
 
1138
i_s_cmpmem_reset_init(
 
1139
/*==================*/
 
1140
                        /* out: 0 on success */
 
1141
        )
 
1142
{
 
1143
        if ((innodb_cmpmem_reset_schema_table= new drizzled::plugin::InfoSchemaTable("INNODB_CMPMEM_RESET")) == NULL)
 
1144
                return(1);
 
1145
 
 
1146
        innodb_cmpmem_reset_schema_table->setColumnInfo(i_s_cmpmem_fields_info);
 
1147
        innodb_cmpmem_reset_schema_table->setInfoSchemaMethods(&cmpmem_reset_methods);
 
1148
        return(0);
 
1149
}
 
1150
 
 
1151
 
 
1152
/***********************************************************************
 
1153
Unbind a dynamic INFORMATION_SCHEMA table. */
 
1154
int
 
1155
i_s_common_deinit(
 
1156
/*==============*/
 
1157
                        /* out: 0 on success */
 
1158
        drizzled::plugin::Registry &registry)   /* in/out: table schema object */
 
1159
{
 
1160
        registry.remove(innodb_trx_schema_table);
 
1161
        registry.remove(innodb_locks_schema_table);
 
1162
        registry.remove(innodb_lock_waits_schema_table);
 
1163
        registry.remove(innodb_cmp_schema_table);
 
1164
        registry.remove(innodb_cmp_reset_schema_table);
 
1165
        registry.remove(innodb_cmpmem_schema_table);
 
1166
        registry.remove(innodb_cmpmem_reset_schema_table);
 
1167
 
 
1168
        delete innodb_trx_schema_table;
 
1169
        delete innodb_locks_schema_table;
 
1170
        delete innodb_lock_waits_schema_table;
 
1171
        delete innodb_cmp_schema_table;
 
1172
        delete innodb_cmp_reset_schema_table;
 
1173
        delete innodb_cmpmem_schema_table;
 
1174
        delete innodb_cmpmem_reset_schema_table;
 
1175
 
 
1176
        return(0);
 
1177
}