Skip to content
Permalink
Browse files

Bug#16852278 SIMPLIFY RECORD COMPARISONS

cmp_data(): Common inline function for comparing two fields.
Compare the common prefix with memcmp().

Assert that the fields being compared cannot be stored externally. Only clustered index leaf page records can contain externally stored fields, and the clustered index records should differ already in the PRIMARY KEY columns, which cannot be stored externally.

page_cmp_dtuple_rec_with_match(): Remove, and call
cmp_dtuple_rec_with_match() instead, on user records only.

cmp_rec_rec_with_match(): Remove the unused parameter matched_bytes.
Ignore the initial value of *matched_fields (assume that it is 0).

page_cur_search(): Remove the constant parameter PAGE_CUR_LE.

Remove support for byte-level prefix granularity in searches.

There were 2 users of this information: the adaptive hash index, and
prefix searches (cmp_dtuple_is_prefix_of_rec(), called for match_mode
== ROW_SEL_EXACT_PREFIX).

The byte-level granularity was only available for VARBINARY columns,
and before rb#2350 Bug#16723431 REMOVE SRV_LATIN1_ORDERING, for the
default collation latin1_swedish_ci. Prefix searches should never
supply a partial-field prefix, due to an assertion in
row_sel_convert_mysql_key_to_innobase().

The adaptive hash index is unlikely to benefit much from the
byte-level granularity either. (No performance penalty was observed
when testing rb#2350, and the keys did include latin1_swedish_ci.)

btr_cur_t: Remove up_bytes, low_bytes.
btr_search_t: Remove n_bytes.
buf_block_t: Remove n_bytes, curr_n_bytes.

dtuple_fold(), rec_fold(): Remove n_bytes.

ut_pair_min(), ut_pair_cmp(): Remove.

page_cur_search_with_match(), page_cur_try_search_shortcut():
Remove iup_matched_bytes, ilow_matched_bytes.

cmp_dtuple_rec_with_match_low(), cmp_dtuple_rec_with_match():
Remove matched_bytes.

Remove the normalization of the comparison result to -1 or 1.
Instead, return negative or positive, and adjust the callers.

btr_search_check_guess(), page_cur_search_with_match(), page_validate(),:
Allow a wider range of return values from cmp_dtuple_rec_with_match().

row_merge_blocks(): Allow a wider range of return values from
cmp_rec_rec_simple().

ib_like_t: Remove the unused and unsupported operations SUFFIX,
SUBSTR, REGEXP.

eval_cmp_like(), eval_cmp(): Simplify the code.

pars_like_rebind(): Remove the unsupported ib_like_t operations.

dtuple_coll_cmp(), cmp_data_data(), cmp_dtuple_rec(),
cmp_dtuple_rec_with_match_low(), cmp_rec_rec(),
cmp_rec_rec_with_match(), cmp_rec_rec_simple(), cmp_dfield_dfield(),
innobase_mysql_cmp(), cmp_whole_field(), cmp_data(),
cmp_dfield_dfield_like_prefix(), row_merge_tuple_cmp(): Return
negative or positive instead of -1 or 1.

dtype_get_pad_char(): Merge to ib_col_set_value() and cmp_data().

cmp_decimal(): Refactored from cmp_decimal(). Compare two DATA_DECIMAL
fields. This should only be needed for table definitions before MySQL 5.1.
MYSQL_TYPE_NEWDECIMAL is compared as binary strings.

cmp_debug_dtuple_rec_with_match(): Remove. This is virtually identical
to its only caller. There should not be any inconsistency between the
different comparison functions, because all of them should use cmp_data().

rb#2490 approved by Jimmy Yang
  • Loading branch information...
Marko Mäkelä
Marko Mäkelä committed May 29, 2013
1 parent 41797df commit 6f5f19b338543277a108a97710de8dd59b9dbb60
Showing with 710 additions and 1,563 deletions.
  1. +3 −14 storage/innobase/api/api0api.cc
  2. +2 −4 storage/innobase/btr/btr0btr.cc
  3. +4 −16 storage/innobase/btr/btr0cur.cc
  4. +53 −143 storage/innobase/btr/btr0sea.cc
  5. +0 −1 storage/innobase/buf/buf0buf.cc
  6. +11 −19 storage/innobase/data/data0data.cc
  7. +5 −8 storage/innobase/dict/dict0stats.cc
  8. +44 −65 storage/innobase/eval/eval0eval.cc
  9. +3 −8 storage/innobase/handler/ha_innodb.cc
  10. +3 −6 storage/innobase/ibuf/ibuf0ibuf.cc
  11. +0 −8 storage/innobase/include/btr0cur.h
  12. +0 −3 storage/innobase/include/btr0sea.h
  13. +2 −6 storage/innobase/include/buf0buf.h
  14. +7 −9 storage/innobase/include/data0data.h
  15. +1 −19 storage/innobase/include/data0data.ic
  16. +3 −15 storage/innobase/include/data0type.h
  17. +0 −42 storage/innobase/include/data0type.ic
  18. +25 −18 storage/innobase/include/page0cur.h
  19. +32 −20 storage/innobase/include/page0cur.ic
  20. +4 −5 storage/innobase/include/page0page.h
  21. +5 −7 storage/innobase/include/page0page.ic
  22. +105 −105 storage/innobase/include/rem0cmp.h
  23. +34 −30 storage/innobase/include/rem0cmp.ic
  24. +0 −2 storage/innobase/include/rem0rec.h
  25. +1 −21 storage/innobase/include/rem0rec.ic
  26. +0 −23 storage/innobase/include/ut0ut.h
  27. +1 −51 storage/innobase/include/ut0ut.ic
  28. +40 −98 storage/innobase/page/page0cur.cc
  29. +1 −1 storage/innobase/page/page0page.cc
  30. +3 −37 storage/innobase/pars/pars0pars.cc
  31. +303 −734 storage/innobase/rem/rem0cmp.cc
  32. +2 −7 storage/innobase/row/row0ins.cc
  33. +12 −14 storage/innobase/row/row0merge.cc
  34. +1 −4 storage/innobase/row/row0mysql.cc
@@ -2370,23 +2370,12 @@ ib_col_set_value(
ut_error;
break;

case DATA_CHAR: {
ulint pad_char = ULINT_UNDEFINED;

pad_char = dtype_get_pad_char(
dtype_get_mtype(dtype), dtype_get_prtype(dtype));

ut_a(pad_char != ULINT_UNDEFINED);

memset((byte*) dst + len,
pad_char,
col_len - len);

case DATA_CHAR:
memcpy(dst, src, len);

memset((byte*) dst + len, 0x20, col_len - len);
len = col_len;
break;
}

case DATA_BLOB:
case DATA_GEOMETRY:
case DATA_BINARY:
@@ -2261,8 +2261,7 @@ btr_root_raise_and_insert(
}

/* Reposition the cursor to the child node */
page_cur_search(new_block, index, tuple,
PAGE_CUR_LE, page_cursor);
page_cur_search(new_block, index, tuple, page_cursor);

/* Split the child and insert tuple */
return(btr_page_split_and_insert(flags, cursor, offsets, heap,
@@ -3101,8 +3100,7 @@ btr_page_split_and_insert(
/* 7. Reposition the cursor for insert and try insertion */
page_cursor = btr_cur_get_page_cur(cursor);

page_cur_search(insert_block, cursor->index, tuple,
PAGE_CUR_LE, page_cursor);
page_cur_search(insert_block, cursor->index, tuple, page_cursor);

rec = page_cur_tuple_insert(page_cursor, tuple, cursor->index,
offsets, heap, n_ext, mtr);
@@ -387,9 +387,7 @@ btr_cur_search_to_nth_level(
ulint height;
ulint page_no;
ulint up_match;
ulint up_bytes;
ulint low_match;
ulint low_bytes;
ulint savepoint;
ulint rw_latch;
ulint page_mode;
@@ -420,9 +418,7 @@ btr_cur_search_to_nth_level(
ut_ad(index->page != FIL_NULL);

UNIV_MEM_INVALID(&cursor->up_match, sizeof cursor->up_match);
UNIV_MEM_INVALID(&cursor->up_bytes, sizeof cursor->up_bytes);
UNIV_MEM_INVALID(&cursor->low_match, sizeof cursor->low_match);
UNIV_MEM_INVALID(&cursor->low_bytes, sizeof cursor->low_bytes);
#ifdef UNIV_DEBUG
cursor->up_match = ULINT_UNDEFINED;
cursor->low_match = ULINT_UNDEFINED;
@@ -561,9 +557,7 @@ btr_cur_search_to_nth_level(
page_no = dict_index_get_page(index);

up_match = 0;
up_bytes = 0;
low_match = 0;
low_bytes = 0;

height = ULINT_UNDEFINED;

@@ -748,8 +742,8 @@ btr_cur_search_to_nth_level(
}

page_cur_search_with_match(
block, index, tuple, page_mode, &up_match, &up_bytes,
&low_match, &low_bytes, page_cursor);
block, index, tuple, page_mode, &up_match,
&low_match, page_cursor);

if (estimate) {
btr_cur_add_path_info(cursor, height, root_height);
@@ -799,9 +793,7 @@ btr_cur_search_to_nth_level(
btr_assert_not_corrupted(child_block, index);
} else {
cursor->low_match = low_match;
cursor->low_bytes = low_bytes;
cursor->up_match = up_match;
cursor->up_bytes = up_bytes;

#ifdef BTR_CUR_ADAPT
/* We do a dirty read of btr_search_enabled here. We
@@ -3807,8 +3799,6 @@ btr_estimate_number_of_different_key_vals(
page_t* page;
rec_t* rec;
ulint n_cols;
ulint matched_fields;
ulint matched_bytes;
ib_uint64_t* n_diff;
ib_uint64_t* n_not_null;
ibool stats_null_not_equal;
@@ -3900,6 +3890,7 @@ btr_estimate_number_of_different_key_vals(
}

while (!page_rec_is_supremum(rec)) {
ulint matched_fields;
rec_t* next_rec = page_rec_get_next(rec);
if (page_rec_is_supremum(next_rec)) {
total_external_size +=
@@ -3908,8 +3899,6 @@ btr_estimate_number_of_different_key_vals(
break;
}

matched_fields = 0;
matched_bytes = 0;
offsets_next_rec = rec_get_offsets(next_rec, index,
offsets_next_rec,
ULINT_UNDEFINED,
@@ -3918,8 +3907,7 @@ btr_estimate_number_of_different_key_vals(
cmp_rec_rec_with_match(rec, next_rec,
offsets_rec, offsets_next_rec,
index, stats_null_not_equal,
&matched_fields,
&matched_bytes);
&matched_fields);

for (j = matched_fields; j < n_cols; j++) {
/* We add one if this index record has

0 comments on commit 6f5f19b

Please sign in to comment.
You can’t perform that action at this time.