From 4d40985a7a71e82dab2adc95c9e412ad71571382 Mon Sep 17 00:00:00 2001
From: Jimmy Yang <jimmy.yang@oracle.com>
Date: Mon, 29 Aug 2011 02:44:28 -0700
Subject: [PATCH] Fix Bug 12922077 - SEGV IN
 DICT_SET_CORRUPTED_INDEX_CACHE_ONLY(), DROP TABLE

rb://752 approved by Sunny Bains
---
 storage/innobase/dict/dict0dict.c    | 12 ++++++++++--
 storage/innobase/dict/dict0load.c    |  3 ++-
 storage/innobase/include/dict0dict.h |  3 ++-
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/storage/innobase/dict/dict0dict.c b/storage/innobase/dict/dict0dict.c
index dfb733cb36c..2a2c7652817 100644
--- a/storage/innobase/dict/dict0dict.c
+++ b/storage/innobase/dict/dict0dict.c
@@ -5206,7 +5206,8 @@ UNIV_INTERN
 void
 dict_set_corrupted_index_cache_only(
 /*================================*/
-	dict_index_t*	index)		/*!< in/out: index */
+	dict_index_t*	index,		/*!< in/out: index */
+	dict_table_t*	table)		/*!< in/out: table */
 {
 	ut_ad(index);
 	ut_ad(mutex_own(&dict_sys->mutex));
@@ -5216,7 +5217,14 @@ dict_set_corrupted_index_cache_only(
 	/* Mark the table as corrupted only if the clustered index
 	is corrupted */
 	if (dict_index_is_clust(index)) {
-		index->table->corrupted = TRUE;
+		dict_table_t*	corrupt_table;
+
+		corrupt_table = table ? table : index->table;
+		ut_ad(!index->table || !table || index->table  == table);
+
+		if (corrupt_table) {
+			corrupt_table->corrupted = TRUE;
+		}
 	}
 
 	index->type |= DICT_CORRUPT;
diff --git a/storage/innobase/dict/dict0load.c b/storage/innobase/dict/dict0load.c
index 60590aa6638..e13cc1b31f1 100644
--- a/storage/innobase/dict/dict0load.c
+++ b/storage/innobase/dict/dict0load.c
@@ -1497,7 +1497,8 @@ dict_load_indexes(
 				dictionary cache for such metadata corruption,
 				since we would always be able to set it
 				when loading the dictionary cache */
-				dict_set_corrupted_index_cache_only(index);
+				dict_set_corrupted_index_cache_only(
+					index, table);
 
 				fprintf(stderr,
 					"InnoDB: Index is corrupt but forcing"
diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h
index 93e9162dc87..57e51cbb6ba 100644
--- a/storage/innobase/include/dict0dict.h
+++ b/storage/innobase/include/dict0dict.h
@@ -1298,7 +1298,8 @@ UNIV_INTERN
 void
 dict_set_corrupted_index_cache_only(
 /*================================*/
-	dict_index_t*	index);		/*!< in/out: index */
+	dict_index_t*	index,		/*!< in/out: index */
+	dict_table_t*	table);		/*!< in/out: table */
 
 /**********************************************************************//**
 Flags a table with specified space_id corrupted in the table dictionary
-- 
2.30.9