summaryrefslogtreecommitdiff
path: root/storage/innobase/dict/dict0mem.cc
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-05-05 21:16:22 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2020-05-05 21:16:22 +0300
commit7bcaa541aa1f298abf8e863566a19b3e9ec2f659 (patch)
tree066d58ad89536edf0e9a3de898506735c933381f /storage/innobase/dict/dict0mem.cc
parent36b8ac2c0d763a3f96b254cb6e2cbdbc40dde22b (diff)
parent2c3c851d2cba73825f81cd06220138b15c17ae4d (diff)
downloadmariadb-git-7bcaa541aa1f298abf8e863566a19b3e9ec2f659.tar.gz
Merge 10.4 into 10.5
Diffstat (limited to 'storage/innobase/dict/dict0mem.cc')
-rw-r--r--storage/innobase/dict/dict0mem.cc52
1 files changed, 42 insertions, 10 deletions
diff --git a/storage/innobase/dict/dict0mem.cc b/storage/innobase/dict/dict0mem.cc
index c3b4ae76dd4..a119dd84b56 100644
--- a/storage/innobase/dict/dict0mem.cc
+++ b/storage/innobase/dict/dict0mem.cc
@@ -606,17 +606,15 @@ dict_mem_table_col_rename_low(
}
}
- dict_index_t* new_index = dict_foreign_find_index(
+ /* New index can be null if InnoDB already dropped
+ the foreign index when FOREIGN_KEY_CHECKS is
+ disabled */
+ foreign->foreign_index = dict_foreign_find_index(
foreign->foreign_table, NULL,
foreign->foreign_col_names,
foreign->n_fields, NULL, true, false,
NULL, NULL, NULL);
- /* New index can be null if InnoDB already dropped
- the foreign index when FOREIGN_KEY_CHECKS is
- disabled */
- foreign->foreign_index = new_index;
-
} else {
for (unsigned f = 0; f < foreign->n_fields; f++) {
@@ -638,7 +636,41 @@ dict_mem_table_col_rename_low(
foreign = *it;
- ut_ad(foreign->referenced_index != NULL);
+ if (!foreign->referenced_index) {
+ /* Referenced index could have been dropped
+ when foreign_key_checks is disabled. In that case,
+ rename the corresponding referenced_col_names and
+ find the equivalent referenced index also */
+ for (unsigned f = 0; f < foreign->n_fields; f++) {
+
+ const char*& rc =
+ foreign->referenced_col_names[f];
+ if (strcmp(rc, from)) {
+ continue;
+ }
+
+ if (to_len <= strlen(rc)) {
+ memcpy(const_cast<char*>(rc), to,
+ to_len + 1);
+ } else {
+ rc = static_cast<char*>(
+ mem_heap_dup(
+ foreign->heap,
+ to, to_len + 1));
+ }
+ }
+
+ /* New index can be null if InnoDB already dropped
+ the referenced index when FOREIGN_KEY_CHECKS is
+ disabled */
+ foreign->referenced_index = dict_foreign_find_index(
+ foreign->referenced_table, NULL,
+ foreign->referenced_col_names,
+ foreign->n_fields, NULL, true, false,
+ NULL, NULL, NULL);
+ return;
+ }
+
for (unsigned f = 0; f < foreign->n_fields; f++) {
/* foreign->referenced_col_names[] need to be
@@ -1288,7 +1320,7 @@ bool dict_table_t::deserialise_columns(const byte* metadata, ulint len)
bool
dict_index_t::vers_history_row(
const rec_t* rec,
- const offset_t* offsets)
+ const rec_offs* offsets)
{
ut_ad(is_primary());
@@ -1319,8 +1351,8 @@ dict_index_t::vers_history_row(
bool error = false;
mem_heap_t* heap = NULL;
dict_index_t* clust_index = NULL;
- offset_t offsets_[REC_OFFS_NORMAL_SIZE];
- offset_t* offsets = offsets_;
+ rec_offs offsets_[REC_OFFS_NORMAL_SIZE];
+ rec_offs* offsets = offsets_;
rec_offs_init(offsets_);
mtr_t mtr;