summaryrefslogtreecommitdiff
path: root/storage/innobase/dict
diff options
context:
space:
mode:
Diffstat (limited to 'storage/innobase/dict')
-rw-r--r--storage/innobase/dict/dict0crea.c370
-rw-r--r--storage/innobase/dict/dict0dict.c274
-rw-r--r--storage/innobase/dict/dict0load.c38
-rw-r--r--storage/innobase/dict/dict0mem.c50
4 files changed, 270 insertions, 462 deletions
diff --git a/storage/innobase/dict/dict0crea.c b/storage/innobase/dict/dict0crea.c
index 6f0a81296ac..4233cb05773 100644
--- a/storage/innobase/dict/dict0crea.c
+++ b/storage/innobase/dict/dict0crea.c
@@ -24,6 +24,7 @@ Created 1/8/1996 Heikki Tuuri
#include "pars0pars.h"
#include "trx0roll.h"
#include "usr0sess.h"
+#include "ut0vec.h"
/*********************************************************************
Based on a table object, this function builds the entry to be inserted
@@ -74,14 +75,14 @@ dict_create_sys_tables_tuple(
dfield = dtuple_get_nth_field(entry, 3);
ptr = mem_heap_alloc(heap, 4);
- mach_write_to_4(ptr, table->type);
+ mach_write_to_4(ptr, DICT_TABLE_ORDINARY);
dfield_set_data(dfield, ptr, 4);
/* 6: MIX_ID ---------------------------*/
dfield = dtuple_get_nth_field(entry, 4);
ptr = mem_heap_alloc(heap, 8);
- mach_write_to_8(ptr, table->mix_id);
+ memset(ptr, 0, 8);
dfield_set_data(dfield, ptr, 8);
/* 7: MIX_LEN --------------------------*/
@@ -89,19 +90,13 @@ dict_create_sys_tables_tuple(
dfield = dtuple_get_nth_field(entry, 5);
ptr = mem_heap_alloc(heap, 4);
- mach_write_to_4(ptr, table->mix_len);
+ memset(ptr, 0, 4);
dfield_set_data(dfield, ptr, 4);
/* 8: CLUSTER_NAME ---------------------*/
dfield = dtuple_get_nth_field(entry, 6);
+ dfield_set_data(dfield, NULL, UNIV_SQL_NULL); /* not supported */
- if (table->type == DICT_TABLE_CLUSTER_MEMBER) {
- dfield_set_data(dfield, table->cluster_name,
- ut_strlen(table->cluster_name));
- ut_error; /* Oracle-style clusters are not supported yet */
- } else {
- dfield_set_data(dfield, NULL, UNIV_SQL_NULL);
- }
/* 9: SPACE ----------------------------*/
dfield = dtuple_get_nth_field(entry, 7);
@@ -207,7 +202,6 @@ dict_build_table_def_step(
tab_node_t* node) /* in: table create node */
{
dict_table_t* table;
- dict_table_t* cluster_table;
dtuple_t* row;
ulint error;
const char* path_or_name;
@@ -235,23 +229,6 @@ dict_build_table_def_step(
return(DB_TOO_BIG_RECORD);
}
- if (table->type == DICT_TABLE_CLUSTER_MEMBER) {
-
- cluster_table = dict_table_get_low(table->cluster_name);
-
- if (cluster_table == NULL) {
-
- return(DB_CLUSTER_NOT_FOUND);
- }
-
- /* Inherit space and mix len from the cluster */
-
- table->space = cluster_table->space;
- table->mix_len = cluster_table->mix_len;
-
- table->mix_id = dict_hdr_get_new_id(DICT_HDR_MIX_ID);
- }
-
if (srv_file_per_table) {
/* We create a new single-table tablespace for the table.
We initially let it be 4 pages:
@@ -614,15 +591,6 @@ dict_create_index_tree_step(
sys_indexes = dict_sys->sys_indexes;
- if (index->type & DICT_CLUSTERED
- && table->type == DICT_TABLE_CLUSTER_MEMBER) {
-
- /* Do not create a new index tree: entries are put to the
- cluster tree */
-
- return(DB_SUCCESS);
- }
-
/* Run a mini-transaction in which the index tree is allocated for
the index and its root address is written to the index entry in
sys_indexes */
@@ -1159,11 +1127,8 @@ dict_create_or_check_foreign_constraint_tables(void)
{
dict_table_t* table1;
dict_table_t* table2;
- que_thr_t* thr;
- que_t* graph;
ulint error;
trx_t* trx;
- const char* str;
mutex_enter(&(dict_sys->mutex));
@@ -1215,7 +1180,7 @@ dict_create_or_check_foreign_constraint_tables(void)
VARBINARY, like in other InnoDB system tables, to get a clean
design. */
- str =
+ error = que_eval_sql(NULL,
"PROCEDURE CREATE_FOREIGN_SYS_TABLES_PROC () IS\n"
"BEGIN\n"
"CREATE TABLE\n"
@@ -1227,22 +1192,8 @@ dict_create_or_check_foreign_constraint_tables(void)
"SYS_FOREIGN_COLS(ID CHAR, POS INT, FOR_COL_NAME CHAR, REF_COL_NAME CHAR);\n"
"CREATE UNIQUE CLUSTERED INDEX ID_IND ON SYS_FOREIGN_COLS (ID, POS);\n"
"COMMIT WORK;\n"
- "END;\n";
-
- graph = pars_sql(str);
-
- ut_a(graph);
-
- graph->trx = trx;
- trx->graph = NULL;
-
- graph->fork_type = QUE_FORK_MYSQL_INTERFACE;
-
- ut_a(thr = que_fork_start_command(graph));
-
- que_run_threads(thr);
-
- error = trx->error_state;
+ "END;\n"
+ , trx);
if (error != DB_SUCCESS) {
fprintf(stderr, "InnoDB: error %lu in creation\n",
@@ -1261,8 +1212,6 @@ dict_create_or_check_foreign_constraint_tables(void)
error = DB_MUST_GET_MORE_FILE_SPACE;
}
- que_graph_free(graph);
-
trx->op_info = "";
row_mysql_unlock_data_dictionary(trx);
@@ -1277,150 +1226,23 @@ dict_create_or_check_foreign_constraint_tables(void)
return(error);
}
-/************************************************************************
-Adds foreign key definitions to data dictionary tables in the database. We
-look at table->foreign_list, and also generate names to constraints that were
-not named by the user. A generated constraint has a name of the format
-databasename/tablename_ibfk_<number>, where the numbers start from 1, and are
-given locally for this table, that is, the number is not global, as in the
-old format constraints < 4.0.18 it used to be. */
+/********************************************************************
+Evaluate the given foreign key SQL statement. */
ulint
-dict_create_add_foreigns_to_dictionary(
-/*===================================*/
+dict_foreign_eval_sql(
+/*==================*/
/* out: error code or DB_SUCCESS */
- ulint start_id,/* in: if we are actually doing ALTER TABLE
- ADD CONSTRAINT, we want to generate constraint
- numbers which are bigger than in the table so
- far; we number the constraints from
- start_id + 1 up; start_id should be set to 0 if
- we are creating a new table, or if the table
- so far has no constraints for which the name
- was generated here */
+ pars_info_t* info, /* in: info struct, or NULL */
+ const char* sql, /* in: SQL string to evaluate */
dict_table_t* table, /* in: table */
+ dict_foreign_t* foreign,/* in: foreign */
trx_t* trx) /* in: transaction */
{
- dict_foreign_t* foreign;
- que_thr_t* thr;
- que_t* graph;
- ulint number = start_id + 1;
- ulint len;
ulint error;
FILE* ef = dict_foreign_err_file;
- ulint i;
- char* sql;
- char* sqlend;
- /* This procedure builds an InnoDB stored procedure which will insert
- the necessary rows into SYS_FOREIGN and SYS_FOREIGN_COLS. */
- static const char str1[] = "PROCEDURE ADD_FOREIGN_DEFS_PROC () IS\n"
- "BEGIN\n"
- "INSERT INTO SYS_FOREIGN VALUES(";
- static const char str2[] = ");\n";
- static const char str3[] =
- "INSERT INTO SYS_FOREIGN_COLS VALUES(";
- static const char str4[] =
- "COMMIT WORK;\n"
- "END;\n";
-#ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&(dict_sys->mutex)));
-#endif /* UNIV_SYNC_DEBUG */
-
- if (NULL == dict_table_get_low("SYS_FOREIGN")) {
- fprintf(stderr,
-"InnoDB: table SYS_FOREIGN not found from internal data dictionary\n");
-
- return(DB_ERROR);
- }
-
- foreign = UT_LIST_GET_FIRST(table->foreign_list);
-loop:
- if (foreign == NULL) {
-
- return(DB_SUCCESS);
- }
-
- if (foreign->id == NULL) {
- /* Generate a new constraint id */
- ulint namelen = strlen(table->name);
- char* id = mem_heap_alloc(foreign->heap, namelen + 20);
- /* no overflow if number < 1e13 */
- sprintf(id, "%s_ibfk_%lu", table->name, (ulong) number++);
- foreign->id = id;
- }
-
- len = (sizeof str1) + (sizeof str2) + (sizeof str4) - 3
- + 9/* ' and , chars */ + 10/* 32-bit integer */
- + ut_strlenq(foreign->id, '\'') * (foreign->n_fields + 1)
- + ut_strlenq(table->name, '\'')
- + ut_strlenq(foreign->referenced_table_name, '\'');
-
- for (i = 0; i < foreign->n_fields; i++) {
- len += 9/* ' and , chars */ + 10/* 32-bit integer */
- + (sizeof str3) + (sizeof str2) - 2
- + ut_strlenq(foreign->foreign_col_names[i], '\'')
- + ut_strlenq(foreign->referenced_col_names[i], '\'');
- }
-
- sql = sqlend = mem_alloc(len + 1);
-
- /* INSERT INTO SYS_FOREIGN VALUES(...); */
- memcpy(sqlend, str1, (sizeof str1) - 1);
- sqlend += (sizeof str1) - 1;
- *sqlend++ = '\'';
- sqlend = ut_strcpyq(sqlend, '\'', foreign->id);
- *sqlend++ = '\'', *sqlend++ = ',', *sqlend++ = '\'';
- sqlend = ut_strcpyq(sqlend, '\'', table->name);
- *sqlend++ = '\'', *sqlend++ = ',', *sqlend++ = '\'';
- sqlend = ut_strcpyq(sqlend, '\'', foreign->referenced_table_name);
- *sqlend++ = '\'', *sqlend++ = ',';
- sqlend += sprintf(sqlend, "%010lu",
- foreign->n_fields + (foreign->type << 24));
- memcpy(sqlend, str2, (sizeof str2) - 1);
- sqlend += (sizeof str2) - 1;
-
- for (i = 0; i < foreign->n_fields; i++) {
- /* INSERT INTO SYS_FOREIGN_COLS VALUES(...); */
- memcpy(sqlend, str3, (sizeof str3) - 1);
- sqlend += (sizeof str3) - 1;
- *sqlend++ = '\'';
- sqlend = ut_strcpyq(sqlend, '\'', foreign->id);
- *sqlend++ = '\''; *sqlend++ = ',';
- sqlend += sprintf(sqlend, "%010lu", (ulong) i);
- *sqlend++ = ','; *sqlend++ = '\'';
- sqlend = ut_strcpyq(sqlend, '\'',
- foreign->foreign_col_names[i]);
- *sqlend++ = '\''; *sqlend++ = ','; *sqlend++ = '\'';
- sqlend = ut_strcpyq(sqlend, '\'',
- foreign->referenced_col_names[i]);
- *sqlend++ = '\'';
- memcpy(sqlend, str2, (sizeof str2) - 1);
- sqlend += (sizeof str2) - 1;
- }
-
- memcpy(sqlend, str4, sizeof str4);
- sqlend += sizeof str4;
-
- ut_a(sqlend == sql + len + 1);
-
- graph = pars_sql(sql);
-
- ut_a(graph);
-
- mem_free(sql);
-
- graph->trx = trx;
- trx->graph = NULL;
-
- graph->fork_type = QUE_FORK_MYSQL_INTERFACE;
-
- ut_a(thr = que_fork_start_command(graph));
-
- que_run_threads(thr);
-
- error = trx->error_state;
-
- que_graph_free(graph);
+ error = que_eval_sql(info, sql, trx);
if (error == DB_DUPLICATE_KEY) {
mutex_enter(&dict_foreign_err_mutex);
@@ -1466,7 +1288,163 @@ loop:
return(error);
}
- foreign = UT_LIST_GET_NEXT(foreign_list, foreign);
+ return(DB_SUCCESS);
+}
+
+/************************************************************************
+Add a single foreign key field definition to the data dictionary tables in
+the database. */
+static
+ulint
+dict_create_add_foreign_field_to_dictionary(
+/*========================================*/
+ /* out: error code or DB_SUCCESS */
+ ulint field_nr, /* in: foreign field number */
+ dict_table_t* table, /* in: table */
+ dict_foreign_t* foreign, /* in: foreign */
+ trx_t* trx) /* in: transaction */
+{
+ pars_info_t* info = pars_info_create();
+
+ pars_info_add_str_literal(info, "id", foreign->id);
+
+ pars_info_add_int4_literal(info, "pos", field_nr);
+
+ pars_info_add_str_literal(info, "for_col_name",
+ foreign->foreign_col_names[field_nr]);
+
+ pars_info_add_str_literal(info, "ref_col_name",
+ foreign->referenced_col_names[field_nr]);
+
+ return dict_foreign_eval_sql(info,
+ "PROCEDURE P () IS\n"
+ "BEGIN\n"
+ "INSERT INTO SYS_FOREIGN_COLS VALUES"
+ "(:id, :pos, :for_col_name, :ref_col_name);\n"
+ "END;\n"
+ , table, foreign, trx);
+}
+
+/************************************************************************
+Add a single foreign key definition to the data dictionary tables in the
+database. We also generate names to constraints that were not named by the
+user. A generated constraint has a name of the format
+databasename/tablename_ibfk_<number>, where the numbers start from 1, and
+are given locally for this table, that is, the number is not global, as in
+the old format constraints < 4.0.18 it used to be. */
+static
+ulint
+dict_create_add_foreign_to_dictionary(
+/*==================================*/
+ /* out: error code or DB_SUCCESS */
+ ulint* id_nr, /* in/out: number to use in id generation;
+ incremented if used */
+ dict_table_t* table, /* in: table */
+ dict_foreign_t* foreign,/* in: foreign */
+ trx_t* trx) /* in: transaction */
+{
+ ulint error;
+ ulint i;
+
+ pars_info_t* info = pars_info_create();
+
+ if (foreign->id == NULL) {
+ /* Generate a new constraint id */
+ ulint namelen = strlen(table->name);
+ char* id = mem_heap_alloc(foreign->heap, namelen + 20);
+ /* no overflow if number < 1e13 */
+ sprintf(id, "%s_ibfk_%lu", table->name, (ulong) (*id_nr)++);
+ foreign->id = id;
+ }
+
+ pars_info_add_str_literal(info, "id", foreign->id);
+
+ pars_info_add_str_literal(info, "for_name", table->name);
+
+ pars_info_add_str_literal(info, "ref_name",
+ foreign->referenced_table_name);
+
+ pars_info_add_int4_literal(info, "n_cols",
+ foreign->n_fields + (foreign->type << 24));
+
+ error = dict_foreign_eval_sql(info,
+ "PROCEDURE P () IS\n"
+ "BEGIN\n"
+ "INSERT INTO SYS_FOREIGN VALUES"
+ "(:id, :for_name, :ref_name, :n_cols);\n"
+ "END;\n"
+ , table, foreign, trx);
+
+ if (error != DB_SUCCESS) {
+
+ return(error);
+ }
+
+ for (i = 0; i < foreign->n_fields; i++) {
+ error = dict_create_add_foreign_field_to_dictionary(i,
+ table, foreign, trx);
+
+ if (error != DB_SUCCESS) {
+
+ return(error);
+ }
+ }
+
+ error = dict_foreign_eval_sql(NULL,
+ "PROCEDURE P () IS\n"
+ "BEGIN\n"
+ "COMMIT WORK;\n"
+ "END;\n"
+ , table, foreign, trx);
- goto loop;
+ return(error);
+}
+
+/************************************************************************
+Adds foreign key definitions to data dictionary tables in the database. */
+
+ulint
+dict_create_add_foreigns_to_dictionary(
+/*===================================*/
+ /* out: error code or DB_SUCCESS */
+ ulint start_id,/* in: if we are actually doing ALTER TABLE
+ ADD CONSTRAINT, we want to generate constraint
+ numbers which are bigger than in the table so
+ far; we number the constraints from
+ start_id + 1 up; start_id should be set to 0 if
+ we are creating a new table, or if the table
+ so far has no constraints for which the name
+ was generated here */
+ dict_table_t* table, /* in: table */
+ trx_t* trx) /* in: transaction */
+{
+ dict_foreign_t* foreign;
+ ulint number = start_id + 1;
+ ulint error;
+
+#ifdef UNIV_SYNC_DEBUG
+ ut_ad(mutex_own(&(dict_sys->mutex)));
+#endif /* UNIV_SYNC_DEBUG */
+
+ if (NULL == dict_table_get_low("SYS_FOREIGN")) {
+ fprintf(stderr,
+"InnoDB: table SYS_FOREIGN not found from internal data dictionary\n");
+
+ return(DB_ERROR);
+ }
+
+ for (foreign = UT_LIST_GET_FIRST(table->foreign_list);
+ foreign;
+ foreign = UT_LIST_GET_NEXT(foreign_list, foreign)) {
+
+ error = dict_create_add_foreign_to_dictionary(&number,
+ table, foreign, trx);
+
+ if (error != DB_SUCCESS) {
+
+ return(error);
+ }
+ }
+
+ return(DB_SUCCESS);
}
diff --git a/storage/innobase/dict/dict0dict.c b/storage/innobase/dict/dict0dict.c
index 1fac5e26fa9..877d4afe8f0 100644
--- a/storage/innobase/dict/dict0dict.c
+++ b/storage/innobase/dict/dict0dict.c
@@ -658,6 +658,19 @@ dict_table_get_nth_col_pos(
}
/************************************************************************
+Check whether the table uses the compact page format. */
+
+ibool
+dict_table_is_comp_noninline(
+/*=========================*/
+ /* out: TRUE if table uses the
+ compact page format */
+ const dict_table_t* table) /* in: table */
+{
+ return(dict_table_is_comp(table));
+}
+
+/************************************************************************
Checks if a column is in the ordering columns of the clustered index of a
table. Column prefixes are treated like whole columns. */
@@ -870,13 +883,6 @@ dict_table_add_to_cache(
ut_a(table2 == NULL);
}
- if (table->type == DICT_TABLE_CLUSTER_MEMBER) {
-
- table->mix_id_len = mach_dulint_get_compressed_size(
- table->mix_id);
- mach_dulint_write_compressed(table->mix_id_buf, table->mix_id);
- }
-
/* Add the columns to the column hash table */
for (i = 0; i < table->n_cols; i++) {
dict_col_add_to_cache(table, dict_table_get_nth_col(table, i));
@@ -1251,15 +1257,13 @@ dict_table_remove_from_cache(
/* Remove table from LRU list of tables */
UT_LIST_REMOVE(table_LRU, dict_sys->table_LRU, table);
- mutex_free(&(table->autoinc_mutex));
-
size = mem_heap_get_size(table->heap);
ut_ad(dict_sys->size >= size);
dict_sys->size -= size;
- mem_heap_free(table->heap);
+ dict_mem_table_free(table);
}
/**************************************************************************
@@ -1380,6 +1384,38 @@ dict_col_reposition_in_cache(
HASH_INSERT(dict_col_t, hash, dict_sys->col_hash, fold, col);
}
+/********************************************************************
+If the given column name is reserved for InnoDB system columns, return
+TRUE. */
+
+ibool
+dict_col_name_is_reserved(
+/*======================*/
+ /* out: TRUE if name is reserved */
+ const char* name) /* in: column name */
+{
+ /* This check reminds that if a new system column is added to
+ the program, it should be dealt with here. */
+#if DATA_N_SYS_COLS != 4
+#error "DATA_N_SYS_COLS != 4"
+#endif
+
+ static const char* reserved_names[] = {
+ "DB_ROW_ID", "DB_TRX_ID", "DB_ROLL_PTR", "DB_MIX_ID"
+ };
+
+ ulint i;
+
+ for (i = 0; i < UT_ARR_SIZE(reserved_names); i++) {
+ if (strcmp(name, reserved_names[i]) == 0) {
+
+ return(TRUE);
+ }
+ }
+
+ return(FALSE);
+}
+
/**************************************************************************
Adds an index to the dictionary cache. */
@@ -1394,7 +1430,6 @@ dict_index_add_to_cache(
{
dict_index_t* new_index;
dict_tree_t* tree;
- dict_table_t* cluster;
dict_field_t* field;
ulint n_ord;
ibool success;
@@ -1468,21 +1503,11 @@ dict_index_add_to_cache(
dict_field_get_col(field)->ord_part++;
}
- if (table->type == DICT_TABLE_CLUSTER_MEMBER) {
- /* The index tree is found from the cluster object */
-
- cluster = dict_table_get_low(table->cluster_name);
+ /* Create an index tree memory object for the index */
+ tree = dict_tree_create(new_index, page_no);
+ ut_ad(tree);
- tree = dict_index_get_tree(
- UT_LIST_GET_FIRST(cluster->indexes));
- new_index->tree = tree;
- } else {
- /* Create an index tree memory object for the index */
- tree = dict_tree_create(new_index, page_no);
- ut_ad(tree);
-
- new_index->tree = tree;
- }
+ new_index->tree = tree;
if (!UNIV_UNLIKELY(new_index->type & DICT_UNIVERSAL)) {
@@ -1500,7 +1525,7 @@ dict_index_add_to_cache(
}
/* Add the index to the list of indexes stored in the tree */
- UT_LIST_ADD_LAST(tree_indexes, tree->tree_indexes, new_index);
+ tree->tree_index = new_index;
/* If the dictionary cache grows too big, trim the table LRU list */
@@ -1532,7 +1557,7 @@ dict_index_remove_from_cache(
ut_ad(mutex_own(&(dict_sys->mutex)));
#endif /* UNIV_SYNC_DEBUG */
- ut_ad(UT_LIST_GET_LEN((index->tree)->tree_indexes) == 1);
+ ut_ad(index->tree->tree_index);
dict_tree_free(index->tree);
/* Decrement the ord_part counts in columns which are ordering */
@@ -1553,7 +1578,7 @@ dict_index_remove_from_cache(
dict_sys->size -= size;
- mem_heap_free(index->heap);
+ dict_mem_index_free(index);
}
/***********************************************************************
@@ -1699,8 +1724,6 @@ dict_table_copy_types(
dtype_t* type;
ulint i;
- ut_ad(!(table->type & DICT_UNIVERSAL));
-
for (i = 0; i < dtuple_get_n_fields(tuple); i++) {
dfield_type = dfield_get_type(dtuple_get_nth_field(tuple, i));
@@ -1749,22 +1772,8 @@ dict_index_build_internal_clust(
new_index->id = index->id;
- if (table->type != DICT_TABLE_ORDINARY) {
- /* The index is mixed: copy common key prefix fields */
-
- dict_index_copy(new_index, index, 0, table->mix_len);
-
- /* Add the mix id column */
- dict_index_add_col(new_index,
- dict_table_get_sys_col(table, DATA_MIX_ID), 0);
-
- /* Copy the rest of fields */
- dict_index_copy(new_index, index, table->mix_len,
- index->n_fields);
- } else {
- /* Copy the fields of index */
- dict_index_copy(new_index, index, 0, index->n_fields);
- }
+ /* Copy the fields of index */
+ dict_index_copy(new_index, index, 0, index->n_fields);
if (UNIV_UNLIKELY(index->type & DICT_UNIVERSAL)) {
/* No fixed number of fields determines an entry uniquely */
@@ -3641,7 +3650,7 @@ dict_tree_create(
tree->id = index->id;
- UT_LIST_INIT(tree->tree_indexes);
+ tree->tree_index = NULL;
tree->magic_n = DICT_TREE_MAGIC_N;
@@ -3667,135 +3676,7 @@ dict_tree_free(
mem_free(tree);
}
-/**************************************************************************
-In an index tree, finds the index corresponding to a record in the tree. */
-UNIV_INLINE
-dict_index_t*
-dict_tree_find_index_low(
-/*=====================*/
- /* out: index */
- dict_tree_t* tree, /* in: index tree */
- rec_t* rec) /* in: record for which to find correct
- index */
-{
- dict_index_t* index;
- dict_table_t* table;
- dulint mix_id;
- ulint len;
-
- index = UT_LIST_GET_FIRST(tree->tree_indexes);
- ut_ad(index);
- table = index->table;
-
- if ((index->type & DICT_CLUSTERED)
- && UNIV_UNLIKELY(table->type != DICT_TABLE_ORDINARY)) {
-
- /* Get the mix id of the record */
- ut_a(!dict_table_is_comp(table));
-
- mix_id = mach_dulint_read_compressed(
- rec_get_nth_field_old(rec, table->mix_len, &len));
-
- while (ut_dulint_cmp(table->mix_id, mix_id) != 0) {
-
- index = UT_LIST_GET_NEXT(tree_indexes, index);
- table = index->table;
- ut_ad(index);
- }
- }
-
- return(index);
-}
-
-/**************************************************************************
-In an index tree, finds the index corresponding to a record in the tree. */
-
-dict_index_t*
-dict_tree_find_index(
-/*=================*/
- /* out: index */
- dict_tree_t* tree, /* in: index tree */
- rec_t* rec) /* in: record for which to find correct
- index */
-{
- dict_index_t* index;
-
- index = dict_tree_find_index_low(tree, rec);
-
- return(index);
-}
-
-/**************************************************************************
-In an index tree, finds the index corresponding to a dtuple which is used
-in a search to a tree. */
-
-dict_index_t*
-dict_tree_find_index_for_tuple(
-/*===========================*/
- /* out: index; NULL if the tuple does not
- contain the mix id field in a mixed tree */
- dict_tree_t* tree, /* in: index tree */
- dtuple_t* tuple) /* in: tuple for which to find index */
-{
- dict_index_t* index;
- dict_table_t* table;
- dulint mix_id;
-
- ut_ad(dtuple_check_typed(tuple));
-
- if (UT_LIST_GET_LEN(tree->tree_indexes) == 1) {
-
- return(UT_LIST_GET_FIRST(tree->tree_indexes));
- }
-
- index = UT_LIST_GET_FIRST(tree->tree_indexes);
- ut_ad(index);
- table = index->table;
-
- if (dtuple_get_n_fields(tuple) <= table->mix_len) {
-
- return(NULL);
- }
-
- /* Get the mix id of the record */
-
- mix_id = mach_dulint_read_compressed(
- dfield_get_data(
- dtuple_get_nth_field(tuple, table->mix_len)));
-
- while (ut_dulint_cmp(table->mix_id, mix_id) != 0) {
-
- index = UT_LIST_GET_NEXT(tree_indexes, index);
- table = index->table;
- ut_ad(index);
- }
-
- return(index);
-}
-
-/***********************************************************************
-Checks if a table which is a mixed cluster member owns a record. */
-
-ibool
-dict_is_mixed_table_rec(
-/*====================*/
- /* out: TRUE if the record belongs to this
- table */
- dict_table_t* table, /* in: table in a mixed cluster */
- rec_t* rec) /* in: user record in the clustered index */
-{
- byte* mix_id_field;
- ulint len;
-
- ut_ad(!dict_table_is_comp(table));
-
- mix_id_field = rec_get_nth_field_old(rec,
- table->mix_len, &len);
-
- return(len == table->mix_id_len
- && !ut_memcmp(table->mix_id_buf, mix_id_field, len));
-}
-
+#ifdef UNIV_DEBUG
/**************************************************************************
Checks that a tuple has n_fields_cmp value in a sensible range, so that
no comparison can occur with the page number field in a node pointer. */
@@ -3807,19 +3688,14 @@ dict_tree_check_search_tuple(
dict_tree_t* tree, /* in: index tree */
dtuple_t* tuple) /* in: tuple used in a search */
{
- dict_index_t* index;
-
- index = dict_tree_find_index_for_tuple(tree, tuple);
-
- if (index == NULL) {
-
- return(TRUE);
- }
+ dict_index_t* index = tree->tree_index;
+ ut_a(index);
ut_a(dtuple_get_n_fields_cmp(tuple)
<= dict_index_get_n_unique_in_tree(index));
return(TRUE);
}
+#endif /* UNIV_DEBUG */
/**************************************************************************
Builds a node pointer out of a physical record and a page number. */
@@ -3842,7 +3718,7 @@ dict_tree_build_node_ptr(
byte* buf;
ulint n_unique;
- ind = dict_tree_find_index_low(tree, rec);
+ ind = tree->tree_index;
if (UNIV_UNLIKELY(tree->type & DICT_UNIVERSAL)) {
/* In a universal index tree, we take the whole record as
@@ -3910,7 +3786,7 @@ dict_tree_copy_rec_order_prefix(
ulint n;
UNIV_PREFETCH_R(rec);
- index = dict_tree_find_index_low(tree, rec);
+ index = tree->tree_index;
if (UNIV_UNLIKELY(tree->type & DICT_UNIVERSAL)) {
ut_a(!dict_table_is_comp(index->table));
@@ -3938,7 +3814,7 @@ dict_tree_build_data_tuple(
dtuple_t* tuple;
dict_index_t* ind;
- ind = dict_tree_find_index_low(tree, rec);
+ ind = tree->tree_index;
ut_ad(dict_table_is_comp(ind->table)
|| n_fields <= rec_get_n_fields_old(rec));
@@ -4097,6 +3973,18 @@ dict_update_statistics(
}
/**************************************************************************
+A noninlined version of dict_table_get_low. */
+
+dict_table_t*
+dict_table_get_low_noninlined(
+/*==========================*/
+ /* out: table, NULL if not found */
+ const char* table_name) /* in: table name */
+{
+ return(dict_table_get_low(table_name));
+}
+
+/**************************************************************************
Prints info of a foreign key constraint. */
static
void
@@ -4520,15 +4408,3 @@ dict_index_name_print(
fputs(" of table ", file);
ut_print_name(file, trx, index->table_name);
}
-
-/************************************************************************
-Export an inlined function for use in ha_innodb.c. */
-ibool
-innodb_dict_table_is_comp(
-/*===============*/
- /* out: TRUE if table uses the
- compact page format */
- const dict_table_t* table) /* in: table */
-{
- return dict_table_is_comp(table);
-}
diff --git a/storage/innobase/dict/dict0load.c b/storage/innobase/dict/dict0load.c
index 09935c03288..4779e50f176 100644
--- a/storage/innobase/dict/dict0load.c
+++ b/storage/innobase/dict/dict0load.c
@@ -768,7 +768,7 @@ dict_load_table(
if (!btr_pcur_is_on_user_rec(&pcur, &mtr)
|| rec_get_deleted_flag(rec, 0)) {
/* Not found */
-
+ err_exit:
btr_pcur_close(&pcur);
mtr_commit(&mtr);
mem_heap_free(heap);
@@ -780,11 +780,8 @@ dict_load_table(
/* Check if the table name in record is the searched one */
if (len != ut_strlen(name) || ut_memcmp(name, field, len) != 0) {
- btr_pcur_close(&pcur);
- mtr_commit(&mtr);
- mem_heap_free(heap);
- return(NULL);
+ goto err_exit;
}
ut_a(0 == ut_strcmp("SPACE",
@@ -848,36 +845,17 @@ dict_load_table(
table->id = mach_read_from_8(field);
field = rec_get_nth_field_old(rec, 5, &len);
- table->type = mach_read_from_4(field);
-
- if (table->type == DICT_TABLE_CLUSTER_MEMBER) {
- ut_error;
-#if 0 /* clustered tables have not been implemented yet */
- field = rec_get_nth_field_old(rec, 6, &len);
- table->mix_id = mach_read_from_8(field);
-
- field = rec_get_nth_field_old(rec, 8, &len);
- table->cluster_name = mem_heap_strdupl(heap, (char*) field, len);
-#endif
- }
-
- if ((table->type == DICT_TABLE_CLUSTER)
- || (table->type == DICT_TABLE_CLUSTER_MEMBER)) {
-
- field = rec_get_nth_field_old(rec, 7, &len);
- ut_a(len == 4);
- table->mix_len = mach_read_from_4(field);
+ if (UNIV_UNLIKELY(mach_read_from_4(field) != DICT_TABLE_ORDINARY)) {
+ ut_print_timestamp(stderr);
+ fprintf(stderr,
+ " InnoDB: table %s: unknown table type %lu\n",
+ name, (ulong) mach_read_from_4(field));
+ goto err_exit;
}
btr_pcur_close(&pcur);
mtr_commit(&mtr);
- if (table->type == DICT_TABLE_CLUSTER_MEMBER) {
- /* Load the cluster table definition if not yet in
- memory cache */
- dict_table_get_low(table->cluster_name);
- }
-
dict_load_columns(table, heap);
dict_table_add_to_cache(table);
diff --git a/storage/innobase/dict/dict0mem.c b/storage/innobase/dict/dict0mem.c
index d9f0ad3d84e..fe21890adc8 100644
--- a/storage/innobase/dict/dict0mem.c
+++ b/storage/innobase/dict/dict0mem.c
@@ -50,7 +50,6 @@ dict_mem_table_create(
table->heap = heap;
- table->type = DICT_TABLE_ORDINARY;
table->flags = flags;
table->name = mem_heap_strdup(heap, name);
table->dir_path_of_temp_table = NULL;
@@ -66,9 +65,6 @@ dict_mem_table_create(
table->cached = FALSE;
- table->mix_id = ut_dulint_zero;
- table->mix_len = 0;
-
table->cols = mem_heap_alloc(heap, (n_cols + DATA_N_SYS_COLS)
* sizeof(dict_col_t));
UT_LIST_INIT(table->indexes);
@@ -97,42 +93,19 @@ dict_mem_table_create(
return(table);
}
-/**************************************************************************
-Creates a cluster memory object. */
-
-dict_table_t*
-dict_mem_cluster_create(
-/*====================*/
- /* out, own: cluster object */
- const char* name, /* in: cluster name */
- ulint space, /* in: space where the clustered indexes
- of the member tables are placed */
- ulint n_cols, /* in: number of columns */
- ulint mix_len)/* in: length of the common key prefix in the
- cluster */
-{
- dict_table_t* cluster;
-
- /* Clustered tables cannot work with the compact record format. */
- cluster = dict_mem_table_create(name, space, n_cols, 0);
-
- cluster->type = DICT_TABLE_CLUSTER;
- cluster->mix_len = mix_len;
-
- return(cluster);
-}
-
-/**************************************************************************
-Declares a non-published table as a member in a cluster. */
+/********************************************************************
+Free a table memory object. */
void
-dict_mem_table_make_cluster_member(
-/*===============================*/
- dict_table_t* table, /* in: non-published table */
- const char* cluster_name) /* in: cluster name */
+dict_mem_table_free(
+/*================*/
+ dict_table_t* table) /* in: table */
{
- table->type = DICT_TABLE_CLUSTER_MEMBER;
- table->cluster_name = cluster_name;
+ ut_ad(table);
+ ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
+
+ mutex_free(&(table->autoinc_mutex));
+ mem_heap_free(table->heap);
}
/**************************************************************************
@@ -286,5 +259,8 @@ dict_mem_index_free(
/*================*/
dict_index_t* index) /* in: index */
{
+ ut_ad(index);
+ ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
+
mem_heap_free(index->heap);
}