From 3ba52c1eb8cec286b2abfd0e70e66948381857d3 Mon Sep 17 00:00:00 2001 From: "jan@hundin.mysql.fi" <> Date: Wed, 12 Jan 2005 10:36:50 +0200 Subject: [PATCH 1/2] Take a shared record lock (LOCK_REC_NOT_GAP) for a matching record in the foreign key check because we can allow inserts into gaps (Support Issue #4317). --- innobase/row/row0ins.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/innobase/row/row0ins.c b/innobase/row/row0ins.c index f8a98f74c09..15ffabf70cc 100644 --- a/innobase/row/row0ins.c +++ b/innobase/row/row0ins.c @@ -1105,7 +1105,6 @@ row_ins_check_foreign_constraint( dict_table_t* check_table; dict_index_t* check_index; ulint n_fields_cmp; - ibool unique_search; rec_t* rec; btr_pcur_t pcur; ibool moved; @@ -1223,14 +1222,6 @@ run_again: dtuple_set_n_fields_cmp(entry, foreign->n_fields); - if (dict_index_get_n_unique(check_index) <= foreign->n_fields) { - /* We can just set a LOCK_REC_NOT_GAP type lock */ - - unique_search = TRUE; - } else { - unique_search = FALSE; - } - btr_pcur_open(check_index, entry, PAGE_CUR_GE, BTR_SEARCH_LEAF, &pcur, &mtr); @@ -1268,17 +1259,13 @@ run_again: break; } } else { - /* Found a matching record */ + /* Found a matching record. Lock only + a record because we can allow inserts + into gaps */ - if (unique_search) { - err = row_ins_set_shared_rec_lock( - LOCK_REC_NOT_GAP, - rec, check_index, thr); - } else { - err = row_ins_set_shared_rec_lock( - LOCK_ORDINARY, - rec, check_index, thr); - } + err = row_ins_set_shared_rec_lock( + LOCK_REC_NOT_GAP, + rec, check_index, thr); if (err != DB_SUCCESS) { From ea1bd1d5e5f86c8c8d9d569524d7d62d878ddc22 Mon Sep 17 00:00:00 2001 From: "marko@hundin.mysql.fi" <> Date: Tue, 25 Jan 2005 14:16:41 +0200 Subject: [PATCH 2/2] InnoDB: Enable ut_ad() assertions in MySQL debug builds. --- innobase/include/univ.i | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/innobase/include/univ.i b/innobase/include/univ.i index 4854e5a7b78..12846593977 100644 --- a/innobase/include/univ.i +++ b/innobase/include/univ.i @@ -86,8 +86,10 @@ memory is read outside the allocated blocks. */ /* Make a non-inline debug version */ +#ifdef DBUG_ON +# define UNIV_DEBUG +#endif /* DBUG_ON */ /* -#define UNIV_DEBUG #define UNIV_SYNC_DEBUG #define UNIV_MEM_DEBUG