summaryrefslogtreecommitdiff
path: root/storage/innobase/handler/ha_innodb.cc
diff options
context:
space:
mode:
Diffstat (limited to 'storage/innobase/handler/ha_innodb.cc')
-rw-r--r--storage/innobase/handler/ha_innodb.cc110
1 files changed, 37 insertions, 73 deletions
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index fd168adb702..8a37c67eb6a 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -1527,20 +1527,27 @@ static void innodb_drop_database(handlerton*, char *path)
we will "manually" purge the tablespaces that belong to the
records that we delete-marked. */
- mem_heap_t *heap= mem_heap_create(100);
- dtuple_t *tuple= dtuple_create(heap, 1);
- dfield_t *dfield= dtuple_get_nth_field(tuple, 0);
+ dfield_t dfield;
+ dtuple_t tuple{
+ 0,1,1,&dfield,0,nullptr
+#ifdef UNIV_DEBUG
+ , DATA_TUPLE_MAGIC_N
+#endif
+ };
dict_index_t* sys_index= UT_LIST_GET_FIRST(dict_sys.sys_tables->indexes);
btr_pcur_t pcur;
namebuf[len++]= '/';
- dfield_set_data(dfield, namebuf, len);
- dict_index_copy_types(tuple, sys_index, 1);
+ dfield_set_data(&dfield, namebuf, len);
+ dict_index_copy_types(&tuple, sys_index, 1);
std::vector<pfs_os_file_t> to_close;
mtr_t mtr;
mtr.start();
- for (btr_pcur_open_on_user_rec(sys_index, tuple, PAGE_CUR_GE,
+ err= btr_pcur_open_on_user_rec(sys_index, &tuple, PAGE_CUR_GE,
BTR_SEARCH_LEAF, &pcur, &mtr);
- btr_pcur_is_on_user_rec(&pcur);
+ if (err != DB_SUCCESS)
+ goto err_exit;
+
+ for (; btr_pcur_is_on_user_rec(&pcur);
btr_pcur_move_to_next_user_rec(&pcur, &mtr))
{
const rec_t *rec= btr_pcur_get_rec(&pcur);
@@ -1581,8 +1588,8 @@ static void innodb_drop_database(handlerton*, char *path)
to_close.emplace_back(detached);
}
}
+ err_exit:
mtr.commit();
- mem_heap_free(heap);
for (pfs_os_file_t detached : to_close)
os_file_close(detached);
/* Any changes must be persisted before we return. */
@@ -2016,8 +2023,10 @@ static void drop_garbage_tables_after_restore()
ut_d(purge_sys.stop_FTS());
mtr.start();
- btr_pcur_open_at_index_side(true, dict_sys.sys_tables->indexes.start,
- BTR_SEARCH_LEAF, &pcur, true, 0, &mtr);
+ if (btr_pcur_open_at_index_side(true, dict_sys.sys_tables->indexes.start,
+ BTR_SEARCH_LEAF, &pcur, true, 0, &mtr) !=
+ DB_SUCCESS)
+ goto all_fail;
for (;;)
{
btr_pcur_move_to_next_user_rec(&pcur, &mtr);
@@ -2101,9 +2110,11 @@ fail:
os_file_close(d);
mtr.start();
- pcur.restore_position(BTR_SEARCH_LEAF, &mtr);
+ if (pcur.restore_position(BTR_SEARCH_LEAF, &mtr) == btr_pcur_t::CORRUPTED)
+ break;
}
+all_fail:
mtr.commit();
trx->free();
ut_free(pcur.old_rec_buf);
@@ -2227,6 +2238,7 @@ convert_error_code_to_mysql(
code should be introduced */
case DB_CORRUPTION:
+ case DB_PAGE_CORRUPTED:
return(HA_ERR_CRASHED);
case DB_OUT_OF_FILE_SPACE:
@@ -14987,15 +14999,8 @@ inline int ha_innobase::defragment_table()
for (dict_index_t *index= dict_table_get_first_index(m_prebuilt->table);
index; index= dict_table_get_next_index(index))
{
- if (index->is_corrupted() || index->is_spatial())
- continue;
-
- if (index->page == FIL_NULL)
- {
- /* Do not defragment auxiliary tables related to FULLTEXT INDEX. */
- ut_ad(index->type & DICT_FTS);
+ if (!index->is_btree())
continue;
- }
if (btr_defragment_find_index(index))
{
@@ -15106,7 +15111,6 @@ ha_innobase::check(
THD* thd, /*!< in: user thread handle */
HA_CHECK_OPT* check_opt) /*!< in: check options */
{
- dict_index_t* index;
ulint n_rows;
ulint n_rows_in_table = ULINT_UNDEFINED;
bool is_ok = true;
@@ -15147,30 +15151,6 @@ ha_innobase::check(
m_prebuilt->trx->op_info = "checking table";
- if (m_prebuilt->table->corrupted) {
- /* If some previous operation has marked the table as
- corrupted in memory, and has not propagated such to
- clustered index, we will do so here */
- index = dict_table_get_first_index(m_prebuilt->table);
-
- if (!index->is_corrupted()) {
- dict_set_corrupted(index, "CHECK TABLE", false);
- }
-
- push_warning_printf(m_user_thd,
- Sql_condition::WARN_LEVEL_WARN,
- HA_ERR_INDEX_CORRUPT,
- "InnoDB: Index %s is marked as"
- " corrupted",
- index->name());
-
- /* Now that the table is already marked as corrupted,
- there is no need to check any index of this table */
- m_prebuilt->trx->op_info = "";
-
- DBUG_RETURN(HA_ADMIN_CORRUPT);
- }
-
uint old_isolation_level = m_prebuilt->trx->isolation_level;
/* We must run the index record counts at an isolation level
@@ -15181,10 +15161,9 @@ ha_innobase::check(
? TRX_ISO_READ_UNCOMMITTED
: TRX_ISO_REPEATABLE_READ;
- ut_ad(!m_prebuilt->table->corrupted);
-
- for (index = dict_table_get_first_index(m_prebuilt->table);
- index != NULL;
+ for (dict_index_t* index
+ = dict_table_get_first_index(m_prebuilt->table);
+ index;
index = dict_table_get_next_index(index)) {
/* If this is an index being created or dropped, skip */
if (!index->is_committed()) {
@@ -15200,25 +15179,13 @@ ha_innobase::check(
if (err != DB_SUCCESS) {
is_ok = false;
- if (err == DB_DECRYPTION_FAILED) {
- push_warning_printf(
- thd,
- Sql_condition::WARN_LEVEL_WARN,
- ER_NO_SUCH_TABLE,
- "Table %s is encrypted but encryption service or"
- " used key_id is not available. "
- " Can't continue checking table.",
- index->table->name.m_name);
- } else {
- push_warning_printf(
- thd,
- Sql_condition::WARN_LEVEL_WARN,
- ER_NOT_KEYFILE,
- "InnoDB: The B-tree of"
- " index %s is corrupted.",
- index->name());
- }
-
+ push_warning_printf(
+ thd,
+ Sql_condition::WARN_LEVEL_WARN,
+ ER_NOT_KEYFILE,
+ "InnoDB: The B-tree of"
+ " index %s is corrupted.",
+ index->name());
continue;
}
}
@@ -15236,8 +15203,7 @@ ha_innobase::check(
if (!index->is_primary()) {
m_prebuilt->index_usable = FALSE;
dict_set_corrupted(index,
- "dict_set_index_corrupted",
- false);
+ "dict_set_index_corrupted");
});
if (UNIV_UNLIKELY(!m_prebuilt->index_usable)) {
@@ -15299,8 +15265,7 @@ ha_innobase::check(
" index %s is corrupted.",
index->name());
is_ok = false;
- dict_set_corrupted(index, "CHECK TABLE-check index",
- false);
+ dict_set_corrupted(index, "CHECK TABLE-check index");
}
@@ -15315,8 +15280,7 @@ ha_innobase::check(
" entries, should be " ULINTPF ".",
index->name(), n_rows, n_rows_in_table);
is_ok = false;
- dict_set_corrupted(index, "CHECK TABLE; Wrong count",
- false);
+ dict_set_corrupted(index, "CHECK TABLE; Wrong count");
}
}