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
/**************************************************//**
21
InnoDB INFORMATION SCHEMA tables interface to MySQL.
23
Created July 18, 2007 Vasil Dimov
24
*******************************************************/
27
#include <drizzled/error.h>
28
#include "drizzled/charset_info.h"
29
#include "drizzled/internal/my_sys.h"
30
#include <drizzled/my_hash.h>
31
#include <drizzled/plugin.h>
32
#include <drizzled/field.h>
33
#include <drizzled/table.h>
34
#include <drizzled/time_functions.h>
35
#include "drizzled/global_charset_info.h"
44
#include "trx0trx.h" /* for TRX_QUE_STATE_STR_MAX_LEN */
45
#include "buf0buddy.h" /* for i_s_cmpmem */
46
#include "buf0buf.h" /* for buf_pool and PAGE_ZIP_MIN_SIZE */
47
#include "ha_prototypes.h" /* for innobase_convert_name() */
48
#include "srv0start.h" /* for srv_was_started */
50
#include "handler0vars.h"
52
using namespace drizzled;
54
static const char plugin_author[] = "Innobase Oy";
61
#define RETURN_IF_INNODB_NOT_STARTED(plugin_name) \
63
if (!srv_was_started) { \
64
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN, \
65
ER_CANT_FIND_SYSTEM_REC, \
66
"InnoDB: SELECTing from " \
67
"INFORMATION_SCHEMA.%s but " \
68
"the InnoDB storage engine " \
69
"is not installed", plugin_name); \
74
#define STRUCT_FLD(name, value) value
76
plugin::InfoSchemaTable *innodb_trx_schema_table= NULL;
77
plugin::InfoSchemaTable *innodb_locks_schema_table= NULL;
78
plugin::InfoSchemaTable *innodb_lock_waits_schema_table= NULL;
79
plugin::InfoSchemaTable *innodb_cmp_schema_table= NULL;
80
plugin::InfoSchemaTable *innodb_cmp_reset_schema_table= NULL;
81
plugin::InfoSchemaTable *innodb_cmpmem_schema_table= NULL;
82
plugin::InfoSchemaTable *innodb_cmpmem_reset_schema_table= NULL;
84
static TrxISMethods trx_methods;
85
static CmpISMethods cmp_methods;
86
static CmpResetISMethods cmp_reset_methods;
87
static CmpmemISMethods cmpmem_methods;
88
static CmpmemResetISMethods cmpmem_reset_methods;
91
Use the following types mapping:
93
C type ST_FIELD_INFO::field_type
94
---------------------------------
95
long DRIZZLE_TYPE_LONGLONG
96
(field_length=MY_INT64_NUM_DECIMAL_DIGITS)
98
long unsigned DRIZZLE_TYPE_LONGLONG
99
(field_length=MY_INT64_NUM_DECIMAL_DIGITS, field_flags=MY_I_S_UNSIGNED)
101
char* DRIZZLE_TYPE_STRING
104
float DRIZZLE_TYPE_FLOAT
105
(field_length=0 is ignored)
107
void* DRIZZLE_TYPE_LONGLONG
108
(field_length=MY_INT64_NUM_DECIMAL_DIGITS, field_flags=MY_I_S_UNSIGNED)
110
boolean (if else) DRIZZLE_TYPE_LONG
113
time_t DRIZZLE_TYPE_DATETIME
114
(field_length=0 ignored)
115
---------------------------------
118
/*******************************************************************//**
119
Auxiliary function to store time_t value in MYSQL_TYPE_DATETIME
121
@return 0 on success */
126
Field* field, /*!< in/out: target field for storage */
127
time_t time) /*!< in: value to store */
129
DRIZZLE_TIME my_time;
133
/* use this if you are sure that `variables' and `time_zone'
134
are always initialized */
135
session->variables.time_zone->gmt_sec_to_TIME(
136
&my_time, (time_t) time);
138
localtime_r(&time, &tm_time);
139
localtime_to_TIME(&my_time, &tm_time);
140
my_time.time_type = DRIZZLE_TIMESTAMP_DATETIME;
143
return(field->store_time(&my_time, DRIZZLE_TIMESTAMP_DATETIME));
146
/*******************************************************************//**
147
Auxiliary function to store char* value in MYSQL_TYPE_STRING field.
148
@return 0 on success */
153
Field* field, /*!< in/out: target field for storage */
154
const char* str) /*!< in: NUL-terminated utf-8 string,
161
ret = field->store(str, strlen(str),
162
system_charset_info);
163
field->set_notnull();
166
ret = 0; /* success */
173
/*******************************************************************//**
174
Auxiliary function to store ulint value in DRIZZLE_TYPE_LONGLONG field.
175
If the value is ULINT_UNDEFINED then the field it set to NULL.
176
@return 0 on success */
181
Field* field, /*!< in/out: target field for storage */
182
ulint n) /*!< in: value to store */
186
if (n != ULINT_UNDEFINED) {
188
ret = field->store(n);
189
field->set_notnull();
192
ret = 0; /* success */
199
/* Fields of the dynamic table INFORMATION_SCHEMA.innodb_trx */
200
static plugin::ColumnInfo innodb_trx_fields_info[] =
203
plugin::ColumnInfo("trx_id",
205
DRIZZLE_TYPE_VARCHAR,
210
#define IDX_TRX_STATE 1
211
plugin::ColumnInfo("trx_state",
212
TRX_QUE_STATE_STR_MAX_LEN + 1,
213
DRIZZLE_TYPE_VARCHAR,
218
#define IDX_TRX_STARTED 2
219
plugin::ColumnInfo("trx_started",
221
DRIZZLE_TYPE_DATETIME,
226
#define IDX_TRX_REQUESTED_LOCK_ID 3
227
plugin::ColumnInfo("trx_requested_lock_id",
228
TRX_I_S_LOCK_ID_MAX_LEN + 1,
229
DRIZZLE_TYPE_VARCHAR,
234
#define IDX_TRX_WAIT_STARTED 4
235
plugin::ColumnInfo("trx_wait_started",
237
DRIZZLE_TYPE_DATETIME,
242
#define IDX_TRX_WEIGHT 5
243
plugin::ColumnInfo("trx_weight",
244
MY_INT64_NUM_DECIMAL_DIGITS,
245
DRIZZLE_TYPE_LONGLONG,
250
#define IDX_TRX_DRIZZLE_THREAD_ID 6
251
plugin::ColumnInfo("trx_mysql_thread_id",
252
MY_INT64_NUM_DECIMAL_DIGITS,
253
DRIZZLE_TYPE_LONGLONG,
258
#define IDX_TRX_QUERY 7
259
plugin::ColumnInfo("trx_query",
260
TRX_I_S_TRX_QUERY_MAX_LEN,
261
DRIZZLE_TYPE_VARCHAR,
269
/*******************************************************************//**
270
Read data from cache buffer and fill the INFORMATION_SCHEMA.innodb_trx
272
@return 0 on success */
275
fill_innodb_trx_from_cache(
276
/*=======================*/
277
trx_i_s_cache_t* cache, /*!< in: cache to read from */
278
Table* table, /*!< in/out: fill this table */
279
plugin::InfoSchemaTable *schema_table)
283
char lock_id[TRX_I_S_LOCK_ID_MAX_LEN + 1];
286
fields = table->field;
288
rows_num = trx_i_s_cache_get_rows_used(cache,
291
for (i = 0; i < rows_num; i++) {
294
char trx_id[TRX_ID_MAX_LEN + 1];
296
row = (i_s_trx_row_t*)
297
trx_i_s_cache_get_nth_row(
298
cache, I_S_INNODB_TRX, i);
301
ut_snprintf(trx_id, sizeof(trx_id), TRX_ID_FMT, row->trx_id);
302
OK(field_store_string(fields[IDX_TRX_ID], trx_id));
305
OK(field_store_string(fields[IDX_TRX_STATE],
309
OK(field_store_time_t(fields[IDX_TRX_STARTED],
310
(time_t) row->trx_started));
312
/* trx_requested_lock_id */
313
/* trx_wait_started */
314
if (row->trx_wait_started != 0) {
316
OK(field_store_string(
317
fields[IDX_TRX_REQUESTED_LOCK_ID],
318
trx_i_s_create_lock_id(
319
row->requested_lock_row,
320
lock_id, sizeof(lock_id))));
321
/* field_store_string() sets it no notnull */
323
OK(field_store_time_t(
324
fields[IDX_TRX_WAIT_STARTED],
325
(time_t) row->trx_wait_started));
326
fields[IDX_TRX_WAIT_STARTED]->set_notnull();
329
fields[IDX_TRX_REQUESTED_LOCK_ID]->set_null();
330
fields[IDX_TRX_WAIT_STARTED]->set_null();
334
OK(fields[IDX_TRX_WEIGHT]->store((int64_t) row->trx_weight,
337
/* trx_mysql_thread_id */
338
OK(fields[IDX_TRX_DRIZZLE_THREAD_ID]->store(
339
row->trx_mysql_thread_id));
342
OK(field_store_string(fields[IDX_TRX_QUERY],
345
schema_table->addRow(table->record[0],
346
table->s->reclength);
352
/*******************************************************************//**
353
Bind the dynamic table INFORMATION_SCHEMA.innodb_trx
354
@return 0 on success */
359
if ((innodb_trx_schema_table= new plugin::InfoSchemaTable("INNODB_TRX")) == NULL)
362
innodb_trx_schema_table->setColumnInfo(innodb_trx_fields_info);
363
innodb_trx_schema_table->setInfoSchemaMethods(&trx_methods);
369
/* Fields of the dynamic table INFORMATION_SCHEMA.innodb_locks */
370
static plugin::ColumnInfo innodb_locks_fields_info[] =
372
#define IDX_LOCK_ID 0
373
plugin::ColumnInfo("lock_id",
374
TRX_I_S_LOCK_ID_MAX_LEN + 1,
375
DRIZZLE_TYPE_VARCHAR,
380
#define IDX_LOCK_TRX_ID 1
381
plugin::ColumnInfo("lock_trx_id",
383
DRIZZLE_TYPE_VARCHAR,
388
#define IDX_LOCK_MODE 2
389
plugin::ColumnInfo("lock_mode",
390
/* S[,GAP] X[,GAP] IS[,GAP] IX[,GAP] AUTO_INC UNKNOWN */
392
DRIZZLE_TYPE_VARCHAR,
397
#define IDX_LOCK_TYPE 3
398
plugin::ColumnInfo("lock_type",
399
32, /* RECORD|TABLE|UNKNOWN */
400
DRIZZLE_TYPE_VARCHAR,
405
#define IDX_LOCK_TABLE 4
406
plugin::ColumnInfo("lock_table",
408
DRIZZLE_TYPE_VARCHAR,
413
#define IDX_LOCK_INDEX 5
414
plugin::ColumnInfo("lock_index",
416
DRIZZLE_TYPE_VARCHAR,
421
#define IDX_LOCK_SPACE 6
422
plugin::ColumnInfo("lock_space",
423
MY_INT64_NUM_DECIMAL_DIGITS,
424
DRIZZLE_TYPE_LONGLONG,
426
MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL,
429
#define IDX_LOCK_PAGE 7
430
plugin::ColumnInfo("lock_page",
431
MY_INT64_NUM_DECIMAL_DIGITS,
432
DRIZZLE_TYPE_LONGLONG,
434
MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL,
437
#define IDX_LOCK_REC 8
438
plugin::ColumnInfo("lock_rec",
439
MY_INT64_NUM_DECIMAL_DIGITS,
440
DRIZZLE_TYPE_LONGLONG,
442
MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL,
445
#define IDX_LOCK_DATA 9
446
plugin::ColumnInfo("lock_data",
447
TRX_I_S_LOCK_DATA_MAX_LEN,
448
DRIZZLE_TYPE_VARCHAR,
456
/*******************************************************************//**
457
Read data from cache buffer and fill the INFORMATION_SCHEMA.innodb_locks
459
@return 0 on success */
462
fill_innodb_locks_from_cache(
463
/*=========================*/
464
trx_i_s_cache_t* cache, /*!< in: cache to read from */
465
Session* session,/*!< in: MySQL client connection */
466
Table* table, /*!< in/out: fill this table */
467
plugin::InfoSchemaTable *schema_table)
471
char lock_id[TRX_I_S_LOCK_ID_MAX_LEN + 1];
474
fields = table->field;
476
rows_num = trx_i_s_cache_get_rows_used(cache,
479
for (i = 0; i < rows_num; i++) {
481
i_s_locks_row_t* row;
483
/* note that the decoded database or table name is
484
never expected to be longer than NAME_LEN;
485
NAME_LEN for database name
486
2 for surrounding quotes around database name
487
NAME_LEN for table name
488
2 for surrounding quotes around table name
489
1 for the separating dot (.)
490
9 for the #mysql50# prefix */
491
char buf[2 * NAME_LEN + 14];
494
char lock_trx_id[TRX_ID_MAX_LEN + 1];
496
row = (i_s_locks_row_t*)
497
trx_i_s_cache_get_nth_row(
498
cache, I_S_INNODB_LOCKS, i);
501
trx_i_s_create_lock_id(row, lock_id, sizeof(lock_id));
502
OK(field_store_string(fields[IDX_LOCK_ID],
506
ut_snprintf(lock_trx_id, sizeof(lock_trx_id),
507
TRX_ID_FMT, row->lock_trx_id);
508
OK(field_store_string(fields[IDX_LOCK_TRX_ID], lock_trx_id));
511
OK(field_store_string(fields[IDX_LOCK_MODE],
515
OK(field_store_string(fields[IDX_LOCK_TYPE],
519
bufend = innobase_convert_name(buf, sizeof(buf),
521
strlen(row->lock_table),
523
OK(fields[IDX_LOCK_TABLE]->store(buf, bufend - buf,
524
system_charset_info));
527
if (row->lock_index != NULL) {
529
bufend = innobase_convert_name(buf, sizeof(buf),
531
strlen(row->lock_index),
533
OK(fields[IDX_LOCK_INDEX]->store(buf, bufend - buf,
534
system_charset_info));
535
fields[IDX_LOCK_INDEX]->set_notnull();
538
fields[IDX_LOCK_INDEX]->set_null();
542
OK(field_store_ulint(fields[IDX_LOCK_SPACE],
546
OK(field_store_ulint(fields[IDX_LOCK_PAGE],
550
OK(field_store_ulint(fields[IDX_LOCK_REC],
554
OK(field_store_string(fields[IDX_LOCK_DATA],
557
schema_table->addRow(table->record[0],
558
table->s->reclength);
564
/*******************************************************************//**
565
Bind the dynamic table INFORMATION_SCHEMA.innodb_locks
566
@return 0 on success */
572
if ((innodb_locks_schema_table= new plugin::InfoSchemaTable("INNODB_LOCKS")) == NULL)
575
innodb_locks_schema_table->setColumnInfo(innodb_locks_fields_info);
576
innodb_locks_schema_table->setInfoSchemaMethods(&trx_methods);
581
/* Fields of the dynamic table INFORMATION_SCHEMA.innodb_lock_waits */
582
static plugin::ColumnInfo innodb_lock_waits_fields_info[] =
584
#define IDX_REQUESTING_TRX_ID 0
585
plugin::ColumnInfo("requesting_trx_id",
587
DRIZZLE_TYPE_VARCHAR,
592
#define IDX_REQUESTED_LOCK_ID 1
593
plugin::ColumnInfo("requested_lock_id",
594
TRX_I_S_LOCK_ID_MAX_LEN + 1,
595
DRIZZLE_TYPE_VARCHAR,
600
#define IDX_BLOCKING_TRX_ID 2
601
plugin::ColumnInfo("blocking_trx_id",
603
DRIZZLE_TYPE_VARCHAR,
608
#define IDX_BLOCKING_LOCK_ID 3
609
plugin::ColumnInfo("blocking_lock_id",
610
TRX_I_S_LOCK_ID_MAX_LEN + 1,
611
DRIZZLE_TYPE_VARCHAR,
619
/*******************************************************************//**
620
Read data from cache buffer and fill the
621
INFORMATION_SCHEMA.innodb_lock_waits table with it.
622
@return 0 on success */
625
fill_innodb_lock_waits_from_cache(
626
/*==============================*/
627
trx_i_s_cache_t* cache, /*!< in: cache to read from */
628
Table* table, /*!< in/out: fill this table */
629
plugin::InfoSchemaTable *schema_table)
633
char requested_lock_id[TRX_I_S_LOCK_ID_MAX_LEN + 1];
634
char blocking_lock_id[TRX_I_S_LOCK_ID_MAX_LEN + 1];
637
fields = table->field;
639
rows_num = trx_i_s_cache_get_rows_used(cache,
640
I_S_INNODB_LOCK_WAITS);
642
for (i = 0; i < rows_num; i++) {
644
i_s_lock_waits_row_t* row;
646
char requesting_trx_id[TRX_ID_MAX_LEN + 1];
647
char blocking_trx_id[TRX_ID_MAX_LEN + 1];
649
row = (i_s_lock_waits_row_t*)
650
trx_i_s_cache_get_nth_row(
651
cache, I_S_INNODB_LOCK_WAITS, i);
653
/* requesting_trx_id */
654
ut_snprintf(requesting_trx_id, sizeof(requesting_trx_id),
655
TRX_ID_FMT, row->requested_lock_row->lock_trx_id);
656
OK(field_store_string(fields[IDX_REQUESTING_TRX_ID],
659
/* requested_lock_id */
660
OK(field_store_string(
661
fields[IDX_REQUESTED_LOCK_ID],
662
trx_i_s_create_lock_id(
663
row->requested_lock_row,
665
sizeof(requested_lock_id))));
667
/* blocking_trx_id */
668
ut_snprintf(blocking_trx_id, sizeof(blocking_trx_id),
669
TRX_ID_FMT, row->blocking_lock_row->lock_trx_id);
670
OK(field_store_string(fields[IDX_BLOCKING_TRX_ID],
673
/* blocking_lock_id */
674
OK(field_store_string(
675
fields[IDX_BLOCKING_LOCK_ID],
676
trx_i_s_create_lock_id(
677
row->blocking_lock_row,
679
sizeof(blocking_lock_id))));
681
schema_table->addRow(table->record[0],
682
table->s->reclength);
688
/*******************************************************************//**
689
Bind the dynamic table INFORMATION_SCHEMA.innodb_lock_waits
690
@return 0 on success */
692
innodb_lock_waits_init()
693
/*===================*/
696
if ((innodb_lock_waits_schema_table= new plugin::InfoSchemaTable("INNODB_LOCK_WAITS")) == NULL)
699
innodb_lock_waits_schema_table->setColumnInfo(innodb_lock_waits_fields_info);
700
innodb_lock_waits_schema_table->setInfoSchemaMethods(&trx_methods);
707
/*******************************************************************//**
708
Common function to fill any of the dynamic tables:
709
INFORMATION_SCHEMA.innodb_trx
710
INFORMATION_SCHEMA.innodb_locks
711
INFORMATION_SCHEMA.innodb_lock_waits
712
@return 0 on success */
714
TrxISMethods::fillTable(
715
/*======================*/
716
Session* session,/*!< in: thread */
717
Table* table, /*!< in/out: tables to fill */
718
plugin::InfoSchemaTable *schema_table)
720
const char* table_name;
722
trx_i_s_cache_t* cache;
724
/* minimize the number of places where global variables are
726
cache = trx_i_s_cache;
728
/* which table we have to fill? */
729
table_name = schema_table->getName().c_str();
730
/* or table_name = tables->schema_table->table_name; */
732
RETURN_IF_INNODB_NOT_STARTED(table_name);
734
/* update the cache */
735
trx_i_s_cache_start_write(cache);
736
trx_i_s_possibly_fetch_data_into_cache(cache);
737
trx_i_s_cache_end_write(cache);
739
if (trx_i_s_cache_is_truncated(cache)) {
741
/* XXX show warning to user if possible */
742
fprintf(stderr, "Warning: data in %s truncated due to "
743
"memory limit of %d bytes\n", table_name,
749
trx_i_s_cache_start_read(cache);
751
if (innobase_strcasecmp(table_name, "innodb_trx") == 0) {
753
if (fill_innodb_trx_from_cache(
754
cache, table, schema_table) != 0) {
759
} else if (innobase_strcasecmp(table_name, "innodb_locks") == 0) {
761
if (fill_innodb_locks_from_cache(
762
cache, session, table, schema_table) != 0) {
767
} else if (innobase_strcasecmp(table_name, "innodb_lock_waits") == 0) {
769
if (fill_innodb_lock_waits_from_cache(
770
cache, table, schema_table) != 0) {
777
/* huh! what happened!? */
779
"InnoDB: trx_i_s_common_fill_table() was "
780
"called to fill unknown table: %s.\n"
781
"This function only knows how to fill "
782
"innodb_trx, innodb_locks and "
783
"innodb_lock_waits tables.\n", table_name);
788
trx_i_s_cache_end_read(cache);
793
/* if this function returns something else than 0 then a
794
deadlock occurs between the mysqld server and mysql client,
795
see http://bugs.mysql.com/29900 ; when that bug is resolved
796
we can enable the return(ret) above */
801
/* Fields of the dynamic table information_schema.innodb_cmp. */
802
static plugin::ColumnInfo i_s_cmp_fields_info[] =
804
plugin::ColumnInfo("page_size",
809
"Compressed Page Size"),
811
plugin::ColumnInfo("compress_ops",
812
MY_INT32_NUM_DECIMAL_DIGITS,
816
"Total Number of Compressions"),
818
plugin::ColumnInfo("compress_ops_ok",
819
MY_INT32_NUM_DECIMAL_DIGITS,
823
"Total Number of Successful Compressions"),
825
plugin::ColumnInfo("compress_time",
826
MY_INT32_NUM_DECIMAL_DIGITS,
830
"Total Duration of Compressions in Seconds"),
832
plugin::ColumnInfo("uncompress_ops",
833
MY_INT32_NUM_DECIMAL_DIGITS,
837
"Total Number of Decompressions"),
839
plugin::ColumnInfo("uncompress_time",
840
MY_INT32_NUM_DECIMAL_DIGITS,
844
"Total Duration of Decompressions in Seconds"),
850
/*******************************************************************//**
851
Fill the dynamic table information_schema.innodb_cmp or
853
@return 0 on success, 1 on failure */
858
Session* session,/*!< in: thread */
859
Table* table, /*!< in/out: tables to fill */
860
plugin::InfoSchemaTable *schema_table,
861
ibool reset) /*!< in: TRUE=reset cumulated counts */
866
RETURN_IF_INNODB_NOT_STARTED(schema_table->getName().c_str());
868
for (uint i = 0; i < PAGE_ZIP_NUM_SSIZE - 1; i++) {
869
page_zip_stat_t* zip_stat = &page_zip_stat[i];
871
table->field[0]->store(PAGE_ZIP_MIN_SIZE << i);
873
/* The cumulated counts are not protected by any
874
mutex. Thus, some operation in page0zip.c could
875
increment a counter between the time we read it and
876
clear it. We could introduce mutex protection, but it
877
could cause a measureable performance hit in
879
table->field[1]->store(zip_stat->compressed);
880
table->field[2]->store(zip_stat->compressed_ok);
881
table->field[3]->store(
882
(ulong) (zip_stat->compressed_usec / 1000000));
883
table->field[4]->store(zip_stat->decompressed);
884
table->field[5]->store(
885
(ulong) (zip_stat->decompressed_usec / 1000000));
888
memset(zip_stat, 0, sizeof *zip_stat);
891
schema_table->addRow(table->record[0],
892
table->s->reclength);
898
/*******************************************************************//**
899
Fill the dynamic table information_schema.innodb_cmp.
900
@return 0 on success, 1 on failure */
902
CmpISMethods::fillTable(
904
Session* session,/*!< in: thread */
905
Table* table, /*!< in/out: tables to fill */
906
plugin::InfoSchemaTable *schema_table)
908
return(i_s_cmp_fill_low(session, table, schema_table, FALSE));
911
/*******************************************************************//**
912
Fill the dynamic table information_schema.innodb_cmp_reset.
913
@return 0 on success, 1 on failure */
915
CmpResetISMethods::fillTable(
917
Session* session,/*!< in: thread */
918
Table* table, /*!< in/out: tables to fill */
919
plugin::InfoSchemaTable *schema_table)
921
return(i_s_cmp_fill_low(session, table, schema_table, TRUE));
924
/*******************************************************************//**
925
Bind the dynamic table information_schema.innodb_cmp.
926
@return 0 on success */
932
if ((innodb_cmp_schema_table= new plugin::InfoSchemaTable("INNODB_CMP")) == NULL)
935
innodb_cmp_schema_table->setColumnInfo(i_s_cmp_fields_info);
936
innodb_cmp_schema_table->setInfoSchemaMethods(&cmp_methods);
941
/*******************************************************************//**
942
Bind the dynamic table information_schema.innodb_cmp_reset.
943
@return 0 on success */
949
if ((innodb_cmp_reset_schema_table= new plugin::InfoSchemaTable("INNODB_CMP_RESET")) == NULL)
952
innodb_cmp_reset_schema_table->setColumnInfo(i_s_cmp_fields_info);
953
innodb_cmp_reset_schema_table->setInfoSchemaMethods(&cmp_reset_methods);
960
/* Fields of the dynamic table information_schema.innodb_cmpmem. */
961
static plugin::ColumnInfo i_s_cmpmem_fields_info[] =
963
plugin::ColumnInfo("page_size",
970
plugin::ColumnInfo("pages_used",
971
MY_INT32_NUM_DECIMAL_DIGITS,
977
plugin::ColumnInfo("pages_free",
978
MY_INT32_NUM_DECIMAL_DIGITS,
982
"Currently Available"),
984
plugin::ColumnInfo("relocation_ops",
985
MY_INT64_NUM_DECIMAL_DIGITS,
986
DRIZZLE_TYPE_LONGLONG,
989
"Total Number of Relocations"),
991
plugin::ColumnInfo("relocation_time",
992
MY_INT32_NUM_DECIMAL_DIGITS,
996
"Total Duration of Relocations, in Seconds"),
1001
/*******************************************************************//**
1002
Fill the dynamic table information_schema.innodb_cmpmem or
1003
innodb_cmpmem_reset.
1004
@return 0 on success, 1 on failure */
1007
i_s_cmpmem_fill_low(
1008
/*================*/
1009
Session* session,/*!< in: thread */
1010
Table* table, /*!< in/out: tables to fill */
1011
plugin::InfoSchemaTable *schema_table,
1012
ibool reset) /*!< in: TRUE=reset cumulated counts */
1016
RETURN_IF_INNODB_NOT_STARTED(schema_table->getName().c_str());
1018
buf_pool_mutex_enter();
1020
for (uint x = 0; x <= BUF_BUDDY_SIZES; x++) {
1021
buf_buddy_stat_t* buddy_stat = &buf_buddy_stat[x];
1023
table->field[0]->store(BUF_BUDDY_LOW << x);
1024
table->field[1]->store(buddy_stat->used);
1025
table->field[2]->store(UNIV_LIKELY(x < BUF_BUDDY_SIZES)
1026
? UT_LIST_GET_LEN(buf_pool->zip_free[x])
1028
table->field[3]->store((int64_t) buddy_stat->relocated, true);
1029
table->field[4]->store(
1030
(ulong) (buddy_stat->relocated_usec / 1000000));
1033
/* This is protected by buf_pool_mutex. */
1034
buddy_stat->relocated = 0;
1035
buddy_stat->relocated_usec = 0;
1038
schema_table->addRow(table->record[0],
1039
table->s->reclength);
1042
buf_pool_mutex_exit();
1046
/*******************************************************************//**
1047
Fill the dynamic table information_schema.innodb_cmpmem.
1048
@return 0 on success, 1 on failure */
1050
CmpmemISMethods::fillTable(
1052
Session* session,/*!< in: thread */
1053
Table* table, /*!< in/out: tables to fill */
1054
plugin::InfoSchemaTable *schema_table)
1056
return(i_s_cmpmem_fill_low(session, table, schema_table, FALSE));
1059
/*******************************************************************//**
1060
Fill the dynamic table information_schema.innodb_cmpmem_reset.
1061
@return 0 on success, 1 on failure */
1063
CmpmemResetISMethods::fillTable(
1064
/*==================*/
1065
Session* session,/*!< in: thread */
1066
Table* table, /*!< in/out: tables to fill */
1067
plugin::InfoSchemaTable *schema_table)
1069
return(i_s_cmpmem_fill_low(session, table, schema_table, TRUE));
1072
/*******************************************************************//**
1073
Bind the dynamic table information_schema.innodb_cmpmem.
1074
@return 0 on success */
1080
if ((innodb_cmpmem_schema_table= new plugin::InfoSchemaTable("INNODB_CMPMEM")) == NULL)
1083
innodb_cmpmem_schema_table->setColumnInfo(i_s_cmpmem_fields_info);
1084
innodb_cmpmem_schema_table->setInfoSchemaMethods(&cmpmem_methods);
1089
/*******************************************************************//**
1090
Bind the dynamic table information_schema.innodb_cmpmem_reset.
1091
@return 0 on success */
1093
i_s_cmpmem_reset_init()
1094
/*==================*/
1096
if ((innodb_cmpmem_reset_schema_table= new plugin::InfoSchemaTable("INNODB_CMPMEM_RESET")) == NULL)
1099
innodb_cmpmem_reset_schema_table->setColumnInfo(i_s_cmpmem_fields_info);
1100
innodb_cmpmem_reset_schema_table->setInfoSchemaMethods(&cmpmem_reset_methods);
1105
/*******************************************************************//**
1106
Unbind a dynamic INFORMATION_SCHEMA table.
1107
@return 0 on success */
1111
plugin::Registry ®istry) /*!< in/out: table schema object */
1113
registry.remove(innodb_trx_schema_table);
1114
registry.remove(innodb_locks_schema_table);
1115
registry.remove(innodb_lock_waits_schema_table);
1116
registry.remove(innodb_cmp_schema_table);
1117
registry.remove(innodb_cmp_reset_schema_table);
1118
registry.remove(innodb_cmpmem_schema_table);
1119
registry.remove(innodb_cmpmem_reset_schema_table);
1121
delete innodb_trx_schema_table;
1122
delete innodb_locks_schema_table;
1123
delete innodb_lock_waits_schema_table;
1124
delete innodb_cmp_schema_table;
1125
delete innodb_cmp_reset_schema_table;
1126
delete innodb_cmpmem_schema_table;
1127
delete innodb_cmpmem_reset_schema_table;