Commit dddb6592 authored by marko's avatar marko

branches/zip: row_mysql_handle_errors(): Replace the if-else with

switch-case.
parent f2186190
...@@ -469,26 +469,21 @@ row_mysql_handle_errors( ...@@ -469,26 +469,21 @@ row_mysql_handle_errors(
trx->error_state = DB_SUCCESS; trx->error_state = DB_SUCCESS;
if ((err == DB_DUPLICATE_KEY) switch (err) {
|| (err == DB_FOREIGN_DUPLICATE_KEY)) { case DB_LOCK_WAIT_TIMEOUT:
if (savept) { if (row_rollback_on_timeout) {
/* Roll back the latest, possibly incomplete trx_general_rollback_for_mysql(trx, FALSE, NULL);
insertion or update */ break;
trx_general_rollback_for_mysql(trx, TRUE, savept);
}
} else if (err == DB_TOO_BIG_RECORD) {
if (savept) {
/* Roll back the latest, possibly incomplete
insertion or update */
trx_general_rollback_for_mysql(trx, TRUE, savept);
} }
/* MySQL will roll back the latest SQL statement */ /* fall through */
} else if (err == DB_ROW_IS_REFERENCED case DB_DUPLICATE_KEY:
|| err == DB_NO_REFERENCED_ROW case DB_FOREIGN_DUPLICATE_KEY:
|| err == DB_CANNOT_ADD_CONSTRAINT case DB_TOO_BIG_RECORD:
|| err == DB_TOO_MANY_CONCURRENT_TRXS) { case DB_ROW_IS_REFERENCED:
case DB_NO_REFERENCED_ROW:
case DB_CANNOT_ADD_CONSTRAINT:
case DB_TOO_MANY_CONCURRENT_TRXS:
case DB_OUT_OF_FILE_SPACE:
if (savept) { if (savept) {
/* Roll back the latest, possibly incomplete /* Roll back the latest, possibly incomplete
insertion or update */ insertion or update */
...@@ -496,8 +491,8 @@ row_mysql_handle_errors( ...@@ -496,8 +491,8 @@ row_mysql_handle_errors(
trx_general_rollback_for_mysql(trx, TRUE, savept); trx_general_rollback_for_mysql(trx, TRUE, savept);
} }
/* MySQL will roll back the latest SQL statement */ /* MySQL will roll back the latest SQL statement */
} else if (err == DB_LOCK_WAIT) { break;
case DB_LOCK_WAIT:
srv_suspend_mysql_thread(thr); srv_suspend_mysql_thread(thr);
if (trx->error_state != DB_SUCCESS) { if (trx->error_state != DB_SUCCESS) {
...@@ -510,31 +505,15 @@ row_mysql_handle_errors( ...@@ -510,31 +505,15 @@ row_mysql_handle_errors(
return(TRUE); return(TRUE);
} else if (err == DB_DEADLOCK case DB_DEADLOCK:
|| err == DB_LOCK_TABLE_FULL case DB_LOCK_TABLE_FULL:
|| (err == DB_LOCK_WAIT_TIMEOUT
&& row_rollback_on_timeout)) {
/* Roll back the whole transaction; this resolution was added /* Roll back the whole transaction; this resolution was added
to version 3.23.43 */ to version 3.23.43 */
trx_general_rollback_for_mysql(trx, FALSE, NULL); trx_general_rollback_for_mysql(trx, FALSE, NULL);
break;
} else if (err == DB_OUT_OF_FILE_SPACE case DB_MUST_GET_MORE_FILE_SPACE:
|| err == DB_LOCK_WAIT_TIMEOUT) {
ut_ad(!(err == DB_LOCK_WAIT_TIMEOUT
&& row_rollback_on_timeout));
if (savept) {
/* Roll back the latest, possibly incomplete
insertion or update */
trx_general_rollback_for_mysql(trx, TRUE, savept);
}
/* MySQL will roll back the latest SQL statement */
} else if (err == DB_MUST_GET_MORE_FILE_SPACE) {
fputs("InnoDB: The database cannot continue" fputs("InnoDB: The database cannot continue"
" operation because of\n" " operation because of\n"
"InnoDB: lack of space. You must add" "InnoDB: lack of space. You must add"
...@@ -542,8 +521,8 @@ row_mysql_handle_errors( ...@@ -542,8 +521,8 @@ row_mysql_handle_errors(
"InnoDB: my.cnf and restart the database.\n", stderr); "InnoDB: my.cnf and restart the database.\n", stderr);
exit(1); exit(1);
} else if (err == DB_CORRUPTION) {
case DB_CORRUPTION:
fputs("InnoDB: We detected index corruption" fputs("InnoDB: We detected index corruption"
" in an InnoDB type table.\n" " in an InnoDB type table.\n"
"InnoDB: You have to dump + drop + reimport" "InnoDB: You have to dump + drop + reimport"
...@@ -558,7 +537,8 @@ row_mysql_handle_errors( ...@@ -558,7 +537,8 @@ row_mysql_handle_errors(
"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/" "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/"
"forcing-recovery.html" "forcing-recovery.html"
" for help.\n", stderr); " for help.\n", stderr);
} else { break;
default:
fprintf(stderr, "InnoDB: unknown error code %lu\n", fprintf(stderr, "InnoDB: unknown error code %lu\n",
(ulong) err); (ulong) err);
ut_error; ut_error;
......
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