diff --git a/btr/btr0cur.c b/btr/btr0cur.c index 8a3fdb154c5..917b9ecf910 100644 --- a/btr/btr0cur.c +++ b/btr/btr0cur.c @@ -3578,6 +3578,7 @@ btr_store_big_rec_extern_fields( /* out: DB_SUCCESS or error */ dict_index_t* index, /* in: index of rec; the index tree MUST be X-latched */ + buf_block_t* rec_block, /* in/out: block containing rec */ rec_t* rec, /* in/out: record */ const ulint* offsets, /* in: rec_get_offsets(rec, index); the "external storage" flags in offsets @@ -3599,16 +3600,15 @@ btr_store_big_rec_extern_fields( ulint i; mtr_t mtr; page_zip_des_t* page_zip; - buf_block_t* rec_block; z_stream c_stream; ut_ad(rec_offs_validate(rec, index, offsets)); ut_ad(mtr_memo_contains(local_mtr, dict_index_get_lock(index), MTR_MEMO_X_LOCK)); - ut_ad(mtr_memo_contains_page(local_mtr, rec, MTR_MEMO_PAGE_X_FIX)); + ut_ad(mtr_memo_contains(local_mtr, rec_block, MTR_MEMO_PAGE_X_FIX)); + ut_ad(buf_block_get_frame(rec_block) == page_align(rec)); ut_a(dict_index_is_clust(index)); - rec_block = buf_block_align(rec); page_zip = buf_block_get_page_zip(rec_block); ut_a(dict_table_zip_size(index->table) == buf_block_get_zip_size(rec_block)); diff --git a/include/btr0cur.h b/include/btr0cur.h index edec2b2bc71..48fcdef71c0 100644 --- a/include/btr0cur.h +++ b/include/btr0cur.h @@ -476,6 +476,7 @@ btr_store_big_rec_extern_fields( /* out: DB_SUCCESS or error */ dict_index_t* index, /* in: index of rec; the index tree MUST be X-latched */ + buf_block_t* rec_block, /* in/out: block containing rec */ rec_t* rec, /* in: record */ const ulint* offsets, /* in: rec_get_offsets(rec, index); the "external storage" flags in offsets diff --git a/include/page0cur.h b/include/page0cur.h index 8f54f7e807d..55da757d73d 100644 --- a/include/page0cur.h +++ b/include/page0cur.h @@ -180,7 +180,8 @@ page_cur_insert_rec_low( otherwise */ rec_t* current_rec,/* in: current record after which the new record is inserted */ - page_zip_des_t* page_zip,/* in: compressed page, or NULL */ + 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 */ ulint* offsets,/* in/out: rec_get_offsets(rec, index) */ diff --git a/include/page0cur.ic b/include/page0cur.ic index 031ff633fc7..9ee1d8240a0 100644 --- a/include/page0cur.ic +++ b/include/page0cur.ic @@ -235,8 +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, - buf_block_get_page_zip(cursor->block), + rec = page_cur_insert_rec_low(cursor->rec, cursor->block, index, rec, offsets, mtr); mem_heap_free(heap); return(rec); @@ -258,8 +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, - buf_block_get_page_zip(cursor->block), + return(page_cur_insert_rec_low(cursor->rec, cursor->block, index, rec, offsets, mtr)); } diff --git a/include/page0page.ic b/include/page0page.ic index 8445b96e3cf..1d72c5cd9a3 100644 --- a/include/page0page.ic +++ b/include/page0page.ic @@ -671,12 +671,11 @@ page_rec_get_next_low( fprintf(stderr, "InnoDB: Next record offset is nonsensical %lu" " in record at offset %lu\n" - "InnoDB: rec address %p, first buffer frame %p\n" - "InnoDB: buffer pool high end %p, buf fix count %lu\n", - (ulong)offs, (ulong)(rec - page), - (void*) rec, (void*) buf_pool->frame_zero, - (void*) buf_pool->high_end, - (ulong) buf_block_align(rec)->buf_fix_count); + "InnoDB: rec address %p, space id %lu, page %lu\n", + (ulong)offs, (ulong) page_offset(rec), + (void*) rec, + (ulong) page_get_space_id(rec), + (ulong) page_get_page_no(rec)); buf_page_print(page, 0); ut_error; diff --git a/page/page0cur.c b/page/page0cur.c index 6b45078c677..8d8210a2bce 100644 --- a/page/page0cur.c +++ b/page/page0cur.c @@ -895,7 +895,8 @@ page_cur_insert_rec_low( otherwise */ rec_t* current_rec,/* in: current record after which the new record is inserted */ - page_zip_des_t* page_zip,/* in: compressed page, or NULL */ + 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 */ ulint* offsets,/* in/out: rec_get_offsets(rec, index) */ @@ -911,7 +912,9 @@ page_cur_insert_rec_low( rec_t* insert_rec; /* inserted record */ ulint heap_no; /* heap number of the inserted record */ - page_zip_des_t* page_zip_orig = page_zip; + page_zip_des_t* page_zip; + + page_zip = block ? buf_block_get_page_zip(block) : NULL; ut_ad(rec_offs_validate(rec, index, offsets)); @@ -1116,20 +1119,19 @@ use_heap: if (UNIV_LIKELY_NULL(page_zip)) { page_zip_write_rec(page_zip, insert_rec, index, offsets, 1); - } else if (UNIV_LIKELY_NULL(page_zip_orig)) { + } else if (UNIV_LIKELY_NULL(block) + && UNIV_LIKELY_NULL(buf_block_get_page_zip(block))) { ut_a(page_is_comp(page)); + page_zip = buf_block_get_page_zip(block); + /* Recompress or reorganize and recompress the page. */ if (UNIV_UNLIKELY - (!page_zip_compress(page_zip_orig, page, index, mtr))) { + (!page_zip_compress(page_zip, page, index, mtr))) { /* Before trying to reorganize the page, store the number of preceding records on the page. */ ulint insert_pos = page_rec_get_n_recs_before(insert_rec); - buf_block_t* block - = buf_block_align(page); - - ut_ad(buf_block_get_page_zip(block) == page_zip_orig); if (page_zip_reorganize(block, index, mtr)) { /* The page was reorganized: @@ -1137,7 +1139,7 @@ use_heap: insert_rec = page + PAGE_NEW_INFIMUM; do { - insert_rec = rec_get_next_ptr( + insert_rec = page + rec_get_next_offs( insert_rec, TRUE); } while (--insert_pos); @@ -1145,7 +1147,7 @@ use_heap: } /* Out of space: restore the page */ - if (!page_zip_decompress(page_zip_orig, page)) { + if (!page_zip_decompress(page_zip, page)) { ut_error; /* Memory corrupted? */ } ut_ad(page_validate(page, index)); diff --git a/row/row0ins.c b/row/row0ins.c index ad2c6ef5557..2b236301cc7 100644 --- a/row/row0ins.c +++ b/row/row0ins.c @@ -2145,8 +2145,9 @@ function_exit: offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, &heap); - err = btr_store_big_rec_extern_fields(index, rec, - offsets, big_rec, &mtr); + err = btr_store_big_rec_extern_fields( + index, btr_cur_get_block(&cursor), + rec, offsets, big_rec, &mtr); if (modify) { dtuple_big_rec_free(big_rec); diff --git a/row/row0upd.c b/row/row0upd.c index 684e3df9527..92518565c69 100644 --- a/row/row0upd.c +++ b/row/row0upd.c @@ -1607,7 +1607,7 @@ row_upd_clust_rec( ut_a(btr_pcur_restore_position(BTR_MODIFY_TREE, pcur, mtr)); rec = btr_cur_get_rec(btr_cur); err = btr_store_big_rec_extern_fields( - index, rec, + index, btr_cur_get_block(btr_cur), rec, rec_get_offsets(rec, index, offsets_, ULINT_UNDEFINED, &heap), big_rec, mtr);