diff options
author | Sergei Golubchik <sergii@pisem.net> | 2011-07-18 23:04:24 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2011-07-18 23:04:24 +0200 |
commit | 4e46d8e5bff140f2549841167dc4b65a3c0a645d (patch) | |
tree | c6612dcc1d0fbd801c084e6c36307d9e5913a293 /storage/xtradb/page | |
parent | 9a02c69f5c6766eaf552284a2a4dd0f1d26ecd2c (diff) | |
parent | d4d7a8fa62c406be73f6c0f6d75e795293db548b (diff) | |
download | mariadb-git-4e46d8e5bff140f2549841167dc4b65a3c0a645d.tar.gz |
merge with xtradb-5.5.15
fix test cases
Diffstat (limited to 'storage/xtradb/page')
-rw-r--r-- | storage/xtradb/page/page0cur.c | 78 | ||||
-rw-r--r-- | storage/xtradb/page/page0page.c | 141 | ||||
-rw-r--r-- | storage/xtradb/page/page0zip.c | 33 |
3 files changed, 93 insertions, 159 deletions
diff --git a/storage/xtradb/page/page0cur.c b/storage/xtradb/page/page0cur.c index fa3d2532deb..936762b986a 100644 --- a/storage/xtradb/page/page0cur.c +++ b/storage/xtradb/page/page0cur.c @@ -564,74 +564,6 @@ page_cur_open_on_rnd_user_rec( } while (rnd--); } -UNIV_INTERN -void -page_cur_open_on_nth_user_rec( -/*==========================*/ - buf_block_t* block, /*!< in: page */ - page_cur_t* cursor, /*!< out: page cursor */ - ulint nth) -{ - ulint n_recs = page_get_n_recs(buf_block_get_frame(block)); - - page_cur_set_before_first(block, cursor); - - if (UNIV_UNLIKELY(n_recs == 0)) { - - return; - } - - nth--; - - if (nth >= n_recs) { - nth = n_recs - 1; - } - - do { - page_cur_move_to_next(cursor); - } while (nth--); -} - -UNIV_INTERN -ibool -page_cur_open_on_rnd_user_rec_after_nth( -/*==========================*/ - buf_block_t* block, /*!< in: page */ - page_cur_t* cursor, /*!< out: page cursor */ - ulint nth) -{ - ulint rnd; - ulint n_recs = page_get_n_recs(buf_block_get_frame(block)); - ibool ret; - - page_cur_set_before_first(block, cursor); - - if (UNIV_UNLIKELY(n_recs == 0)) { - - return (FALSE); - } - - nth--; - - if (nth >= n_recs) { - nth = n_recs - 1; - } - - rnd = (ulint) (nth + page_cur_lcg_prng() % (n_recs - nth)); - - if (rnd == nth) { - ret = TRUE; - } else { - ret = FALSE; - } - - do { - page_cur_move_to_next(cursor); - } while (rnd--); - - return (ret); -} - /***********************************************************//** Writes the log record of a record insert on a page. */ static @@ -1217,6 +1149,8 @@ use_heap: current_rec, index, mtr); } + btr_blob_dbg_add_rec(insert_rec, index, offsets, "insert"); + return(insert_rec); } @@ -1263,10 +1197,12 @@ page_cur_insert_rec_zip_reorg( } /* Out of space: restore the page */ + btr_blob_dbg_remove(page, index, "insert_zip_fail"); if (!page_zip_decompress(page_zip, page, FALSE)) { ut_error; /* Memory corrupted? */ } ut_ad(page_validate(page, index)); + btr_blob_dbg_add(page, index, "insert_zip_fail"); return(NULL); } @@ -1558,6 +1494,8 @@ use_heap: page_zip_write_rec(page_zip, insert_rec, index, offsets, 1); + btr_blob_dbg_add_rec(insert_rec, index, offsets, "insert_zip_ok"); + /* 9. Write log record of the insert */ if (UNIV_LIKELY(mtr != NULL)) { page_cur_insert_rec_write_log(insert_rec, rec_size, @@ -1765,6 +1703,9 @@ page_copy_rec_list_end_to_created_page( heap_top += rec_size; + rec_offs_make_valid(insert_rec, index, offsets); + btr_blob_dbg_add_rec(insert_rec, index, offsets, "copy_end"); + page_cur_insert_rec_write_log(insert_rec, rec_size, prev_rec, index, mtr); prev_rec = insert_rec; @@ -2012,6 +1953,7 @@ page_cur_delete_rec( page_dir_slot_set_n_owned(cur_dir_slot, page_zip, cur_n_owned - 1); /* 6. Free the memory occupied by the record */ + btr_blob_dbg_remove_rec(current_rec, index, offsets, "delete"); page_mem_free(page, page_zip, current_rec, index, offsets); /* 7. Now we have decremented the number of owned records of the slot. diff --git a/storage/xtradb/page/page0page.c b/storage/xtradb/page/page0page.c index 10008f9ac25..17f6c6bbc36 100644 --- a/storage/xtradb/page/page0page.c +++ b/storage/xtradb/page/page0page.c @@ -166,11 +166,11 @@ static ibool page_dir_slot_check( /*================*/ - page_dir_slot_t* slot) /*!< in: slot */ + const page_dir_slot_t* slot) /*!< in: slot */ { - page_t* page; - ulint n_slots; - ulint n_owned; + const page_t* page; + ulint n_slots; + ulint n_owned; ut_a(slot); @@ -218,7 +218,7 @@ page_set_max_trx_id( const ibool is_hashed = block->is_hashed; if (is_hashed) { - rw_lock_x_lock(&btr_search_latch); + rw_lock_x_lock(btr_search_get_latch(block->index->id)); } ut_ad(!mtr || mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX)); @@ -235,8 +235,8 @@ page_set_max_trx_id( 8, mtr); #ifndef UNIV_HOTBACKUP } else if (mtr) { - mlog_write_dulint(page + (PAGE_HEADER + PAGE_MAX_TRX_ID), - trx_id, mtr); + mlog_write_ull(page + (PAGE_HEADER + PAGE_MAX_TRX_ID), + trx_id, mtr); #endif /* !UNIV_HOTBACKUP */ } else { mach_write_to_8(page + (PAGE_HEADER + PAGE_MAX_TRX_ID), trx_id); @@ -244,7 +244,7 @@ page_set_max_trx_id( #ifndef UNIV_HOTBACKUP if (is_hashed) { - rw_lock_x_unlock(&btr_search_latch); + rw_lock_x_unlock(btr_search_get_latch(block->index->id)); } #endif /* !UNIV_HOTBACKUP */ } @@ -457,7 +457,7 @@ page_create_low( page_header_set_field(page, NULL, PAGE_DIRECTION, PAGE_NO_DIRECTION); page_header_set_field(page, NULL, PAGE_N_DIRECTION, 0); page_header_set_field(page, NULL, PAGE_N_RECS, 0); - page_set_max_trx_id(block, NULL, ut_dulint_zero, NULL); + page_set_max_trx_id(block, NULL, 0, NULL); memset(heap_top, 0, UNIV_PAGE_SIZE - PAGE_EMPTY_DIR_START - page_offset(heap_top)); @@ -685,12 +685,16 @@ page_copy_rec_list_end( if (UNIV_UNLIKELY (!page_zip_reorganize(new_block, index, mtr))) { + btr_blob_dbg_remove(new_page, index, + "copy_end_reorg_fail"); if (UNIV_UNLIKELY (!page_zip_decompress(new_page_zip, new_page, FALSE))) { ut_error; } ut_ad(page_validate(new_page, index)); + btr_blob_dbg_add(new_page, index, + "copy_end_reorg_fail"); return(NULL); } else { /* The page was reorganized: @@ -803,12 +807,16 @@ page_copy_rec_list_start( if (UNIV_UNLIKELY (!page_zip_reorganize(new_block, index, mtr))) { + btr_blob_dbg_remove(new_page, index, + "copy_start_reorg_fail"); if (UNIV_UNLIKELY (!page_zip_decompress(new_page_zip, new_page, FALSE))) { ut_error; } ut_ad(page_validate(new_page, index)); + btr_blob_dbg_add(new_page, index, + "copy_start_reorg_fail"); return(NULL); } else { /* The page was reorganized: @@ -1080,6 +1088,9 @@ page_delete_rec_list_end( /* Remove the record chain segment from the record chain */ page_rec_set_next(prev_rec, page_get_supremum_rec(page)); + btr_blob_dbg_op(page, rec, index, "delete_end", + btr_blob_dbg_remove_rec); + /* Catenate the deleted chain segment to the page free list */ page_rec_set_next(last_rec, page_header_get_ptr(page, PAGE_FREE)); @@ -1242,28 +1253,6 @@ page_move_rec_list_start( return(TRUE); } - -/***********************************************************************//** -This is a low-level operation which is used in a database index creation -to update the page number of a created B-tree to a data dictionary record. */ -UNIV_INTERN -void -page_rec_write_index_page_no( -/*=========================*/ - rec_t* rec, /*!< in: record to update */ - ulint i, /*!< in: index of the field to update */ - ulint page_no,/*!< in: value to write */ - mtr_t* mtr) /*!< in: mtr */ -{ - byte* data; - ulint len; - - data = rec_get_nth_field_old(rec, i, &len); - - ut_ad(len == 4); - - mlog_write_ulint(data, page_no, MLOG_4BYTES, mtr); -} #endif /* !UNIV_HOTBACKUP */ /**************************************************************//** @@ -1792,12 +1781,12 @@ UNIV_INTERN ibool page_rec_validate( /*==============*/ - rec_t* rec, /*!< in: physical record */ + const rec_t* rec, /*!< in: physical record */ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ { - ulint n_owned; - ulint heap_no; - page_t* page; + ulint n_owned; + ulint heap_no; + const page_t* page; page = page_align(rec); ut_a(!page_is_comp(page) == !rec_offs_comp(offsets)); @@ -1878,16 +1867,16 @@ UNIV_INTERN ibool page_simple_validate_old( /*=====================*/ - page_t* page) /*!< in: old-style index page */ + const page_t* page) /*!< in: index page in ROW_FORMAT=REDUNDANT */ { - page_dir_slot_t* slot; - ulint slot_no; - ulint n_slots; - rec_t* rec; - byte* rec_heap_top; - ulint count; - ulint own_count; - ibool ret = FALSE; + const page_dir_slot_t* slot; + ulint slot_no; + ulint n_slots; + const rec_t* rec; + const byte* rec_heap_top; + ulint count; + ulint own_count; + ibool ret = FALSE; ut_a(!page_is_comp(page)); @@ -2000,7 +1989,7 @@ page_simple_validate_old( goto func_exit; } - rec = page_rec_get_next(rec); + rec = page_rec_get_next_const(rec); own_count++; } @@ -2061,7 +2050,7 @@ page_simple_validate_old( goto func_exit; } - rec = page_rec_get_next(rec); + rec = page_rec_get_next_const(rec); } if (UNIV_UNLIKELY(page_dir_get_n_heap(page) != count + 1)) { @@ -2088,16 +2077,16 @@ UNIV_INTERN ibool page_simple_validate_new( /*=====================*/ - page_t* page) /*!< in: new-style index page */ + const page_t* page) /*!< in: index page in ROW_FORMAT!=REDUNDANT */ { - page_dir_slot_t* slot; - ulint slot_no; - ulint n_slots; - rec_t* rec; - byte* rec_heap_top; - ulint count; - ulint own_count; - ibool ret = FALSE; + const page_dir_slot_t* slot; + ulint slot_no; + ulint n_slots; + const rec_t* rec; + const byte* rec_heap_top; + ulint count; + ulint own_count; + ibool ret = FALSE; ut_a(page_is_comp(page)); @@ -2210,7 +2199,7 @@ page_simple_validate_new( goto func_exit; } - rec = page_rec_get_next(rec); + rec = page_rec_get_next_const(rec); own_count++; } @@ -2272,7 +2261,7 @@ page_simple_validate_new( goto func_exit; } - rec = page_rec_get_next(rec); + rec = page_rec_get_next_const(rec); } if (UNIV_UNLIKELY(page_dir_get_n_heap(page) != count + 1)) { @@ -2297,26 +2286,26 @@ UNIV_INTERN ibool page_validate( /*==========*/ - page_t* page, /*!< in: index page */ + const page_t* page, /*!< in: index page */ dict_index_t* index) /*!< in: data dictionary index containing the page record type definition */ { - page_dir_slot_t*slot; - mem_heap_t* heap; - byte* buf; - ulint count; - ulint own_count; - ulint rec_own_count; - ulint slot_no; - ulint data_size; - rec_t* rec; - rec_t* old_rec = NULL; - ulint offs; - ulint n_slots; - ibool ret = FALSE; - ulint i; - ulint* offsets = NULL; - ulint* old_offsets = NULL; + const page_dir_slot_t* slot; + mem_heap_t* heap; + byte* buf; + ulint count; + ulint own_count; + ulint rec_own_count; + ulint slot_no; + ulint data_size; + const rec_t* rec; + const rec_t* old_rec = NULL; + ulint offs; + ulint n_slots; + ibool ret = FALSE; + ulint i; + ulint* offsets = NULL; + ulint* old_offsets = NULL; if (UNIV_UNLIKELY((ibool) !!page_is_comp(page) != dict_table_is_comp(index->table))) { @@ -2471,7 +2460,7 @@ page_validate( count++; own_count++; old_rec = rec; - rec = page_rec_get_next(rec); + rec = page_rec_get_next_const(rec); /* set old_offsets to offsets; recycle offsets */ { @@ -2545,7 +2534,7 @@ n_owned_zero: buf[offs + i] = 1; } - rec = page_rec_get_next(rec); + rec = page_rec_get_next_const(rec); } if (UNIV_UNLIKELY(page_dir_get_n_heap(page) != count + 1)) { diff --git a/storage/xtradb/page/page0zip.c b/storage/xtradb/page/page0zip.c index a94d2d54417..b81cba4826a 100644 --- a/storage/xtradb/page/page0zip.c +++ b/storage/xtradb/page/page0zip.c @@ -464,7 +464,7 @@ page_zip_fields_encode( if (fixed_sum && UNIV_UNLIKELY (fixed_sum + field->fixed_len - > DICT_MAX_INDEX_COL_LEN)) { + > DICT_MAX_FIXED_COL_LEN)) { /* Write out the length of the preceding non-nullable fields, to avoid exceeding the maximum @@ -653,13 +653,13 @@ page_zip_dir_encode( Allocate memory for zlib. */ static void* -page_zip_malloc( +page_zip_zalloc( /*============*/ void* opaque, /*!< in/out: memory heap */ uInt items, /*!< in: number of items to allocate */ uInt size) /*!< in: size of an item in bytes */ { - return(mem_heap_alloc(opaque, items * size)); + return(mem_heap_zalloc(opaque, items * size)); } /**********************************************************************//** @@ -684,7 +684,7 @@ page_zip_set_alloc( { z_stream* strm = stream; - strm->zalloc = page_zip_malloc; + strm->zalloc = page_zip_zalloc; strm->zfree = page_zip_free; strm->opaque = heap; } @@ -2916,19 +2916,18 @@ zlib_error: page_zip_set_alloc(&d_stream, heap); - if (UNIV_UNLIKELY(inflateInit2(&d_stream, UNIV_PAGE_SIZE_SHIFT) - != Z_OK)) { - ut_error; - } - d_stream.next_in = page_zip->data + PAGE_DATA; /* Subtract the space reserved for the page header and the end marker of the modification log. */ d_stream.avail_in = page_zip_get_size(page_zip) - (PAGE_DATA + 1); - d_stream.next_out = page + PAGE_ZIP_START; d_stream.avail_out = UNIV_PAGE_SIZE - PAGE_ZIP_START; + if (UNIV_UNLIKELY(inflateInit2(&d_stream, UNIV_PAGE_SIZE_SHIFT) + != Z_OK)) { + ut_error; + } + /* Decode the zlib header and the index information. */ if (UNIV_UNLIKELY(inflate(&d_stream, Z_BLOCK) != Z_OK)) { @@ -4426,6 +4425,7 @@ page_zip_reorganize( dict_index_t* index, /*!< in: index of the B-tree node */ mtr_t* mtr) /*!< in: mini-transaction */ { + buf_pool_t* buf_pool = buf_pool_from_block(block); page_zip_des_t* page_zip = buf_block_get_page_zip(block); page_t* page = buf_block_get_frame(block); buf_block_t* temp_block; @@ -4443,8 +4443,8 @@ page_zip_reorganize( log_mode = mtr_set_log_mode(mtr, MTR_LOG_NONE); #ifndef UNIV_HOTBACKUP - temp_block = buf_block_alloc(0); - btr_search_drop_page_hash_index(block); + temp_block = buf_block_alloc(buf_pool); + btr_search_drop_page_hash_index(block, index); block->check_index_page_at_flush = TRUE; #else /* !UNIV_HOTBACKUP */ ut_ad(block == back_block1); @@ -4455,6 +4455,8 @@ page_zip_reorganize( /* Copy the old page to temporary space */ buf_frame_copy(temp_page, page); + btr_blob_dbg_remove(page, index, "zip_reorg"); + /* Recreate the page: note that global data on page (possible segment headers, next page-field, etc.) is preserved intact */ @@ -4471,7 +4473,7 @@ page_zip_reorganize( /* Copy max trx id to recreated page */ trx_id_t max_trx_id = page_get_max_trx_id(temp_page); page_set_max_trx_id(block, NULL, max_trx_id, NULL); - ut_ad(!ut_dulint_is_zero(max_trx_id)); + ut_ad(max_trx_id != 0); } /* Restore logging. */ @@ -4513,7 +4515,7 @@ page_zip_copy_recs( mtr_t* mtr) /*!< in: mini-transaction */ { ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX)); - ut_ad(mtr_memo_contains_page(mtr, (page_t*) src, MTR_MEMO_PAGE_X_FIX)); + ut_ad(mtr_memo_contains_page(mtr, src, MTR_MEMO_PAGE_X_FIX)); ut_ad(!dict_index_is_ibuf(index)); #ifdef UNIV_ZIP_DEBUG /* The B-tree operations that call this function may set @@ -4531,7 +4533,7 @@ page_zip_copy_recs( /* The PAGE_MAX_TRX_ID must be set on leaf pages of secondary indexes. It does not matter on other pages. */ ut_a(dict_index_is_clust(index) || !page_is_leaf(src) - || !ut_dulint_is_zero(page_get_max_trx_id(src))); + || page_get_max_trx_id(src)); UNIV_MEM_ASSERT_W(page, UNIV_PAGE_SIZE); UNIV_MEM_ASSERT_W(page_zip->data, page_zip_get_size(page_zip)); @@ -4583,6 +4585,7 @@ page_zip_copy_recs( #ifdef UNIV_ZIP_DEBUG ut_a(page_zip_validate(page_zip, page)); #endif /* UNIV_ZIP_DEBUG */ + btr_blob_dbg_add(page, index, "page_zip_copy_recs"); page_zip_compress_write_log(page_zip, page, index, mtr); } |