Commit 16b374b9 authored by Jan Lindström's avatar Jan Lindström

MDEV-13678: DELETE with CASCADE takes a long time when Galera is enabled

Use wsrep_must_process_fk function to check if foreign key
constraint needs to be processed in case of Galera is enabled.
parent 6a524ca5
......@@ -464,15 +464,10 @@ static
bool
wsrep_must_process_fk(const upd_node_t* node, const trx_t* trx)
{
if (que_node_get_type(node->common.parent) != QUE_NODE_UPDATE
|| !wsrep_on(trx->mysql_thd)) {
return false;
}
const upd_node_t* parent = static_cast<const upd_node_t*>(node->common.parent);
const upd_cascade_t& nodes = *static_cast<const upd_node_t*>(
node->common.parent)->cascade_upd_nodes;
const upd_cascade_t::const_iterator end = nodes.end();
return std::find(nodes.begin(), end, node) == end;
return (!parent || (que_node_get_type(parent) != QUE_NODE_UPDATE) ||
parent->cascade_upd_nodes->empty());
}
#endif /* WITH_WSREP */
......@@ -2435,10 +2430,6 @@ row_upd_sec_index_entry(
if (!rec_get_deleted_flag(
rec, dict_table_is_comp(index->table))) {
#ifdef WITH_WSREP
que_node_t *parent = que_node_get_parent(node);
#endif /* WITH_WSREP */
err = btr_cur_del_mark_set_sec_rec(
flags, btr_cur, TRUE, thr, &mtr);
......@@ -2449,9 +2440,7 @@ row_upd_sec_index_entry(
if (!referenced && foreign &&
wsrep_on(trx->mysql_thd) &&
!wsrep_thd_is_BF(trx->mysql_thd, FALSE) &&
(!parent || (que_node_get_type(parent) !=
QUE_NODE_UPDATE) ||
((upd_node_t*)parent)->cascade_upd_nodes->empty())) {
wsrep_must_process_fk(node, trx)) {
ulint* offsets = rec_get_offsets(
rec, index, NULL, ULINT_UNDEFINED,
&heap);
......@@ -2670,9 +2659,6 @@ row_upd_clust_rec_by_insert(
rec_t* rec;
ulint* offsets = NULL;
#ifdef WITH_WSREP
que_node_t *parent = que_node_get_parent(node);
#endif /* WITH_WSREP */
ut_ad(node);
ut_ad(dict_index_is_clust(index));
......@@ -2761,8 +2747,7 @@ row_upd_clust_rec_by_insert(
}
#ifdef WITH_WSREP
} else if (foreign && wsrep_on(trx->mysql_thd) &&
(!parent || (que_node_get_type(parent) != QUE_NODE_UPDATE) ||
((upd_node_t*)parent)->cascade_upd_nodes->empty())) {
wsrep_must_process_fk(node, trx)) {
err = wsrep_row_upd_check_foreign_constraints(
node, pcur, table, index, offsets, thr, mtr);
......@@ -2979,10 +2964,6 @@ row_upd_del_mark_clust_rec(
ut_ad(dict_index_is_clust(index));
ut_ad(node->is_delete);
#ifdef WITH_WSREP
que_node_t *parent = que_node_get_parent(node);
#endif /* WITH_WSREP */
pcur = node->pcur;
btr_cur = btr_pcur_get_btr_cur(pcur);
......@@ -3009,8 +2990,7 @@ row_upd_del_mark_clust_rec(
node, pcur, index->table, index, offsets, thr, mtr);
#ifdef WITH_WSREP
} else if (trx && wsrep_on(trx->mysql_thd) &&
(!parent || (que_node_get_type(parent) != QUE_NODE_UPDATE) ||
((upd_node_t*)parent)->cascade_upd_nodes->empty())) {
wsrep_must_process_fk(node, trx)) {
err = wsrep_row_upd_check_foreign_constraints(
node, pcur, index->table, index, offsets, thr, mtr);
......
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