mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Check in the support for Information Schema System Table Views. Users
can now view the content of InnoDB System Tables through following information schema tables: information_schema.INNODB_SYS_TABLES information_schema.INNODB_SYS_INDEXES information_schema.INNODB_SYS_COUMNS information_schema.INNODB_SYS_FIELDS information_schema.INNODB_SYS_FOREIGN information_schema.INNODB_SYS_FOREIGN_COLS information_schema.INNODB_SYS_TABLESTATS rb://330 Approved by Marko
This commit is contained in:
@ -109,13 +109,20 @@ Database: information_schema
|
||||
| TRIGGERS |
|
||||
| USER_PRIVILEGES |
|
||||
| VIEWS |
|
||||
| INNODB_CMP_RESET |
|
||||
| INNODB_SYS_FIELDS |
|
||||
| INNODB_TRX |
|
||||
| INNODB_CMPMEM_RESET |
|
||||
| INNODB_SYS_INDEXES |
|
||||
| INNODB_LOCK_WAITS |
|
||||
| INNODB_CMPMEM |
|
||||
| INNODB_SYS_TABLESTATS |
|
||||
| INNODB_CMP |
|
||||
| INNODB_SYS_COLUMNS |
|
||||
| INNODB_CMP_RESET |
|
||||
| INNODB_SYS_FOREIGN_COLS |
|
||||
| INNODB_LOCKS |
|
||||
| INNODB_CMPMEM_RESET |
|
||||
| INNODB_CMPMEM |
|
||||
| INNODB_SYS_FOREIGN |
|
||||
| INNODB_SYS_TABLES |
|
||||
+---------------------------------------+
|
||||
Database: INFORMATION_SCHEMA
|
||||
+---------------------------------------+
|
||||
@ -151,13 +158,20 @@ Database: INFORMATION_SCHEMA
|
||||
| TRIGGERS |
|
||||
| USER_PRIVILEGES |
|
||||
| VIEWS |
|
||||
| INNODB_CMP_RESET |
|
||||
| INNODB_SYS_FIELDS |
|
||||
| INNODB_TRX |
|
||||
| INNODB_CMPMEM_RESET |
|
||||
| INNODB_SYS_INDEXES |
|
||||
| INNODB_LOCK_WAITS |
|
||||
| INNODB_CMPMEM |
|
||||
| INNODB_SYS_TABLESTATS |
|
||||
| INNODB_CMP |
|
||||
| INNODB_SYS_COLUMNS |
|
||||
| INNODB_CMP_RESET |
|
||||
| INNODB_SYS_FOREIGN_COLS |
|
||||
| INNODB_LOCKS |
|
||||
| INNODB_CMPMEM_RESET |
|
||||
| INNODB_CMPMEM |
|
||||
| INNODB_SYS_FOREIGN |
|
||||
| INNODB_SYS_TABLES |
|
||||
+---------------------------------------+
|
||||
Wildcard: inf_rmation_schema
|
||||
+--------------------+
|
||||
|
110
mysql-test/suite/innodb/r/innodb-system-table-view.result
Normal file
110
mysql-test/suite/innodb/r/innodb-system-table-view.result
Normal file
@ -0,0 +1,110 @@
|
||||
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES;
|
||||
TABLE_ID NAME FLAG N_COLS SPACE
|
||||
11 SYS_FOREIGN 0 7 0
|
||||
12 SYS_FOREIGN_COLS 0 7 0
|
||||
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES;
|
||||
INDEX_ID NAME TABLE_ID TYPE N_FIELDS PAGE_NO SPACE
|
||||
11 ID_IND 11 3 1 302 0
|
||||
12 FOR_IND 11 0 1 303 0
|
||||
13 REF_IND 11 0 1 304 0
|
||||
14 ID_IND 12 3 2 305 0
|
||||
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS;
|
||||
TABLE_ID NAME POS MTYPE PRTYPE LEN
|
||||
11 ID 0 1 524292 0
|
||||
11 FOR_NAME 1 1 524292 0
|
||||
11 REF_NAME 2 1 524292 0
|
||||
11 N_COLS 3 6 0 4
|
||||
12 ID 0 1 524292 0
|
||||
12 POS 1 6 0 4
|
||||
12 FOR_COL_NAME 2 1 524292 0
|
||||
12 REF_COL_NAME 3 1 524292 0
|
||||
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS;
|
||||
INDEX_ID NAME POS
|
||||
11 ID 0
|
||||
12 FOR_NAME 0
|
||||
13 REF_NAME 0
|
||||
14 ID 0
|
||||
14 POS 1
|
||||
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN;
|
||||
ID FOR_NAME REF_NAME N_COLS TYPE
|
||||
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS;
|
||||
ID FOR_COL_NAME REF_COL_NAME POS
|
||||
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS;
|
||||
TABLE_ID NAME STATS_INITIALIZED NUM_ROWS CLUST_INDEX_SIZE OTHER_INDEX_SIZE MODIFIED_COUNTER AUTOINC MYSQL_HANDLES_OPENED
|
||||
11 SYS_FOREIGN Uninitialized 0 0 0 0 0 0
|
||||
12 SYS_FOREIGN_COLS Uninitialized 0 0 0 0 0 0
|
||||
CREATE TABLE parent (id INT NOT NULL,
|
||||
PRIMARY KEY (id)) ENGINE=INNODB;
|
||||
CREATE TABLE child (id INT, parent_id INT,
|
||||
INDEX par_ind (parent_id),
|
||||
CONSTRAINT constraint_test
|
||||
FOREIGN KEY (parent_id) REFERENCES parent(id)
|
||||
ON DELETE CASCADE) ENGINE=INNODB;
|
||||
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN;
|
||||
ID FOR_NAME REF_NAME N_COLS TYPE
|
||||
test/constraint_test test/child test/parent 1 1
|
||||
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS;
|
||||
ID FOR_COL_NAME REF_COL_NAME POS
|
||||
test/constraint_test parent_id id 0
|
||||
INSERT INTO parent VALUES(1);
|
||||
SELECT name, num_rows, mysql_handles_opened
|
||||
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
|
||||
WHERE name LIKE "%parent";
|
||||
name num_rows mysql_handles_opened
|
||||
test/parent 1 1
|
||||
SELECT NAME, FLAG, N_COLS, SPACE FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES;
|
||||
NAME FLAG N_COLS SPACE
|
||||
SYS_FOREIGN 0 7 0
|
||||
SYS_FOREIGN_COLS 0 7 0
|
||||
test/child 1 5 0
|
||||
test/parent 1 4 0
|
||||
SELECT name, n_fields
|
||||
from INFORMATION_SCHEMA.INNODB_SYS_INDEXES
|
||||
WHERE table_id In (SELECT table_id from
|
||||
INFORMATION_SCHEMA.INNODB_SYS_TABLES
|
||||
WHERE name LIKE "%parent%");
|
||||
name n_fields
|
||||
PRIMARY 1
|
||||
SELECT name, n_fields
|
||||
from INFORMATION_SCHEMA.INNODB_SYS_INDEXES
|
||||
WHERE table_id In (SELECT table_id from
|
||||
INFORMATION_SCHEMA.INNODB_SYS_TABLES
|
||||
WHERE name LIKE "%child%");
|
||||
name n_fields
|
||||
GEN_CLUST_INDEX 0
|
||||
par_ind 1
|
||||
SELECT name, pos, mtype, len
|
||||
from INFORMATION_SCHEMA.INNODB_SYS_COLUMNS
|
||||
WHERE table_id In (SELECT table_id from
|
||||
INFORMATION_SCHEMA.INNODB_SYS_TABLES
|
||||
WHERE name LIKE "%child%");
|
||||
name pos mtype len
|
||||
id 0 6 4
|
||||
parent_id 1 6 4
|
||||
DROP TABLE child;
|
||||
DROP TABLE parent;
|
||||
CREATE TABLE parent (id INT NOT NULL, newid INT NOT NULL,
|
||||
PRIMARY KEY (id, newid)) ENGINE=INNODB;
|
||||
CREATE TABLE child (id INT, parent_id INT,
|
||||
INDEX par_ind (parent_id),
|
||||
CONSTRAINT constraint_test
|
||||
FOREIGN KEY (id, parent_id) REFERENCES parent(id, newid)
|
||||
ON DELETE CASCADE) ENGINE=INNODB;
|
||||
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN;
|
||||
ID FOR_NAME REF_NAME N_COLS TYPE
|
||||
test/constraint_test test/child test/parent 2 1
|
||||
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS;
|
||||
ID FOR_COL_NAME REF_COL_NAME POS
|
||||
test/constraint_test id id 0
|
||||
test/constraint_test parent_id newid 1
|
||||
INSERT INTO parent VALUES(1, 9);
|
||||
SELECT * FROM parent WHERE id IN (SELECT id FROM parent);
|
||||
id newid
|
||||
1 9
|
||||
SELECT name, num_rows, mysql_handles_opened
|
||||
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
|
||||
WHERE name LIKE "%parent";
|
||||
name num_rows mysql_handles_opened
|
||||
test/parent 1 2
|
||||
DROP TABLE child;
|
||||
DROP TABLE parent;
|
94
mysql-test/suite/innodb/t/innodb-system-table-view.test
Normal file
94
mysql-test/suite/innodb/t/innodb-system-table-view.test
Normal file
@ -0,0 +1,94 @@
|
||||
# This is the test for Information Schema System Table View
|
||||
# that displays the InnoDB system table content through
|
||||
# information schema tables.
|
||||
|
||||
--source include/have_innodb.inc
|
||||
|
||||
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES;
|
||||
|
||||
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES;
|
||||
|
||||
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS;
|
||||
|
||||
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS;
|
||||
|
||||
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN;
|
||||
|
||||
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS;
|
||||
|
||||
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS;
|
||||
|
||||
# Create a foreign key constraint, and verify the information
|
||||
# in INFORMATION_SCHEMA.INNODB_SYS_FOREIGN and
|
||||
# INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS
|
||||
CREATE TABLE parent (id INT NOT NULL,
|
||||
PRIMARY KEY (id)) ENGINE=INNODB;
|
||||
|
||||
CREATE TABLE child (id INT, parent_id INT,
|
||||
INDEX par_ind (parent_id),
|
||||
CONSTRAINT constraint_test
|
||||
FOREIGN KEY (parent_id) REFERENCES parent(id)
|
||||
ON DELETE CASCADE) ENGINE=INNODB;
|
||||
|
||||
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN;
|
||||
|
||||
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS;
|
||||
|
||||
# Insert a row in the table "parent", and see whether that reflected in
|
||||
# INNODB_SYS_TABLESTATS
|
||||
INSERT INTO parent VALUES(1);
|
||||
|
||||
SELECT name, num_rows, mysql_handles_opened
|
||||
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
|
||||
WHERE name LIKE "%parent";
|
||||
|
||||
SELECT NAME, FLAG, N_COLS, SPACE FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES;
|
||||
|
||||
SELECT name, n_fields
|
||||
from INFORMATION_SCHEMA.INNODB_SYS_INDEXES
|
||||
WHERE table_id In (SELECT table_id from
|
||||
INFORMATION_SCHEMA.INNODB_SYS_TABLES
|
||||
WHERE name LIKE "%parent%");
|
||||
|
||||
SELECT name, n_fields
|
||||
from INFORMATION_SCHEMA.INNODB_SYS_INDEXES
|
||||
WHERE table_id In (SELECT table_id from
|
||||
INFORMATION_SCHEMA.INNODB_SYS_TABLES
|
||||
WHERE name LIKE "%child%");
|
||||
|
||||
SELECT name, pos, mtype, len
|
||||
from INFORMATION_SCHEMA.INNODB_SYS_COLUMNS
|
||||
WHERE table_id In (SELECT table_id from
|
||||
INFORMATION_SCHEMA.INNODB_SYS_TABLES
|
||||
WHERE name LIKE "%child%");
|
||||
|
||||
DROP TABLE child;
|
||||
|
||||
DROP TABLE parent;
|
||||
|
||||
# Create table with 2 columns in the foreign key constraint
|
||||
CREATE TABLE parent (id INT NOT NULL, newid INT NOT NULL,
|
||||
PRIMARY KEY (id, newid)) ENGINE=INNODB;
|
||||
|
||||
CREATE TABLE child (id INT, parent_id INT,
|
||||
INDEX par_ind (parent_id),
|
||||
CONSTRAINT constraint_test
|
||||
FOREIGN KEY (id, parent_id) REFERENCES parent(id, newid)
|
||||
ON DELETE CASCADE) ENGINE=INNODB;
|
||||
|
||||
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN;
|
||||
|
||||
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS;
|
||||
|
||||
INSERT INTO parent VALUES(1, 9);
|
||||
|
||||
# Nested query will open the table handle twice
|
||||
SELECT * FROM parent WHERE id IN (SELECT id FROM parent);
|
||||
|
||||
SELECT name, num_rows, mysql_handles_opened
|
||||
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
|
||||
WHERE name LIKE "%parent";
|
||||
|
||||
DROP TABLE child;
|
||||
|
||||
DROP TABLE parent;
|
File diff suppressed because it is too large
Load Diff
@ -177,10 +177,6 @@ dict_mem_table_add_col(
|
||||
ulint len) /*!< in: precision */
|
||||
{
|
||||
dict_col_t* col;
|
||||
#ifndef UNIV_HOTBACKUP
|
||||
ulint mbminlen;
|
||||
ulint mbmaxlen;
|
||||
#endif /* !UNIV_HOTBACKUP */
|
||||
ulint i;
|
||||
|
||||
ut_ad(table);
|
||||
@ -205,19 +201,7 @@ dict_mem_table_add_col(
|
||||
|
||||
col = dict_table_get_nth_col(table, i);
|
||||
|
||||
col->ind = (unsigned int) i;
|
||||
col->ord_part = 0;
|
||||
|
||||
col->mtype = (unsigned int) mtype;
|
||||
col->prtype = (unsigned int) prtype;
|
||||
col->len = (unsigned int) len;
|
||||
|
||||
#ifndef UNIV_HOTBACKUP
|
||||
dtype_get_mblen(mtype, prtype, &mbminlen, &mbmaxlen);
|
||||
|
||||
col->mbminlen = (unsigned int) mbminlen;
|
||||
col->mbmaxlen = (unsigned int) mbmaxlen;
|
||||
#endif /* !UNIV_HOTBACKUP */
|
||||
dict_mem_fill_column_struct(col, i, mtype, prtype, len);
|
||||
}
|
||||
|
||||
/**********************************************************************//**
|
||||
@ -244,22 +228,9 @@ dict_mem_index_create(
|
||||
heap = mem_heap_create(DICT_HEAP_SIZE);
|
||||
index = mem_heap_zalloc(heap, sizeof(dict_index_t));
|
||||
|
||||
index->heap = heap;
|
||||
dict_mem_fill_index_struct(index, heap, table_name, index_name,
|
||||
space, type, n_fields);
|
||||
|
||||
index->type = type;
|
||||
#ifndef UNIV_HOTBACKUP
|
||||
index->space = (unsigned int) space;
|
||||
#endif /* !UNIV_HOTBACKUP */
|
||||
index->name = mem_heap_strdup(heap, index_name);
|
||||
index->table_name = table_name;
|
||||
index->n_fields = (unsigned int) n_fields;
|
||||
index->fields = mem_heap_alloc(heap, 1 + n_fields
|
||||
* sizeof(dict_field_t));
|
||||
/* The '1 +' above prevents allocation
|
||||
of an empty mem block */
|
||||
#ifdef UNIV_DEBUG
|
||||
index->magic_n = DICT_INDEX_MAGIC_N;
|
||||
#endif /* UNIV_DEBUG */
|
||||
return(index);
|
||||
}
|
||||
|
||||
|
@ -11105,7 +11105,15 @@ i_s_innodb_lock_waits,
|
||||
i_s_innodb_cmp,
|
||||
i_s_innodb_cmp_reset,
|
||||
i_s_innodb_cmpmem,
|
||||
i_s_innodb_cmpmem_reset
|
||||
i_s_innodb_cmpmem_reset,
|
||||
i_s_innodb_sys_tables,
|
||||
i_s_innodb_sys_tablestats,
|
||||
i_s_innodb_sys_indexes,
|
||||
i_s_innodb_sys_columns,
|
||||
i_s_innodb_sys_fields,
|
||||
i_s_innodb_sys_foreign,
|
||||
i_s_innodb_sys_foreign_cols
|
||||
|
||||
mysql_declare_plugin_end;
|
||||
|
||||
/** @brief Initialize the default value of innodb_commit_concurrency.
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -33,5 +33,12 @@ extern struct st_mysql_plugin i_s_innodb_cmp;
|
||||
extern struct st_mysql_plugin i_s_innodb_cmp_reset;
|
||||
extern struct st_mysql_plugin i_s_innodb_cmpmem;
|
||||
extern struct st_mysql_plugin i_s_innodb_cmpmem_reset;
|
||||
extern struct st_mysql_plugin i_s_innodb_sys_tables;
|
||||
extern struct st_mysql_plugin i_s_innodb_sys_tablestats;
|
||||
extern struct st_mysql_plugin i_s_innodb_sys_indexes;
|
||||
extern struct st_mysql_plugin i_s_innodb_sys_columns;
|
||||
extern struct st_mysql_plugin i_s_innodb_sys_fields;
|
||||
extern struct st_mysql_plugin i_s_innodb_sys_foreign;
|
||||
extern struct st_mysql_plugin i_s_innodb_sys_foreign_cols;
|
||||
|
||||
#endif /* i_s_h */
|
||||
|
@ -765,7 +765,7 @@ dict_table_get_low(
|
||||
table = dict_table_check_if_in_cache_low(table_name);
|
||||
|
||||
if (table == NULL) {
|
||||
table = dict_load_table(table_name);
|
||||
table = dict_load_table(table_name, TRUE);
|
||||
}
|
||||
|
||||
ut_ad(!table || table->cached);
|
||||
|
@ -31,6 +31,35 @@ Created 4/24/1996 Heikki Tuuri
|
||||
#include "dict0types.h"
|
||||
#include "ut0byte.h"
|
||||
#include "mem0mem.h"
|
||||
#include "btr0types.h"
|
||||
|
||||
/** enum that defines all 6 system table IDs */
|
||||
enum dict_system_table_id {
|
||||
SYS_TABLES = 0,
|
||||
SYS_INDEXES,
|
||||
SYS_COLUMNS,
|
||||
SYS_FIELDS,
|
||||
SYS_FOREIGN,
|
||||
SYS_FOREIGN_COLS,
|
||||
|
||||
/* This must be last item. Defines the number of system tables. */
|
||||
SYS_NUM_SYSTEM_TABLES
|
||||
};
|
||||
|
||||
typedef enum dict_system_table_id dict_system_id_t;
|
||||
|
||||
/** Status bit for dict_process_sys_tables_rec() */
|
||||
enum dict_table_info {
|
||||
DICT_TABLE_LOAD_FROM_RECORD = 0,/*!< Directly populate a dict_table_t
|
||||
structure with information from
|
||||
a SYS_TABLES record */
|
||||
DICT_TABLE_LOAD_FROM_CACHE = 1, /*!< Check first whether dict_table_t
|
||||
is in the cache, if so, return it */
|
||||
DICT_TABLE_UPDATE_STATS = 2 /*!< whether to update statistics
|
||||
when loading SYS_TABLES information. */
|
||||
};
|
||||
|
||||
typedef enum dict_table_info dict_table_info_t;
|
||||
|
||||
/********************************************************************//**
|
||||
In a crash recovery we already have all the tablespace objects created.
|
||||
@ -54,6 +83,74 @@ char*
|
||||
dict_get_first_table_name_in_db(
|
||||
/*============================*/
|
||||
const char* name); /*!< in: database name which ends to '/' */
|
||||
|
||||
/********************************************************************//**
|
||||
Loads a table definition from a SYS_TABLES record to dict_table_t.
|
||||
Does not load any columns or indexes.
|
||||
@return error message, or NULL on success */
|
||||
UNIV_INTERN
|
||||
const char*
|
||||
dict_load_table_low(
|
||||
/*================*/
|
||||
const char* name, /*!< in: table name */
|
||||
const rec_t* rec, /*!< in: SYS_TABLES record */
|
||||
dict_table_t** table); /*!< out,own: table, or NULL */
|
||||
/********************************************************************//**
|
||||
Loads a table column definition from a SYS_COLUMNS record to
|
||||
dict_table_t.
|
||||
@return error message, or NULL on success */
|
||||
UNIV_INTERN
|
||||
const char*
|
||||
dict_load_column_low(
|
||||
/*=================*/
|
||||
dict_table_t* table, /*!< in/out: table, could be NULL
|
||||
if we just populate a dict_column_t
|
||||
struct with information from
|
||||
a SYS_COLUMNS record */
|
||||
mem_heap_t* heap, /*!< in/out: memory heap
|
||||
for temporary storage */
|
||||
dict_col_t* column, /*!< out: dict_column_t to fill */
|
||||
dulint* table_id, /*!< out: table id */
|
||||
const char** col_name, /*!< out: column name */
|
||||
const rec_t* rec); /*!< in: SYS_COLUMNS record */
|
||||
/********************************************************************//**
|
||||
Loads an index definition from a SYS_INDEXES record to dict_index_t.
|
||||
@return error message, or NULL on success */
|
||||
UNIV_INTERN
|
||||
const char*
|
||||
dict_load_index_low(
|
||||
/*================*/
|
||||
byte* table_id, /*!< in/out: table id (8 bytes_,
|
||||
an "in" value if cached=TRUE
|
||||
and "out" when cached=FALSE */
|
||||
const char* table_name, /*!< in: table name */
|
||||
mem_heap_t* heap, /*!< in/out: temporary memory heap */
|
||||
const rec_t* rec, /*!< in: SYS_INDEXES record */
|
||||
ibool cached, /*!< in: TRUE = add to cache
|
||||
FALSE = do not */
|
||||
dict_index_t** index); /*!< out,own: index, or NULL */
|
||||
/********************************************************************//**
|
||||
Loads an index field definition from a SYS_FIELDS record to
|
||||
dict_index_t.
|
||||
@return error message, or NULL on success */
|
||||
UNIV_INTERN
|
||||
const char*
|
||||
dict_load_field_low(
|
||||
/*================*/
|
||||
byte* index_id, /*!< in/out: index id (8 bytes)
|
||||
an "in" value if index != NULL
|
||||
and "out" if index == NULL */
|
||||
dict_index_t* index, /*!< in/out: index, could be NULL
|
||||
if we just populate a dict_field_t
|
||||
struct with information from
|
||||
a SYS_FIELDS record */
|
||||
dict_field_t* sys_field, /*!< out: dict_field_t to be
|
||||
filled */
|
||||
ulint* pos, /*!< out: Field position */
|
||||
byte* last_index_id, /*!< in: last index id */
|
||||
mem_heap_t* heap, /*!< in/out: memory heap
|
||||
for temporary storage */
|
||||
const rec_t* rec); /*!< in: SYS_FIELDS record */
|
||||
/********************************************************************//**
|
||||
Loads a table definition and also all its index definitions, and also
|
||||
the cluster definition if the table is a member in a cluster. Also loads
|
||||
@ -66,8 +163,9 @@ UNIV_INTERN
|
||||
dict_table_t*
|
||||
dict_load_table(
|
||||
/*============*/
|
||||
const char* name); /*!< in: table name in the
|
||||
const char* name, /*!< in: table name in the
|
||||
databasename/tablename format */
|
||||
ibool cached);/*!< in: TRUE=add to cache, FALSE=do not */
|
||||
/***********************************************************************//**
|
||||
Loads a table object based on the table id.
|
||||
@return table; NULL if table does not exist */
|
||||
@ -107,7 +205,113 @@ void
|
||||
dict_print(void);
|
||||
/*============*/
|
||||
|
||||
|
||||
/********************************************************************//**
|
||||
This function opens a system table, and return the first record.
|
||||
@return first record of the system table */
|
||||
UNIV_INTERN
|
||||
const rec_t*
|
||||
dict_startscan_system(
|
||||
/*==================*/
|
||||
btr_pcur_t* pcur, /*!< out: persistent cursor to
|
||||
the record */
|
||||
mtr_t* mtr, /*!< in: the mini-transaction */
|
||||
dict_system_id_t system_id); /*!< in: which system table to open */
|
||||
/********************************************************************//**
|
||||
This function get the next system table record as we scan the table.
|
||||
@return the record if found, NULL if end of scan. */
|
||||
UNIV_INTERN
|
||||
const rec_t*
|
||||
dict_getnext_system(
|
||||
/*================*/
|
||||
btr_pcur_t* pcur, /*!< in/out: persistent cursor
|
||||
to the record */
|
||||
mtr_t* mtr); /*!< in: the mini-transaction */
|
||||
/********************************************************************//**
|
||||
This function processes one SYS_TABLES record and populate the dict_table_t
|
||||
struct for the table. Extracted out of dict_print() to be used by
|
||||
both monitor table output and information schema innodb_sys_tables output.
|
||||
@return error message, or NULL on success */
|
||||
UNIV_INTERN
|
||||
const char*
|
||||
dict_process_sys_tables_rec(
|
||||
/*========================*/
|
||||
mem_heap_t* heap, /*!< in: temporary memory heap */
|
||||
const rec_t* rec, /*!< in: SYS_TABLES record */
|
||||
dict_table_t** table, /*!< out: dict_table_t to fill */
|
||||
dict_table_info_t status); /*!< in: status bit controls
|
||||
options such as whether we shall
|
||||
look for dict_table_t from cache
|
||||
first */
|
||||
/********************************************************************//**
|
||||
This function parses a SYS_INDEXES record and populate a dict_index_t
|
||||
structure with the information from the record. For detail information
|
||||
about SYS_INDEXES fields, please refer to dict_boot() function.
|
||||
@return error message, or NULL on success */
|
||||
UNIV_INTERN
|
||||
const char*
|
||||
dict_process_sys_indexes_rec(
|
||||
/*=========================*/
|
||||
mem_heap_t* heap, /*!< in/out: heap memory */
|
||||
const rec_t* rec, /*!< in: current SYS_INDEXES rec */
|
||||
dict_index_t* index, /*!< out: dict_index_t to be
|
||||
filled */
|
||||
dulint* table_id); /*!< out: table id */
|
||||
/********************************************************************//**
|
||||
This function parses a SYS_COLUMNS record and populate a dict_column_t
|
||||
structure with the information from the record.
|
||||
@return error message, or NULL on success */
|
||||
UNIV_INTERN
|
||||
const char*
|
||||
dict_process_sys_columns_rec(
|
||||
/*=========================*/
|
||||
mem_heap_t* heap, /*!< in/out: heap memory */
|
||||
const rec_t* rec, /*!< in: current SYS_COLUMNS rec */
|
||||
dict_col_t* column, /*!< out: dict_col_t to be filled */
|
||||
dulint* table_id, /*!< out: table id */
|
||||
const char** col_name); /*!< out: column name */
|
||||
/********************************************************************//**
|
||||
This function parses a SYS_FIELDS record and populate a dict_field_t
|
||||
structure with the information from the record.
|
||||
@return error message, or NULL on success */
|
||||
UNIV_INTERN
|
||||
const char*
|
||||
dict_process_sys_fields_rec(
|
||||
/*========================*/
|
||||
mem_heap_t* heap, /*!< in/out: heap memory */
|
||||
const rec_t* rec, /*!< in: current SYS_FIELDS rec */
|
||||
dict_field_t* sys_field, /*!< out: dict_field_t to be
|
||||
filled */
|
||||
ulint* pos, /*!< out: Field position */
|
||||
dulint* index_id, /*!< out: current index id */
|
||||
dulint last_id); /*!< in: previous index id */
|
||||
/********************************************************************//**
|
||||
This function parses a SYS_FOREIGN record and populate a dict_foreign_t
|
||||
structure with the information from the record. For detail information
|
||||
about SYS_FOREIGN fields, please refer to dict_load_foreign() function
|
||||
@return error message, or NULL on success */
|
||||
UNIV_INTERN
|
||||
const char*
|
||||
dict_process_sys_foreign_rec(
|
||||
/*=========================*/
|
||||
mem_heap_t* heap, /*!< in/out: heap memory */
|
||||
const rec_t* rec, /*!< in: current SYS_FOREIGN rec */
|
||||
dict_foreign_t* foreign); /*!< out: dict_foreign_t to be
|
||||
filled */
|
||||
/********************************************************************//**
|
||||
This function parses a SYS_FOREIGN_COLS record and extract necessary
|
||||
information from the record and return to caller.
|
||||
@return error message, or NULL on success */
|
||||
UNIV_INTERN
|
||||
const char*
|
||||
dict_process_sys_foreign_col_rec(
|
||||
/*=============================*/
|
||||
mem_heap_t* heap, /*!< in/out: heap memory */
|
||||
const rec_t* rec, /*!< in: current SYS_FOREIGN_COLS rec */
|
||||
const char** name, /*!< out: foreign key constraint name */
|
||||
const char** for_col_name, /*!< out: referencing column name */
|
||||
const char** ref_col_name, /*!< out: referenced column name
|
||||
in referenced table */
|
||||
ulint* pos); /*!< out: column position */
|
||||
#ifndef UNIV_NONINL
|
||||
#include "dict0load.ic"
|
||||
#endif
|
||||
|
@ -147,6 +147,36 @@ dict_mem_table_add_col(
|
||||
ulint prtype, /*!< in: precise type */
|
||||
ulint len); /*!< in: precision */
|
||||
/**********************************************************************//**
|
||||
This function poplulates a dict_col_t memory structure with
|
||||
supplied information. */
|
||||
UNIV_INLINE
|
||||
void
|
||||
dict_mem_fill_column_struct(
|
||||
/*========================*/
|
||||
dict_col_t* column, /*!< out: column struct to be
|
||||
filled */
|
||||
ulint col_pos, /*!< in: column position */
|
||||
ulint mtype, /*!< in: main data type */
|
||||
ulint prtype, /*!< in: precise type */
|
||||
ulint col_len); /*!< in: column lenght */
|
||||
/**********************************************************************//**
|
||||
This function poplulates a dict_index_t index memory structure with
|
||||
supplied information. */
|
||||
UNIV_INLINE
|
||||
void
|
||||
dict_mem_fill_index_struct(
|
||||
/*=======================*/
|
||||
dict_index_t* index, /*!< out: index to be filled */
|
||||
mem_heap_t* heap, /*!< in: memory heap */
|
||||
const char* table_name, /*!< in: table name */
|
||||
const char* index_name, /*!< in: index name */
|
||||
ulint space, /*!< in: space where the index tree is
|
||||
placed, ignored if the index is of
|
||||
the clustered type */
|
||||
ulint type, /*!< in: DICT_UNIQUE,
|
||||
DICT_CLUSTERED, ... ORed */
|
||||
ulint n_fields); /*!< in: number of fields */
|
||||
/**********************************************************************//**
|
||||
Creates an index memory object.
|
||||
@return own: index object */
|
||||
UNIV_INTERN
|
||||
|
@ -23,4 +23,82 @@ Data dictionary memory object creation
|
||||
Created 1/8/1996 Heikki Tuuri
|
||||
***********************************************************************/
|
||||
|
||||
#include "data0type.h"
|
||||
#include "dict0mem.h"
|
||||
#include "fil0fil.h"
|
||||
|
||||
/**********************************************************************//**
|
||||
This function poplulates a dict_index_t index memory structure with
|
||||
supplied information. */
|
||||
UNIV_INLINE
|
||||
void
|
||||
dict_mem_fill_index_struct(
|
||||
/*=======================*/
|
||||
dict_index_t* index, /*!< out: index to be filled */
|
||||
mem_heap_t* heap, /*!< in: memory heap */
|
||||
const char* table_name, /*!< in: table name */
|
||||
const char* index_name, /*!< in: index name */
|
||||
ulint space, /*!< in: space where the index tree is
|
||||
placed, ignored if the index is of
|
||||
the clustered type */
|
||||
ulint type, /*!< in: DICT_UNIQUE,
|
||||
DICT_CLUSTERED, ... ORed */
|
||||
ulint n_fields) /*!< in: number of fields */
|
||||
{
|
||||
|
||||
if (heap) {
|
||||
index->heap = heap;
|
||||
index->name = mem_heap_strdup(heap, index_name);
|
||||
index->fields = (dict_field_t*) mem_heap_alloc(
|
||||
heap, 1 + n_fields * sizeof(dict_field_t));
|
||||
} else {
|
||||
index->name = index_name;
|
||||
index->heap = NULL;
|
||||
index->fields = NULL;
|
||||
}
|
||||
|
||||
index->type = type;
|
||||
#ifndef UNIV_HOTBACKUP
|
||||
index->space = (unsigned int) space;
|
||||
index->page = FIL_NULL;
|
||||
#endif /* !UNIV_HOTBACKUP */
|
||||
index->table_name = table_name;
|
||||
index->n_fields = (unsigned int) n_fields;
|
||||
/* The '1 +' above prevents allocation
|
||||
of an empty mem block */
|
||||
#ifdef UNIV_DEBUG
|
||||
index->magic_n = DICT_INDEX_MAGIC_N;
|
||||
#endif /* UNIV_DEBUG */
|
||||
}
|
||||
|
||||
/**********************************************************************//**
|
||||
This function poplulates a dict_col_t memory structure with
|
||||
supplied information. */
|
||||
UNIV_INLINE
|
||||
void
|
||||
dict_mem_fill_column_struct(
|
||||
/*========================*/
|
||||
dict_col_t* column, /*!< out: column struct to be
|
||||
filled */
|
||||
ulint col_pos, /*!< in: column position */
|
||||
ulint mtype, /*!< in: main data type */
|
||||
ulint prtype, /*!< in: precise type */
|
||||
ulint col_len) /*!< in: column lenght */
|
||||
{
|
||||
#ifndef UNIV_HOTBACKUP
|
||||
ulint mbminlen;
|
||||
ulint mbmaxlen;
|
||||
#endif /* !UNIV_HOTBACKUP */
|
||||
|
||||
column->ind = (unsigned int) col_pos;
|
||||
column->ord_part = 0;
|
||||
column->mtype = (unsigned int) mtype;
|
||||
column->prtype = (unsigned int) prtype;
|
||||
column->len = (unsigned int) col_len;
|
||||
#ifndef UNIV_HOTBACKUP
|
||||
dtype_get_mblen(mtype, prtype, &mbminlen, &mbmaxlen);
|
||||
|
||||
column->mbminlen = (unsigned int) mbminlen;
|
||||
column->mbmaxlen = (unsigned int) mbmaxlen;
|
||||
#endif /* !UNIV_HOTBACKUP */
|
||||
}
|
||||
|
@ -3285,7 +3285,7 @@ check_next_foreign:
|
||||
|
||||
dict_table_remove_from_cache(table);
|
||||
|
||||
if (dict_load_table(name) != NULL) {
|
||||
if (dict_load_table(name, TRUE) != NULL) {
|
||||
ut_print_timestamp(stderr);
|
||||
fputs(" InnoDB: Error: not able to remove table ",
|
||||
stderr);
|
||||
@ -3431,7 +3431,7 @@ row_mysql_drop_temp_tables(void)
|
||||
btr_pcur_store_position(&pcur, &mtr);
|
||||
btr_pcur_commit_specify_mtr(&pcur, &mtr);
|
||||
|
||||
table = dict_load_table(table_name);
|
||||
table = dict_load_table(table_name, TRUE);
|
||||
|
||||
if (table) {
|
||||
row_drop_table_for_mysql(table_name, trx, FALSE);
|
||||
|
Reference in New Issue
Block a user