summaryrefslogtreecommitdiff
path: root/storage/innobase
diff options
context:
space:
mode:
Diffstat (limited to 'storage/innobase')
-rw-r--r--storage/innobase/btr/btr0btr.cc16
-rw-r--r--storage/innobase/btr/btr0defragment.cc2
-rw-r--r--storage/innobase/btr/btr0sea.cc14
-rw-r--r--storage/innobase/buf/buf0buf.cc4
-rw-r--r--storage/innobase/buf/buf0lru.cc2
-rw-r--r--storage/innobase/fsp/fsp0file.cc22
-rw-r--r--storage/innobase/handler/ha_innodb.cc32
-rw-r--r--storage/innobase/handler/handler0alter.cc15
-rw-r--r--storage/innobase/include/btr0sea.h2
-rw-r--r--storage/innobase/include/fsp0fsp.h16
-rw-r--r--storage/innobase/page/page0zip.cc2
-rw-r--r--storage/innobase/row/row0import.cc24
-rw-r--r--storage/innobase/row/row0ins.cc6
-rw-r--r--storage/innobase/row/row0log.cc2
-rw-r--r--storage/innobase/row/row0quiesce.cc15
15 files changed, 120 insertions, 54 deletions
diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc
index 4b77277263f..6fd9686304c 100644
--- a/storage/innobase/btr/btr0btr.cc
+++ b/storage/innobase/btr/btr0btr.cc
@@ -951,7 +951,7 @@ static void btr_free_root(buf_block_t *block, mtr_t *mtr)
MTR_MEMO_PAGE_SX_FIX));
ut_ad(mtr->is_named_space(block->page.id().space()));
- btr_search_drop_page_hash_index(block);
+ btr_search_drop_page_hash_index(block, false);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_root_fseg_validate(PAGE_HEADER + PAGE_BTR_SEG_TOP + block->frame,
@@ -1364,7 +1364,7 @@ static void btr_page_reorganize_low(page_cur_t *cursor, dict_index_t *index,
/* Copy the old page to temporary space */
memcpy_aligned<UNIV_PAGE_SIZE_MIN>(old->frame, block->frame, srv_page_size);
- btr_search_drop_page_hash_index(block);
+ btr_search_drop_page_hash_index(block, false);
/* Save the cursor position. */
const ulint pos= page_rec_get_n_recs_before(cursor->rec);
@@ -1668,7 +1668,7 @@ btr_page_empty(
ut_a(!page_zip || page_zip_validate(page_zip, block->frame, index));
#endif /* UNIV_ZIP_DEBUG */
- btr_search_drop_page_hash_index(block);
+ btr_search_drop_page_hash_index(block, false);
/* Recreate the page: note that global data on page (possible
segment headers, next page-field, etc.) is preserved intact */
@@ -3301,7 +3301,7 @@ btr_lift_page_up(
mem_heap_free(heap);
}
- btr_search_drop_page_hash_index(block);
+ btr_search_drop_page_hash_index(block, false);
/* Make the father empty */
btr_page_empty(father_block, father_page_zip, index, page_level, mtr);
@@ -3583,7 +3583,7 @@ retry:
goto err_exit;
}
- btr_search_drop_page_hash_index(block);
+ btr_search_drop_page_hash_index(block, false);
/* Remove the page from the level list */
if (DB_SUCCESS != btr_level_list_remove(*block, *index, mtr)) {
@@ -3691,7 +3691,7 @@ retry:
goto err_exit;
}
- btr_search_drop_page_hash_index(block);
+ btr_search_drop_page_hash_index(block, false);
#ifdef UNIV_BTR_DEBUG
if (merge_page_zip && left_page_no == FIL_NULL) {
@@ -3916,7 +3916,7 @@ btr_discard_only_page_on_level(
ut_ad(fil_page_index_page_check(page));
ut_ad(block->page.id().space() == index->table->space->id);
ut_ad(mtr->memo_contains_flagged(block, MTR_MEMO_PAGE_X_FIX));
- btr_search_drop_page_hash_index(block);
+ btr_search_drop_page_hash_index(block, false);
if (dict_index_is_spatial(index)) {
/* Check any concurrent search having this page */
@@ -4081,7 +4081,7 @@ btr_discard_page(
ut_a(page_is_comp(merge_block->frame) == page_is_comp(block->frame));
ut_ad(!memcmp_aligned<2>(&merge_block->frame[PAGE_HEADER + PAGE_LEVEL],
&block->frame[PAGE_HEADER + PAGE_LEVEL], 2));
- btr_search_drop_page_hash_index(block);
+ btr_search_drop_page_hash_index(block, false);
if (dict_index_is_spatial(index)) {
rtr_node_ptr_delete(&parent_cursor, mtr);
diff --git a/storage/innobase/btr/btr0defragment.cc b/storage/innobase/btr/btr0defragment.cc
index 09454aeccc1..a5335c73934 100644
--- a/storage/innobase/btr/btr0defragment.cc
+++ b/storage/innobase/btr/btr0defragment.cc
@@ -529,7 +529,7 @@ btr_defragment_merge_pages(
free it. */
lock_update_merge_left(to_block, orig_pred,
from_block);
- btr_search_drop_page_hash_index(from_block);
+ btr_search_drop_page_hash_index(from_block, false);
ut_a(DB_SUCCESS == btr_level_list_remove(*from_block, *index,
mtr));
btr_page_get_father(index, from_block, mtr, &parent);
diff --git a/storage/innobase/btr/btr0sea.cc b/storage/innobase/btr/btr0sea.cc
index 81794676af1..d277c1cc362 100644
--- a/storage/innobase/btr/btr0sea.cc
+++ b/storage/innobase/btr/btr0sea.cc
@@ -716,7 +716,7 @@ btr_search_update_hash_ref(
if (index != cursor->index) {
ut_ad(index->id == cursor->index->id);
- btr_search_drop_page_hash_index(block);
+ btr_search_drop_page_hash_index(block, false);
return;
}
@@ -1440,7 +1440,7 @@ void btr_search_drop_page_hash_when_freed(const page_id_t page_id)
dropping the table (preventing eviction). */
ut_ad(index->table->get_ref_count() > 0
|| mutex_own(&dict_sys.mutex));
- btr_search_drop_page_hash_index(block);
+ btr_search_drop_page_hash_index(block, false);
}
}
@@ -1512,7 +1512,7 @@ btr_search_build_page_hash_index(
}
if (rebuild) {
- btr_search_drop_page_hash_index(block);
+ btr_search_drop_page_hash_index(block, false);
}
/* Check that the values for hash index build are sensible */
@@ -1741,7 +1741,7 @@ btr_search_move_or_delete_hash_entries(
if (new_block->index) {
drop_exit:
- btr_search_drop_page_hash_index(block);
+ btr_search_drop_page_hash_index(block, false);
return;
}
@@ -1816,7 +1816,7 @@ void btr_search_update_hash_on_delete(btr_cur_t* cursor)
}
if (index != cursor->index) {
- btr_search_drop_page_hash_index(block);
+ btr_search_drop_page_hash_index(block, false);
return;
}
@@ -1893,7 +1893,7 @@ btr_search_update_hash_node_on_insert(btr_cur_t* cursor, rw_lock_t* ahi_latch)
if (index != cursor->index) {
ut_ad(index->id == cursor->index->id);
- btr_search_drop_page_hash_index(block);
+ btr_search_drop_page_hash_index(block, false);
return;
}
@@ -1987,7 +1987,7 @@ btr_search_update_hash_on_insert(btr_cur_t* cursor, rw_lock_t* ahi_latch)
#endif
if (index != cursor->index) {
ut_ad(index->id == cursor->index->id);
- btr_search_drop_page_hash_index(block);
+ btr_search_drop_page_hash_index(block, false);
return;
}
diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc
index 272c8fadf6b..83eee85d749 100644
--- a/storage/innobase/buf/buf0buf.cc
+++ b/storage/innobase/buf/buf0buf.cc
@@ -2327,7 +2327,7 @@ void buf_page_free(fil_space_t *space, uint32_t page, mtr_t *mtr,
#ifdef BTR_CUR_HASH_ADAPT
if (block->index)
- btr_search_drop_page_hash_index(block);
+ btr_search_drop_page_hash_index(block, false);
#endif /* BTR_CUR_HASH_ADAPT */
block->page.status= buf_page_t::FREED;
@@ -3511,7 +3511,7 @@ loop:
#ifdef BTR_CUR_HASH_ADAPT
if (drop_hash_entry)
- btr_search_drop_page_hash_index(block);
+ btr_search_drop_page_hash_index(block, false);
#endif /* BTR_CUR_HASH_ADAPT */
if (block->page.ibuf_exist)
diff --git a/storage/innobase/buf/buf0lru.cc b/storage/innobase/buf/buf0lru.cc
index b8f3b23a477..f7a3543c493 100644
--- a/storage/innobase/buf/buf0lru.cc
+++ b/storage/innobase/buf/buf0lru.cc
@@ -967,7 +967,7 @@ func_exit:
order to avoid bogus Valgrind or MSAN warnings.*/
MEM_MAKE_DEFINED(block->frame, srv_page_size);
- btr_search_drop_page_hash_index(block);
+ btr_search_drop_page_hash_index(block, false);
MEM_UNDEFINED(block->frame, srv_page_size);
if (UNIV_LIKELY_NULL(b)) {
diff --git a/storage/innobase/fsp/fsp0file.cc b/storage/innobase/fsp/fsp0file.cc
index 57164113647..f631c548591 100644
--- a/storage/innobase/fsp/fsp0file.cc
+++ b/storage/innobase/fsp/fsp0file.cc
@@ -29,6 +29,7 @@ Created 2013-7-26 by Kevin Lewis
#include "os0file.h"
#include "page0page.h"
#include "srv0start.h"
+#include "log.h"
/** Initialize the name, size and order of this datafile
@param[in] name tablespace name, will be copied
@@ -351,10 +352,23 @@ Datafile::read_first_page(bool read_only_mode)
if (!fil_space_t::is_valid_flags(m_flags, m_space_id)) {
ulint cflags = fsp_flags_convert_from_101(m_flags);
if (cflags == ULINT_UNDEFINED) {
- ib::error()
- << "Invalid flags " << ib::hex(m_flags)
- << " in " << m_filepath;
- return(DB_CORRUPTION);
+ switch (fsp_flags_is_incompatible_mysql(m_flags)) {
+ case 0:
+ sql_print_error("InnoDB: Invalid flags 0x%zx in %s",
+ m_flags, m_filepath);
+ return(DB_CORRUPTION);
+ case 3:
+ case 2:
+ sql_print_error("InnoDB: MySQL-8.0 tablespace in %s",
+ m_filepath);
+ break;
+ case 1:
+ sql_print_error("InnoDB: MySQL Encrypted tablespace in %s",
+ m_filepath);
+ break;
+ }
+ sql_print_error("InnoDB: Restart in MySQL for migration/recovery.");
+ return(DB_UNSUPPORTED);
} else {
m_flags = cflags;
}
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 7cd41c6e529..c61f65385a4 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -5804,11 +5804,6 @@ ha_innobase::open(const char* name, int, uint)
MONITOR_INC(MONITOR_TABLE_OPEN);
if ((ib_table->flags2 & DICT_TF2_DISCARDED)) {
-
- ib_senderrf(thd,
- IB_LOG_LEVEL_WARN, ER_TABLESPACE_DISCARDED,
- table->s->table_name.str);
-
/* Allow an open because a proper DISCARD should have set
all the flags and index root page numbers to FIL_NULL that
should prevent any DML from running but it should allow DDL
@@ -13650,6 +13645,12 @@ int ha_innobase::truncate()
if (ib_table->is_temporary()) {
info.options|= HA_LEX_CREATE_TMP_TABLE;
} else {
+ if (!ib_table->space) {
+ ib_senderrf(m_user_thd,
+ IB_LOG_LEVEL_WARN, ER_TABLESPACE_DISCARDED,
+ table->s->table_name.str);
+ }
+
dict_get_and_save_data_dir_path(ib_table, false);
}
@@ -18200,7 +18201,9 @@ innodb_enable_monitor_at_startup(
/****************************************************************//**
Callback function for accessing the InnoDB variables from MySQL:
SHOW VARIABLES. */
-static int show_innodb_vars(THD*, SHOW_VAR* var, char*)
+static int show_innodb_vars(THD*, SHOW_VAR* var, void *,
+ struct system_status_var *status_var,
+ enum enum_var_type var_type)
{
innodb_export_status();
var->type = SHOW_ARRAY;
@@ -18706,7 +18709,7 @@ innodb_background_scrub_data_interval_warn(
}
static SHOW_VAR innodb_status_variables_export[]= {
- {"Innodb", (char*) &show_innodb_vars, SHOW_FUNC},
+ SHOW_FUNC_ENTRY("Innodb", &show_innodb_vars),
{NullS, NullS, SHOW_LONG}
};
@@ -20341,17 +20344,13 @@ static TABLE* innodb_find_table_for_vc(THD* thd, dict_table_t* table)
return mysql_table;
}
-/** Get the computed value by supplying the base column values.
-@param[in,out] table table whose virtual column
- template to be built */
+/** Only used by the purge thread
+@param[in,out] table table whose virtual column template to be built */
TABLE* innobase_init_vc_templ(dict_table_t* table)
{
- if (table->vc_templ != NULL) {
- return NULL;
- }
DBUG_ENTER("innobase_init_vc_templ");
- table->vc_templ = UT_NEW_NOKEY(dict_vcol_templ_t());
+ ut_ad(table->vc_templ == NULL);
TABLE *mysql_table= innodb_find_table_for_vc(current_thd, table);
@@ -20360,8 +20359,11 @@ TABLE* innobase_init_vc_templ(dict_table_t* table)
DBUG_RETURN(NULL);
}
+ dict_vcol_templ_t* vc_templ = UT_NEW_NOKEY(dict_vcol_templ_t());
+
mutex_enter(&dict_sys.mutex);
- innobase_build_v_templ(mysql_table, table, table->vc_templ, NULL, true);
+ table->vc_templ = vc_templ;
+ innobase_build_v_templ(mysql_table, table, vc_templ, nullptr, true);
mutex_exit(&dict_sys.mutex);
DBUG_RETURN(mysql_table);
}
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index bf262d921e3..b60809a94c1 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -2054,6 +2054,12 @@ ha_innobase::check_if_supported_inplace_alter(
update_thd();
+ if (!m_prebuilt->table->space) {
+ ib_senderrf(m_user_thd, IB_LOG_LEVEL_WARN,
+ ER_TABLESPACE_DISCARDED,
+ table->s->table_name.str);
+ }
+
if (ha_alter_info->handler_flags
& ~(INNOBASE_INPLACE_IGNORE
| INNOBASE_ALTER_INSTANT
@@ -5706,7 +5712,16 @@ static bool innobase_instant_try(
const dict_col_t* old_cols = user_table->cols;
DBUG_ASSERT(user_table->n_cols == ctx->old_n_cols);
+#ifdef BTR_CUR_HASH_ADAPT
+ /* Acquire the ahi latch to avoid a race condition
+ between ahi access and instant alter table */
+ rw_lock_t* ahi_latch = btr_search_sys.get_latch(*index);
+ rw_lock_x_lock(ahi_latch);
+#endif /* BTR_CUR_HASH_ADAPT */
const bool metadata_changed = ctx->instant_column();
+#ifdef BTR_CUR_HASH_ADAPT
+ rw_lock_x_unlock(ahi_latch);
+#endif /* BTR_CUR_HASH_ADAPT */
DBUG_ASSERT(index->n_fields >= n_old_fields);
/* The table may have been emptied and may have lost its
diff --git a/storage/innobase/include/btr0sea.h b/storage/innobase/include/btr0sea.h
index be0dc69b4cb..cd29e13f5bd 100644
--- a/storage/innobase/include/btr0sea.h
+++ b/storage/innobase/include/btr0sea.h
@@ -99,7 +99,7 @@ btr_search_move_or_delete_hash_entries(
@param[in] garbage_collect drop ahi only if the index is marked
as freed */
void btr_search_drop_page_hash_index(buf_block_t* block,
- bool garbage_collect= false);
+ bool garbage_collect);
/** Drop possible adaptive hash index entries when a page is evicted
from the buffer pool or freed in a file, or the index is being dropped.
diff --git a/storage/innobase/include/fsp0fsp.h b/storage/innobase/include/fsp0fsp.h
index 7245db39273..1be45915239 100644
--- a/storage/innobase/include/fsp0fsp.h
+++ b/storage/innobase/include/fsp0fsp.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2013, 2020, MariaDB Corporation.
+Copyright (c) 2013, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -719,6 +719,20 @@ fsp_flags_match(ulint expected, ulint actual)
return(actual == expected);
}
+/** Determine if FSP_SPACE_FLAGS are from an incompatible MySQL format.
+@param flags the contents of FSP_SPACE_FLAGS
+@return MySQL flags shifted.
+@retval 0, if not a MySQL incompatible format. */
+MY_ATTRIBUTE((warn_unused_result, const))
+inline ulint fsp_flags_is_incompatible_mysql(ulint flags)
+{
+ /*
+ MySQL-8.0 SDI flag (bit 14),
+ or MySQL 5.7 Encyption flag (bit 13)
+ */
+ return flags >> 13 & 3;
+}
+
/** Determine the descriptor index within a descriptor page.
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] offset page offset
diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc
index 86c3a4dff32..647bc381755 100644
--- a/storage/innobase/page/page0zip.cc
+++ b/storage/innobase/page/page0zip.cc
@@ -4415,7 +4415,7 @@ page_zip_reorganize(
mtr_log_t log_mode = mtr_set_log_mode(mtr, MTR_LOG_NONE);
temp_block = buf_block_alloc();
- btr_search_drop_page_hash_index(block);
+ btr_search_drop_page_hash_index(block, false);
temp_page = temp_block->frame;
/* Copy the old page to temporary space */
diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc
index a0ce7d63222..1737d8c7ce9 100644
--- a/storage/innobase/row/row0import.cc
+++ b/storage/innobase/row/row0import.cc
@@ -47,6 +47,7 @@ Created 2012-02-08 by Sunny Bains.
#ifdef HAVE_SNAPPY
#include "snappy-c.h"
#endif
+#include "log.h"
#include "scope.h"
@@ -596,6 +597,18 @@ protected:
ulint m_space_flags;
};
+ATTRIBUTE_COLD static dberr_t invalid_space_flags(ulint flags)
+{
+ if (fsp_flags_is_incompatible_mysql(flags))
+ {
+ sql_print_error("InnoDB: unsupported MySQL tablespace");
+ return DB_UNSUPPORTED;
+ }
+
+ sql_print_error("InnoDB: Invalid FSP_SPACE_FLAGS=0x%zx", flags);
+ return DB_CORRUPTION;
+}
+
/** Determine the page size to use for traversing the tablespace
@param file_size size of the tablespace file in bytes
@param block contents of the first page in the tablespace file.
@@ -611,7 +624,7 @@ AbstractCallback::init(
if (!fil_space_t::is_valid_flags(m_space_flags, true)) {
ulint cflags = fsp_flags_convert_from_101(m_space_flags);
if (cflags == ULINT_UNDEFINED) {
- return(DB_CORRUPTION);
+ return DB_CORRUPTION;
}
m_space_flags = cflags;
}
@@ -3173,7 +3186,7 @@ static dberr_t handle_instant_metadata(dict_table_t *table,
if (!success)
return DB_IO_ERROR;
- if (os_file_get_size(file) < srv_page_size * 4)
+ if (os_file_get_size(file) < srv_page_size)
return DB_CORRUPTION;
SCOPE_EXIT([&file]() { os_file_close(file); });
@@ -3193,10 +3206,7 @@ static dberr_t handle_instant_metadata(dict_table_t *table,
{
auto cflags= fsp_flags_convert_from_101(space_flags);
if (cflags == ULINT_UNDEFINED)
- {
- ib::error() << "Invalid FSP_SPACE_FLAGS=" << ib::hex(space_flags);
- return DB_CORRUPTION;
- }
+ return invalid_space_flags(space_flags);
space_flags= static_cast<decltype(space_flags)>(cflags);
}
@@ -4537,7 +4547,7 @@ row_import_for_mysql(
ib_errf(trx->mysql_thd, IB_LOG_LEVEL_ERROR,
ER_INTERNAL_ERROR,
- "Cannot reset LSNs in table %s : %s",
+ "Error importing tablespace for table %s : %s",
table_name, ut_strerr(err));
}
diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc
index e7fe0afced7..a7cf58a5c39 100644
--- a/storage/innobase/row/row0ins.cc
+++ b/storage/innobase/row/row0ins.cc
@@ -895,11 +895,7 @@ row_ins_foreign_fill_virtual(
&ext, update->heap);
n_diff = update->n_fields;
- if (index->table->vc_templ == NULL) {
- /** This can occur when there is a cascading
- delete or update after restart. */
- innobase_init_vc_templ(index->table);
- }
+ ut_ad(index->table->vc_templ != NULL);
ib_vcol_row vc(NULL);
uchar *record = vc.record(thd, index, &mysql_table);
diff --git a/storage/innobase/row/row0log.cc b/storage/innobase/row/row0log.cc
index ceefe626044..b8b4bd56239 100644
--- a/storage/innobase/row/row0log.cc
+++ b/storage/innobase/row/row0log.cc
@@ -2368,6 +2368,8 @@ func_exit_committed:
mtr_start(&mtr);
index->set_modified(mtr);
+ ut_free(pcur.old_rec_buf);
+
if (ROW_FOUND != row_search_index_entry(
index, entry, BTR_MODIFY_TREE, &pcur, &mtr)) {
ut_ad(0);
diff --git a/storage/innobase/row/row0quiesce.cc b/storage/innobase/row/row0quiesce.cc
index f106cc8a39d..063fed764e8 100644
--- a/storage/innobase/row/row0quiesce.cc
+++ b/storage/innobase/row/row0quiesce.cc
@@ -105,11 +105,17 @@ row_quiesce_write_indexes(
FILE* file, /*!< in: file to write to */
THD* thd) /*!< in/out: session */
{
+ ulint n_indexes = 0;
+ for (const dict_index_t* index = UT_LIST_GET_FIRST(table->indexes);
+ index; index = UT_LIST_GET_NEXT(indexes, index)) {
+ n_indexes += index->is_committed();
+ }
+
{
byte row[sizeof(ib_uint32_t)];
/* Write the number of indexes in the table. */
- mach_write_to_4(row, UT_LIST_GET_LEN(table->indexes));
+ mach_write_to_4(row, n_indexes);
DBUG_EXECUTE_IF("ib_export_io_write_failure_11",
close(fileno(file)););
@@ -131,6 +137,12 @@ row_quiesce_write_indexes(
index != 0 && err == DB_SUCCESS;
index = UT_LIST_GET_NEXT(indexes, index)) {
+ if (!index->is_committed()) {
+ continue;
+ }
+
+ ut_ad(n_indexes); ut_d(n_indexes--);
+
byte* ptr;
byte row[sizeof(index_id_t)
+ sizeof(ib_uint32_t) * 8];
@@ -201,6 +213,7 @@ row_quiesce_write_indexes(
err = row_quiesce_write_index_fields(index, file, thd);
}
+ ut_ad(!n_indexes);
return(err);
}