21#include "data_dictionary.h"
23#include <drizzled/current_session.h>
40InnodbSysTablesTool::InnodbSysTablesTool() :
41 plugin::TableFunction(
"DATA_DICTIONARY",
"INNODB_SYS_TABLES")
43 add_field(
"TABLE_ID", plugin::TableFunction::NUMBER, 0,
false);
44 add_field(
"NAME", plugin::TableFunction::STRING, NAME_LEN + 1,
false);
45 add_field(
"FLAG", plugin::TableFunction::NUMBER, 0,
false);
46 add_field(
"N_COLS", plugin::TableFunction::NUMBER, 0,
false);
47 add_field(
"SPACE", plugin::TableFunction::NUMBER, 0,
false);
50InnodbSysTablesTool::Generator::Generator(
Field **arg) :
51 plugin::TableFunction::Generator(arg)
56bool InnodbSysTablesTool::Generator::populate()
64 rec = dict_startscan_system(&pcur, &mtr, SYS_TABLES);
71 rec = dict_getnext_system(&pcur, &mtr);
83 dict_table_t* table_rec;
87 err_msg = dict_process_sys_tables_rec(heap, rec, &table_rec,
95 push(table_rec->
name);
96 push(
static_cast<uint64_t
>(table_rec->
flags));
97 push(
static_cast<uint64_t
>(table_rec->
n_cols));
98 push(
static_cast<uint64_t
>(table_rec->
space));
109 dict_mem_table_free(table_rec);
117InnodbSysTableStatsTool::InnodbSysTableStatsTool() :
118 plugin::TableFunction(
"DATA_DICTIONARY",
"INNODB_SYS_TABLESTATS")
120 add_field(
"TABLE_ID", plugin::TableFunction::NUMBER, 0,
false);
121 add_field(
"NAME", plugin::TableFunction::STRING, NAME_LEN + 1,
false);
122 add_field(
"STATS_INITIALIZED", plugin::TableFunction::STRING, NAME_LEN + 1,
false);
123 add_field(
"NUM_ROWS", plugin::TableFunction::NUMBER, 0,
false);
124 add_field(
"CLUST_INDEX_SIZE", plugin::TableFunction::NUMBER, 0,
false);
125 add_field(
"OTHER_INDEX_SIZE", plugin::TableFunction::NUMBER, 0,
false);
126 add_field(
"MODIFIED_COUNTER", plugin::TableFunction::NUMBER, 0,
false);
127 add_field(
"AUTOINC", plugin::TableFunction::NUMBER, 0,
false);
128 add_field(
"HANDLES_OPENED", plugin::TableFunction::NUMBER, 0,
false);
131InnodbSysTableStatsTool::Generator::Generator(
Field **arg) :
132 plugin::TableFunction::Generator(arg)
137bool InnodbSysTableStatsTool::Generator::populate()
144 rec = dict_startscan_system(&pcur, &mtr, SYS_TABLES);
151 rec = dict_getnext_system(&pcur, &mtr);
163 dict_table_t* table_rec;
167 err_msg = dict_process_sys_tables_rec(heap, rec, &table_rec,
175 push(table_rec->
name);
179 push(
"Uninitialized");
197InnodbSysIndexesTool::InnodbSysIndexesTool() :
198 plugin::TableFunction(
"DATA_DICTIONARY",
"INNODB_SYS_INDEXES")
200 add_field(
"INDEX_ID", plugin::TableFunction::NUMBER, 0,
false);
201 add_field(
"NAME", plugin::TableFunction::STRING, NAME_LEN + 1,
false);
202 add_field(
"TABLE_ID", plugin::TableFunction::NUMBER, 0,
false);
203 add_field(
"TYPE", plugin::TableFunction::NUMBER, 0,
false);
204 add_field(
"N_FIELDS", plugin::TableFunction::NUMBER, 0,
false);
205 add_field(
"PAGE_NO", plugin::TableFunction::NUMBER, 0,
false);
206 add_field(
"SPACE", plugin::TableFunction::NUMBER, 0,
false);
209InnodbSysIndexesTool::Generator::Generator(
Field **arg) :
210 plugin::TableFunction::Generator(arg)
215bool InnodbSysIndexesTool::Generator::populate()
224 rec = dict_startscan_system(&pcur, &mtr, SYS_INDEXES);
231 rec = dict_getnext_system(&pcur, &mtr);
242 const char* err_msg;;
244 dict_index_t index_rec;
248 err_msg = dict_process_sys_indexes_rec(heap, rec, &index_rec,
255 push(index_rec.
name);
256 push(
static_cast<uint64_t
>(table_id));
257 push(
static_cast<uint64_t
>(index_rec.
type));
258 push(
static_cast<uint64_t
>(index_rec.
n_fields));
259 push(
static_cast<uint64_t
>(index_rec.
page));
260 push(
static_cast<uint64_t
>(index_rec.
space));
280InnodbSysColumnsTool::InnodbSysColumnsTool() :
281 plugin::TableFunction(
"DATA_DICTIONARY",
"INNODB_SYS_COLUMNS")
283 add_field(
"TABLE_ID", plugin::TableFunction::NUMBER, 0,
false);
284 add_field(
"NAME", plugin::TableFunction::STRING, NAME_LEN + 1,
false);
285 add_field(
"POS", plugin::TableFunction::NUMBER, 0,
false);
286 add_field(
"MTYPE", plugin::TableFunction::NUMBER, 0,
false);
287 add_field(
"PRTYPE", plugin::TableFunction::NUMBER, 0,
false);
288 add_field(
"LEN", plugin::TableFunction::NUMBER, 0,
false);
291InnodbSysColumnsTool::Generator::Generator(
Field **arg) :
292 plugin::TableFunction::Generator(arg)
297bool InnodbSysColumnsTool::Generator::populate()
304 rec = dict_startscan_system(&pcur, &mtr, SYS_COLUMNS);
311 rec = dict_getnext_system(&pcur, &mtr);
323 dict_col_t column_rec;
325 const char* col_name;
329 err_msg = dict_process_sys_columns_rec(heap, rec, &column_rec,
330 &table_id, &col_name);
338 push(
static_cast<uint64_t
>(column_rec.
ind));
339 push(
static_cast<uint64_t
>(column_rec.
mtype));
340 push(
static_cast<uint64_t
>(column_rec.
prtype));
341 push(
static_cast<uint64_t
>(column_rec.
len));
353InnodbSysFieldsTool::InnodbSysFieldsTool() :
354 plugin::TableFunction(
"DATA_DICTIONARY",
"INNODB_SYS_FIELDS")
356 add_field(
"INDEX_ID", plugin::TableFunction::NUMBER, 0,
false);
357 add_field(
"NAME", plugin::TableFunction::STRING, NAME_LEN + 1,
false);
358 add_field(
"POS", plugin::TableFunction::NUMBER, 0,
false);
361InnodbSysFieldsTool::Generator::Generator(
Field **arg) :
362 plugin::TableFunction::Generator(arg)
367bool InnodbSysFieldsTool::Generator::populate()
379 rec = dict_startscan_system(&pcur, &mtr, SYS_FIELDS);
386 rec = dict_getnext_system(&pcur, &mtr);
401 dict_field_t field_rec;
405 err_msg = dict_process_sys_fields_rec(heap, rec, &field_rec,
406 &pos, &index_id, last_id);
413 push(field_rec.
name);
414 push(
static_cast<uint64_t
>(pos));
428InnodbSysForeignTool::InnodbSysForeignTool() :
429 plugin::TableFunction(
"DATA_DICTIONARY",
"INNODB_SYS_FOREIGN")
431 add_field(
"ID", plugin::TableFunction::STRING, NAME_LEN + 1,
false);
432 add_field(
"FOR_NAME", plugin::TableFunction::STRING, NAME_LEN + 1,
false);
433 add_field(
"REF_NAME", plugin::TableFunction::STRING, NAME_LEN + 1,
false);
434 add_field(
"N_COLS", plugin::TableFunction::NUMBER, 0,
false);
435 add_field(
"TYPE", plugin::TableFunction::NUMBER, 0,
false);
438InnodbSysForeignTool::Generator::Generator(
Field **arg) :
439 plugin::TableFunction::Generator(arg)
444bool InnodbSysForeignTool::Generator::populate()
452 rec = dict_startscan_system(&pcur, &mtr, SYS_FOREIGN);
459 rec = dict_getnext_system(&pcur, &mtr);
471 dict_foreign_t foreign_rec;
475 err_msg = dict_process_sys_foreign_rec(heap, rec, &foreign_rec);
481 push(foreign_rec.
id);
484 push(
static_cast<uint64_t
>(foreign_rec.
n_fields));
485 push(
static_cast<uint64_t
>(foreign_rec.
type));
497InnodbSysForeignColsTool::InnodbSysForeignColsTool() :
498 plugin::TableFunction(
"DATA_DICTIONARY",
"INNODB_SYS_FOREIGN_COLS")
500 add_field(
"ID", plugin::TableFunction::STRING, NAME_LEN + 1,
false);
501 add_field(
"FOR_COL_NAME", plugin::TableFunction::STRING, NAME_LEN + 1,
false);
502 add_field(
"REF_COL_NAME", plugin::TableFunction::STRING, NAME_LEN + 1,
false);
503 add_field(
"POS", plugin::TableFunction::NUMBER, 0,
false);
506InnodbSysForeignColsTool::Generator::Generator(
Field **arg) :
507 plugin::TableFunction::Generator(arg)
512bool InnodbSysForeignColsTool::Generator::populate()
520 rec = dict_startscan_system(&pcur, &mtr, SYS_FOREIGN_COLS);
527 rec = dict_getnext_system(&pcur, &mtr);
541 const char* for_col_name;
542 const char* ref_col_name;
546 err_msg = dict_process_sys_foreign_col_rec(heap, rec, &name, &for_col_name,
547 &ref_col_name, &pos);
556 push(
static_cast<uint64_t
>(pos));
573CmpTool::CmpTool(
bool in_reset) :
574 plugin::TableFunction(
"DATA_DICTIONARY", in_reset ?
"INNODB_CMP_RESET" :
"INNODB_CMP"),
575 outer_reset(in_reset)
577 add_field(
"PAGE_SIZE", plugin::TableFunction::NUMBER, 0,
false);
578 add_field(
"COMPRESS_OPS", plugin::TableFunction::NUMBER, 0,
false);
579 add_field(
"COMPRESS_OPS_OK", plugin::TableFunction::NUMBER, 0,
false);
580 add_field(
"COMPRESS_TIME", plugin::TableFunction::NUMBER, 0,
false);
581 add_field(
"UNCOMPRESS_OPS", plugin::TableFunction::NUMBER, 0,
false);
582 add_field(
"UNCOMPRESS_TIME", plugin::TableFunction::NUMBER, 0,
false);
585CmpTool::Generator::Generator(
Field **arg,
bool in_reset) :
586 plugin::TableFunction::Generator(arg),
588 inner_reset(in_reset)
592bool CmpTool::Generator::populate()
609 push(
static_cast<uint64_t
>(zip_stat->
compressed));
617 memset(zip_stat, 0,
sizeof *zip_stat);
629CmpmemTool::CmpmemTool(
bool in_reset) :
630 plugin::TableFunction(
"DATA_DICTIONARY", in_reset ?
"INNODB_CMPMEM_RESET" :
"INNODB_CMPMEM"),
631 outer_reset(in_reset)
633 add_field(
"BUF_POOL", plugin::TableFunction::NUMBER, 0,
false);
634 add_field(
"PAGE_SIZE", plugin::TableFunction::NUMBER, 0,
false);
635 add_field(
"PAGES_USED", plugin::TableFunction::NUMBER, 0,
false);
636 add_field(
"PAGES_FREE", plugin::TableFunction::NUMBER, 0,
false);
637 add_field(
"RELOCATION_OPS", plugin::TableFunction::NUMBER, 0,
false);
638 add_field(
"RELOCATION_TIME", plugin::TableFunction::NUMBER, 0,
false);
641CmpmemTool::Generator::Generator(
Field **arg,
bool in_reset) :
642 plugin::TableFunction::Generator(arg),
644 inner_reset(in_reset)
648CmpmemTool::Generator::~Generator()
652bool CmpmemTool::Generator::populate()
669 push(
static_cast<uint64_t
>(buf_pool_nr));
671 push(
static_cast<uint64_t
>(buddy_stat->
used));
697InnodbTrxTool::InnodbTrxTool(
const char* in_table_name) :
698 plugin::TableFunction(
"DATA_DICTIONARY", in_table_name),
699 table_name(in_table_name)
704 add_field(
"TRX_STATE");
705 add_field(
"TRX_STARTED", plugin::TableFunction::NUMBER, 0,
false);
706 add_field(
"TRX_REQUESTED_LOCK_ID");
707 add_field(
"TRX_WAIT_STARTED", plugin::TableFunction::NUMBER, 0,
false);
708 add_field(
"TRX_WEIGHT", plugin::TableFunction::NUMBER, 0,
false);
709 add_field(
"TRX_DRIZZLE_THREAD_ID", plugin::TableFunction::NUMBER, 0,
false);
713 add_field(
"TRX_TABLES_LOCKED", plugin::TableFunction::NUMBER, 0,
false);
714 add_field(
"TRX_LOCK_STRUCTS", plugin::TableFunction::NUMBER, 0,
false);
715 add_field(
"TRX_LOCK_MEMORY_BYTES", plugin::TableFunction::NUMBER, 0,
false);
716 add_field(
"TRX_ROWS_LOCKED", plugin::TableFunction::NUMBER, 0,
false);
717 add_field(
"TRX_ROWS_MODIFIED", plugin::TableFunction::NUMBER, 0,
false);
718 add_field(
"TRX_CONCURRENCY_TICKETS", plugin::TableFunction::NUMBER, 0,
false);
720 add_field(
"TRX_UNIQUE_CHECKS", plugin::TableFunction::NUMBER, 0,
false);
721 add_field(
"TRX_FOREIGN_KEY_CHECKS", plugin::TableFunction::NUMBER, 0,
false);
722 add_field(
"TRX_LAST_FOREIGN_KEY_ERROR", plugin::TableFunction::STRING,
724 add_field(
"TRX_ADAPTIVE_HASH_LATCHED", plugin::TableFunction::NUMBER, 0,
false);
725 add_field(
"TRX_ADAPTIVE_HASH_TIMEOUT", plugin::TableFunction::NUMBER, 0,
false);
729 add_field(
"LOCK_ID");
730 add_field(
"LOCK_TRX_ID");
731 add_field(
"LOCK_MODE");
732 add_field(
"LOCK_TYPE");
733 add_field(
"LOCK_TABLE");
734 add_field(
"LOCK_INDEX");
735 add_field(
"LOCK_SPACE", plugin::TableFunction::NUMBER, 0,
false);
736 add_field(
"LOCK_PAGE", plugin::TableFunction::NUMBER, 0,
false);
737 add_field(
"LOCK_REC", plugin::TableFunction::NUMBER, 0,
false);
738 add_field(
"LOCK_DATA");
742 add_field(
"REQUESTING_TRX_ID");
743 add_field(
"REQUESTED_LOCK_ID");
744 add_field(
"BLOCKING_TRX_ID");
745 add_field(
"BLOCKING_LOCK_ID");
749InnodbTrxTool::Generator::Generator(
Field **arg,
const char* in_table_name) :
750 plugin::TableFunction::Generator(arg),
751 table_name(in_table_name)
760 errmsg_printf(error::ERROR, _(
"Warning: data in %s truncated due to memory limit of %d bytes\n"),
776InnodbTrxTool::Generator::~Generator()
781bool InnodbTrxTool::Generator::populate()
783 if (record_number == number_rows)
790 populate_innodb_trx();
794 populate_innodb_locks();
798 populate_innodb_lock_waits();
809void InnodbTrxTool::Generator::populate_innodb_locks()
825 char buf[2 * NAME_LEN + 14];
848 &getSession(), TRUE);
856 &getSession(), FALSE);
865 push(
static_cast<uint64_t
>(row->
lock_page));
866 push(
static_cast<uint64_t
>(row->
lock_rec));
870void InnodbTrxTool::Generator::populate_innodb_trx()
891 push(
static_cast<uint64_t
>(0));
892 push(
static_cast<uint64_t
>(0));
926void InnodbTrxTool::Generator::populate_innodb_lock_waits()
940 ut_snprintf(requesting_trx_id,
sizeof(requesting_trx_id),
942 push(requesting_trx_id);
945 sizeof(requested_lock_id)));
947 ut_snprintf(blocking_trx_id,
sizeof(blocking_trx_id),
949 push(blocking_trx_id);
952 sizeof(blocking_lock_id)));
#define buf_pool_mutex_exit(b)
UNIV_INLINE buf_pool_t * buf_pool_from_array(ulint index)
#define buf_pool_mutex_enter(b)
struct buf_pool_struct buf_pool_t
struct buf_buddy_stat_struct buf_buddy_stat_t
@ DICT_TABLE_LOAD_FROM_RECORD
@ DICT_TABLE_LOAD_FROM_CACHE
UNIV_INTERN char * innobase_convert_name(char *buf, ulint buflen, const char *id, ulint idlen, drizzled::Session *session, ibool table_id)
UNIV_INTERN int innobase_strcasecmp(const char *a, const char *b)
#define mem_heap_create(N)
UNIV_INLINE void mem_heap_empty(mem_heap_t *heap)
#define mem_heap_free(heap)
UNIV_INTERN void mtr_commit(mtr_t *mtr) __attribute__((nonnull))
UNIV_INLINE void mtr_start(mtr_t *mtr) __attribute__((nonnull))
TODO: Rename this file - func.h is stupid.
struct page_zip_stat_struct page_zip_stat_t
#define PAGE_ZIP_MIN_SIZE
page_zip_stat_t page_zip_stat[PAGE_ZIP_NUM_SSIZE_MAX - 1]
#define PAGE_ZIP_NUM_SSIZE
ulint srv_buf_pool_instances
ib_uint64_t relocated_usec
buf_buddy_stat_t buddy_stat[BUF_BUDDY_SIZES_MAX+1]
char * referenced_table_name
char * foreign_table_name
ulint n_mysql_handles_opened
ulint stat_clustered_index_size
unsigned stat_initialized
ulint stat_sum_of_other_index_sizes
ulint stat_modified_counter
const i_s_locks_row_t * blocking_lock_row
const i_s_locks_row_t * requested_lock_row
ulint trx_search_latch_timeout
const i_s_locks_row_t * requested_lock_row
const char * trx_operation_state
ulint trx_lock_memory_bytes
ib_time_t trx_wait_started
ibool trx_foreign_key_checks
const char * trx_foreign_key_error
ulint trx_concurrency_tickets
ulint trx_mysql_thread_id
const char * trx_isolation_level
ibool trx_has_search_latch
ib_uint64_t compressed_usec
ib_uint64_t decompressed_usec
UNIV_INTERN int trx_i_s_possibly_fetch_data_into_cache(trx_i_s_cache_t *cache)
UNIV_INTERN void trx_i_s_cache_start_write(trx_i_s_cache_t *cache)
#define TRX_I_S_MEM_LIMIT
#define TRX_I_S_TRX_FK_ERROR_MAX_LEN
UNIV_INTERN void trx_i_s_cache_start_read(trx_i_s_cache_t *cache)
UNIV_INTERN void trx_i_s_cache_end_read(trx_i_s_cache_t *cache)
struct i_s_trx_row_struct i_s_trx_row_t
trx_i_s_cache_t * trx_i_s_cache
UNIV_INTERN void * trx_i_s_cache_get_nth_row(trx_i_s_cache_t *cache, enum i_s_table table, ulint n)
#define TRX_I_S_TRX_ISOLATION_LEVEL_MAX_LEN
struct i_s_locks_row_struct i_s_locks_row_t
#define TRX_I_S_TRX_QUERY_MAX_LEN
#define TRX_I_S_LOCK_ID_MAX_LEN
UNIV_INTERN void trx_i_s_cache_end_write(trx_i_s_cache_t *cache)
UNIV_INTERN ibool trx_i_s_cache_is_truncated(trx_i_s_cache_t *cache)
struct i_s_lock_waits_row_struct i_s_lock_waits_row_t
UNIV_INTERN char * trx_i_s_create_lock_id(const i_s_locks_row_t *row, char *lock_id, ulint lock_id_size)
UNIV_INTERN ulint trx_i_s_cache_get_rows_used(trx_i_s_cache_t *cache, enum i_s_table table)
#define TRX_I_S_TRX_OP_STATE_MAX_LEN
#define UT_LIST_GET_LEN(BASE)