From b8ad5dea56e4ddf612668d636d6cef57ef5efdcb Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Wed, 18 Jun 2003 04:05:10 +0300 Subject: [PATCH] row0vers.c, row0sel.c: Backport the clust rec bug fix from 4.0 --- innobase/row/row0sel.c | 23 +++++++++++++++++++++-- innobase/row/row0vers.c | 14 -------------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/innobase/row/row0sel.c b/innobase/row/row0sel.c index c9de502eb9a..b06476219c6 100644 --- a/innobase/row/row0sel.c +++ b/innobase/row/row0sel.c @@ -598,7 +598,14 @@ row_sel_get_clust_rec( clust_rec = btr_pcur_get_rec(&(plan->clust_pcur)); - ut_ad(page_rec_is_user_rec(clust_rec)); + if (!page_rec_is_user_rec(clust_rec) + || btr_pcur_get_low_match(&(plan->clust_pcur)) + < dict_index_get_n_unique(index)) { + + clust_rec = NULL; + + goto func_exit; + } if (!node->read_view) { /* Try to place a lock on the index record */ @@ -661,6 +668,7 @@ row_sel_get_clust_rec( row_sel_fetch_columns(index, clust_rec, UT_LIST_GET_FIRST(plan->columns)); +func_exit: *out_rec = clust_rec; return(DB_SUCCESS); @@ -2206,7 +2214,17 @@ row_sel_get_clust_rec_for_mysql( clust_rec = btr_pcur_get_rec(prebuilt->clust_pcur); - ut_ad(page_rec_is_user_rec(clust_rec)); + /* Note: only if the search ends up on a non-infimum record is the + low_match value the real match to the search tuple */ + + if (!page_rec_is_user_rec(clust_rec) + || btr_pcur_get_low_match(prebuilt->clust_pcur) + < dict_index_get_n_unique(clust_index)) { + + clust_rec = NULL; + + goto func_exit; + } if (prebuilt->select_lock_type != LOCK_NONE) { /* Try to place a lock on the index record */ @@ -2268,6 +2286,7 @@ row_sel_get_clust_rec_for_mysql( } } +func_exit: *out_rec = clust_rec; if (prebuilt->select_lock_type == LOCK_X) { diff --git a/innobase/row/row0vers.c b/innobase/row/row0vers.c index cd8b18e5e12..baef6bca4ea 100644 --- a/innobase/row/row0vers.c +++ b/innobase/row/row0vers.c @@ -76,23 +76,9 @@ row_vers_impl_x_locked_off_kernel( clust_rec = row_get_clust_rec(BTR_SEARCH_LEAF, rec, index, &clust_index, &mtr); if (!clust_rec) { - rec_sprintf(err_buf, 900, rec); - - ut_print_timestamp(stderr); - fprintf(stderr, -" InnoDB: Error: cannot find the clustered index record\n" -"InnoDB: for a secondary index record in table %s index %s.\n" -"InnoDB: Secondary index record %s.\n" -"InnoDB: The table is probably corrupt. Please run CHECK TABLE on it.\n" -"InnoDB: You can try to repair the table by dump + drop + reimport.\n" -"InnoDB: Send a detailed bug report to mysql@lists.mysql.com.\n", - index->table_name, index->name, err_buf); mutex_enter(&kernel_mutex); mtr_commit(&mtr); - /* We assume there is no lock on the record, though this - is not certain because the table is apparently corrupt */ - return(NULL); }