1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Fix Bug #54582 stack overflow when opening many tables linked with

foreign keys at once

rb://391 approved by Heikki
Z
This commit is contained in:
Jimmy Yang
2010-08-04 03:11:33 -07:00
parent 127ca52594
commit 04970a2ff1
16 changed files with 276 additions and 19 deletions

View File

@ -576,6 +576,13 @@ handle_new_error:
"InnoDB: " REFMAN "forcing-recovery.html"
" for help.\n", stderr);
break;
case DB_FOREIGN_EXCEED_MAX_CASCADE:
fprintf(stderr, "InnoDB: Cannot delete/update rows with"
" cascading foreign key constraints that exceed max"
" depth of %lu\n"
"Please drop excessive foreign constraints"
" and try again\n", (ulong) DICT_FK_MAX_RECURSIVE_LOAD);
break;
default:
fprintf(stderr, "InnoDB: unknown error code %lu\n",
(ulong) err);
@ -1381,11 +1388,15 @@ row_update_for_mysql(
run_again:
thr->run_node = node;
thr->prev_node = node;
thr->fk_cascade_depth = 0;
row_upd_step(thr);
err = trx->error_state;
/* Reset fk_cascade_depth back to 0 */
thr->fk_cascade_depth = 0;
if (err != DB_SUCCESS) {
que_thr_stop_for_mysql(thr);
@ -1576,6 +1587,12 @@ row_update_cascade_for_mysql(
trx_t* trx;
trx = thr_get_trx(thr);
thr->fk_cascade_depth++;
if (thr->fk_cascade_depth > FK_MAX_CASCADE_DEL) {
return (DB_FOREIGN_EXCEED_MAX_CASCADE);
}
run_again:
thr->run_node = node;
thr->prev_node = node;
@ -2056,7 +2073,7 @@ row_table_add_foreign_constraints(
name, reject_fks);
if (err == DB_SUCCESS) {
/* Check that also referencing constraints are ok */
err = dict_load_foreigns(name, TRUE);
err = dict_load_foreigns(name, FALSE, TRUE);
}
if (err != DB_SUCCESS) {
@ -3915,7 +3932,7 @@ end:
an ALTER, not in a RENAME. */
err = dict_load_foreigns(
new_name, !old_is_tmp || trx->check_foreigns);
new_name, FALSE, !old_is_tmp || trx->check_foreigns);
if (err != DB_SUCCESS) {
ut_print_timestamp(stderr);