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/my_error.h"
32
#include <drizzled/plugin.h>
33
#include <drizzled/field.h>
34
#include <drizzled/table.h>
35
#include <drizzled/plugin/info_schema_table.h>
36
#include <drizzled/time_functions.h>
37
#include "drizzled/global_charset_info.h"
45
#include "trx0trx.h" /* for TRX_QUE_STATE_STR_MAX_LEN */
46
#include "buf0buddy.h" /* for i_s_cmpmem */
47
#include "buf0buf.h" /* for buf_pool and PAGE_ZIP_MIN_SIZE */
48
#include "ha_prototypes.h" /* for innobase_convert_name() */
49
#include "srv0start.h" /* for srv_was_started */
51
#include "handler0vars.h"
53
using namespace drizzled;
55
static const char plugin_author[] = "Innobase Oy";
62
#define RETURN_IF_INNODB_NOT_STARTED(plugin_name) \
64
if (!srv_was_started) { \
65
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN, \
66
ER_CANT_FIND_SYSTEM_REC, \
67
"InnoDB: SELECTing from " \
68
"INFORMATION_SCHEMA.%s but " \
69
"the InnoDB storage engine " \
70
"is not installed", plugin_name); \
75
#define STRUCT_FLD(name, value) value
77
plugin::InfoSchemaTable *innodb_trx_schema_table= NULL;
78
plugin::InfoSchemaTable *innodb_locks_schema_table= NULL;
79
plugin::InfoSchemaTable *innodb_lock_waits_schema_table= NULL;
80
plugin::InfoSchemaTable *innodb_cmp_schema_table= NULL;
81
plugin::InfoSchemaTable *innodb_cmp_reset_schema_table= NULL;
82
plugin::InfoSchemaTable *innodb_cmpmem_schema_table= NULL;
83
plugin::InfoSchemaTable *innodb_cmpmem_reset_schema_table= NULL;
85
static TrxISMethods trx_methods;
86
static CmpISMethods cmp_methods;
87
static CmpResetISMethods cmp_reset_methods;
88
static CmpmemISMethods cmpmem_methods;
89
static CmpmemResetISMethods cmpmem_reset_methods;
92
Use the following types mapping:
94
C type ST_FIELD_INFO::field_type
95
---------------------------------
96
long DRIZZLE_TYPE_LONGLONG
97
(field_length=MY_INT64_NUM_DECIMAL_DIGITS)
99
long unsigned DRIZZLE_TYPE_LONGLONG
100
(field_length=MY_INT64_NUM_DECIMAL_DIGITS, field_flags=MY_I_S_UNSIGNED)
102
char* DRIZZLE_TYPE_STRING
105
float DRIZZLE_TYPE_FLOAT
106
(field_length=0 is ignored)
108
void* DRIZZLE_TYPE_LONGLONG
109
(field_length=MY_INT64_NUM_DECIMAL_DIGITS, field_flags=MY_I_S_UNSIGNED)
111
boolean (if else) DRIZZLE_TYPE_LONG
114
time_t DRIZZLE_TYPE_DATETIME
115
(field_length=0 ignored)
116
---------------------------------
119
/*******************************************************************//**
120
Auxiliary function to store time_t value in MYSQL_TYPE_DATETIME
122
@return 0 on success */
127
Field* field, /*!< in/out: target field for storage */
128
time_t time) /*!< in: value to store */
130
DRIZZLE_TIME my_time;
134
/* use this if you are sure that `variables' and `time_zone'
135
are always initialized */
136
session->variables.time_zone->gmt_sec_to_TIME(
137
&my_time, (time_t) time);
139
localtime_r(&time, &tm_time);
140
localtime_to_TIME(&my_time, &tm_time);
141
my_time.time_type = DRIZZLE_TIMESTAMP_DATETIME;
144
return(field->store_time(&my_time, DRIZZLE_TIMESTAMP_DATETIME));
147
/*******************************************************************//**
148
Auxiliary function to store char* value in MYSQL_TYPE_STRING field.
149
@return 0 on success */
154
Field* field, /*!< in/out: target field for storage */
155
const char* str) /*!< in: NUL-terminated utf-8 string,
162
ret = field->store(str, strlen(str),
163
system_charset_info);
164
field->set_notnull();
167
ret = 0; /* success */
174
/*******************************************************************//**
175
Auxiliary function to store ulint value in DRIZZLE_TYPE_LONGLONG field.
176
If the value is ULINT_UNDEFINED then the field it set to NULL.
177
@return 0 on success */
182
Field* field, /*!< in/out: target field for storage */
183
ulint n) /*!< in: value to store */
187
if (n != ULINT_UNDEFINED) {
189
ret = field->store(n);
190
field->set_notnull();
193
ret = 0; /* success */
200
/* Fields of the dynamic table INFORMATION_SCHEMA.innodb_trx */
201
static plugin::ColumnInfo innodb_trx_fields_info[] =
204
plugin::ColumnInfo("trx_id",
206
DRIZZLE_TYPE_VARCHAR,
211
#define IDX_TRX_STATE 1
212
plugin::ColumnInfo("trx_state",
213
TRX_QUE_STATE_STR_MAX_LEN + 1,
214
DRIZZLE_TYPE_VARCHAR,
219
#define IDX_TRX_STARTED 2
220
plugin::ColumnInfo("trx_started",
222
DRIZZLE_TYPE_DATETIME,
227
#define IDX_TRX_REQUESTED_LOCK_ID 3
228
plugin::ColumnInfo("trx_requested_lock_id",
229
TRX_I_S_LOCK_ID_MAX_LEN + 1,
230
DRIZZLE_TYPE_VARCHAR,
235
#define IDX_TRX_WAIT_STARTED 4
236
plugin::ColumnInfo("trx_wait_started",
238
DRIZZLE_TYPE_DATETIME,
243
#define IDX_TRX_WEIGHT 5
244
plugin::ColumnInfo("trx_weight",
245
MY_INT64_NUM_DECIMAL_DIGITS,
246
DRIZZLE_TYPE_LONGLONG,
251
#define IDX_TRX_DRIZZLE_THREAD_ID 6
252
plugin::ColumnInfo("trx_mysql_thread_id",
253
MY_INT64_NUM_DECIMAL_DIGITS,
254
DRIZZLE_TYPE_LONGLONG,
259
#define IDX_TRX_QUERY 7
260
plugin::ColumnInfo("trx_query",
261
TRX_I_S_TRX_QUERY_MAX_LEN,
262
DRIZZLE_TYPE_VARCHAR,
270
/*******************************************************************//**
271
Read data from cache buffer and fill the INFORMATION_SCHEMA.innodb_trx
273
@return 0 on success */
276
fill_innodb_trx_from_cache(
277
/*=======================*/
278
trx_i_s_cache_t* cache, /*!< in: cache to read from */
279
Table* table, /*!< in/out: fill this table */
280
plugin::InfoSchemaTable *schema_table)
284
char lock_id[TRX_I_S_LOCK_ID_MAX_LEN + 1];
287
fields = table->field;
289
rows_num = trx_i_s_cache_get_rows_used(cache,
292
for (i = 0; i < rows_num; i++) {
295
char trx_id[TRX_ID_MAX_LEN + 1];
297
row = (i_s_trx_row_t*)
298
trx_i_s_cache_get_nth_row(
299
cache, I_S_INNODB_TRX, i);
302
ut_snprintf(trx_id, sizeof(trx_id), TRX_ID_FMT, row->trx_id);
303
OK(field_store_string(fields[IDX_TRX_ID], trx_id));
306
OK(field_store_string(fields[IDX_TRX_STATE],
310
OK(field_store_time_t(fields[IDX_TRX_STARTED],
311
(time_t) row->trx_started));
313
/* trx_requested_lock_id */
314
/* trx_wait_started */
315
if (row->trx_wait_started != 0) {
317
OK(field_store_string(
318
fields[IDX_TRX_REQUESTED_LOCK_ID],
319
trx_i_s_create_lock_id(
320
row->requested_lock_row,
321
lock_id, sizeof(lock_id))));
322
/* field_store_string() sets it no notnull */
324
OK(field_store_time_t(
325
fields[IDX_TRX_WAIT_STARTED],
326
(time_t) row->trx_wait_started));
327
fields[IDX_TRX_WAIT_STARTED]->set_notnull();
330
fields[IDX_TRX_REQUESTED_LOCK_ID]->set_null();
331
fields[IDX_TRX_WAIT_STARTED]->set_null();
335
OK(fields[IDX_TRX_WEIGHT]->store((int64_t) row->trx_weight,
338
/* trx_mysql_thread_id */
339
OK(fields[IDX_TRX_DRIZZLE_THREAD_ID]->store(
340
row->trx_mysql_thread_id));
343
OK(field_store_string(fields[IDX_TRX_QUERY],
346
schema_table->addRow(table->record[0],
347
table->s->reclength);
353
/*******************************************************************//**
354
Bind the dynamic table INFORMATION_SCHEMA.innodb_trx
355
@return 0 on success */
360
if ((innodb_trx_schema_table= new plugin::InfoSchemaTable("INNODB_TRX")) == NULL)
363
innodb_trx_schema_table->setColumnInfo(innodb_trx_fields_info);
364
innodb_trx_schema_table->setInfoSchemaMethods(&trx_methods);
370
/* Fields of the dynamic table INFORMATION_SCHEMA.innodb_locks */
371
static plugin::ColumnInfo innodb_locks_fields_info[] =
373
#define IDX_LOCK_ID 0
374
plugin::ColumnInfo("lock_id",
375
TRX_I_S_LOCK_ID_MAX_LEN + 1,
376
DRIZZLE_TYPE_VARCHAR,
381
#define IDX_LOCK_TRX_ID 1
382
plugin::ColumnInfo("lock_trx_id",
384
DRIZZLE_TYPE_VARCHAR,
389
#define IDX_LOCK_MODE 2
390
plugin::ColumnInfo("lock_mode",
391
/* S[,GAP] X[,GAP] IS[,GAP] IX[,GAP] AUTO_INC UNKNOWN */
393
DRIZZLE_TYPE_VARCHAR,
398
#define IDX_LOCK_TYPE 3
399
plugin::ColumnInfo("lock_type",
400
32, /* RECORD|TABLE|UNKNOWN */
401
DRIZZLE_TYPE_VARCHAR,
406
#define IDX_LOCK_TABLE 4
407
plugin::ColumnInfo("lock_table",
409
DRIZZLE_TYPE_VARCHAR,
414
#define IDX_LOCK_INDEX 5
415
plugin::ColumnInfo("lock_index",
417
DRIZZLE_TYPE_VARCHAR,
422
#define IDX_LOCK_SPACE 6
423
plugin::ColumnInfo("lock_space",
424
MY_INT64_NUM_DECIMAL_DIGITS,
425
DRIZZLE_TYPE_LONGLONG,
427
MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL,
430
#define IDX_LOCK_PAGE 7
431
plugin::ColumnInfo("lock_page",
432
MY_INT64_NUM_DECIMAL_DIGITS,
433
DRIZZLE_TYPE_LONGLONG,
435
MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL,
438
#define IDX_LOCK_REC 8
439
plugin::ColumnInfo("lock_rec",
440
MY_INT64_NUM_DECIMAL_DIGITS,
441
DRIZZLE_TYPE_LONGLONG,
443
MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL,
446
#define IDX_LOCK_DATA 9
447
plugin::ColumnInfo("lock_data",
448
TRX_I_S_LOCK_DATA_MAX_LEN,
449
DRIZZLE_TYPE_VARCHAR,
457
/*******************************************************************//**
458
Read data from cache buffer and fill the INFORMATION_SCHEMA.innodb_locks
460
@return 0 on success */
463
fill_innodb_locks_from_cache(
464
/*=========================*/
465
trx_i_s_cache_t* cache, /*!< in: cache to read from */
466
Session* session,/*!< in: MySQL client connection */
467
Table* table, /*!< in/out: fill this table */
468
plugin::InfoSchemaTable *schema_table)
472
char lock_id[TRX_I_S_LOCK_ID_MAX_LEN + 1];
475
fields = table->field;
477
rows_num = trx_i_s_cache_get_rows_used(cache,
480
for (i = 0; i < rows_num; i++) {
482
i_s_locks_row_t* row;
484
/* note that the decoded database or table name is
485
never expected to be longer than NAME_LEN;
486
NAME_LEN for database name
487
2 for surrounding quotes around database name
488
NAME_LEN for table name
489
2 for surrounding quotes around table name
490
1 for the separating dot (.)
491
9 for the #mysql50# prefix */
492
char buf[2 * NAME_LEN + 14];
495
char lock_trx_id[TRX_ID_MAX_LEN + 1];
497
row = (i_s_locks_row_t*)
498
trx_i_s_cache_get_nth_row(
499
cache, I_S_INNODB_LOCKS, i);
502
trx_i_s_create_lock_id(row, lock_id, sizeof(lock_id));
503
OK(field_store_string(fields[IDX_LOCK_ID],
507
ut_snprintf(lock_trx_id, sizeof(lock_trx_id),
508
TRX_ID_FMT, row->lock_trx_id);
509
OK(field_store_string(fields[IDX_LOCK_TRX_ID], lock_trx_id));
512
OK(field_store_string(fields[IDX_LOCK_MODE],
516
OK(field_store_string(fields[IDX_LOCK_TYPE],
520
bufend = innobase_convert_name(buf, sizeof(buf),
522
strlen(row->lock_table),
524
OK(fields[IDX_LOCK_TABLE]->store(buf, bufend - buf,
525
system_charset_info));
528
if (row->lock_index != NULL) {
530
bufend = innobase_convert_name(buf, sizeof(buf),
532
strlen(row->lock_index),
534
OK(fields[IDX_LOCK_INDEX]->store(buf, bufend - buf,
535
system_charset_info));
536
fields[IDX_LOCK_INDEX]->set_notnull();
539
fields[IDX_LOCK_INDEX]->set_null();
543
OK(field_store_ulint(fields[IDX_LOCK_SPACE],
547
OK(field_store_ulint(fields[IDX_LOCK_PAGE],
551
OK(field_store_ulint(fields[IDX_LOCK_REC],
555
OK(field_store_string(fields[IDX_LOCK_DATA],
558
schema_table->addRow(table->record[0],
559
table->s->reclength);
565
/*******************************************************************//**
566
Bind the dynamic table INFORMATION_SCHEMA.innodb_locks
567
@return 0 on success */
573
if ((innodb_locks_schema_table= new plugin::InfoSchemaTable("INNODB_LOCKS")) == NULL)
576
innodb_locks_schema_table->setColumnInfo(innodb_locks_fields_info);
577
innodb_locks_schema_table->setInfoSchemaMethods(&trx_methods);
582
/* Fields of the dynamic table INFORMATION_SCHEMA.innodb_lock_waits */
583
static plugin::ColumnInfo innodb_lock_waits_fields_info[] =
585
#define IDX_REQUESTING_TRX_ID 0
586
plugin::ColumnInfo("requesting_trx_id",
588
DRIZZLE_TYPE_VARCHAR,
593
#define IDX_REQUESTED_LOCK_ID 1
594
plugin::ColumnInfo("requested_lock_id",
595
TRX_I_S_LOCK_ID_MAX_LEN + 1,
596
DRIZZLE_TYPE_VARCHAR,
601
#define IDX_BLOCKING_TRX_ID 2
602
plugin::ColumnInfo("blocking_trx_id",
604
DRIZZLE_TYPE_VARCHAR,
609
#define IDX_BLOCKING_LOCK_ID 3
610
plugin::ColumnInfo("blocking_lock_id",
611
TRX_I_S_LOCK_ID_MAX_LEN + 1,
612
DRIZZLE_TYPE_VARCHAR,
620
/*******************************************************************//**
621
Read data from cache buffer and fill the
622
INFORMATION_SCHEMA.innodb_lock_waits table with it.
623
@return 0 on success */
626
fill_innodb_lock_waits_from_cache(
627
/*==============================*/
628
trx_i_s_cache_t* cache, /*!< in: cache to read from */
629
Table* table, /*!< in/out: fill this table */
630
plugin::InfoSchemaTable *schema_table)
634
char requested_lock_id[TRX_I_S_LOCK_ID_MAX_LEN + 1];
635
char blocking_lock_id[TRX_I_S_LOCK_ID_MAX_LEN + 1];
638
fields = table->field;
640
rows_num = trx_i_s_cache_get_rows_used(cache,
641
I_S_INNODB_LOCK_WAITS);
643
for (i = 0; i < rows_num; i++) {
645
i_s_lock_waits_row_t* row;
647
char requesting_trx_id[TRX_ID_MAX_LEN + 1];
648
char blocking_trx_id[TRX_ID_MAX_LEN + 1];
650
row = (i_s_lock_waits_row_t*)
651
trx_i_s_cache_get_nth_row(
652
cache, I_S_INNODB_LOCK_WAITS, i);
654
/* requesting_trx_id */
655
ut_snprintf(requesting_trx_id, sizeof(requesting_trx_id),
656
TRX_ID_FMT, row->requested_lock_row->lock_trx_id);
657
OK(field_store_string(fields[IDX_REQUESTING_TRX_ID],
660
/* requested_lock_id */
661
OK(field_store_string(
662
fields[IDX_REQUESTED_LOCK_ID],
663
trx_i_s_create_lock_id(
664
row->requested_lock_row,
666
sizeof(requested_lock_id))));
668
/* blocking_trx_id */
669
ut_snprintf(blocking_trx_id, sizeof(blocking_trx_id),
670
TRX_ID_FMT, row->blocking_lock_row->lock_trx_id);
671
OK(field_store_string(fields[IDX_BLOCKING_TRX_ID],
674
/* blocking_lock_id */
675
OK(field_store_string(
676
fields[IDX_BLOCKING_LOCK_ID],
677
trx_i_s_create_lock_id(
678
row->blocking_lock_row,
680
sizeof(blocking_lock_id))));
682
schema_table->addRow(table->record[0],
683
table->s->reclength);
689
/*******************************************************************//**
690
Bind the dynamic table INFORMATION_SCHEMA.innodb_lock_waits
691
@return 0 on success */
693
innodb_lock_waits_init()
694
/*===================*/
697
if ((innodb_lock_waits_schema_table= new plugin::InfoSchemaTable("INNODB_LOCK_WAITS")) == NULL)
700
innodb_lock_waits_schema_table->setColumnInfo(innodb_lock_waits_fields_info);
701
innodb_lock_waits_schema_table->setInfoSchemaMethods(&trx_methods);
708
/*******************************************************************//**
709
Common function to fill any of the dynamic tables:
710
INFORMATION_SCHEMA.innodb_trx
711
INFORMATION_SCHEMA.innodb_locks
712
INFORMATION_SCHEMA.innodb_lock_waits
713
@return 0 on success */
715
TrxISMethods::fillTable(
716
/*======================*/
717
Session* session,/*!< in: thread */
718
Table* table, /*!< in/out: tables to fill */
719
plugin::InfoSchemaTable *schema_table)
721
const char* table_name;
723
trx_i_s_cache_t* cache;
725
/* minimize the number of places where global variables are
727
cache = trx_i_s_cache;
729
/* which table we have to fill? */
730
table_name = schema_table->getName().c_str();
731
/* or table_name = tables->schema_table->table_name; */
733
RETURN_IF_INNODB_NOT_STARTED(table_name);
735
/* update the cache */
736
trx_i_s_cache_start_write(cache);
737
trx_i_s_possibly_fetch_data_into_cache(cache);
738
trx_i_s_cache_end_write(cache);
740
if (trx_i_s_cache_is_truncated(cache)) {
742
/* XXX show warning to user if possible */
743
fprintf(stderr, "Warning: data in %s truncated due to "
744
"memory limit of %d bytes\n", table_name,
750
trx_i_s_cache_start_read(cache);
752
if (innobase_strcasecmp(table_name, "innodb_trx") == 0) {
754
if (fill_innodb_trx_from_cache(
755
cache, table, schema_table) != 0) {
760
} else if (innobase_strcasecmp(table_name, "innodb_locks") == 0) {
762
if (fill_innodb_locks_from_cache(
763
cache, session, table, schema_table) != 0) {
768
} else if (innobase_strcasecmp(table_name, "innodb_lock_waits") == 0) {
770
if (fill_innodb_lock_waits_from_cache(
771
cache, table, schema_table) != 0) {
778
/* huh! what happened!? */
780
"InnoDB: trx_i_s_common_fill_table() was "
781
"called to fill unknown table: %s.\n"
782
"This function only knows how to fill "
783
"innodb_trx, innodb_locks and "
784
"innodb_lock_waits tables.\n", table_name);
789
trx_i_s_cache_end_read(cache);
794
/* if this function returns something else than 0 then a
795
deadlock occurs between the mysqld server and mysql client,
796
see http://bugs.mysql.com/29900 ; when that bug is resolved
797
we can enable the return(ret) above */
802
/* Fields of the dynamic table information_schema.innodb_cmp. */
803
static plugin::ColumnInfo i_s_cmp_fields_info[] =
805
plugin::ColumnInfo("page_size",
810
"Compressed Page Size"),
812
plugin::ColumnInfo("compress_ops",
813
MY_INT32_NUM_DECIMAL_DIGITS,
817
"Total Number of Compressions"),
819
plugin::ColumnInfo("compress_ops_ok",
820
MY_INT32_NUM_DECIMAL_DIGITS,
824
"Total Number of Successful Compressions"),
826
plugin::ColumnInfo("compress_time",
827
MY_INT32_NUM_DECIMAL_DIGITS,
831
"Total Duration of Compressions in Seconds"),
833
plugin::ColumnInfo("uncompress_ops",
834
MY_INT32_NUM_DECIMAL_DIGITS,
838
"Total Number of Decompressions"),
840
plugin::ColumnInfo("uncompress_time",
841
MY_INT32_NUM_DECIMAL_DIGITS,
845
"Total Duration of Decompressions in Seconds"),
851
/*******************************************************************//**
852
Fill the dynamic table information_schema.innodb_cmp or
854
@return 0 on success, 1 on failure */
859
Session* session,/*!< in: thread */
860
Table* table, /*!< in/out: tables to fill */
861
plugin::InfoSchemaTable *schema_table,
862
ibool reset) /*!< in: TRUE=reset cumulated counts */
867
RETURN_IF_INNODB_NOT_STARTED(schema_table->getName().c_str());
869
for (uint i = 0; i < PAGE_ZIP_NUM_SSIZE - 1; i++) {
870
page_zip_stat_t* zip_stat = &page_zip_stat[i];
872
table->field[0]->store(PAGE_ZIP_MIN_SIZE << i);
874
/* The cumulated counts are not protected by any
875
mutex. Thus, some operation in page0zip.c could
876
increment a counter between the time we read it and
877
clear it. We could introduce mutex protection, but it
878
could cause a measureable performance hit in
880
table->field[1]->store(zip_stat->compressed);
881
table->field[2]->store(zip_stat->compressed_ok);
882
table->field[3]->store(
883
(ulong) (zip_stat->compressed_usec / 1000000));
884
table->field[4]->store(zip_stat->decompressed);
885
table->field[5]->store(
886
(ulong) (zip_stat->decompressed_usec / 1000000));
889
memset(zip_stat, 0, sizeof *zip_stat);
892
schema_table->addRow(table->record[0],
893
table->s->reclength);
899
/*******************************************************************//**
900
Fill the dynamic table information_schema.innodb_cmp.
901
@return 0 on success, 1 on failure */
903
CmpISMethods::fillTable(
905
Session* session,/*!< in: thread */
906
Table* table, /*!< in/out: tables to fill */
907
plugin::InfoSchemaTable *schema_table)
909
return(i_s_cmp_fill_low(session, table, schema_table, FALSE));
912
/*******************************************************************//**
913
Fill the dynamic table information_schema.innodb_cmp_reset.
914
@return 0 on success, 1 on failure */
916
CmpResetISMethods::fillTable(
918
Session* session,/*!< in: thread */
919
Table* table, /*!< in/out: tables to fill */
920
plugin::InfoSchemaTable *schema_table)
922
return(i_s_cmp_fill_low(session, table, schema_table, TRUE));
925
/*******************************************************************//**
926
Bind the dynamic table information_schema.innodb_cmp.
927
@return 0 on success */
933
if ((innodb_cmp_schema_table= new plugin::InfoSchemaTable("INNODB_CMP")) == NULL)
936
innodb_cmp_schema_table->setColumnInfo(i_s_cmp_fields_info);
937
innodb_cmp_schema_table->setInfoSchemaMethods(&cmp_methods);
942
/*******************************************************************//**
943
Bind the dynamic table information_schema.innodb_cmp_reset.
944
@return 0 on success */
950
if ((innodb_cmp_reset_schema_table= new plugin::InfoSchemaTable("INNODB_CMP_RESET")) == NULL)
953
innodb_cmp_reset_schema_table->setColumnInfo(i_s_cmp_fields_info);
954
innodb_cmp_reset_schema_table->setInfoSchemaMethods(&cmp_reset_methods);
961
/* Fields of the dynamic table information_schema.innodb_cmpmem. */
962
static plugin::ColumnInfo i_s_cmpmem_fields_info[] =
964
plugin::ColumnInfo("page_size",
971
plugin::ColumnInfo("pages_used",
972
MY_INT32_NUM_DECIMAL_DIGITS,
978
plugin::ColumnInfo("pages_free",
979
MY_INT32_NUM_DECIMAL_DIGITS,
983
"Currently Available"),
985
plugin::ColumnInfo("relocation_ops",
986
MY_INT64_NUM_DECIMAL_DIGITS,
987
DRIZZLE_TYPE_LONGLONG,
990
"Total Number of Relocations"),
992
plugin::ColumnInfo("relocation_time",
993
MY_INT32_NUM_DECIMAL_DIGITS,
997
"Total Duration of Relocations, in Seconds"),
1002
/*******************************************************************//**
1003
Fill the dynamic table information_schema.innodb_cmpmem or
1004
innodb_cmpmem_reset.
1005
@return 0 on success, 1 on failure */
1008
i_s_cmpmem_fill_low(
1009
/*================*/
1010
Session* session,/*!< in: thread */
1011
Table* table, /*!< in/out: tables to fill */
1012
plugin::InfoSchemaTable *schema_table,
1013
ibool reset) /*!< in: TRUE=reset cumulated counts */
1017
RETURN_IF_INNODB_NOT_STARTED(schema_table->getName().c_str());
1019
buf_pool_mutex_enter();
1021
for (uint x = 0; x <= BUF_BUDDY_SIZES; x++) {
1022
buf_buddy_stat_t* buddy_stat = &buf_buddy_stat[x];
1024
table->field[0]->store(BUF_BUDDY_LOW << x);
1025
table->field[1]->store(buddy_stat->used);
1026
table->field[2]->store(UNIV_LIKELY(x < BUF_BUDDY_SIZES)
1027
? UT_LIST_GET_LEN(buf_pool->zip_free[x])
1029
table->field[3]->store((int64_t) buddy_stat->relocated, true);
1030
table->field[4]->store(
1031
(ulong) (buddy_stat->relocated_usec / 1000000));
1034
/* This is protected by buf_pool_mutex. */
1035
buddy_stat->relocated = 0;
1036
buddy_stat->relocated_usec = 0;
1039
schema_table->addRow(table->record[0],
1040
table->s->reclength);
1043
buf_pool_mutex_exit();
1047
/*******************************************************************//**
1048
Fill the dynamic table information_schema.innodb_cmpmem.
1049
@return 0 on success, 1 on failure */
1051
CmpmemISMethods::fillTable(
1053
Session* session,/*!< in: thread */
1054
Table* table, /*!< in/out: tables to fill */
1055
plugin::InfoSchemaTable *schema_table)
1057
return(i_s_cmpmem_fill_low(session, table, schema_table, FALSE));
1060
/*******************************************************************//**
1061
Fill the dynamic table information_schema.innodb_cmpmem_reset.
1062
@return 0 on success, 1 on failure */
1064
CmpmemResetISMethods::fillTable(
1065
/*==================*/
1066
Session* session,/*!< in: thread */
1067
Table* table, /*!< in/out: tables to fill */
1068
plugin::InfoSchemaTable *schema_table)
1070
return(i_s_cmpmem_fill_low(session, table, schema_table, TRUE));
1073
/*******************************************************************//**
1074
Bind the dynamic table information_schema.innodb_cmpmem.
1075
@return 0 on success */
1081
if ((innodb_cmpmem_schema_table= new plugin::InfoSchemaTable("INNODB_CMPMEM")) == NULL)
1084
innodb_cmpmem_schema_table->setColumnInfo(i_s_cmpmem_fields_info);
1085
innodb_cmpmem_schema_table->setInfoSchemaMethods(&cmpmem_methods);
1090
/*******************************************************************//**
1091
Bind the dynamic table information_schema.innodb_cmpmem_reset.
1092
@return 0 on success */
1094
i_s_cmpmem_reset_init()
1095
/*==================*/
1097
if ((innodb_cmpmem_reset_schema_table= new plugin::InfoSchemaTable("INNODB_CMPMEM_RESET")) == NULL)
1100
innodb_cmpmem_reset_schema_table->setColumnInfo(i_s_cmpmem_fields_info);
1101
innodb_cmpmem_reset_schema_table->setInfoSchemaMethods(&cmpmem_reset_methods);
1106
/*******************************************************************//**
1107
Unbind a dynamic INFORMATION_SCHEMA table.
1108
@return 0 on success */
1112
plugin::Registry ®istry) /*!< in/out: table schema object */
1114
registry.remove(innodb_trx_schema_table);
1115
registry.remove(innodb_locks_schema_table);
1116
registry.remove(innodb_lock_waits_schema_table);
1117
registry.remove(innodb_cmp_schema_table);
1118
registry.remove(innodb_cmp_reset_schema_table);
1119
registry.remove(innodb_cmpmem_schema_table);
1120
registry.remove(innodb_cmpmem_reset_schema_table);
1122
delete innodb_trx_schema_table;
1123
delete innodb_locks_schema_table;
1124
delete innodb_lock_waits_schema_table;
1125
delete innodb_cmp_schema_table;
1126
delete innodb_cmp_reset_schema_table;
1127
delete innodb_cmpmem_schema_table;
1128
delete innodb_cmpmem_reset_schema_table;