diff --git a/include/page0cur.h b/include/page0cur.h index 55da757d73d..32eca82d18a 100644 --- a/include/page0cur.h +++ b/include/page0cur.h @@ -178,9 +178,9 @@ page_cur_insert_rec_low( /*====================*/ /* out: pointer to record if succeed, NULL otherwise */ - rec_t* current_rec,/* in: current record after which the - new record is inserted */ - buf_block_t* block, /* in: buffer block of current_rec, or NULL + rec_t** current_rec,/* in/out: pointer to current record after + which the new record is inserted */ + buf_block_t* block, /* in: buffer block of *current_rec, or NULL if the compressed page is not to be updated */ dict_index_t* index, /* in: record descriptor */ rec_t* rec, /* in: pointer to a physical record */ diff --git a/include/page0cur.ic b/include/page0cur.ic index 9ee1d8240a0..71cadda188d 100644 --- a/include/page0cur.ic +++ b/include/page0cur.ic @@ -235,7 +235,7 @@ page_cur_tuple_insert( index, tuple, ext, n_ext); offsets = rec_get_offsets(rec, index, NULL, ULINT_UNDEFINED, &heap); - rec = page_cur_insert_rec_low(cursor->rec, cursor->block, + rec = page_cur_insert_rec_low(&cursor->rec, cursor->block, index, rec, offsets, mtr); mem_heap_free(heap); return(rec); @@ -257,7 +257,7 @@ page_cur_rec_insert( ulint* offsets,/* in/out: rec_get_offsets(rec, index) */ mtr_t* mtr) /* in: mini-transaction handle, or NULL */ { - return(page_cur_insert_rec_low(cursor->rec, cursor->block, + return(page_cur_insert_rec_low(&cursor->rec, cursor->block, index, rec, offsets, mtr)); } diff --git a/page/page0cur.c b/page/page0cur.c index 8d8210a2bce..e4d9bf3679a 100644 --- a/page/page0cur.c +++ b/page/page0cur.c @@ -893,9 +893,9 @@ page_cur_insert_rec_low( /*====================*/ /* out: pointer to record if succeed, NULL otherwise */ - rec_t* current_rec,/* in: current record after which the - new record is inserted */ - buf_block_t* block, /* in: buffer block of current_rec, or NULL + rec_t** current_rec,/* in/out: pointer to current record after + which the new record is inserted */ + buf_block_t* block, /* in: buffer block of *current_rec, or NULL if the compressed page is not to be updated */ dict_index_t* index, /* in: record descriptor */ rec_t* rec, /* in: pointer to a physical record */ @@ -918,11 +918,11 @@ page_cur_insert_rec_low( ut_ad(rec_offs_validate(rec, index, offsets)); - page = page_align(current_rec); + page = page_align(*current_rec); ut_ad(dict_table_is_comp(index->table) == (ibool) !!page_is_comp(page)); - ut_ad(!page_rec_is_supremum(current_rec)); + ut_ad(!page_rec_is_supremum(*current_rec)); #ifdef UNIV_ZIP_DEBUG ut_a(!page_zip || page_zip_validate(page_zip, page)); #endif /* UNIV_ZIP_DEBUG */ @@ -1021,21 +1021,21 @@ use_heap: rec_offs_make_valid(insert_rec, index, offsets); /* 4. Insert the record in the linked list of records */ - ut_ad(current_rec != insert_rec); + ut_ad(*current_rec != insert_rec); { /* next record after current before the insertion */ - rec_t* next_rec = page_rec_get_next(current_rec); + rec_t* next_rec = page_rec_get_next(*current_rec); #ifdef UNIV_DEBUG if (page_is_comp(page)) { - ut_ad(rec_get_status(current_rec) + ut_ad(rec_get_status(*current_rec) <= REC_STATUS_INFIMUM); ut_ad(rec_get_status(insert_rec) < REC_STATUS_INFIMUM); ut_ad(rec_get_status(next_rec) != REC_STATUS_INFIMUM); } #endif page_rec_set_next(insert_rec, next_rec); - page_rec_set_next(current_rec, insert_rec); + page_rec_set_next(*current_rec, insert_rec); } page_header_set_field(page, page_zip, PAGE_N_RECS, @@ -1047,7 +1047,7 @@ use_heap: rec_set_n_owned_new(insert_rec, NULL, 0); rec_set_heap_no_new(insert_rec, heap_no); if (UNIV_LIKELY_NULL(page_zip)) { - page_zip_dir_insert(page_zip, current_rec, free_rec, + page_zip_dir_insert(page_zip, *current_rec, free_rec, insert_rec); } } else { @@ -1068,7 +1068,7 @@ use_heap: PAGE_NO_DIRECTION); page_header_set_field(page, page_zip, PAGE_N_DIRECTION, 0); - } else if ((last_insert == current_rec) + } else if ((last_insert == *current_rec) && (page_header_get_field(page, PAGE_DIRECTION) != PAGE_LEFT)) { @@ -1135,13 +1135,18 @@ use_heap: if (page_zip_reorganize(block, index, mtr)) { /* The page was reorganized: - Seek to insert_pos to find insert_rec. */ + Seek to insert_pos to find insert_rec, + and update *current_rec. */ insert_rec = page + PAGE_NEW_INFIMUM; - do { + while (--insert_pos) { insert_rec = page + rec_get_next_offs( insert_rec, TRUE); - } while (--insert_pos); + } + + *current_rec = insert_rec; + insert_rec = page + + rec_get_next_offs(insert_rec, TRUE); return(insert_rec); } @@ -1160,7 +1165,7 @@ use_heap: /* 9. Write log record of the insert */ if (UNIV_LIKELY(mtr != NULL)) { page_cur_insert_rec_write_log(insert_rec, rec_size, - current_rec, index, mtr); + *current_rec, index, mtr); } return(insert_rec); diff --git a/page/page0page.c b/page/page0page.c index 473f0bba29d..b29a181bcac 100644 --- a/page/page0page.c +++ b/page/page0page.c @@ -540,7 +540,7 @@ page_copy_rec_list_end_no_locks( rec_t* ins_rec; offsets = rec_get_offsets(cur1_rec, index, offsets, ULINT_UNDEFINED, &heap); - ins_rec = page_cur_insert_rec_low(cur2, NULL, index, + ins_rec = page_cur_insert_rec_low(&cur2, NULL, index, cur1_rec, offsets, mtr); if (UNIV_UNLIKELY(!ins_rec)) { /* Track an assertion failure reported on the mailing @@ -705,7 +705,7 @@ page_copy_rec_list_start( rec_t* cur1_rec = page_cur_get_rec(&cur1); offsets = rec_get_offsets(cur1_rec, index, offsets, ULINT_UNDEFINED, &heap); - cur2 = page_cur_insert_rec_low(cur2, NULL, index, + cur2 = page_cur_insert_rec_low(&cur2, NULL, index, cur1_rec, offsets, mtr); ut_a(cur2);