Commit 279f992b authored by Aakanksha Verma's avatar Aakanksha Verma Committed by Marko Mäkelä

Bug #27141613 ASSERTION: TRX0REC.CC:319:COL->IS_VIRTUAL() / CRASH IN TRX_UNDO_READ_V_COLS

PROBLEM
=======
When add of virtual index fails with DB_TOO_BIG_RECORD , the virtual
index being freed isn't removed from the list of indexes a virtual
column(which is part of the index). This while the undo log is read
could fetch a wrong value during rollback and cause the assertion
reported in the bug particularly.

FIX
===
Added a function that is called when the virtual index being freed would
allow the index be removed from the index list of virtual column which
was a field of that index.

Reviwed By: Jimmy Yang<Jimmy.Yang@oracle.com>
RB: 18528
parent c88ac735
......@@ -2428,6 +2428,41 @@ dict_index_add_to_cache(
table, index, NULL, page_no, strict));
}
/** Clears the virtual column's index list before index is
being freed.
@param[in] index Index being freed */
void
dict_index_remove_from_v_col_list(dict_index_t* index) {
if (dict_index_has_virtual(index)) {
const dict_col_t* col;
const dict_v_col_t* vcol;
for (ulint i = 0; i < dict_index_get_n_fields(index); i++) {
col = dict_index_get_nth_col(index, i);
if (dict_col_is_virtual(col)) {
vcol = reinterpret_cast<const dict_v_col_t*>(
col);
/* This could be NULL, when we do add
virtual column, add index together. We do not
need to track this virtual column's index */
if (vcol->v_indexes == NULL) {
continue;
}
dict_v_idx_list::iterator it;
for (it = vcol->v_indexes->begin();
it != vcol->v_indexes->end(); ++it) {
dict_v_idx_t v_index = *it;
if (v_index.index == index) {
vcol->v_indexes->erase(it);
break;
}
}
}
}
}
}
/** Adds an index to the dictionary cache, with possible indexing newly
added column.
@param[in,out] table table on which the index is
......
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
Copyright (c) 2013, 2018, MariaDB Corporation.
......@@ -1034,6 +1034,7 @@ dict_mem_index_free(
UT_DELETE(index->rtr_track->rtr_active);
}
dict_index_remove_from_v_col_list(index);
mem_heap_free(index->heap);
}
......
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
Copyright (c) 2013, 2018, MariaDB Corporation.
......@@ -1121,6 +1121,12 @@ dict_index_add_to_cache(
ibool strict)
MY_ATTRIBUTE((warn_unused_result));
/** Clears the virtual column's index list before index is being freed.
@param[in] index Index being freed */
void
dict_index_remove_from_v_col_list(
dict_index_t* index);
/** Adds an index to the dictionary cache, with possible indexing newly
added column.
@param[in] table table on which the index is
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment