summaryrefslogtreecommitdiff
path: root/storage/xtradb/dict
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2011-11-24 18:48:58 +0200
committerMichael Widenius <monty@askmonty.org>2011-11-24 18:48:58 +0200
commit69204571425ed3221e94c7eb1e030c00089bca26 (patch)
tree3d9cfbc44a057883c7db6bce267c8ebfd5fa9313 /storage/xtradb/dict
parente3e60a4102d6918e4231e402bef89b1a6b2a20cb (diff)
parentd26aefb0775048128495eaab151ee4118f8f7afd (diff)
downloadmariadb-git-69204571425ed3221e94c7eb1e030c00089bca26.tar.gz
Merge with MariaDB 5.1
Diffstat (limited to 'storage/xtradb/dict')
-rw-r--r--storage/xtradb/dict/dict0dict.c7
-rw-r--r--storage/xtradb/dict/dict0load.c63
-rw-r--r--storage/xtradb/dict/dict0mem.c9
3 files changed, 73 insertions, 6 deletions
diff --git a/storage/xtradb/dict/dict0dict.c b/storage/xtradb/dict/dict0dict.c
index 18880a5c72c..a8a1d7a11e6 100644
--- a/storage/xtradb/dict/dict0dict.c
+++ b/storage/xtradb/dict/dict0dict.c
@@ -4524,6 +4524,8 @@ dict_store_statistics(
break;
}
+ btr_pcur_store_position(&pcur, &mtr);
+
if (rec_get_deleted_flag(rec, 0)) {
/* don't count */
i--;
@@ -4564,6 +4566,10 @@ dict_store_statistics(
rests--;
next_rec:
+ mtr_commit(&mtr);
+ mtr_start(&mtr);
+ btr_pcur_restore_position(BTR_MODIFY_LEAF, &pcur, &mtr);
+
btr_pcur_move_to_next_user_rec(&pcur, &mtr);
}
btr_pcur_close(&pcur);
@@ -4654,6 +4660,7 @@ dict_update_statistics(
do {
if (table->is_corrupt) {
ut_a(srv_pass_corrupt_table);
+ dict_table_stats_unlock(table, RW_X_LATCH);
return;
}
diff --git a/storage/xtradb/dict/dict0load.c b/storage/xtradb/dict/dict0load.c
index edd77e2530f..64d7fad3557 100644
--- a/storage/xtradb/dict/dict0load.c
+++ b/storage/xtradb/dict/dict0load.c
@@ -554,9 +554,10 @@ dict_load_columns(
}
/********************************************************************//**
-Loads definitions for index fields. */
+Loads definitions for index fields.
+@return DB_SUCCESS if ok, DB_CORRUPTION if failed */
static
-void
+ulint
dict_load_fields(
/*=============*/
dict_index_t* index, /*!< in: index whose fields to load */
@@ -575,6 +576,7 @@ dict_load_fields(
byte* buf;
ulint i;
mtr_t mtr;
+ ulint error = DB_SUCCESS;
ut_ad(mutex_own(&(dict_sys->mutex)));
@@ -641,6 +643,26 @@ dict_load_fields(
field = rec_get_nth_field_old(rec, 4, &len);
+ if (prefix_len >= DICT_MAX_INDEX_COL_LEN) {
+ fprintf(stderr, "InnoDB: Error: load index"
+ " '%s' failed.\n"
+ "InnoDB: index field '%s' has a prefix"
+ " length of %lu bytes,\n"
+ "InnoDB: which exceeds the"
+ " maximum limit of %lu bytes.\n"
+ "InnoDB: Please use server that"
+ " supports long index prefix\n"
+ "InnoDB: or turn on"
+ " innodb_force_recovery to load"
+ " the table\n",
+ index->name, mem_heap_strdupl(
+ heap, (char*) field, len),
+ (ulong) prefix_len,
+ (ulong) (DICT_MAX_INDEX_COL_LEN - 1));
+ error = DB_CORRUPTION;
+ goto func_exit;
+ }
+
dict_mem_index_add_field(index,
mem_heap_strdupl(heap,
(char*) field, len),
@@ -650,8 +672,10 @@ next_rec:
btr_pcur_move_to_next_user_rec(&pcur, &mtr);
}
+func_exit:
btr_pcur_close(&pcur);
mtr_commit(&mtr);
+ return(error);
}
/********************************************************************//**
@@ -802,7 +826,25 @@ dict_load_indexes(
space, type, n_fields);
index->id = id;
- dict_load_fields(index, heap);
+ error = dict_load_fields(index, heap);
+
+ if (error != DB_SUCCESS) {
+ fprintf(stderr, "InnoDB: Error: load index '%s'"
+ " for table '%s' failed\n",
+ index->name, table->name);
+
+ /* If the force recovery flag is set, and
+ if the failed index is not the primary index, we
+ will continue and open other indexes */
+ if (srv_force_recovery
+ && !(index->type & DICT_CLUSTERED)) {
+ error = DB_SUCCESS;
+ goto next_rec;
+ } else {
+ goto func_exit;
+ }
+ }
+
error = dict_index_add_to_cache(table, index, page_no,
FALSE);
/* The data dictionary tables should never contain
@@ -1028,9 +1070,18 @@ err_exit:
} else {
table->fk_max_recusive_level = 0;
}
- } else if (!srv_force_recovery) {
- dict_table_remove_from_cache(table);
- table = NULL;
+ } else {
+ dict_index_t* index;
+
+ /* Make sure that at least the clustered index was loaded.
+ Otherwise refuse to load the table */
+ index = dict_table_get_first_index(table);
+
+ if (!srv_force_recovery || !index
+ || !(index->type & DICT_CLUSTERED)) {
+ dict_table_remove_from_cache(table);
+ table = NULL;
+ }
}
#if 0
if (err != DB_SUCCESS && table != NULL) {
diff --git a/storage/xtradb/dict/dict0mem.c b/storage/xtradb/dict/dict0mem.c
index f2d219bfd4f..c3da053c2de 100644
--- a/storage/xtradb/dict/dict0mem.c
+++ b/storage/xtradb/dict/dict0mem.c
@@ -36,6 +36,9 @@ Created 1/8/1996 Heikki Tuuri
#ifndef UNIV_HOTBACKUP
# include "lock0lock.h"
#endif /* !UNIV_HOTBACKUP */
+#ifdef UNIV_BLOB_DEBUG
+# include "ut0rbt.h"
+#endif /* UNIV_BLOB_DEBUG */
#define DICT_HEAP_SIZE 100 /*!< initial memory heap size when
creating a table or index object */
@@ -318,6 +321,12 @@ dict_mem_index_free(
{
ut_ad(index);
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
+#ifdef UNIV_BLOB_DEBUG
+ if (index->blobs) {
+ mutex_free(&index->blobs_mutex);
+ rbt_free(index->blobs);
+ }
+#endif /* UNIV_BLOB_DEBUG */
mem_heap_free(index->heap);
}