📄 dict0dict.h
字号:
/******************************************************Data dictionary system(c) 1996 Innobase OyCreated 1/8/1996 Heikki Tuuri*******************************************************/#ifndef dict0dict_h#define dict0dict_h#include "univ.i"#include "dict0types.h"#include "dict0mem.h"#include "data0type.h"#include "data0data.h"#include "sync0sync.h"#include "sync0rw.h"#include "mem0mem.h"#include "rem0types.h"#include "btr0types.h"#include "ut0mem.h"#include "ut0lst.h"#include "hash0hash.h"#include "ut0rnd.h"#include "ut0byte.h"#include "trx0types.h"/**********************************************************************Makes all characters in a NUL-terminated UTF-8 string lower case. */voiddict_casedn_str(/*============*/ char* a); /* in/out: string to put in lower case *//************************************************************************Get the database name length in a table name. */ulintdict_get_db_name_len(/*=================*/ /* out: database name length */ const char* name); /* in: table name in the form dbname '/' tablename *//*************************************************************************Accepts a specified string. Comparisons are case-insensitive. */const char*dict_accept(/*========*/ /* out: if string was accepted, the pointer is moved after that, else ptr is returned */ const char* ptr, /* in: scan from this */ const char* string, /* in: accept only this string as the next non-whitespace string */ ibool* success);/* out: TRUE if accepted *//************************************************************************Decrements the count of open MySQL handles to a table. */voiddict_table_decrement_handle_count(/*==============================*/ dict_table_t* table); /* in: table *//**************************************************************************Inits the data dictionary module. */voiddict_init(void);/*===========*//************************************************************************Gets the space id of every table of the data dictionary and makes a linearlist and a hash table of them to the data dictionary cache. This functioncan 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 MySQLdatabase directories. */voiddict_load_space_id_list(void);/*=========================*//*************************************************************************Gets the column data type. */UNIV_INLINEdtype_t*dict_col_get_type(/*==============*/ dict_col_t* col);/*************************************************************************Gets the column number. */UNIV_INLINEulintdict_col_get_no(/*============*/ dict_col_t* col);/*************************************************************************Gets the column position in the clustered index. */UNIV_INLINEulintdict_col_get_clust_pos(/*===================*/ dict_col_t* col);/************************************************************************Initializes the autoinc counter. It is not an error to initialize an alreadyinitialized counter. */voiddict_table_autoinc_initialize(/*==========================*/ dict_table_t* table, /* in: table */ ib_longlong value); /* in: next value to assign to a row *//************************************************************************Gets the next autoinc value (== autoinc counter value), 0 if not yetinitialized. If initialized, increments the counter by 1. */ib_longlongdict_table_autoinc_get(/*===================*/ /* out: value for a new row, or 0 */ dict_table_t* table); /* in: table *//************************************************************************Decrements the autoinc counter value by 1. */voiddict_table_autoinc_decrement(/*=========================*/ dict_table_t* table); /* in: table *//************************************************************************Reads the next autoinc value (== autoinc counter value), 0 if not yetinitialized. */ib_longlongdict_table_autoinc_read(/*====================*/ /* out: value for a new row, or 0 */ dict_table_t* table); /* in: table *//************************************************************************Peeks the autoinc counter value, 0 if not yet initialized. Does notincrement the counter. The read not protected by any mutex! */ib_longlongdict_table_autoinc_peek(/*====================*/ /* out: value of the counter */ dict_table_t* table); /* in: table *//************************************************************************Updates the autoinc counter if the value supplied is equal or bigger than thecurrent value. If not inited, does nothing. */voiddict_table_autoinc_update(/*======================*/ dict_table_t* table, /* in: table */ ib_longlong value); /* in: value which was assigned to a row *//**************************************************************************Adds a table object to the dictionary cache. */voiddict_table_add_to_cache(/*====================*/ dict_table_t* table); /* in: table *//**************************************************************************Removes a table object from the dictionary cache. */voiddict_table_remove_from_cache(/*=========================*/ dict_table_t* table); /* in, own: table *//**************************************************************************Renames a table object. */ibooldict_table_rename_in_cache(/*=======================*/ /* out: TRUE if success */ dict_table_t* table, /* in: table */ const char* new_name, /* in: new name */ ibool rename_also_foreigns);/* in: in ALTER TABLE we want to preserve the original table name in constraints which reference it *//**************************************************************************Change the id of a table object in the dictionary cache. This is used inDISCARD TABLESPACE. */voiddict_table_change_id_in_cache(/*==========================*/ dict_table_t* table, /* in: table object already in cache */ dulint new_id);/* in: new id to set *//**************************************************************************Adds a foreign key constraint object to the dictionary cache. May freethe object if there already is an object with the same identifier in.At least one of foreign table or referenced table must already be inthe dictionary cache! */ulintdict_foreign_add_to_cache(/*======================*/ /* out: DB_SUCCESS or error code */ dict_foreign_t* foreign, /* in, own: foreign key constraint */ ibool check_charsets);/* in: TRUE=check charset compatibility *//*************************************************************************Checks if a table is referenced by foreign keys. */ibooldict_table_referenced_by_foreign_key(/*=================================*/ /* out: TRUE if table is referenced by a foreign key */ dict_table_t* table); /* in: InnoDB table *//*************************************************************************Scans a table create SQL string and adds to the data dictionarythe foreign key constraints declared in the string. This functionshould be called after the indexes for a table have been created.Each foreign key constraint must be accompanied with indexes inbot participating tables. The indexes are allowed to contain morefields than mentioned in the constraint. */ulintdict_create_foreign_constraints(/*============================*/ /* out: error code or DB_SUCCESS */ trx_t* trx, /* in: transaction */ const char* 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 */ const char* name, /* in: table full name in the normalized form database_name/table_name */ ibool reject_fks); /* in: if TRUE, fail with error code DB_CANNOT_ADD_CONSTRAINT if any foreign keys are found. *//**************************************************************************Parses the CONSTRAINT id's to be dropped in an ALTER TABLE statement. */ulintdict_foreign_parse_drop_constraints(/*================================*/ /* out: DB_SUCCESS or DB_CANNOT_DROP_CONSTRAINT if syntax error or the constraint id does not match */ mem_heap_t* heap, /* in: heap from which we can allocate memory */ trx_t* trx, /* in: transaction */ dict_table_t* table, /* in: table */ ulint* n, /* out: number of constraints to drop */ const char*** constraints_to_drop); /* out: id's of the constraints to drop *//**************************************************************************Returns a table object and memoryfixes it. NOTE! This is a high-levelfunction to be used mainly from outside the 'dict' directory. Inside thisdirectory dict_table_get_low is usually the appropriate function. */dict_table_t*dict_table_get(/*===========*/ /* out: table, NULL if does not exist */ const char* table_name, /* in: table name */ trx_t* trx); /* in: transaction handle *//**************************************************************************Returns a table object and increments MySQL open handle count on the table.*/dict_table_t*dict_table_get_and_increment_handle_count(/*======================================*/ /* out: table, NULL if does not exist */ const char* table_name, /* in: table name */ trx_t* trx); /* in: transaction handle or NULL *//**************************************************************************Returns a table object, based on table id, and memoryfixes it. */dict_table_t*dict_table_get_on_id(/*=================*/ /* out: table, NULL if does not exist */ dulint table_id, /* in: table id */ trx_t* trx); /* in: transaction handle *//**************************************************************************Returns a table object, based on table id, and memoryfixes it. */UNIV_INLINEdict_table_t*dict_table_get_on_id_low(/*=====================*/ /* out: table, NULL if does not exist */ dulint table_id, /* in: table id */ trx_t* trx); /* in: transaction handle *//**************************************************************************Releases a table from being memoryfixed. Currently this has no relevance. */UNIV_INLINEvoiddict_table_release(/*===============*/ dict_table_t* table); /* in: table to be released *//**************************************************************************Checks if a table is in the dictionary cache. */UNIV_INLINEdict_table_t*dict_table_check_if_in_cache_low(/*==============================*/ /* out: table, NULL if not found */ const char* table_name); /* in: table name *//**************************************************************************Gets a table; loads it to the dictionary cache if necessary. A low-levelfunction. */UNIV_INLINEdict_table_t*dict_table_get_low(/*===============*/ /* out: table, NULL if not found */ const char* table_name); /* in: table name *//**************************************************************************Returns an index object. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -