diff options
Diffstat (limited to 'storage/innobase/dict/dict0stats.cc')
-rw-r--r-- | storage/innobase/dict/dict0stats.cc | 59 |
1 files changed, 26 insertions, 33 deletions
diff --git a/storage/innobase/dict/dict0stats.cc b/storage/innobase/dict/dict0stats.cc index a85b02aa844..31cb2a2bf4e 100644 --- a/storage/innobase/dict/dict0stats.cc +++ b/storage/innobase/dict/dict0stats.cc @@ -1010,8 +1010,8 @@ dict_stats_analyze_index_level( bool prev_rec_is_copied; byte* prev_rec_buf = NULL; ulint prev_rec_buf_size = 0; - ulint* rec_offsets; - ulint* prev_rec_offsets; + offset_t* rec_offsets; + offset_t* prev_rec_offsets; ulint i; DEBUG_PRINTF(" %s(table=%s, index=%s, level=" ULINTPF ")\n", @@ -1032,9 +1032,9 @@ dict_stats_analyze_index_level( i = (REC_OFFS_HEADER_SIZE + 1 + 1) + n_uniq; heap = mem_heap_create((2 * sizeof *rec_offsets) * i); - rec_offsets = static_cast<ulint*>( + rec_offsets = static_cast<offset_t*>( mem_heap_alloc(heap, i * sizeof *rec_offsets)); - prev_rec_offsets = static_cast<ulint*>( + prev_rec_offsets = static_cast<offset_t*>( mem_heap_alloc(heap, i * sizeof *prev_rec_offsets)); rec_offs_set_n_alloc(rec_offsets, i); rec_offs_set_n_alloc(prev_rec_offsets, i); @@ -1327,11 +1327,11 @@ to the number of externally stored pages which were encountered @return offsets1 or offsets2 (the offsets of *out_rec), or NULL if the page is empty and does not contain user records. */ UNIV_INLINE -ulint* +offset_t* dict_stats_scan_page( const rec_t** out_rec, - ulint* offsets1, - ulint* offsets2, + offset_t* offsets1, + offset_t* offsets2, const dict_index_t* index, const page_t* page, ulint n_prefix, @@ -1339,8 +1339,8 @@ dict_stats_scan_page( ib_uint64_t* n_diff, ib_uint64_t* n_external_pages) { - ulint* offsets_rec = offsets1; - ulint* offsets_next_rec = offsets2; + offset_t* offsets_rec = offsets1; + offset_t* offsets_next_rec = offsets2; const rec_t* rec; const rec_t* next_rec; /* A dummy heap, to be passed to rec_get_offsets(). @@ -1406,23 +1406,16 @@ dict_stats_scan_page( } rec = next_rec; - { - /* Assign offsets_rec = offsets_next_rec - so that offsets_rec matches with rec which - was just assigned rec = next_rec above. - Also need to point offsets_next_rec to the - place where offsets_rec was pointing before - because we have just 2 placeholders where - data is actually stored: - offsets1 and offsets2 and we - are using them in circular fashion - (offsets[_next]_rec are just pointers to - those placeholders). */ - ulint* offsets_tmp; - offsets_tmp = offsets_rec; - offsets_rec = offsets_next_rec; - offsets_next_rec = offsets_tmp; - } + /* Assign offsets_rec = offsets_next_rec so that + offsets_rec matches with rec which was just assigned + rec = next_rec above. Also need to point + offsets_next_rec to the place where offsets_rec was + pointing before because we have just 2 placeholders + where data is actually stored: offsets1 and offsets2 + and we are using them in circular fashion + (offsets[_next]_rec are just pointers to those + placeholders). */ + std::swap(offsets_rec, offsets_next_rec); if (should_count_external_pages) { *n_external_pages += btr_rec_get_externally_stored_len( @@ -1461,9 +1454,9 @@ dict_stats_analyze_index_below_cur( const page_t* page; mem_heap_t* heap; const rec_t* rec; - ulint* offsets1; - ulint* offsets2; - ulint* offsets_rec; + offset_t* offsets1; + offset_t* offsets2; + offset_t* offsets_rec; ulint size; mtr_t mtr; @@ -1481,10 +1474,10 @@ dict_stats_analyze_index_below_cur( heap = mem_heap_create(size * (sizeof *offsets1 + sizeof *offsets2)); - offsets1 = static_cast<ulint*>(mem_heap_alloc( + offsets1 = static_cast<offset_t*>(mem_heap_alloc( heap, size * sizeof *offsets1)); - offsets2 = static_cast<ulint*>(mem_heap_alloc( + offsets2 = static_cast<offset_t*>(mem_heap_alloc( heap, size * sizeof *offsets2)); rec_offs_set_n_alloc(offsets1, size); @@ -1745,8 +1738,8 @@ dict_stats_analyze_index_for_n_prefix( ut_a(left <= right); ut_a(right <= last_idx_on_level); - const ulint rnd = right == left ? 0 : - ut_rnd_gen_ulint() % (right - left); + const ulint rnd = ut_rnd_interval( + static_cast<ulint>(right - left)); const ib_uint64_t dive_below_idx = boundaries->at(static_cast<unsigned>(left + rnd)); |