@@ -47,7 +47,6 @@ page_cur_try_search_shortcut(
47
47
not yet completely matched */
48
48
page_cur_t * cursor ) /* out: page cursor */
49
49
{
50
- int cmp ;
51
50
rec_t * rec ;
52
51
rec_t * next_rec ;
53
52
ulint low_match ;
@@ -79,19 +78,17 @@ page_cur_try_search_shortcut(
79
78
up_match = low_match ;
80
79
up_bytes = low_bytes ;
81
80
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 ) {
85
83
goto exit_func ;
86
84
}
87
85
88
86
next_rec = page_rec_get_next (rec );
89
87
offsets = rec_get_offsets (next_rec , index , offsets ,
90
88
dtuple_get_n_fields (tuple ), & heap );
91
89
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 ) {
95
92
goto exit_func ;
96
93
}
97
94
@@ -115,7 +112,7 @@ page_cur_try_search_shortcut(
115
112
ut_a (* ilow_matched_fields == low_match );
116
113
ut_a (* ilow_matched_bytes == low_bytes );
117
114
#endif
118
- if (next_rec != page_get_supremum_rec ( page )) {
115
+ if (! page_rec_is_supremum ( next_rec )) {
119
116
120
117
* iup_matched_fields = up_match ;
121
118
* iup_matched_bytes = up_bytes ;
@@ -137,6 +134,7 @@ page_cur_try_search_shortcut(
137
134
138
135
#endif
139
136
137
+ #ifdef PAGE_CUR_LE_OR_EXTENDS
140
138
/********************************************************************
141
139
Checks if the nth field in a record is a character type field which extends
142
140
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(
185
183
186
184
return (FALSE);
187
185
}
186
+ #endif /* PAGE_CUR_LE_OR_EXTENDS */
188
187
189
188
/********************************************************************
190
189
Searches the right position for a page cursor. */
@@ -240,9 +239,14 @@ page_cur_search_with_match(
240
239
ut_ad (dtuple_validate (tuple ));
241
240
ut_ad (dtuple_check_typed (tuple ));
242
241
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
+
246
250
page_check_dir (page );
247
251
248
252
#ifdef PAGE_CUR_ADAPT
@@ -261,16 +265,18 @@ page_cur_search_with_match(
261
265
return ;
262
266
}
263
267
}
264
- /*# ifdef UNIV_SEARCH_DEBUG */
268
+ # ifdef PAGE_CUR_DBG
265
269
if (mode == PAGE_CUR_DBG ) {
266
270
mode = PAGE_CUR_LE ;
267
271
}
268
- /*#endif */
272
+ # endif
269
273
#endif
270
274
271
275
/* The following flag does not work for non-latin1 char sets because
272
276
cmp_full_field does not tell how many bytes matched */
277
+ #ifdef PAGE_CUR_LE_OR_EXTENDS
273
278
ut_a (mode != PAGE_CUR_LE_OR_EXTENDS );
279
+ #endif /* PAGE_CUR_LE_OR_EXTENDS */
274
280
275
281
/* If mode PAGE_CUR_G is specified, we are trying to position the
276
282
cursor to answer a query of the form "tuple < X", where tuple is
@@ -308,33 +314,36 @@ page_cur_search_with_match(
308
314
cmp = cmp_dtuple_rec_with_match (tuple , mid_rec , offsets ,
309
315
& cur_matched_fields ,
310
316
& cur_matched_bytes );
311
- if (cmp == 1 ) {
317
+ if (UNIV_LIKELY (cmp > 0 )) {
318
+ low_slot_match :
312
319
low = mid ;
313
320
low_matched_fields = cur_matched_fields ;
314
321
low_matched_bytes = cur_matched_bytes ;
315
322
316
- } else if (cmp == -1 ) {
323
+ } else if (UNIV_LIKELY (cmp /* == -1 */ )) {
324
+ #ifdef PAGE_CUR_LE_OR_EXTENDS
317
325
if (mode == PAGE_CUR_LE_OR_EXTENDS
318
326
&& page_cur_rec_field_extends (tuple , mid_rec ,
319
327
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
- }
328
328
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 :
335
333
up = mid ;
336
334
up_matched_fields = cur_matched_fields ;
337
335
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 ;
338
347
}
339
348
}
340
349
@@ -360,32 +369,35 @@ page_cur_search_with_match(
360
369
cmp = cmp_dtuple_rec_with_match (tuple , mid_rec , offsets ,
361
370
& cur_matched_fields ,
362
371
& cur_matched_bytes );
363
- if (cmp == 1 ) {
372
+ if (UNIV_LIKELY (cmp > 0 )) {
373
+ low_rec_match :
364
374
low_rec = mid_rec ;
365
375
low_matched_fields = cur_matched_fields ;
366
376
low_matched_bytes = cur_matched_bytes ;
367
377
368
- } else if (cmp == -1 ) {
378
+ } else if (UNIV_LIKELY (cmp /* == -1 */ )) {
379
+ #ifdef PAGE_CUR_LE_OR_EXTENDS
369
380
if (mode == PAGE_CUR_LE_OR_EXTENDS
370
381
&& page_cur_rec_field_extends (tuple , mid_rec ,
371
382
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 ;
379
385
}
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 :
386
388
up_rec = mid_rec ;
387
389
up_matched_fields = cur_matched_fields ;
388
390
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 ;
389
401
}
390
402
}
391
403
0 commit comments