Skip to content

Commit 551288b

Browse files
author
Aditya A
committed
Bug#33691659 - ON DELETE CASCADE with generated column crashes in innobase_get_computed_value
ANALYSIS ======== 1. A cascade delete from the parent table triggers delete on the child table. Before a clustered index record is deleted in the child table, a copy of row is built to remove secondary index record, since the secondary index is defined on the virtual column it is necessary to materialize the virtual columns. 2. We were skipping this materialization which causes it to fail on uninitialized template in innobase_get_computed_value() when trying to remove the secondary index rows defined on virtual column. FIX === 1. We must initialize virtual column template for materializing virtual column if child table has an index on a virtual column. Change-Id: Ib2381d81aa96024ed395261650421f6318f380b8
1 parent 0ac1764 commit 551288b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

storage/innobase/row/row0ins.cc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,11 +1309,17 @@ row_ins_foreign_check_on_constraint(
13091309
clust_index, tmp_heap);
13101310
}
13111311

1312-
if (cascade->is_delete && foreign->v_cols != NULL
1313-
&& foreign->v_cols->size() > 0
1314-
&& table->vc_templ == NULL) {
1312+
/* A cascade delete from the parent table triggers delete on the child
1313+
table. Before a clustered index record is deleted in the child table,
1314+
a copy of row is built to remove secondary index records. This copy of
1315+
the row requires virtual columns to be materialized. Hence, if child
1316+
table has any virtual columns which are indexed, we have to initialize
1317+
virtual column template. */
1318+
if (cascade->is_delete && dict_table_has_indexed_v_cols(table) &&
1319+
table->vc_templ == NULL) {
13151320
innobase_init_vc_templ(table);
13161321
}
1322+
13171323
if (node->is_delete
13181324
? (foreign->type & DICT_FOREIGN_ON_DELETE_SET_NULL)
13191325
: (foreign->type & DICT_FOREIGN_ON_UPDATE_SET_NULL)) {

0 commit comments

Comments
 (0)