Skip to content

Commit 774916a

Browse files
author
marko@hundin.mysql.fi
committed
Merge marko@bk-internal.mysql.com:/home/bk/mysql-5.0
into hundin.mysql.fi:/home/marko/mysql-5.0-current
2 parents 5b8683d + 4eba989 commit 774916a

File tree

5 files changed

+165
-95
lines changed

5 files changed

+165
-95
lines changed

innobase/btr/btr0cur.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,9 @@ btr_cur_search_to_nth_level(
316316
if (btr_search_latch.writer == RW_LOCK_NOT_LOCKED
317317
&& latch_mode <= BTR_MODIFY_LEAF && info->last_hash_succ
318318
&& !estimate
319+
#ifdef PAGE_CUR_LE_OR_EXTENDS
319320
&& mode != PAGE_CUR_LE_OR_EXTENDS
321+
#endif /* PAGE_CUR_LE_OR_EXTENDS */
320322
&& srv_use_adaptive_hash_indexes
321323
&& btr_search_guess_on_hash(index, info, tuple, mode,
322324
latch_mode, cursor,
@@ -391,8 +393,10 @@ btr_cur_search_to_nth_level(
391393
break;
392394
default:
393395
ut_ad(mode == PAGE_CUR_L
394-
|| mode == PAGE_CUR_LE
395-
|| mode == PAGE_CUR_LE_OR_EXTENDS);
396+
#ifdef PAGE_CUR_LE_OR_EXTENDS
397+
|| mode == PAGE_CUR_LE_OR_EXTENDS
398+
#endif /* PAGE_CUR_LE_OR_EXTENDS */
399+
|| mode == PAGE_CUR_LE);
396400
page_mode = mode;
397401
break;
398402
}

innobase/include/page0cur.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ Created 10/4/1994 Heikki Tuuri
2626
#define PAGE_CUR_GE 2
2727
#define PAGE_CUR_L 3
2828
#define PAGE_CUR_LE 4
29-
#define PAGE_CUR_LE_OR_EXTENDS 5 /* This is a search mode used in
29+
/*#define PAGE_CUR_LE_OR_EXTENDS 5*/ /* This is a search mode used in
3030
"column LIKE 'abc%' ORDER BY column DESC";
3131
we have to find strings which are <= 'abc' or
3232
which extend it */
33-
#define PAGE_CUR_DBG 6
33+
#ifdef UNIV_SEARCH_DEBUG
34+
# define PAGE_CUR_DBG 6 /* As PAGE_CUR_LE, but skips search shortcut */
35+
#endif /* UNIV_SEARCH_DEBUG */
3436

3537
#ifdef PAGE_CUR_ADAPT
3638
# ifdef UNIV_SEARCH_PERF_STAT

innobase/page/page0cur.c

+56-44
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ page_cur_try_search_shortcut(
4747
not yet completely matched */
4848
page_cur_t* cursor) /* out: page cursor */
4949
{
50-
int cmp;
5150
rec_t* rec;
5251
rec_t* next_rec;
5352
ulint low_match;
@@ -79,19 +78,17 @@ page_cur_try_search_shortcut(
7978
up_match = low_match;
8079
up_bytes = low_bytes;
8180

82-
cmp = page_cmp_dtuple_rec_with_match(tuple, rec, offsets, &low_match,
83-
&low_bytes);
84-
if (cmp == -1) {
81+
if (page_cmp_dtuple_rec_with_match(tuple, rec, offsets,
82+
&low_match, &low_bytes) < 0) {
8583
goto exit_func;
8684
}
8785

8886
next_rec = page_rec_get_next(rec);
8987
offsets = rec_get_offsets(next_rec, index, offsets,
9088
dtuple_get_n_fields(tuple), &heap);
9189

92-
cmp = page_cmp_dtuple_rec_with_match(tuple, next_rec, offsets,
93-
&up_match, &up_bytes);
94-
if (cmp != -1) {
90+
if (page_cmp_dtuple_rec_with_match(tuple, next_rec, offsets,
91+
&up_match, &up_bytes) >= 0) {
9592
goto exit_func;
9693
}
9794

@@ -115,7 +112,7 @@ page_cur_try_search_shortcut(
115112
ut_a(*ilow_matched_fields == low_match);
116113
ut_a(*ilow_matched_bytes == low_bytes);
117114
#endif
118-
if (next_rec != page_get_supremum_rec(page)) {
115+
if (!page_rec_is_supremum(next_rec)) {
119116

120117
*iup_matched_fields = up_match;
121118
*iup_matched_bytes = up_bytes;
@@ -137,6 +134,7 @@ page_cur_try_search_shortcut(
137134

138135
#endif
139136

137+
#ifdef PAGE_CUR_LE_OR_EXTENDS
140138
/********************************************************************
141139
Checks if the nth field in a record is a character type field which extends
142140
the nth field in tuple, i.e., the field is longer or equal in length and has
@@ -185,6 +183,7 @@ page_cur_rec_field_extends(
185183

186184
return(FALSE);
187185
}
186+
#endif /* PAGE_CUR_LE_OR_EXTENDS */
188187

189188
/********************************************************************
190189
Searches the right position for a page cursor. */
@@ -240,9 +239,14 @@ page_cur_search_with_match(
240239
ut_ad(dtuple_validate(tuple));
241240
ut_ad(dtuple_check_typed(tuple));
242241
ut_ad((mode == PAGE_CUR_L) || (mode == PAGE_CUR_LE)
243-
|| (mode == PAGE_CUR_G) || (mode == PAGE_CUR_GE)
244-
|| (mode == PAGE_CUR_LE_OR_EXTENDS) || (mode == PAGE_CUR_DBG));
245-
242+
#ifdef PAGE_CUR_DBG
243+
|| (mode == PAGE_CUR_DBG)
244+
#endif /* PAGE_CUR_DBG */
245+
#ifdef PAGE_CUR_LE_OR_EXTENDS
246+
|| (mode == PAGE_CUR_LE_OR_EXTENDS)
247+
#endif /* PAGE_CUR_LE_OR_EXTENDS */
248+
|| (mode == PAGE_CUR_G) || (mode == PAGE_CUR_GE));
249+
246250
page_check_dir(page);
247251

248252
#ifdef PAGE_CUR_ADAPT
@@ -261,16 +265,18 @@ page_cur_search_with_match(
261265
return;
262266
}
263267
}
264-
/*#ifdef UNIV_SEARCH_DEBUG */
268+
# ifdef PAGE_CUR_DBG
265269
if (mode == PAGE_CUR_DBG) {
266270
mode = PAGE_CUR_LE;
267271
}
268-
/*#endif */
272+
# endif
269273
#endif
270274

271275
/* The following flag does not work for non-latin1 char sets because
272276
cmp_full_field does not tell how many bytes matched */
277+
#ifdef PAGE_CUR_LE_OR_EXTENDS
273278
ut_a(mode != PAGE_CUR_LE_OR_EXTENDS);
279+
#endif /* PAGE_CUR_LE_OR_EXTENDS */
274280

275281
/* If mode PAGE_CUR_G is specified, we are trying to position the
276282
cursor to answer a query of the form "tuple < X", where tuple is
@@ -308,33 +314,36 @@ page_cur_search_with_match(
308314
cmp = cmp_dtuple_rec_with_match(tuple, mid_rec, offsets,
309315
&cur_matched_fields,
310316
&cur_matched_bytes);
311-
if (cmp == 1) {
317+
if (UNIV_LIKELY(cmp > 0)) {
318+
low_slot_match:
312319
low = mid;
313320
low_matched_fields = cur_matched_fields;
314321
low_matched_bytes = cur_matched_bytes;
315322

316-
} else if (cmp == -1) {
323+
} else if (UNIV_LIKELY(cmp /* == -1 */)) {
324+
#ifdef PAGE_CUR_LE_OR_EXTENDS
317325
if (mode == PAGE_CUR_LE_OR_EXTENDS
318326
&& page_cur_rec_field_extends(tuple, mid_rec,
319327
offsets, cur_matched_fields)) {
320-
low = mid;
321-
low_matched_fields = cur_matched_fields;
322-
low_matched_bytes = cur_matched_bytes;
323-
} else {
324-
up = mid;
325-
up_matched_fields = cur_matched_fields;
326-
up_matched_bytes = cur_matched_bytes;
327-
}
328328

329-
} else if (mode == PAGE_CUR_G || mode == PAGE_CUR_LE
330-
|| mode == PAGE_CUR_LE_OR_EXTENDS) {
331-
low = mid;
332-
low_matched_fields = cur_matched_fields;
333-
low_matched_bytes = cur_matched_bytes;
334-
} else {
329+
goto low_slot_match;
330+
}
331+
#endif /* PAGE_CUR_LE_OR_EXTENDS */
332+
up_slot_match:
335333
up = mid;
336334
up_matched_fields = cur_matched_fields;
337335
up_matched_bytes = cur_matched_bytes;
336+
337+
} else if (mode == PAGE_CUR_G || mode == PAGE_CUR_LE
338+
#ifdef PAGE_CUR_LE_OR_EXTENDS
339+
|| mode == PAGE_CUR_LE_OR_EXTENDS
340+
#endif /* PAGE_CUR_LE_OR_EXTENDS */
341+
) {
342+
343+
goto low_slot_match;
344+
} else {
345+
346+
goto up_slot_match;
338347
}
339348
}
340349

@@ -360,32 +369,35 @@ page_cur_search_with_match(
360369
cmp = cmp_dtuple_rec_with_match(tuple, mid_rec, offsets,
361370
&cur_matched_fields,
362371
&cur_matched_bytes);
363-
if (cmp == 1) {
372+
if (UNIV_LIKELY(cmp > 0)) {
373+
low_rec_match:
364374
low_rec = mid_rec;
365375
low_matched_fields = cur_matched_fields;
366376
low_matched_bytes = cur_matched_bytes;
367377

368-
} else if (cmp == -1) {
378+
} else if (UNIV_LIKELY(cmp /* == -1 */)) {
379+
#ifdef PAGE_CUR_LE_OR_EXTENDS
369380
if (mode == PAGE_CUR_LE_OR_EXTENDS
370381
&& page_cur_rec_field_extends(tuple, mid_rec,
371382
offsets, cur_matched_fields)) {
372-
low_rec = mid_rec;
373-
low_matched_fields = cur_matched_fields;
374-
low_matched_bytes = cur_matched_bytes;
375-
} else {
376-
up_rec = mid_rec;
377-
up_matched_fields = cur_matched_fields;
378-
up_matched_bytes = cur_matched_bytes;
383+
384+
goto low_rec_match;
379385
}
380-
} else if (mode == PAGE_CUR_G || mode == PAGE_CUR_LE
381-
|| mode == PAGE_CUR_LE_OR_EXTENDS) {
382-
low_rec = mid_rec;
383-
low_matched_fields = cur_matched_fields;
384-
low_matched_bytes = cur_matched_bytes;
385-
} else {
386+
#endif /* PAGE_CUR_LE_OR_EXTENDS */
387+
up_rec_match:
386388
up_rec = mid_rec;
387389
up_matched_fields = cur_matched_fields;
388390
up_matched_bytes = cur_matched_bytes;
391+
} else if (mode == PAGE_CUR_G || mode == PAGE_CUR_LE
392+
#ifdef PAGE_CUR_LE_OR_EXTENDS
393+
|| mode == PAGE_CUR_LE_OR_EXTENDS
394+
#endif /* PAGE_CUR_LE_OR_EXTENDS */
395+
) {
396+
397+
goto low_rec_match;
398+
} else {
399+
400+
goto up_rec_match;
389401
}
390402
}
391403

0 commit comments

Comments
 (0)