summaryrefslogtreecommitdiff
path: root/storage/innobase/row/row0upd.cc
diff options
context:
space:
mode:
authorAleksey Midenkov <midenok@gmail.com>2018-05-30 13:19:03 +0300
committerAleksey Midenkov <midenok@gmail.com>2019-10-10 00:20:34 +0300
commit75ba5c815d0272b35a28225d495a4a03fe63d29f (patch)
treeaac71c2c74e9130a2e8ae16ba9e979ff04905d89 /storage/innobase/row/row0upd.cc
parent6684989801cd0e93be5646716bb3cffedd271ce6 (diff)
downloadmariadb-git-75ba5c815d0272b35a28225d495a4a03fe63d29f.tar.gz
MDEV-16210 FK constraints on versioned tables use historical rows, which may cause constraint violation
Constraint check is done on secondary index update. F.ex. DELETE does row_upd_sec_index_entry() and checks constraints in row_upd_check_references_constraints(). UPDATE is optimized for the case when order is not changed (node->cmpl_info & UPD_NODE_NO_ORD_CHANGE) and doesn't do row_upd_sec_index_entry(), so it doesn't check constraints. Since for versioned DELETE we do UPDATE actually, but expect behaviour of DELETE in terms of constraints, we should deny this optimization to get constraints checked. Fix wrong referenced table check when versioned DELETE inserts history in parent table. Set check_ref to false in this case. Removed unused dup_chk_only argument for row_ins_sec_index_entry() and added check_ref argument. MDEV-18057 fix was superseded by this fix and reverted. foreign.test: All key_type combinations: pk, unique, sec(ondary).
Diffstat (limited to 'storage/innobase/row/row0upd.cc')
-rw-r--r--storage/innobase/row/row0upd.cc11
1 files changed, 7 insertions, 4 deletions
diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc
index d081c5c2122..64021b48ee2 100644
--- a/storage/innobase/row/row0upd.cc
+++ b/storage/innobase/row/row0upd.cc
@@ -2529,7 +2529,8 @@ row_upd_sec_index_entry(
ut_a(entry);
/* Insert new index entry */
- err = row_ins_sec_index_entry(index, entry, thr);
+ err = row_ins_sec_index_entry(index, entry, thr,
+ node->is_delete != VERSIONED_DELETE);
func_exit:
mem_heap_free(heap);
@@ -3191,9 +3192,8 @@ row_upd_clust_step(
row_upd_eval_new_vals(node->update);
}
- if (node->cmpl_info & UPD_NODE_NO_ORD_CHANGE) {
+ if (!node->is_delete && node->cmpl_info & UPD_NODE_NO_ORD_CHANGE) {
- node->index = NULL;
err = row_upd_clust_rec(
flags, node, index, offsets, &heap, thr, &mtr);
goto exit_func;
@@ -3237,7 +3237,10 @@ row_upd_clust_step(
goto exit_func;
}
- node->state = UPD_NODE_UPDATE_SOME_SEC;
+ ut_ad(node->is_delete != PLAIN_DELETE);
+ node->state = node->is_delete ?
+ UPD_NODE_UPDATE_ALL_SEC :
+ UPD_NODE_UPDATE_SOME_SEC;
}
node->index = dict_table_get_next_index(index);