From be51d6ae8cff0e8a0974bbad3f0a840ebbc23cd9 Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Thu, 7 Nov 2002 15:05:26 +0200 Subject: [PATCH 1/2] row0mysql.c: Backport from 4.0: Fix corruption of ON DELETE CASCADE in lock wait timeout --- innobase/row/row0mysql.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c index 26878f8c97c..ebb3cbe8dc8 100644 --- a/innobase/row/row0mysql.c +++ b/innobase/row/row0mysql.c @@ -1000,8 +1000,8 @@ row_update_cascade_for_mysql( or set null operation */ dict_table_t* table) /* in: table where we do the operation */ { - ulint err; - trx_t* trx; + ulint err; + trx_t* trx; trx = thr_get_trx(thr); run_again: @@ -1012,11 +1012,26 @@ run_again: err = trx->error_state; - if (err == DB_LOCK_WAIT) { - que_thr_stop_for_mysql(thr); - - row_mysql_handle_errors(&err, trx, thr, NULL); + /* Note that the cascade node is a subnode of another InnoDB + query graph node. We do a normal lock wait in this node, but + all errors are handled by the parent node. */ + if (err == DB_LOCK_WAIT) { + /* Handle lock wait here */ + + que_thr_stop_for_mysql(thr); + + srv_suspend_mysql_thread(thr); + + /* Note that a lock wait may also end in a lock wait timeout */ + + if (trx->error_state != DB_SUCCESS) { + + return(trx->error_state); + } + + /* Retry operation after a normal lock wait */ + goto run_again; } From 81503e476ade009fcfed2bb0d31e2615fcc1319e Mon Sep 17 00:00:00 2001 From: "monty@hundin.mysql.fi" <> Date: Fri, 8 Nov 2002 09:58:28 +0200 Subject: [PATCH 2/2] Fixed rare core dump bug when using complicated GROUP BY query that didn't return any results. This only showed up under heavy load. --- sql/sql_select.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 0c3c19c6e69..3596fdc0c05 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -4970,6 +4970,8 @@ end_write_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), } else { + if (end_of_records) + DBUG_RETURN(0); join->first_record=1; VOID(test_if_group_changed(join->group_fields)); }