MySQL 5.6.14 Source Code Document
|
#include "univ.i"
#include "db0err.h"
#include "dict0types.h"
#include "dict0mem.h"
#include "data0type.h"
#include "data0data.h"
#include "mem0mem.h"
#include "rem0types.h"
#include "ut0mem.h"
#include "ut0lst.h"
#include "hash0hash.h"
#include "ut0rnd.h"
#include "ut0byte.h"
#include "trx0types.h"
#include "row0types.h"
#include "sync0sync.h"
#include "sync0rw.h"
#include "dict0dict.ic"
Go to the source code of this file.
Classes | |
struct | dict_sys_t |
struct | dict_col_meta_t |
struct | dict_table_schema_t |
Macros | |
#define | dict_table_get_first_index(table) UT_LIST_GET_FIRST((table)->indexes) |
#define | dict_table_get_last_index(table) UT_LIST_GET_LAST((table)->indexes) |
#define | dict_table_get_next_index(index) UT_LIST_GET_NEXT(indexes, index) |
#define | dict_table_skip_corrupt_index(index) |
#define | dict_table_next_uncorrupted_index(index) |
#define | dict_table_get_nth_col(table, pos) ((table)->cols + (pos)) |
#define | dict_table_get_sys_col(table, sys) ((table)->cols + (table)->n_cols + (sys) - DATA_N_SYS_COLS) |
#define | dict_index_get_nth_field(index, pos) ((index)->fields + (pos)) |
#define | MAX_NUM_FK_COLUMNS 500 |
Enumerations | |
enum | dict_table_op_t { DICT_TABLE_OP_NORMAL = 0, DICT_TABLE_OP_DROP_ORPHAN, DICT_TABLE_OP_LOAD_TABLESPACE } |
Variables | |
UNIV_INLINE ulint | pure |
FILE * | dict_foreign_err_file |
ib_mutex_t | dict_foreign_err_mutex |
dict_sys_t * | dict_sys |
rw_lock_t | dict_operation_lock |
dict_index_t * | dict_ind_redundant |
dict_index_t * | dict_ind_compact |
UNIV_INTERN ulint | warn_unused_result |
UNIV_INTERN dberr_t | dict_table_schema_check (dict_table_schema_t *req_schema, char *errstr, size_t errstr_sz) __attribute__((nonnull |
#define dict_table_next_uncorrupted_index | ( | index | ) |
Definition at line 711 of file dict0dict.h.
#define dict_table_skip_corrupt_index | ( | index | ) |
Definition at line 705 of file dict0dict.h.
#define MAX_NUM_FK_COLUMNS 500 |
Maximum number of columns in a foreign key constraint. Please Note MySQL
has a much lower limit on the number of columns allowed in a foreign key constraint
Definition at line 1541 of file dict0dict.h.
enum dict_table_op_t |
Operation to perform when opening a table
Definition at line 113 of file dict0dict.h.
UNIV_INTERN void dict_casedn_str | ( | char * | a | ) |
Makes all characters in a NUL-terminated UTF-8 string lower case.
a | in/out: string to put in lower case |
Definition at line 255 of file dict0dict.cc.
UNIV_INTERN void dict_close | ( | void | ) |
Closes the data dictionary module.
Definition at line 6200 of file dict0dict.cc.
UNIV_INLINE void dict_col_copy_type | ( | const dict_col_t * | col, |
dtype_t * | type | ||
) |
Gets the column data type.
col | in: column |
type | out: data type |
UNIV_INLINE ulint dict_col_get_clust_pos | ( | const dict_col_t * | col, |
const dict_index_t * | clust_index | ||
) |
Gets the column position in the clustered index.
col | in: table column |
clust_index | in: clustered index |
UNIV_INLINE ulint dict_col_get_fixed_size | ( | const dict_col_t * | col, |
ulint | comp | ||
) |
Returns the size of a fixed size column, 0 if not a fixed size column.
col | in: column |
comp | in: nonzero=ROW_FORMAT=COMPACT |
UNIV_INLINE ulint dict_col_get_max_size | ( | const dict_col_t * | col | ) |
Returns the maximum size of the column.
col | in: column |
UNIV_INLINE ulint dict_col_get_mbmaxlen | ( | const dict_col_t * | col | ) |
Gets the maximum number of bytes per character.
col | in: column |
UNIV_INLINE ulint dict_col_get_mbminlen | ( | const dict_col_t * | col | ) |
Gets the minimum number of bytes per character.
col | in: column |
UNIV_INLINE ulint dict_col_get_min_size | ( | const dict_col_t * | col | ) |
Returns the minimum size of the column.
col | in: column |
UNIV_INLINE ulint dict_col_get_no | ( | const dict_col_t * | col | ) |
Gets the column number.
col | in: column |
UNIV_INLINE ulint dict_col_get_sql_null_size | ( | const dict_col_t * | col, |
ulint | comp | ||
) |
Returns the ROW_FORMAT=REDUNDANT stored SQL NULL size of a column. For fixed length types it is the fixed length of the type, otherwise 0.
col | in: column |
comp | in: nonzero=ROW_FORMAT=COMPACT |
UNIV_INTERN ibool dict_col_name_is_reserved | ( | const char * | name | ) |
If the given column name is reserved for InnoDB system columns, return TRUE.
name | in: column name |
UNIV_INLINE void dict_col_set_mbminmaxlen | ( | dict_col_t * | col, |
ulint | mbminlen, | ||
ulint | mbmaxlen | ||
) |
Sets the minimum and maximum number of bytes per character.
col | in/out: column |
mbminlen | in: minimum multi-byte character size, in bytes |
mbmaxlen | in: minimum multi-byte character size, in bytes |
UNIV_INTERN dberr_t dict_create_foreign_constraints | ( | trx_t * | trx, |
const char * | sql_string, | ||
size_t | sql_length, | ||
const char * | name, | ||
ibool | reject_fks | ||
) |
Scans a table create SQL string and adds to the data dictionary the foreign key constraints declared in the string. This function should be called after the indexes for a table have been created. Each foreign key constraint must be accompanied with indexes in bot participating tables. The indexes are allowed to contain more fields than mentioned in the constraint.
trx | in: transaction |
sql_string | in: table create statement where foreign keys are declared like: FOREIGN KEY (a, b) REFERENCES table2(c, d), table2 can be written also with the database name before it: test.table2; the default database id the database of parameter name |
sql_length | in: length of sql_string |
name | in: table full name in the normalized form database_name/table_name |
reject_fks | in: if TRUE, fail with error code DB_CANNOT_ADD_CONSTRAINT if any foreign keys are found. |
UNIV_INLINE const dict_col_t* dict_field_get_col | ( | const dict_field_t * | field | ) |
Gets the field column.
field | in: index field |
UNIV_INTERN dberr_t dict_foreign_add_to_cache | ( | dict_foreign_t * | foreign, |
const char ** | col_names, | ||
bool | check_charsets, | ||
dict_err_ignore_t | ignore_err | ||
) |
Adds a foreign key constraint object to the dictionary cache. May free the object if there already is an object with the same identifier in. At least one of foreign table or referenced table must already be in the dictionary cache!
foreign | in, own: foreign key constraint |
col_names | in: column names, or NULL to use foreign->foreign_table->col_names |
check_charsets | in: whether to check charset compatibility |
ignore_err | in: error to be ignored |
UNIV_INTERN dict_index_t* dict_foreign_find_index | ( | const dict_table_t * | table, |
const char ** | col_names, | ||
const char ** | columns, | ||
ulint | n_cols, | ||
const dict_index_t * | types_idx, | ||
bool | check_charsets, | ||
ulint | check_null | ||
) |
Tries to find an index whose first fields are the columns in the array, in the same order and is not marked for deletion and is not the same as types_idx.
table | in: table |
col_names | in: column names, or NULL to use table->col_names |
columns | in: array of column names |
n_cols | in: number of columns |
types_idx | in: NULL or an index whose types the column types must match |
check_charsets | in: whether to check charsets. only has an effect if types_idx != NULL |
check_null | in: nonzero if none of the columns must be declared NOT NULL |
UNIV_INTERN void dict_foreign_free | ( | dict_foreign_t * | foreign | ) |
Frees a foreign key struct. in, own: foreign key struct
Frees a foreign key struct.
foreign | in, own: foreign key struct |
Definition at line 3129 of file dict0dict.cc.
UNIV_INTERN dberr_t dict_foreign_parse_drop_constraints | ( | mem_heap_t * | heap, |
trx_t * | trx, | ||
dict_table_t * | table, | ||
ulint * | n, | ||
const char *** | constraints_to_drop | ||
) |
Parses the CONSTRAINT id's to be dropped in an ALTER TABLE statement.
heap | in: heap from which we can allocate memory |
trx | in: transaction |
table | in: table |
n | out: number of constraints to drop |
constraints_to_drop | out: id's of the constraints to drop |
UNIV_INTERN void UNIV_INTERN void UNIV_INTERN bool dict_foreign_qualify_index | ( | const dict_table_t * | table, |
const char ** | col_names, | ||
const char ** | columns, | ||
ulint | n_cols, | ||
const dict_index_t * | index, | ||
const dict_index_t * | types_idx, | ||
bool | check_charsets, | ||
ulint | check_null | ||
) |
Tries to find an index whose first fields are the columns in the array, in the same order and is not marked for deletion and is not the same as types_idx.
table | in: table |
col_names | in: column names, or NULL to use table->col_names |
columns | in: array of column names |
n_cols | in: number of columns |
index | in: index to check |
types_idx | in: NULL or an index whose types the column types must match |
check_charsets | in: whether to check charsets. only has an effect if types_idx != NULL |
check_null | in: nonzero if none of the columns must be declared NOT NULL |
UNIV_INTERN void dict_foreign_remove_from_cache | ( | dict_foreign_t * | foreign | ) |
Removes a foreign constraint struct from the dictionary cache.
foreign | in, own: foreign constraint |
Definition at line 3140 of file dict0dict.cc.
UNIV_INTERN bool dict_foreign_replace_index | ( | dict_table_t * | table, |
const char ** | col_names, | ||
const dict_index_t * | index | ||
) |
Replace the index passed in with another equivalent index in the foreign key lists of the table.
table | in/out: table |
col_names | in: column names, or NULL to use table->col_names |
index | in: index to be replaced |
UNIV_INTERN void dict_fs2utf8 | ( | const char * | db_and_table, |
char * | db_utf8, | ||
size_t | db_utf8_size, | ||
char * | table_utf8, | ||
size_t | table_utf8_size | ||
) |
Converts a database and table name from filesystem encoding (e.g. d/a@1Kc, same format as used in dict_table_t::name) in two strings in UTF8 encoding (e.g. dцb and aюbØc). The output buffers must be at least MAX_DB_UTF8_LEN and MAX_TABLE_UTF8_LEN bytes.
db_and_table | in: database and table names, e.g. d/a@1Kc |
db_utf8 | out: database name, e.g. dцb |
db_utf8_size | in: dbname_utf8 size |
table_utf8 | out: table name, e.g. aюbØc |
table_utf8_size | in: table_utf8 size |
Definition at line 6138 of file dict0dict.cc.
UNIV_INTERN ulint dict_get_db_name_len | ( | const char * | name | ) |
Get the database name length in a table name.
name | in: table name in the form dbname '/' tablename |
UNIV_INTERN char* dict_get_referenced_table | ( | const char * | name, |
const char * | database_name, | ||
ulint | database_name_len, | ||
const char * | table_name, | ||
ulint | table_name_len, | ||
dict_table_t ** | table, | ||
mem_heap_t * | heap | ||
) |
Open a table from its database and table name, this is currently used by foreign constraint parser to get the referenced table.
Open a table from its database and table name, this is currently used by foreign constraint parser to get the referenced table.
name | in: foreign key table name |
database_name | in: table db name |
database_name_len | in: db name length |
table_name | in: table name |
table_name_len | in: table name length |
table | out: table object or NULL |
heap | in/out: heap memory |
Definition at line 3715 of file dict0dict.cc.
UNIV_INTERN void dict_ind_init | ( | void | ) |
Inits dict_ind_redundant and dict_ind_compact.
Definition at line 5687 of file dict0dict.cc.
UNIV_INTERN void dict_index_add_col | ( | dict_index_t * | index, |
const dict_table_t * | table, | ||
dict_col_t * | col, | ||
ulint | prefix_len | ||
) |
Adds a column to index.
index | in/out: index |
table | in: table |
col | in: column |
prefix_len | in: column prefix length |
Definition at line 2595 of file dict0dict.cc.
UNIV_INTERN dberr_t dict_index_add_to_cache | ( | dict_table_t * | table, |
dict_index_t * | index, | ||
ulint | page_no, | ||
ibool | strict | ||
) |
Adds an index to the dictionary cache.
table | in: table on which the index is |
index | in, own: index; NOTE! The index memory object is freed in this function! |
page_no | in: root page number of the index |
strict | in: TRUE=refuse to create the index if records could be too big to fit in an B-tree page |
UNIV_INTERN dtuple_t* dict_index_build_data_tuple | ( | dict_index_t * | index, |
rec_t * | rec, | ||
ulint | n_fields, | ||
mem_heap_t * | heap | ||
) |
Builds a typed data tuple out of a physical record.
index | in: index |
rec | in: record for which to build data tuple |
n_fields | in: number of data fields |
heap | in: memory heap where tuple created |
UNIV_INTERN dtuple_t* dict_index_build_node_ptr | ( | const dict_index_t * | index, |
const rec_t * | rec, | ||
ulint | page_no, | ||
mem_heap_t * | heap, | ||
ulint | level | ||
) |
Builds a node pointer out of a physical record and a page number.
index | in: index |
rec | in: record for which to build node pointer |
page_no | in: page number to put in node pointer |
heap | in: memory heap where pointer created |
level | in: level of rec in tree: 0 means leaf level |
UNIV_INTERN ulint dict_index_calc_min_rec_len | ( | const dict_index_t * | index | ) |
Calculates the minimum record length in an index.
index | in: index |
UNIV_INTERN ibool dict_index_contains_col_or_prefix | ( | const dict_index_t * | index, |
ulint | n | ||
) |
Returns TRUE if the index contains a column or a prefix of that column.
index | in: index |
n | in: column number |
UNIV_INTERN rec_t* dict_index_copy_rec_order_prefix | ( | const dict_index_t * | index, |
const rec_t * | rec, | ||
ulint * | n_fields, | ||
byte ** | buf, | ||
ulint * | buf_size | ||
) |
Copies an initial segment of a physical record, long enough to specify an index entry uniquely.
index | in: index |
rec | in: record for which to copy prefix |
n_fields | out: number of fields copied |
buf | in/out: memory buffer for the copied prefix, or NULL |
buf_size | in/out: buffer size |
UNIV_INTERN void dict_index_copy_types | ( | dtuple_t * | tuple, |
const dict_index_t * | index, | ||
ulint | n_fields | ||
) |
Copies types of fields contained in index to tuple.
tuple | in/out: data tuple |
index | in: index |
n_fields | in: number of field types to copy |
Definition at line 2668 of file dict0dict.cc.
UNIV_INTERN dict_index_t* dict_index_find_on_id_low | ( | index_id_t | id | ) |
Looks for an index with the given id. NOTE that we do not reserve the dictionary mutex: this function is for emergency purposes like printing info of a corrupt database page!
Looks for an index with the given id. NOTE that we do not reserve the dictionary mutex: this function is for emergency purposes like printing info of a corrupt database page!
id | in: index id |
Definition at line 1359 of file dict0dict.cc.
UNIV_INTERN dict_index_t* dict_index_get_if_in_cache_low | ( | index_id_t | index_id | ) |
Returns an index object if it is found in the dictionary cache. Assumes that dict_sys->mutex is already being held.
index_id | in: index id |
Definition at line 4860 of file dict0dict.cc.
UNIV_INLINE rw_lock_t* dict_index_get_lock | ( | dict_index_t * | index | ) |
Gets the read-write lock of the index tree.
index | in: index |
UNIV_INLINE ulint dict_index_get_min_size | ( | const dict_index_t * | index | ) |
Returns the minimum data size of an index record.
index | in: index |
UNIV_INLINE ulint dict_index_get_n_fields | ( | const dict_index_t * | index | ) |
Gets the number of fields in the internal representation of an index, including fields added by the dictionary system.
index | in: an internal representation of index (in the dictionary cache) |
UNIV_INLINE ulint dict_index_get_n_ordering_defined_by_user | ( | const dict_index_t * | index | ) |
Gets the number of user-defined ordering fields in the index. In the internal representation we add the row id to the ordering fields to make all indexes unique, but this function returns the number of fields the user defined in the index as ordering fields.
index | in: an internal representation of index (in the dictionary cache) |
UNIV_INLINE ulint dict_index_get_n_unique | ( | const dict_index_t * | index | ) |
Gets the number of fields in the internal representation of an index that uniquely determine the position of an index entry in the index, if we do not take multiversioning into account: in the B-tree use the value returned by dict_index_get_n_unique_in_tree.
index | in: an internal representation of index (in the dictionary cache) |
UNIV_INLINE ulint dict_index_get_n_unique_in_tree | ( | const dict_index_t * | index | ) |
Gets the number of fields in the internal representation of an index which uniquely determine the position of an index entry in the index, if we also take multiversioning into account.
index | in: an internal representation of index (in the dictionary cache) |
UNIV_INLINE const dict_col_t* dict_index_get_nth_col | ( | const dict_index_t * | index, |
ulint | pos | ||
) |
Gets pointer to the nth column in an index.
index | in: index |
pos | in: position of the field |
UNIV_INLINE ulint dict_index_get_nth_col_no | ( | const dict_index_t * | index, |
ulint | pos | ||
) |
Gets the column number of the nth field in an index.
index | in: index |
pos | in: position of the field |
UNIV_INTERN ulint dict_index_get_nth_col_or_prefix_pos | ( | const dict_index_t * | index, |
ulint | n, | ||
ibool | inc_prefix | ||
) |
Looks for column n in an index.
index | in: index |
n | in: column number |
inc_prefix | in: TRUE=consider column prefixes too |
UNIV_INLINE ulint dict_index_get_nth_col_pos | ( | const dict_index_t * | index, |
ulint | n | ||
) |
Looks for column n in an index.
index | in: index |
n | in: column number |
UNIV_INTERN ulint dict_index_get_nth_field_pos | ( | const dict_index_t * | index, |
const dict_index_t * | index2, | ||
ulint | n | ||
) |
Looks for a matching field in an index. The column has to be the same. The column in index must be complete, or must contain a prefix longer than the column in index2. That is, we must be able to construct the prefix in index2 from the prefix in index.
index | in: index from which to search |
index2 | in: index |
n | in: field number in index2 |
UNIV_INLINE enum online_index_status dict_index_get_online_status | ( | const dict_index_t * | index | ) |
Gets the status of online index creation.
index | in: secondary index |
UNIV_INLINE ulint dict_index_get_page | ( | const dict_index_t * | tree | ) |
Gets the page number of the root of the index tree.
tree | in: index |
UNIV_INLINE ulint dict_index_get_space | ( | const dict_index_t * | index | ) |
Gets the space id of the root of the index tree.
index | in: index |
UNIV_INLINE ulint dict_index_get_space_reserve | ( | void | ) |
Returns free space reserved for future updates of records. This is relevant only in the case of many consecutive inserts, as updates which make the records bigger might fragment the index.
UNIV_INLINE ulint dict_index_get_sys_col_pos | ( | const dict_index_t * | index, |
ulint | type | ||
) |
Returns the position of a system column in an index.
index | in: index |
type | in: DATA_ROW_ID, ... |
UNIV_INLINE ulint dict_index_is_clust | ( | const dict_index_t * | index | ) |
Check whether the index is the clustered index.
index | in: index |
UNIV_INLINE ulint dict_index_is_corrupted | ( | const dict_index_t * | index | ) |
Check whether the index is corrupted.
index | in: index |
UNIV_INLINE ulint dict_index_is_ibuf | ( | const dict_index_t * | index | ) |
Check whether the index is the insert buffer tree.
index | in: index |
UNIV_INLINE bool dict_index_is_online_ddl | ( | const dict_index_t * | index | ) |
Determines if a secondary index is being or has been created online, or if the table is being rebuilt online, allowing concurrent modifications to the table.
true | if the index is being or has been built online, or if this is a clustered index and the table is being or has been rebuilt online |
false | if the index has been created or the table has been rebuilt completely |
index | in: index |
UNIV_INLINE ulint dict_index_is_sec_or_ibuf | ( | const dict_index_t * | index | ) |
Check whether the index is a secondary index or the insert buffer tree.
index | in: index |
UNIV_INLINE ulint dict_index_is_unique | ( | const dict_index_t * | index | ) |
Check whether the index is unique.
index | in: index |
UNIV_INTERN void UNIV_INTERN void dict_index_name_print | ( | FILE * | file, |
const trx_t * | trx, | ||
const dict_index_t * | index | ||
) |
Displays the names of the index and the table.
file | in: output stream |
trx | in: transaction |
index | in: index to print |
UNIV_INTERN void dict_index_remove_from_cache | ( | dict_table_t * | table, |
dict_index_t * | index | ||
) |
Removes an index from the dictionary cache.
Removes an index from the cache
Removes an index from the dictionary cache.
Removes an index from the cache
table | in/out: table |
index | in, own: index |
Definition at line 2535 of file dict0dict.cc.
UNIV_INLINE void dict_index_set_online_status | ( | dict_index_t * | index, |
enum online_index_status | status | ||
) |
Sets the status of online index creation.
index | in/out: index |
status | in: status |
UNIV_INLINE void dict_index_set_space | ( | dict_index_t * | index, |
ulint | space | ||
) |
Sets the space id of the root of the index tree.
index | in/out: index |
space | in: space id |
UNIV_INTERN void dict_index_zip_failure | ( | dict_index_t * | index | ) |
This function should be called whenever a page compression attempt fails. Updates the compression padding information.
index | in/out: index to be updated. |
Definition at line 6530 of file dict0dict.cc.
UNIV_INTERN ulint dict_index_zip_pad_optimal_page_size | ( | dict_index_t * | index | ) |
Return the optimal page size, for which page will likely compress.
index | in: index for which page size is requested |
UNIV_INTERN void dict_index_zip_success | ( | dict_index_t * | index | ) |
This function should be called whenever a page is successfully compressed. Updates the compression padding information.
index | in/out: index to be updated. |
Definition at line 6507 of file dict0dict.cc.
UNIV_INTERN void dict_init | ( | void | ) |
Inits the data dictionary module.
Definition at line 880 of file dict0dict.cc.
UNIV_INTERN void dict_load_space_id_list | ( | void | ) |
Gets the space id of every table of the data dictionary and makes a linear list and a hash table of them to the data dictionary cache. This function can be called at database startup if we did not need to do a crash recovery. In crash recovery we must scan the space id's from the .ibd files in MySQL database directories.
UNIV_INTERN ulint dict_make_room_in_cache | ( | ulint | max_tables, |
ulint | pct_check | ||
) |
Make room in the table cache by evicting an unused table. The unused table should not be part of FK relationship and currently not used in any user transaction. There is no guarantee that it will remove a table.
Make room in the table cache by evicting an unused table. The unused table should not be part of FK relationship and currently not used in any user transaction. There is no guarantee that it will remove a table.
max_tables | in: max tables allowed in cache |
pct_check | in: max percent to check |
Definition at line 1230 of file dict0dict.cc.
UNIV_INLINE ulint dict_max_field_len_store_undo | ( | dict_table_t * | table, |
const dict_col_t * | col | ||
) |
Determine bytes of column prefix to be stored in the undo log. Please note if the table format is UNIV_FORMAT_A (< UNIV_FORMAT_B), no prefix needs to be stored in the undo log.
table | in: table |
col | in: column which index prefix is based on |
UNIV_INTERN void dict_move_to_mru | ( | dict_table_t * | table | ) |
Move to the most recently used segment of the LRU list.
table | in: table to move to MRU |
Definition at line 916 of file dict0dict.cc.
UNIV_INTERN void dict_mutex_enter_for_mysql | ( | void | ) |
Reserves the dictionary system mutex for MySQL.
Definition at line 319 of file dict0dict.cc.
UNIV_INTERN void dict_mutex_exit_for_mysql | ( | void | ) |
Releases the dictionary system mutex for MySQL.
Definition at line 329 of file dict0dict.cc.
UNIV_INTERN void dict_print_info_on_foreign_key_in_create_format | ( | FILE * | file, |
trx_t * | trx, | ||
dict_foreign_t * | foreign, | ||
ibool | add_newline | ||
) |
Outputs info on a foreign key of a table in a format suitable for CREATE TABLE.
file | in: file where to print |
trx | in: transaction |
foreign | in: foreign key constraint |
add_newline | in: whether to add a newline |
UNIV_INTERN void dict_print_info_on_foreign_keys | ( | ibool | create_table_format, |
FILE * | file, | ||
trx_t * | trx, | ||
dict_table_t * | table | ||
) |
Outputs info on foreign keys of a table.
create_table_format | in: if TRUE then print in a format suitable to be inserted into a CREATE TABLE, otherwise in the format of SHOW TABLE STATUS |
file | in: file where to print |
trx | in: transaction |
table | in: table |
Definition at line 5379 of file dict0dict.cc.
UNIV_INTERN const char* dict_remove_db_name | ( | const char * | name | ) |
Return the end of table name where we have removed dbname and '/'.
name | in: table name in the form dbname '/' tablename |
UNIV_INTERN void dict_set_corrupted | ( | dict_index_t * | index, |
trx_t * | trx, | ||
const char * | ctx | ||
) |
Flags an index and table corrupted both in the data dictionary cache and in the system table SYS_INDEXES.
Flags an index corrupted both in the data dictionary cache and in the SYS_INDEXES
index | in/out: index |
trx | in/out: transaction |
ctx | in: context |
Definition at line 5545 of file dict0dict.cc.
UNIV_INTERN ibool dict_set_corrupted_by_space | ( | ulint | space_id | ) |
Flags a table with specified space_id corrupted in the table dictionary cache.
Flags a table with specified space_id corrupted in the data dictionary cache
space_id | in: space ID |
Definition at line 5521 of file dict0dict.cc.
UNIV_INTERN void dict_set_corrupted_index_cache_only | ( | dict_index_t * | index, |
dict_table_t * | table | ||
) |
Flags an index corrupted in the data dictionary cache only. This is used mostly to mark a corrupted index when index's own dictionary is corrupted, and we force to load such index for repair purpose
index | in/out: index |
table | in/out: table |
Definition at line 5656 of file dict0dict.cc.
UNIV_INTERN ibool dict_str_starts_with_keyword | ( | THD * | thd, |
const char * | str, | ||
const char * | keyword | ||
) |
Determines whether a string starts with the specified keyword.
thd | in: MySQL thread handle |
str | in: string to scan for keyword |
keyword | in: keyword to look for |
UNIV_INTERN void dict_table_add_system_columns | ( | dict_table_t * | table, |
mem_heap_t * | heap | ||
) |
Adds system columns to a table object.
table | in/out: table |
heap | in: temporary heap |
Definition at line 1017 of file dict0dict.cc.
UNIV_INTERN void dict_table_add_to_cache | ( | dict_table_t * | table, |
ibool | can_be_evicted, | ||
mem_heap_t * | heap | ||
) |
Adds a table object to the dictionary cache.
table | in: table |
can_be_evicted | in: TRUE if can be evicted |
heap | in: temporary heap |
Definition at line 1064 of file dict0dict.cc.
UNIV_INTERN void dict_table_autoinc_initialize | ( | dict_table_t * | table, |
ib_uint64_t | value | ||
) |
Unconditionally set the autoinc counter.
table | in/out: table |
value | in: next value to assign to a row |
Definition at line 573 of file dict0dict.cc.
UNIV_INTERN void dict_table_autoinc_lock | ( | dict_table_t * | table | ) |
Acquire the autoinc lock.
table | in/out: table |
Definition at line 562 of file dict0dict.cc.
UNIV_INTERN ib_uint64_t dict_table_autoinc_read | ( | const dict_table_t * | table | ) |
Reads the next autoinc value (== autoinc counter value), 0 if not yet initialized.
table | in: table |
UNIV_INTERN void dict_table_autoinc_unlock | ( | dict_table_t * | table | ) |
Release the autoinc lock.
table | in/out: table |
Definition at line 648 of file dict0dict.cc.
UNIV_INTERN void dict_table_autoinc_update_if_greater | ( | dict_table_t * | table, |
ib_uint64_t | value | ||
) |
Updates the autoinc counter if the value supplied is greater than the current value.
table | in/out: table |
value | in: value which was assigned to a row |
Definition at line 630 of file dict0dict.cc.
UNIV_INTERN void dict_table_change_id_in_cache | ( | dict_table_t * | table, |
table_id_t | new_id | ||
) |
Change the id of a table object in the dictionary cache. This is used in DISCARD TABLESPACE.
table | in/out: table object already in cache |
new_id | in: new id to set |
Definition at line 1784 of file dict0dict.cc.
UNIV_INTERN void dict_table_close | ( | dict_table_t * | table, |
ibool | dict_locked, | ||
ibool | try_drop | ||
) |
Decrements the count of open handles to a table.
table | in/out: table |
dict_locked | in: TRUE=data dictionary locked |
try_drop | in: TRUE=try to drop any orphan indexes after an aborted online index creation |
Definition at line 470 of file dict0dict.cc.
UNIV_INTERN ibool dict_table_col_in_clustered_key | ( | const dict_table_t * | table, |
ulint | n | ||
) |
Checks if a column is in the ordering columns of the clustered index of a table. Column prefixes are treated like whole columns.
table | in: table |
n | in: column number |
UNIV_INTERN void dict_table_copy_types | ( | dtuple_t * | tuple, |
const dict_table_t * | table | ||
) |
Copies types of columns contained in table to tuple and sets all fields of the tuple to the SQL NULL value. This function should be called right after dtuple_create().
tuple | in/out: data tuple |
table | in: table |
Definition at line 2699 of file dict0dict.cc.
UNIV_INTERN ulint dict_table_get_all_fts_indexes | ( | dict_table_t * | table, |
ib_vector_t * | indexes | ||
) |
table | in: table |
indexes | out: all FTS indexes on this table |
Definition at line 588 of file dict0dict.cc.
UNIV_INTERN const char* dict_table_get_col_name | ( | const dict_table_t * | table, |
ulint | col_nr | ||
) |
Returns a column's name.
table | in: table |
col_nr | in: column number |
UNIV_INTERN dict_foreign_t* dict_table_get_foreign_constraint | ( | dict_table_t * | table, |
dict_index_t * | index | ||
) |
Checks if a index is defined for a foreign key constraint. Index is a part of a foreign key constraint if the index is referenced by foreign key or index is a foreign key index
table | in: InnoDB table |
index | in: InnoDB index |
UNIV_INLINE ulint dict_table_get_format | ( | const dict_table_t * | table | ) |
Determine the file format of a table.
table | in: table |
UNIV_INTERN ulint dict_table_get_highest_foreign_id | ( | dict_table_t * | table | ) |
Finds the highest [number] for foreign key constraints of the table. Looks only at the >= 4.0.18-format id's, which are of the form databasename/tablename_ibfk_[number].
Finds the highest [number] for foreign key constraints of the table. Looks only at the >= 4.0.18-format id's, which are of the form databasename/tablename_ibfk_[number].
table | in: table in the dictionary memory cache |
Definition at line 3987 of file dict0dict.cc.
UNIV_INTERN dict_index_t* dict_table_get_index_on_name | ( | dict_table_t * | table, |
const char * | name | ||
) |
Get index by name
table | in: table |
name | in: name of the index to find |
UNIV_INTERN dict_index_t* dict_table_get_index_on_name_and_min_id | ( | dict_table_t * | table, |
const char * | name | ||
) |
In case there is more than one index with the same name return the index with the min(id).
table | in: table |
name | in: name of the index to find |
UNIV_INLINE ulint dict_table_get_n_cols | ( | const dict_table_t * | table | ) |
Gets the number of all columns (also system) in a table in the dictionary cache.
table | in: table |
UNIV_INLINE ib_uint64_t dict_table_get_n_rows | ( | const dict_table_t * | table | ) |
Gets the approximately estimated number of rows in the table.
table | in: table |
UNIV_INLINE ulint dict_table_get_n_sys_cols | ( | const dict_table_t * | table | ) |
Gets the number of system columns in a table in the dictionary cache.
table | in: table |
UNIV_INLINE ulint dict_table_get_n_user_cols | ( | const dict_table_t * | table | ) |
Gets the number of user-defined columns in a table in the dictionary cache.
table | in: table |
UNIV_INTERN ulint dict_table_get_nth_col_pos | ( | const dict_table_t * | table, |
ulint | n | ||
) |
Looks for column n position in the clustered index.
table | in: table |
n | in: column number |
UNIV_INTERN dict_foreign_t* dict_table_get_referenced_constraint | ( | dict_table_t * | table, |
dict_index_t * | index | ||
) |
Check if the index is referenced by a foreign key, if TRUE return the matching instance NULL otherwise.
table | in: InnoDB table |
index | in: InnoDB index |
UNIV_INLINE ulint dict_table_get_sys_col_no | ( | const dict_table_t * | table, |
ulint | sys | ||
) |
Gets the given system column number of a table.
table | in: table |
sys | in: DATA_ROW_ID, ... |
UNIV_INLINE ibool dict_table_has_fts_index | ( | dict_table_t * | table | ) |
Check if the table has an FTS index.
table | in: table |
UNIV_INLINE ibool dict_table_is_comp | ( | const dict_table_t * | table | ) |
Check whether the table uses the compact page format.
table | in: table |
UNIV_INLINE ulint dict_table_is_corrupted | ( | const dict_table_t * | table | ) |
Check whether the table is corrupted.
table | in: table |
UNIV_INLINE bool dict_table_is_discarded | ( | const dict_table_t * | table | ) |
Check if the tablespace for the table has been discarded.
table | in: table to check |
UNIV_INTERN ibool dict_table_is_referenced_by_foreign_key | ( | const dict_table_t * | table | ) |
Checks if a table is referenced by foreign keys.
table | in: InnoDB table |
UNIV_INLINE bool dict_table_is_temporary | ( | const dict_table_t * | table | ) |
Check if it is a temporary table.
table | in: table to check |
UNIV_INTERN void dict_table_move_from_lru_to_non_lru | ( | dict_table_t * | table | ) |
Move a table to the non LRU end of the LRU list.
Move a table to the non-LRU list from the LRU list.
table | in: table to move from LRU to non-LRU |
Definition at line 1290 of file dict0dict.cc.
UNIV_INTERN void dict_table_move_from_non_lru_to_lru | ( | dict_table_t * | table | ) |
Move a table to the LRU list from the non-LRU list.
table | in: table to move from non-LRU to LRU |
Definition at line 1310 of file dict0dict.cc.
UNIV_INLINE void dict_table_n_rows_dec | ( | dict_table_t * | table | ) |
Decrement the number of rows in the table by one. Notice that this operation is not protected by any latch, the number is approximate.
table | in/out: table |
UNIV_INLINE void dict_table_n_rows_inc | ( | dict_table_t * | table | ) |
Increment the number of rows in the table by one. Notice that this operation is not protected by any latch, the number is approximate.
table | in/out: table |
UNIV_INTERN dict_table_t* dict_table_open_on_id | ( | table_id_t | table_id, |
ibool | dict_locked, | ||
dict_table_op_t | table_op | ||
) |
Returns a table object based on table id.
table_id | in: table id |
dict_locked | in: TRUE=data dictionary locked |
table_op | in: operation to perform |
Definition at line 786 of file dict0dict.cc.
UNIV_INTERN dict_table_t* dict_table_open_on_name | ( | const char * | table_name, |
ibool | dict_locked, | ||
ibool | try_drop, | ||
dict_err_ignore_t | ignore_err | ||
) |
Returns a table object and increments its open handle count. NOTE! This is a high-level function to be used mainly from outside the 'dict' directory. Inside this directory dict_table_get_low is usually the appropriate function.
table_name | in: table name |
dict_locked | in: TRUE=data dictionary locked |
try_drop | in: TRUE=try to drop any orphan indexes after an aborted online index creation |
ignore_err | in: error to be ignored when loading the table |
UNIV_INTERN void dict_table_print | ( | dict_table_t * | table | ) |
Prints a table data.
table | in: table |
Definition at line 5127 of file dict0dict.cc.
UNIV_INTERN void dict_table_remove_from_cache | ( | dict_table_t * | table | ) |
Removes a table object from the dictionary cache.
table | in, own: table |
Definition at line 1915 of file dict0dict.cc.
UNIV_INTERN dberr_t dict_table_rename_in_cache | ( | dict_table_t * | table, |
const char * | new_name, | ||
ibool | rename_also_foreigns | ||
) |
Renames a table object.
table | in/out: table |
new_name | in: new name |
rename_also_foreigns | in: in ALTER TABLE we want to preserve the original table name in constraints which reference it |
UNIV_INTERN dberr_t dict_table_schema_check | ( | dict_table_schema_t * | req_schema, |
char * | errstr, | ||
size_t | errstr_sz | ||
) |
Checks whether a table exists and whether it has the given structure. The table must have the same number of columns with the same names and types. The order of the columns does not matter. The caller must own the dictionary mutex. dict_table_schema_check()
req_schema | in/out: required table schema |
errstr | out: human readable error message if != DB_SUCCESS and != DB_TABLE_NOT_FOUND is returned |
errstr_sz | in: errstr size |
UNIV_INTERN void dict_table_stats_lock | ( | const dict_table_t * | table, |
ulint | latch_mode | ||
) |
Lock the appropriate latch to protect a given table's statistics. table->id is used to pick the corresponding latch from a global array of latches.
table | in: table |
latch_mode | in: RW_S_LATCH or RW_X_LATCH |
Definition at line 346 of file dict0dict.cc.
UNIV_INTERN void dict_table_stats_unlock | ( | const dict_table_t * | table, |
ulint | latch_mode | ||
) |
Unlock the latch that has been locked by dict_table_stats_lock()
table | in: table |
latch_mode | in: RW_S_LATCH or RW_X_LATCH |
Definition at line 373 of file dict0dict.cc.
UNIV_INLINE void dict_table_x_lock_indexes | ( | dict_table_t * | table | ) |
Obtain exclusive locks on all index trees of the table. This is to prevent accessing index trees while InnoDB is updating internal metadata for operations such as truncate tables.
table | in: table |
UNIV_INLINE void dict_table_x_unlock_indexes | ( | dict_table_t * | table | ) |
Release the exclusive locks on all index tree.
table | in: table |
UNIV_INLINE ulint dict_table_zip_size | ( | const dict_table_t * | table | ) |
Check whether the table uses the compressed compact page format.
table | in: table |
UNIV_INTERN ibool dict_tables_have_same_db | ( | const char * | name1, |
const char * | name2 | ||
) |
Checks if the database name in two table names is the same.
name1 | in: table name in the form dbname '/' tablename |
name2 | in: table name in the form dbname '/' tablename |
UNIV_INLINE ulint dict_tf_get_format | ( | ulint | flags | ) |
Determine the file format from a dict_table_t::flags.
flags | in: dict_table_t::flags |
UNIV_INLINE ulint dict_tf_get_zip_size | ( | ulint | flags | ) | const |
Extract the compressed page size from table flags.
flags | in: flags |
UNIV_INLINE bool dict_tf_is_valid | ( | ulint | flags | ) |
Validate the table flags.
flags | in: table flags |
UNIV_INLINE void dict_tf_set | ( | ulint * | flags, |
rec_format_t | format, | ||
ulint | zip_ssize, | ||
bool | remote_path | ||
) |
Set the various values in a dict_table_t::flags pointer.
flags | in/out: table |
format | in: file format |
zip_ssize | in: zip shift size |
remote_path | in: table uses DATA DIRECTORY |
UNIV_INLINE ulint dict_tf_to_fsp_flags | ( | ulint | flags | ) | const |
Convert a 32 bit integer table flags to the 32 bit integer that is written into the tablespace header at the offset FSP_SPACE_FLAGS and is also stored in the fil_space_t::flags field. The following chart shows the translation of the low order bit. Other bits are the same. ========================= Low order bit ========================== | REDUNDANT | COMPACT | COMPRESSED | DYNAMIC dict_table_t::flags | 0 | 1 | 1 | 1
flags | in: dict_table_t::flags |
UNIV_INTERN const char* dict_tf_to_row_format_string | ( | ulint | table_flag | ) |
Convert table flag to row format string.
Convert table flag to row format string.
table_flag | in: row format setting |
Definition at line 6597 of file dict0dict.cc.
dict_index_t* dict_ind_compact |
dummy index for ROW_FORMAT=COMPACT supremum and infimum records
Definition at line 39 of file dict0dict.cc.
dict_index_t* dict_ind_redundant |
dummy index for ROW_FORMAT=REDUNDANT supremum and infimum records
Definition at line 37 of file dict0dict.cc.
rw_lock_t dict_operation_lock |
the data dictionary rw-latch protecting dict_sys
table create, drop, etc. reserve this in X-mode; implicit or backround operations purge, rollback, foreign key checks reserve this in S-mode; we cannot trust that MySQL protects implicit or background operations a table drop since MySQL does not know of them; therefore we need this; NOTE: a transaction which reserves this must keep book on the mode in trx_t::dict_operation_lock_mode
Definition at line 90 of file dict0dict.cc.
dict_sys_t* dict_sys |
the dictionary system
Definition at line 80 of file dict0dict.cc.