1
/*****************************************************************************
3
Copyright (c) 2007, 2009, Innobase Oy. All Rights Reserved.
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.
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.
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
17
*****************************************************************************/
19
/******************************************************
20
InnoDB INFORMATION SCHEMA tables interface to MySQL.
22
Created July 18, 2007 Vasil Dimov
23
*******************************************************/
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>
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 */
47
#include "handler0vars.h"
49
static const char plugin_author[] = "Innobase Oy";
56
#define RETURN_IF_INNODB_NOT_STARTED(plugin_name) \
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); \
69
#define STRUCT_FLD(name, value) value
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;
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;
86
Use the following types mapping:
88
C type ST_FIELD_INFO::field_type
89
---------------------------------
90
long DRIZZLE_TYPE_LONGLONG
91
(field_length=MY_INT64_NUM_DECIMAL_DIGITS)
93
long unsigned DRIZZLE_TYPE_LONGLONG
94
(field_length=MY_INT64_NUM_DECIMAL_DIGITS, field_flags=MY_I_S_UNSIGNED)
96
char* DRIZZLE_TYPE_STRING
99
float DRIZZLE_TYPE_FLOAT
100
(field_length=0 is ignored)
102
void* DRIZZLE_TYPE_LONGLONG
103
(field_length=MY_INT64_NUM_DECIMAL_DIGITS, field_flags=MY_I_S_UNSIGNED)
105
boolean (if else) DRIZZLE_TYPE_LONG
108
time_t DRIZZLE_TYPE_DATETIME
109
(field_length=0 ignored)
110
---------------------------------
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);
117
/***********************************************************************
118
Unbind a dynamic INFORMATION_SCHEMA table. */
120
/***********************************************************************
121
Auxiliary function to store time_t value in DRIZZLE_TYPE_DATETIME
127
/* out: 0 on success */
128
Field* field, /* in/out: target field for storage */
129
time_t time) /* in: value to store */
131
DRIZZLE_TIME my_time;
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);
140
localtime_r(&time, &tm_time);
141
localtime_to_TIME(&my_time, &tm_time);
142
my_time.time_type = DRIZZLE_TIMESTAMP_DATETIME;
145
return(field->store_time(&my_time, DRIZZLE_TIMESTAMP_DATETIME));
148
/***********************************************************************
149
Auxiliary function to store char* value in DRIZZLE_TYPE_STRING field. */
154
/* out: 0 on success */
155
Field* field, /* in/out: target field for storage */
156
const char* str) /* in: NUL-terminated utf-8 string,
163
ret = field->store(str, strlen(str),
164
system_charset_info);
165
field->set_notnull();
168
ret = 0; /* success */
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. */
182
/* out: 0 on success */
183
Field* field, /* in/out: target field for storage */
184
ulint n) /* in: value to store */
188
if (n != ULINT_UNDEFINED) {
190
ret = field->store(n);
191
field->set_notnull();
194
ret = 0; /* success */
201
/* Fields of the dynamic table INFORMATION_SCHEMA.innodb_trx */
202
static ColumnInfo innodb_trx_fields_info[] =
207
DRIZZLE_TYPE_VARCHAR,
213
#define IDX_TRX_STATE 1
214
ColumnInfo("trx_state",
215
TRX_QUE_STATE_STR_MAX_LEN + 1,
216
DRIZZLE_TYPE_VARCHAR,
222
#define IDX_TRX_STARTED 2
223
ColumnInfo("trx_started",
225
DRIZZLE_TYPE_DATETIME,
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,
240
#define IDX_TRX_WAIT_STARTED 4
241
ColumnInfo("trx_wait_started",
243
DRIZZLE_TYPE_DATETIME,
249
#define IDX_TRX_WEIGHT 5
250
ColumnInfo("trx_weight",
251
MY_INT64_NUM_DECIMAL_DIGITS,
252
DRIZZLE_TYPE_LONGLONG,
258
#define IDX_TRX_DRIZZLE_THREAD_ID 6
259
ColumnInfo("trx_mysql_thread_id",
260
MY_INT64_NUM_DECIMAL_DIGITS,
261
DRIZZLE_TYPE_LONGLONG,
267
#define IDX_TRX_QUERY 7
268
ColumnInfo("trx_query",
269
TRX_I_S_TRX_QUERY_MAX_LEN,
270
DRIZZLE_TYPE_VARCHAR,
279
/***********************************************************************
280
Read data from cache buffer and fill the INFORMATION_SCHEMA.innodb_trx
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 */
294
char lock_id[TRX_I_S_LOCK_ID_MAX_LEN + 1];
297
fields = table->field;
299
rows_num = trx_i_s_cache_get_rows_used(cache,
302
for (i = 0; i < rows_num; i++) {
305
char trx_id[TRX_ID_MAX_LEN + 1];
307
row = (i_s_trx_row_t*)
308
trx_i_s_cache_get_nth_row(
309
cache, I_S_INNODB_TRX, i);
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));
316
OK(field_store_string(fields[IDX_TRX_STATE],
320
OK(field_store_time_t(fields[IDX_TRX_STARTED],
321
(time_t) row->trx_started));
323
/* trx_requested_lock_id */
324
/* trx_wait_started */
325
if (row->trx_wait_started != 0) {
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 */
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();
340
fields[IDX_TRX_REQUESTED_LOCK_ID]->set_null();
341
fields[IDX_TRX_WAIT_STARTED]->set_null();
345
OK(fields[IDX_TRX_WEIGHT]->store((int64_t) row->trx_weight,
348
/* trx_mysql_thread_id */
349
OK(fields[IDX_TRX_DRIZZLE_THREAD_ID]->store(
350
row->trx_mysql_thread_id));
353
OK(field_store_string(fields[IDX_TRX_QUERY],
356
OK(schema_table_store_record(session, table));
362
/***********************************************************************
363
Bind the dynamic table INFORMATION_SCHEMA.innodb_trx */
367
/* out: 0 on success */
368
) /* in/out: table schema object */
370
if ((innodb_trx_schema_table= new InfoSchemaTable) == NULL)
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");
381
/* Fields of the dynamic table INFORMATION_SCHEMA.innodb_locks */
382
static ColumnInfo innodb_locks_fields_info[] =
384
#define IDX_LOCK_ID 0
385
ColumnInfo("lock_id",
386
TRX_I_S_LOCK_ID_MAX_LEN + 1,
387
DRIZZLE_TYPE_VARCHAR,
393
#define IDX_LOCK_TRX_ID 1
394
ColumnInfo("lock_trx_id",
396
DRIZZLE_TYPE_VARCHAR,
402
#define IDX_LOCK_MODE 2
403
ColumnInfo("lock_mode",
404
/* S[,GAP] X[,GAP] IS[,GAP] IX[,GAP] AUTO_INC UNKNOWN */
406
DRIZZLE_TYPE_VARCHAR,
412
#define IDX_LOCK_TYPE 3
413
ColumnInfo("lock_type",
414
32, /* RECORD|TABLE|UNKNOWN */
415
DRIZZLE_TYPE_VARCHAR,
421
#define IDX_LOCK_TABLE 4
422
ColumnInfo("lock_table",
424
DRIZZLE_TYPE_VARCHAR,
430
#define IDX_LOCK_INDEX 5
431
ColumnInfo("lock_index",
433
DRIZZLE_TYPE_VARCHAR,
439
#define IDX_LOCK_SPACE 6
440
ColumnInfo("lock_space",
441
MY_INT64_NUM_DECIMAL_DIGITS,
442
DRIZZLE_TYPE_LONGLONG,
444
MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL,
448
#define IDX_LOCK_PAGE 7
449
ColumnInfo("lock_page",
450
MY_INT64_NUM_DECIMAL_DIGITS,
451
DRIZZLE_TYPE_LONGLONG,
453
MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL,
457
#define IDX_LOCK_REC 8
458
ColumnInfo("lock_rec",
459
MY_INT64_NUM_DECIMAL_DIGITS,
460
DRIZZLE_TYPE_LONGLONG,
462
MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL,
466
#define IDX_LOCK_DATA 9
467
ColumnInfo("lock_data",
468
TRX_I_S_LOCK_DATA_MAX_LEN,
469
DRIZZLE_TYPE_VARCHAR,
478
/***********************************************************************
479
Read data from cache buffer and fill the INFORMATION_SCHEMA.innodb_locks
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 */
492
char lock_id[TRX_I_S_LOCK_ID_MAX_LEN + 1];
495
fields = table->field;
497
rows_num = trx_i_s_cache_get_rows_used(cache,
500
for (i = 0; i < rows_num; i++) {
502
i_s_locks_row_t* row;
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];
515
char lock_trx_id[TRX_ID_MAX_LEN + 1];
517
row = (i_s_locks_row_t*)
518
trx_i_s_cache_get_nth_row(
519
cache, I_S_INNODB_LOCKS, i);
522
trx_i_s_create_lock_id(row, lock_id, sizeof(lock_id));
523
OK(field_store_string(fields[IDX_LOCK_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));
532
OK(field_store_string(fields[IDX_LOCK_MODE],
536
OK(field_store_string(fields[IDX_LOCK_TYPE],
540
bufend = innobase_convert_name(buf, sizeof(buf),
542
strlen(row->lock_table),
544
OK(fields[IDX_LOCK_TABLE]->store(buf, bufend - buf,
545
system_charset_info));
548
if (row->lock_index != NULL) {
550
bufend = innobase_convert_name(buf, sizeof(buf),
552
strlen(row->lock_index),
554
OK(fields[IDX_LOCK_INDEX]->store(buf, bufend - buf,
555
system_charset_info));
556
fields[IDX_LOCK_INDEX]->set_notnull();
559
fields[IDX_LOCK_INDEX]->set_null();
563
OK(field_store_ulint(fields[IDX_LOCK_SPACE],
567
OK(field_store_ulint(fields[IDX_LOCK_PAGE],
571
OK(field_store_ulint(fields[IDX_LOCK_REC],
575
OK(field_store_string(fields[IDX_LOCK_DATA],
578
OK(schema_table_store_record(session, table));
584
/***********************************************************************
585
Bind the dynamic table INFORMATION_SCHEMA.innodb_locks */
589
/* out: 0 on success */
590
) /* in/out: table schema object */
593
if ((innodb_locks_schema_table= new InfoSchemaTable) == NULL)
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");
603
/* Fields of the dynamic table INFORMATION_SCHEMA.innodb_lock_waits */
604
static ColumnInfo innodb_lock_waits_fields_info[] =
606
#define IDX_REQUESTING_TRX_ID 0
607
ColumnInfo("requesting_trx_id",
609
DRIZZLE_TYPE_VARCHAR,
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,
624
#define IDX_BLOCKING_TRX_ID 2
625
ColumnInfo("blocking_trx_id",
627
DRIZZLE_TYPE_VARCHAR,
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,
645
/***********************************************************************
646
Read data from cache buffer and fill the
647
INFORMATION_SCHEMA.innodb_lock_waits table with it. */
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 */
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];
664
fields = table->field;
666
rows_num = trx_i_s_cache_get_rows_used(cache,
667
I_S_INNODB_LOCK_WAITS);
669
for (i = 0; i < rows_num; i++) {
671
i_s_lock_waits_row_t* row;
673
char requesting_trx_id[TRX_ID_MAX_LEN + 1];
674
char blocking_trx_id[TRX_ID_MAX_LEN + 1];
676
row = (i_s_lock_waits_row_t*)
677
trx_i_s_cache_get_nth_row(
678
cache, I_S_INNODB_LOCK_WAITS, i);
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],
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,
692
sizeof(requested_lock_id))));
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],
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,
706
sizeof(blocking_lock_id))));
708
OK(schema_table_store_record(session, table));
714
/***********************************************************************
715
Bind the dynamic table INFORMATION_SCHEMA.innodb_lock_waits */
717
innodb_lock_waits_init(
718
/*===================*/
719
/* out: 0 on success */
723
if ((innodb_lock_waits_schema_table= new InfoSchemaTable) == NULL)
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");
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 */
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) */
748
const char* table_name;
750
trx_i_s_cache_t* cache;
752
/* minimize the number of places where global variables are
754
cache = trx_i_s_cache;
756
/* which table we have to fill? */
757
table_name = tables->schema_table_name;
758
/* or table_name = tables->schema_table->table_name; */
760
RETURN_IF_INNODB_NOT_STARTED(table_name);
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);
767
if (trx_i_s_cache_is_truncated(cache)) {
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,
777
trx_i_s_cache_start_read(cache);
779
if (innobase_strcasecmp(table_name, "innodb_trx") == 0) {
781
if (fill_innodb_trx_from_cache(
782
cache, session, tables->table) != 0) {
787
} else if (innobase_strcasecmp(table_name, "innodb_locks") == 0) {
789
if (fill_innodb_locks_from_cache(
790
cache, session, tables->table) != 0) {
795
} else if (innobase_strcasecmp(table_name, "innodb_lock_waits") == 0) {
797
if (fill_innodb_lock_waits_from_cache(
798
cache, session, tables->table) != 0) {
805
/* huh! what happened!? */
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);
816
trx_i_s_cache_end_read(cache);
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 */
829
/* Fields of the dynamic table information_schema.innodb_cmp. */
830
static ColumnInfo i_s_cmp_fields_info[] =
832
ColumnInfo("page_size",
837
"Compressed Page Size",
840
ColumnInfo("compress_ops",
841
MY_INT32_NUM_DECIMAL_DIGITS,
845
"Total Number of Compressions",
848
ColumnInfo("compress_ops_ok",
849
MY_INT32_NUM_DECIMAL_DIGITS,
853
"Total Number of Successful Compressions",
856
ColumnInfo("compress_time",
857
MY_INT32_NUM_DECIMAL_DIGITS,
861
"Total Duration of Compressions in Seconds",
864
ColumnInfo("uncompress_ops",
865
MY_INT32_NUM_DECIMAL_DIGITS,
869
"Total Number of Decompressions",
872
ColumnInfo("uncompress_time",
873
MY_INT32_NUM_DECIMAL_DIGITS,
877
"Total Duration of Decompressions in Seconds",
884
/***********************************************************************
885
Fill the dynamic table information_schema.innodb_cmp or
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 */
897
Table* table = (Table *) tables->table;
901
RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name);
903
for (uint i = 0; i < PAGE_ZIP_NUM_SSIZE - 1; i++) {
904
page_zip_stat_t* zip_stat = &page_zip_stat[i];
906
table->field[0]->store(PAGE_ZIP_MIN_SIZE << i);
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
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));
923
memset(zip_stat, 0, sizeof *zip_stat);
926
if (schema_table_store_record(session, table)) {
935
/***********************************************************************
936
Fill the dynamic table information_schema.innodb_cmp. */
938
CmpISMethods::fillTable(
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) */
945
return(i_s_cmp_fill_low(session, tables, cond, FALSE));
948
/***********************************************************************
949
Fill the dynamic table information_schema.innodb_cmp_reset. */
951
CmpResetISMethods::fillTable(
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) */
958
return(i_s_cmp_fill_low(session, tables, cond, TRUE));
962
/***********************************************************************
963
Bind the dynamic table information_schema.innodb_cmp. */
967
/* out: 0 on success */
971
if ((innodb_cmp_schema_table= new InfoSchemaTable) == NULL)
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");
981
/***********************************************************************
982
Bind the dynamic table information_schema.innodb_cmp_reset. */
986
/* out: 0 on success */
987
) /* in/out: table schema object */
990
if ((innodb_cmp_reset_schema_table= new InfoSchemaTable) == NULL)
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");
1002
/* Fields of the dynamic table information_schema.innodb_cmpmem. */
1003
static ColumnInfo i_s_cmpmem_fields_info[] =
1005
ColumnInfo("page_size",
1013
ColumnInfo("pages_used",
1014
MY_INT32_NUM_DECIMAL_DIGITS,
1021
ColumnInfo("pages_free",
1022
MY_INT32_NUM_DECIMAL_DIGITS,
1026
"Currently Available",
1029
ColumnInfo("relocation_ops",
1030
MY_INT64_NUM_DECIMAL_DIGITS,
1031
DRIZZLE_TYPE_LONGLONG,
1034
"Total Number of Relocations",
1037
ColumnInfo("relocation_time",
1038
MY_INT32_NUM_DECIMAL_DIGITS,
1042
"Total Duration of Relocations, in Seconds",
1048
/***********************************************************************
1049
Fill the dynamic table information_schema.innodb_cmpmem or
1050
innodb_cmpmem_reset. */
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 */
1061
Table* table = (Table *) tables->table;
1064
RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name);
1066
buf_pool_mutex_enter();
1068
for (uint x = 0; x <= BUF_BUDDY_SIZES; x++) {
1069
buf_buddy_stat_t* buddy_stat = &buf_buddy_stat[x];
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])
1076
table->field[3]->store((int64_t) buddy_stat->relocated, true);
1077
table->field[4]->store(
1078
(ulong) (buddy_stat->relocated_usec / 1000000));
1081
/* This is protected by buf_pool_mutex. */
1082
buddy_stat->relocated = 0;
1083
buddy_stat->relocated_usec = 0;
1086
if (schema_table_store_record(session, table)) {
1092
buf_pool_mutex_exit();
1096
/***********************************************************************
1097
Fill the dynamic table information_schema.innodb_cmpmem. */
1099
CmpmemISMethods::fillTable(
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) */
1106
return(i_s_cmpmem_fill_low(session, tables, cond, FALSE));
1109
/***********************************************************************
1110
Fill the dynamic table information_schema.innodb_cmpmem_reset. */
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) */
1119
return(i_s_cmpmem_fill_low(session, tables, cond, TRUE));
1122
/***********************************************************************
1123
Bind the dynamic table information_schema.innodb_cmpmem. */
1127
/* out: 0 on success */
1131
if ((innodb_cmpmem_schema_table= new InfoSchemaTable) == NULL)
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");
1141
/***********************************************************************
1142
Bind the dynamic table information_schema.innodb_cmpmem_reset. */
1144
i_s_cmpmem_reset_init(
1145
/*==================*/
1146
/* out: 0 on success */
1149
if ((innodb_cmpmem_reset_schema_table= new InfoSchemaTable) == NULL)
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");
1160
/***********************************************************************
1161
Unbind a dynamic INFORMATION_SCHEMA table. */
1165
/* out: 0 on success */
1166
PluginRegistry ®istry) /* in/out: table schema object */
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);
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;