⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dict0dict.c

📁 这是linux下运行的mysql软件包,可用于linux 下安装 php + mysql + apach 的网络配置
💻 C
📖 第 1 页 / 共 5 页
字号:
/**********************************************************************Data dictionary system(c) 1996 Innobase OyCreated 1/8/1996 Heikki Tuuri***********************************************************************/#include "dict0dict.h"#ifdef UNIV_NONINL#include "dict0dict.ic"#endif#include "buf0buf.h"#include "data0type.h"#include "mach0data.h"#include "dict0boot.h"#include "dict0mem.h"#include "dict0crea.h"#include "trx0undo.h"#include "btr0btr.h"#include "btr0cur.h"#include "btr0sea.h"#include "pars0pars.h"#include "pars0sym.h"#include "que0que.h"#include "rem0cmp.h"dict_sys_t*	dict_sys	= NULL;	/* the dictionary system */rw_lock_t	dict_operation_lock;	/* 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->dict_operation_lock_mode */#define	DICT_HEAP_SIZE		100	/* initial memory heap size when					creating a table or index object */#define DICT_POOL_PER_TABLE_HASH 512	/* buffer pool max size per table					hash table fixed size in bytes */#define DICT_POOL_PER_COL_HASH	128	/* buffer pool max size per column					hash table fixed size in bytes */#define DICT_POOL_PER_VARYING	4	/* buffer pool max size per data					dictionary varying size in bytes *//* Identifies generated InnoDB foreign key names */static char	dict_ibfk[] = "_ibfk_";#ifndef UNIV_HOTBACKUP/**********************************************************************Compares NUL-terminated UTF-8 strings case insensitively.NOTE: the prototype of this function is copied from ha_innodb.cc! If you changethis function, you MUST change also the prototype here! */externintinnobase_strcasecmp(/*================*/				/* out: 0 if a=b, <0 if a<b, >1 if a>b */	const char*	a,	/* in: first string to compare */	const char*	b);	/* in: second string to compare *//**********************************************************************Makes all characters in a NUL-terminated UTF-8 string lower case.NOTE: the prototype of this function is copied from ha_innodb.cc! If you changethis function, you MUST change also the prototype here! */externvoidinnobase_casedn_str(/*================*/	char*	a);	/* in/out: string to put in lower case */#endif /* !UNIV_HOTBACKUP *//**************************************************************************Adds a column to the data dictionary hash table. */staticvoiddict_col_add_to_cache(/*==================*/	dict_table_t*	table,	/* in: table */	dict_col_t*	col);	/* in: column *//**************************************************************************Repositions a column in the data dictionary hash table when the table namechanges. */staticvoiddict_col_reposition_in_cache(/*=========================*/	dict_table_t*	table,		/* in: table */	dict_col_t*	col,		/* in: column */	const char*	new_name);	/* in: new table name *//**************************************************************************Removes a column from the data dictionary hash table. */staticvoiddict_col_remove_from_cache(/*=======================*/	dict_table_t*	table,	/* in: table */	dict_col_t*	col);	/* in: column *//**************************************************************************Removes an index from the dictionary cache. */staticvoiddict_index_remove_from_cache(/*=========================*/	dict_table_t*	table,	/* in: table */	dict_index_t*	index);	/* in, own: index *//***********************************************************************Copies fields contained in index2 to index1. */staticvoiddict_index_copy(/*============*/	dict_index_t*	index1,	/* in: index to copy to */	dict_index_t*	index2,	/* in: index to copy from */	ulint		start,	/* in: first position to copy */	ulint		end);	/* in: last position to copy *//***********************************************************************Tries to find column names for the index in the column hash table andsets the col field of the index. */staticibooldict_index_find_cols(/*=================*/				/* out: TRUE if success */	dict_table_t*	table,	/* in: table */	dict_index_t*	index);	/* in: index */	/***********************************************************************Builds the internal dictionary cache representation for a clusteredindex, containing also system fields not defined by the user. */staticdict_index_t*dict_index_build_internal_clust(/*============================*/				/* out, own: the internal representation				of the clustered index */	dict_table_t*	table,	/* in: table */	dict_index_t*	index);	/* in: user representation of a clustered				index */	/***********************************************************************Builds the internal dictionary cache representation for a non-clusteredindex, containing also system fields not defined by the user. */staticdict_index_t*dict_index_build_internal_non_clust(/*================================*/				/* out, own: the internal representation				of the non-clustered index */	dict_table_t*	table,	/* in: table */	dict_index_t*	index);	/* in: user representation of a non-clustered				index */	/**************************************************************************Removes a foreign constraint struct from the dictionary cache. */staticvoiddict_foreign_remove_from_cache(/*===========================*/	dict_foreign_t*	foreign);	/* in, own: foreign constraint *//**************************************************************************Prints a column data. */staticvoiddict_col_print_low(/*===============*/	dict_col_t*	col);	/* in: column *//**************************************************************************Prints an index data. */staticvoiddict_index_print_low(/*=================*/	dict_index_t*	index);	/* in: index *//**************************************************************************Prints a field data. */staticvoiddict_field_print_low(/*=================*/	dict_field_t*	field);	/* in: field *//*************************************************************************Frees a foreign key struct. */staticvoiddict_foreign_free(/*==============*/	dict_foreign_t*	foreign);	/* in, own: foreign key struct *//* Stream for storing detailed information about the latest foreign keyand unique key errors */FILE*	dict_foreign_err_file		= NULL;mutex_t	dict_foreign_err_mutex; 	/* mutex protecting the foreign					and unique error buffers */	/**********************************************************************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 */{	innobase_casedn_str(a);}/************************************************************************Checks if the database name in two table names is the same. */ibooldict_tables_have_same_db(/*=====================*/				/* out: TRUE if same db name */	const char*	name1,	/* in: table name in the form				dbname '/' tablename */	const char*	name2)	/* in: table name in the form				dbname '/' tablename */{	for (; *name1 == *name2; name1++, name2++) {		if (*name1 == '/') {			return(TRUE);		}		ut_a(*name1); /* the names must contain '/' */	}	return(FALSE);}/************************************************************************Return the end of table name where we have removed dbname and '/'. */staticconst char*dict_remove_db_name(/*================*/				/* out: table name */	const char*	name)	/* in: table name in the form				dbname '/' tablename */{	const char*	s;	s = strchr(name, '/');	ut_a(s);	if (s) s++;	return(s);}/************************************************************************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 */{	const char*	s;	s = strchr(name, '/');	ut_a(s);	return(s - name);}	/************************************************************************Reserves the dictionary system mutex for MySQL. */voiddict_mutex_enter_for_mysql(void)/*============================*/{	mutex_enter(&(dict_sys->mutex));}	/************************************************************************Releases the dictionary system mutex for MySQL. */voiddict_mutex_exit_for_mysql(void)/*===========================*/{	mutex_exit(&(dict_sys->mutex));}	/************************************************************************Decrements the count of open MySQL handles to a table. */voiddict_table_decrement_handle_count(/*==============================*/	dict_table_t*	table)	/* in: table */{	mutex_enter(&(dict_sys->mutex));	ut_a(table->n_mysql_handles_opened > 0);	table->n_mysql_handles_opened--;		mutex_exit(&(dict_sys->mutex));}/************************************************************************Gets the nth column of a table. */dict_col_t*dict_table_get_nth_col_noninline(/*=============================*/				/* out: pointer to column object */	dict_table_t*	table,	/* in: table */	ulint		pos)	/* in: position of column */{	return(dict_table_get_nth_col(table, pos));}/************************************************************************Gets the first index on the table (the clustered index). */dict_index_t*dict_table_get_first_index_noninline(/*=================================*/				/* out: index, NULL if none exists */	dict_table_t*	table)	/* in: table */{	return(dict_table_get_first_index(table));}/************************************************************************Gets the next index on the table. */dict_index_t*dict_table_get_next_index_noninline(/*================================*/				/* out: index, NULL if none left */	dict_index_t*	index)	/* in: index */{	return(dict_table_get_next_index(index));}/**************************************************************************Returns an index object. */dict_index_t*dict_table_get_index_noninline(/*===========================*/				/* out: index, NULL if does not exist */	dict_table_t*	table,	/* in: table */	const char*	name)	/* in: index name */{	return(dict_table_get_index(table, name));}	/************************************************************************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 */{	mutex_enter(&(table->autoinc_mutex));	table->autoinc_inited = TRUE;	table->autoinc = value;	mutex_exit(&(table->autoinc_mutex));}/************************************************************************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 */{	ib_longlong	value;	mutex_enter(&(table->autoinc_mutex));	if (!table->autoinc_inited) {		value = 0;	} else {		value = table->autoinc;		table->autoinc = table->autoinc + 1;	}		mutex_exit(&(table->autoinc_mutex));	return(value);}/************************************************************************Decrements the autoinc counter value by 1. */voiddict_table_autoinc_decrement(/*=========================*/	dict_table_t*	table)	/* in: table */{	mutex_enter(&(table->autoinc_mutex));	table->autoinc = table->autoinc - 1;		mutex_exit(&(table->autoinc_mutex));}/************************************************************************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 */{	ib_longlong	value;	mutex_enter(&(table->autoinc_mutex));	if (!table->autoinc_inited) {		value = 0;	} else {		value = table->autoinc;	}		mutex_exit(&(table->autoinc_mutex));	return(value);}/************************************************************************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 */{	ib_longlong	value;	if (!table->autoinc_inited) {		value = 0;	} else {		value = table->autoinc;	}	return(value);}/************************************************************************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 */{	mutex_enter(&(table->autoinc_mutex));	if (table->autoinc_inited) {		if (value >= table->autoinc) {			table->autoinc = value + 1;		}	}		mutex_exit(&(table->autoinc_mutex));}/************************************************************************Looks for column n in an index. */ulintdict_index_get_nth_col_pos(/*=======================*/				/* out: position in internal representation				of the index; if not contained, returns				ULINT_UNDEFINED */	dict_index_t*	index,	/* in: index */	ulint		n)	/* in: column number */{	dict_field_t*	field;	dict_col_t*	col;	ulint		pos;	ulint		n_fields;		ut_ad(index);	ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -