summaryrefslogtreecommitdiff
path: root/storage/innobase
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2021-02-23 13:01:27 +0100
committerSergei Golubchik <serg@mariadb.org>2021-02-23 13:06:22 +0100
commitf33e57a9e66f7e1790cb84b141381bb668e281a0 (patch)
tree31bb1c5bd8e0addc9e994a1bb42b4703c37f7ed8 /storage/innobase
parent1a0526e2f294acdcac829672794ee1fe708eb2b3 (diff)
parent245d33db4e0586df4fe28362fb002cef0151a1c9 (diff)
downloadmariadb-git-f33e57a9e66f7e1790cb84b141381bb668e281a0.tar.gz
Merge branch '10.4' into 10.5
Diffstat (limited to 'storage/innobase')
-rw-r--r--storage/innobase/btr/btr0sea.cc35
-rw-r--r--storage/innobase/handler/handler0alter.cc34
2 files changed, 66 insertions, 3 deletions
diff --git a/storage/innobase/btr/btr0sea.cc b/storage/innobase/btr/btr0sea.cc
index 68d946aa79d..5c8f97b7bcf 100644
--- a/storage/innobase/btr/btr0sea.cc
+++ b/storage/innobase/btr/btr0sea.cc
@@ -2,7 +2,7 @@
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
-Copyright (c) 2017, 2020, MariaDB Corporation.
+Copyright (c) 2017, 2021, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -707,6 +707,12 @@ btr_search_update_hash_ref(
return;
}
+ if (index != cursor->index) {
+ ut_ad(index->id == cursor->index->id);
+ btr_search_drop_page_hash_index(block);
+ return;
+ }
+
ut_ad(block->page.id().space() == index->table->space_id);
ut_ad(index == cursor->index);
ut_ad(!dict_index_is_ibuf(index));
@@ -1276,12 +1282,13 @@ retry:
rw_lock_s_lock(&part->latch);
assert_block_ahi_valid(block);
- if (!block->index || !btr_search_enabled) {
+ dict_index_t* index = block->index;
+
+ if (!index || !btr_search_enabled) {
rw_lock_s_unlock(&part->latch);
return;
}
- dict_index_t* index = block->index;
#ifdef MYSQL_INDEX_DISABLE_AHI
ut_ad(!index->disable_ahi);
#endif
@@ -1732,6 +1739,7 @@ btr_search_move_or_delete_hash_entries(
: nullptr;
if (new_block->index) {
+drop_exit:
btr_search_drop_page_hash_index(block);
return;
}
@@ -1740,6 +1748,10 @@ btr_search_move_or_delete_hash_entries(
return;
}
+ if (index->freed()) {
+ goto drop_exit;
+ }
+
rw_lock_s_lock(ahi_latch);
if (block->index) {
@@ -1801,6 +1813,11 @@ void btr_search_update_hash_on_delete(btr_cur_t* cursor)
return;
}
+ if (index != cursor->index) {
+ btr_search_drop_page_hash_index(block);
+ return;
+ }
+
ut_ad(block->page.id().space() == index->table->space_id);
ut_a(index == cursor->index);
ut_a(block->curr_n_fields > 0 || block->curr_n_bytes > 0);
@@ -1871,6 +1888,12 @@ btr_search_update_hash_node_on_insert(btr_cur_t* cursor, rw_lock_t* ahi_latch)
return;
}
+ if (index != cursor->index) {
+ ut_ad(index->id == cursor->index->id);
+ btr_search_drop_page_hash_index(block);
+ return;
+ }
+
ut_a(cursor->index == index);
ut_ad(!dict_index_is_ibuf(index));
rw_lock_x_lock(ahi_latch);
@@ -1959,6 +1982,12 @@ btr_search_update_hash_on_insert(btr_cur_t* cursor, rw_lock_t* ahi_latch)
#ifdef MYSQL_INDEX_DISABLE_AHI
ut_a(!index->disable_ahi);
#endif
+ if (index != cursor->index) {
+ ut_ad(index->id == cursor->index->id);
+ btr_search_drop_page_hash_index(block);
+ return;
+ }
+
ut_a(index == cursor->index);
ut_ad(!dict_index_is_ibuf(index));
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index ac17a7a8a3f..44e45e19550 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -8903,6 +8903,7 @@ innobase_rename_column_try(
const char* to)
{
dberr_t error;
+ bool clust_has_prefixes = false;
DBUG_ENTER("innobase_rename_column_try");
@@ -8962,6 +8963,39 @@ innobase_rename_column_try(
if (error != DB_SUCCESS) {
goto err_exit;
}
+
+ if (!has_prefixes || !clust_has_prefixes
+ || f.prefix_len) {
+ continue;
+ }
+
+ /* For secondary indexes, the
+ has_prefixes check can be 'polluted'
+ by PRIMARY KEY column prefix. Try also
+ the simpler encoding of SYS_FIELDS.POS. */
+ info = pars_info_create();
+
+ pars_info_add_ull_literal(info, "indexid", index->id);
+ pars_info_add_int4_literal(info, "nth", i);
+ pars_info_add_str_literal(info, "new", to);
+
+ error = que_eval_sql(
+ info,
+ "PROCEDURE RENAME_SYS_FIELDS_PROC () IS\n"
+ "BEGIN\n"
+ "UPDATE SYS_FIELDS SET COL_NAME=:new\n"
+ "WHERE INDEX_ID=:indexid\n"
+ "AND POS=:nth;\n"
+ "END;\n",
+ FALSE, trx);
+
+ if (error != DB_SUCCESS) {
+ goto err_exit;
+ }
+ }
+
+ if (index == dict_table_get_first_index(ctx.old_table)) {
+ clust_has_prefixes = has_prefixes;
}
}