#include "univ.i"#include "data0data.h"#include "data0type.h"#include "dict0dict.h"#include "rem0rec.h"Include dependency graph for rem0cmp.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Functions | |
| ibool | cmp_types_are_equal (dtype_t *type1, dtype_t *type2, ibool check_charsets) |
| UNIV_INLINE int | cmp_data_data (dtype_t *cur_type, byte *data1, ulint len1, byte *data2, ulint len2) |
| int | cmp_data_data_slow (dtype_t *cur_type, byte *data1, ulint len1, byte *data2, ulint len2) |
| UNIV_INLINE int | cmp_dfield_dfield (dfield_t *dfield1, dfield_t *dfield2) |
| int | cmp_dtuple_rec_with_match (dtuple_t *dtuple, rec_t *rec, const ulint *offsets, ulint *matched_fields, ulint *matched_bytes) |
| int | cmp_dtuple_rec (dtuple_t *dtuple, rec_t *rec, const ulint *offsets) |
| ibool | cmp_dtuple_is_prefix_of_rec (dtuple_t *dtuple, rec_t *rec, const ulint *offsets) |
| int | cmp_rec_rec_with_match (rec_t *rec1, rec_t *rec2, const ulint *offsets1, const ulint *offsets2, dict_index_t *index, ulint *matched_fields, ulint *matched_bytes) |
| UNIV_INLINE int | cmp_rec_rec (rec_t *rec1, rec_t *rec2, const ulint *offsets1, const ulint *offsets2, dict_index_t *index) |
| UNIV_INLINE int cmp_data_data | ( | dtype_t * | cur_type, | |
| byte * | data1, | |||
| ulint | len1, | |||
| byte * | data2, | |||
| ulint | len2 | |||
| ) |
Referenced by dict_load_foreigns(), and row_sel_sec_rec_is_for_clust_rec().
Here is the caller graph for this function:

Definition at line 288 of file rem0cmp.c.
References cmp_collate(), cmp_whole_field(), DATA_BINARY_TYPE, DATA_BLOB, DATA_CHAR, DATA_FLOAT, DATA_MYSQL_LATIN1_SWEDISH_CHARSET_COLL, dtype_get_charset_coll(), dtype_get_pad_char(), dtype_validate(), dtype_struct::mtype, dtype_struct::prtype, ut_ad, and ut_error.
00290 : 1, 0, -1, if data1 is greater, equal, 00291 less than data2, respectively */ 00292 dtype_t* cur_type,/* in: data type of the fields */ 00293 byte* data1, /* in: data field (== a pointer to a memory 00294 buffer) */ 00295 ulint len1, /* in: data field length or UNIV_SQL_NULL */ 00296 byte* data2, /* in: data field (== a pointer to a memory 00297 buffer) */ 00298 ulint len2) /* in: data field length or UNIV_SQL_NULL */ 00299 { 00300 #ifndef UNIV_HOTBACKUP 00301 ulint data1_byte; 00302 ulint data2_byte; 00303 ulint cur_bytes; 00304 00305 ut_ad(dtype_validate(cur_type)); 00306 00307 if (len1 == UNIV_SQL_NULL || len2 == UNIV_SQL_NULL) { 00308 00309 if (len1 == len2) { 00310 00311 return(0); 00312 } 00313 00314 if (len1 == UNIV_SQL_NULL) { 00315 /* We define the SQL null to be the smallest possible 00316 value of a field in the alphabetical order */ 00317 00318 return(-1); 00319 } 00320 00321 return(1); 00322 } 00323 00324 if (cur_type->mtype >= DATA_FLOAT 00325 || (cur_type->mtype == DATA_BLOB 00326 && 0 == (cur_type->prtype & DATA_BINARY_TYPE) 00327 && dtype_get_charset_coll(cur_type->prtype) != 00328 DATA_MYSQL_LATIN1_SWEDISH_CHARSET_COLL)) { 00329 00330 return(cmp_whole_field(cur_type, 00331 data1, (unsigned) len1, 00332 data2, (unsigned) len2)); 00333 } 00334 00335 /* Compare then the fields */ 00336 00337 cur_bytes = 0; 00338 00339 for (;;) { 00340 if (len1 <= cur_bytes) { 00341 if (len2 <= cur_bytes) { 00342 00343 return(0); 00344 } 00345 00346 data1_byte = dtype_get_pad_char(cur_type); 00347 00348 if (data1_byte == ULINT_UNDEFINED) { 00349 00350 return(-1); 00351 } 00352 } else { 00353 data1_byte = *data1; 00354 } 00355 00356 if (len2 <= cur_bytes) { 00357 data2_byte = dtype_get_pad_char(cur_type); 00358 00359 if (data2_byte == ULINT_UNDEFINED) { 00360 00361 return(1); 00362 } 00363 } else { 00364 data2_byte = *data2; 00365 } 00366 00367 if (data1_byte == data2_byte) { 00368 /* If the bytes are equal, they will remain such even 00369 after the collation transformation below */ 00370 00371 goto next_byte; 00372 } 00373 00374 if (cur_type->mtype <= DATA_CHAR 00375 || (cur_type->mtype == DATA_BLOB 00376 && 0 == (cur_type->prtype & DATA_BINARY_TYPE))) { 00377 00378 data1_byte = cmp_collate(data1_byte); 00379 data2_byte = cmp_collate(data2_byte); 00380 } 00381 00382 if (data1_byte > data2_byte) { 00383 00384 return(1); 00385 } else if (data1_byte < data2_byte) { 00386 00387 return(-1); 00388 } 00389 next_byte: 00390 /* Next byte */ 00391 cur_bytes++; 00392 data1++; 00393 data2++; 00394 } 00395 #else /* !UNIV_HOTBACKUP */ 00396 /* This function depends on MySQL code that is not included in 00397 InnoDB Hot Backup builds. Besides, this function should never 00398 be called in InnoDB Hot Backup. */ 00399 ut_error; 00400 #endif /* !UNIV_HOTBACKUP */ 00401 00402 return(0); /* Not reached */ 00403 }
Here is the call graph for this function:

Referenced by dtuple_datas_are_ordering_equal(), and eval_cmp().
Here is the caller graph for this function:

Definition at line 673 of file rem0cmp.c.
References cmp_dtuple_rec_with_match(), dfield_get_len(), dtuple_get_n_fields(), dtuple_get_nth_field(), FALSE, NULL, rec_offs_n_fields(), rec_offs_validate(), TRUE, and ut_ad.
Referenced by row_search_for_mysql().
00675 : TRUE if prefix */ 00676 dtuple_t* dtuple, /* in: data tuple */ 00677 rec_t* rec, /* in: physical record */ 00678 const ulint* offsets)/* in: array returned by rec_get_offsets() */ 00679 { 00680 ulint n_fields; 00681 ulint matched_fields = 0; 00682 ulint matched_bytes = 0; 00683 00684 ut_ad(rec_offs_validate(rec, NULL, offsets)); 00685 n_fields = dtuple_get_n_fields(dtuple); 00686 00687 if (n_fields > rec_offs_n_fields(offsets)) { 00688 00689 return(FALSE); 00690 } 00691 00692 cmp_dtuple_rec_with_match(dtuple, rec, offsets, 00693 &matched_fields, &matched_bytes); 00694 if (matched_fields == n_fields) { 00695 00696 return(TRUE); 00697 } 00698 00699 if (matched_fields == n_fields - 1 00700 && matched_bytes == dfield_get_len( 00701 dtuple_get_nth_field(dtuple, n_fields - 1))) { 00702 return(TRUE); 00703 } 00704 00705 return(FALSE); 00706 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 651 of file rem0cmp.c.
References cmp_dtuple_rec_with_match(), NULL, rec_offs_validate(), and ut_ad.
Referenced by btr_page_insert_fits(), btr_page_split_and_insert(), btr_pcur_restore_position(), btr_validate_level(), row_ins_scan_sec_index_for_duplicate(), row_search_for_mysql(), and row_vers_impl_x_locked_off_kernel().
00653 : 1, 0, -1, if dtuple is greater, equal, 00654 less than rec, respectively; see the comments 00655 for cmp_dtuple_rec_with_match */ 00656 dtuple_t* dtuple, /* in: data tuple */ 00657 rec_t* rec, /* in: physical record */ 00658 const ulint* offsets)/* in: array returned by rec_get_offsets() */ 00659 { 00660 ulint matched_fields = 0; 00661 ulint matched_bytes = 0; 00662 00663 ut_ad(rec_offs_validate(rec, NULL, offsets)); 00664 return(cmp_dtuple_rec_with_match(dtuple, rec, offsets, 00665 &matched_fields, &matched_bytes)); 00666 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int cmp_dtuple_rec_with_match | ( | dtuple_t * | dtuple, | |
| rec_t * | rec, | |||
| const ulint * | offsets, | |||
| ulint * | matched_fields, | |||
| ulint * | matched_bytes | |||
| ) |
Definition at line 415 of file rem0cmp.c.
References cmp_collate(), cmp_whole_field(), DATA_BINARY_TYPE, DATA_BLOB, DATA_CHAR, DATA_FLOAT, DATA_MYSQL_LATIN1_SWEDISH_CHARSET_COLL, dfield_get_data(), dfield_get_len(), dfield_get_type(), dtuple_check_typed(), dtuple_get_info_bits(), dtuple_get_n_fields_cmp(), dtuple_get_nth_field(), dtype_get_charset_coll(), dtype_get_pad_char(), dtype_struct::mtype, NULL, dtype_struct::prtype, rec_get_info_bits(), rec_get_nth_field(), REC_INFO_MIN_REC_FLAG, rec_offs_comp(), rec_offs_n_fields(), rec_offs_nth_extern(), rec_offs_validate(), ut_ad, and ut_error.
Referenced by cmp_dtuple_is_prefix_of_rec(), cmp_dtuple_rec(), page_cur_search_with_match(), row_ins_dupl_error_with_rec(), and row_scan_and_check_index().
00417 : 1, 0, -1, if dtuple is greater, equal, 00418 less than rec, respectively, when only the 00419 common first fields are compared, or 00420 until the first externally stored field in 00421 rec */ 00422 dtuple_t* dtuple, /* in: data tuple */ 00423 rec_t* rec, /* in: physical record which differs from 00424 dtuple in some of the common fields, or which 00425 has an equal number or more fields than 00426 dtuple */ 00427 const ulint* offsets,/* in: array returned by rec_get_offsets() */ 00428 ulint* matched_fields, /* in/out: number of already completely 00429 matched fields; when function returns, 00430 contains the value for current comparison */ 00431 ulint* matched_bytes) /* in/out: number of already matched 00432 bytes within the first field not completely 00433 matched; when function returns, contains the 00434 value for current comparison */ 00435 { 00436 #ifndef UNIV_HOTBACKUP 00437 dtype_t* cur_type; /* pointer to type of the current 00438 field in dtuple */ 00439 dfield_t* dtuple_field; /* current field in logical record */ 00440 ulint dtuple_f_len; /* the length of the current field 00441 in the logical record */ 00442 byte* dtuple_b_ptr; /* pointer to the current byte in 00443 logical field data */ 00444 ulint dtuple_byte; /* value of current byte to be compared 00445 in dtuple*/ 00446 ulint rec_f_len; /* length of current field in rec */ 00447 byte* rec_b_ptr; /* pointer to the current byte in 00448 rec field */ 00449 ulint rec_byte; /* value of current byte to be 00450 compared in rec */ 00451 ulint cur_field; /* current field number */ 00452 ulint cur_bytes; /* number of already matched bytes 00453 in current field */ 00454 int ret = 3333; /* return value */ 00455 00456 ut_ad(dtuple && rec && matched_fields && matched_bytes); 00457 ut_ad(dtuple_check_typed(dtuple)); 00458 ut_ad(rec_offs_validate(rec, NULL, offsets)); 00459 00460 cur_field = *matched_fields; 00461 cur_bytes = *matched_bytes; 00462 00463 ut_ad(cur_field <= dtuple_get_n_fields_cmp(dtuple)); 00464 ut_ad(cur_field <= rec_offs_n_fields(offsets)); 00465 00466 if (cur_bytes == 0 && cur_field == 0) { 00467 ulint rec_info = rec_get_info_bits(rec, 00468 rec_offs_comp(offsets)); 00469 ulint tup_info = dtuple_get_info_bits(dtuple); 00470 00471 if (rec_info & REC_INFO_MIN_REC_FLAG) { 00472 ret = !(tup_info & REC_INFO_MIN_REC_FLAG); 00473 goto order_resolved; 00474 } else if (tup_info & REC_INFO_MIN_REC_FLAG) { 00475 ret = -1; 00476 goto order_resolved; 00477 } 00478 } 00479 00480 /* Match fields in a loop; stop if we run out of fields in dtuple 00481 or find an externally stored field */ 00482 00483 while (cur_field < dtuple_get_n_fields_cmp(dtuple)) { 00484 00485 dtuple_field = dtuple_get_nth_field(dtuple, cur_field); 00486 cur_type = dfield_get_type(dtuple_field); 00487 00488 dtuple_f_len = dfield_get_len(dtuple_field); 00489 00490 rec_b_ptr = rec_get_nth_field(rec, offsets, 00491 cur_field, &rec_f_len); 00492 00493 /* If we have matched yet 0 bytes, it may be that one or 00494 both the fields are SQL null, or the record or dtuple may be 00495 the predefined minimum record, or the field is externally 00496 stored */ 00497 00498 if (UNIV_LIKELY(cur_bytes == 0)) { 00499 if (rec_offs_nth_extern(offsets, cur_field)) { 00500 /* We do not compare to an externally 00501 stored field */ 00502 00503 ret = 0; 00504 00505 goto order_resolved; 00506 } 00507 00508 if (dtuple_f_len == UNIV_SQL_NULL) { 00509 if (rec_f_len == UNIV_SQL_NULL) { 00510 00511 goto next_field; 00512 } 00513 00514 ret = -1; 00515 goto order_resolved; 00516 } else if (rec_f_len == UNIV_SQL_NULL) { 00517 /* We define the SQL null to be the 00518 smallest possible value of a field 00519 in the alphabetical order */ 00520 00521 ret = 1; 00522 goto order_resolved; 00523 } 00524 } 00525 00526 if (cur_type->mtype >= DATA_FLOAT 00527 || (cur_type->mtype == DATA_BLOB 00528 && 0 == (cur_type->prtype & DATA_BINARY_TYPE) 00529 && dtype_get_charset_coll(cur_type->prtype) != 00530 DATA_MYSQL_LATIN1_SWEDISH_CHARSET_COLL)) { 00531 00532 ret = cmp_whole_field( 00533 cur_type, 00534 dfield_get_data(dtuple_field), 00535 (unsigned) dtuple_f_len, 00536 rec_b_ptr, (unsigned) rec_f_len); 00537 00538 if (ret != 0) { 00539 cur_bytes = 0; 00540 00541 goto order_resolved; 00542 } else { 00543 goto next_field; 00544 } 00545 } 00546 00547 /* Set the pointers at the current byte */ 00548 00549 rec_b_ptr = rec_b_ptr + cur_bytes; 00550 dtuple_b_ptr = (byte*)dfield_get_data(dtuple_field) 00551 + cur_bytes; 00552 /* Compare then the fields */ 00553 00554 for (;;) { 00555 if (UNIV_UNLIKELY(rec_f_len <= cur_bytes)) { 00556 if (dtuple_f_len <= cur_bytes) { 00557 00558 goto next_field; 00559 } 00560 00561 rec_byte = dtype_get_pad_char(cur_type); 00562 00563 if (rec_byte == ULINT_UNDEFINED) { 00564 ret = 1; 00565 00566 goto order_resolved; 00567 } 00568 } else { 00569 rec_byte = *rec_b_ptr; 00570 } 00571 00572 if (UNIV_UNLIKELY(dtuple_f_len <= cur_bytes)) { 00573 dtuple_byte = dtype_get_pad_char(cur_type); 00574 00575 if (dtuple_byte == ULINT_UNDEFINED) { 00576 ret = -1; 00577 00578 goto order_resolved; 00579 } 00580 } else { 00581 dtuple_byte = *dtuple_b_ptr; 00582 } 00583 00584 if (dtuple_byte == rec_byte) { 00585 /* If the bytes are equal, they will 00586 remain such even after the collation 00587 transformation below */ 00588 00589 goto next_byte; 00590 } 00591 00592 if (cur_type->mtype <= DATA_CHAR 00593 || (cur_type->mtype == DATA_BLOB 00594 && 0 == 00595 (cur_type->prtype & DATA_BINARY_TYPE))) { 00596 00597 rec_byte = cmp_collate(rec_byte); 00598 dtuple_byte = cmp_collate(dtuple_byte); 00599 } 00600 00601 ret = dtuple_byte - rec_byte; 00602 if (UNIV_UNLIKELY(ret)) { 00603 if (ret < 0) { 00604 ret = -1; 00605 goto order_resolved; 00606 } else { 00607 ret = 1; 00608 goto order_resolved; 00609 } 00610 } 00611 next_byte: 00612 /* Next byte */ 00613 cur_bytes++; 00614 rec_b_ptr++; 00615 dtuple_b_ptr++; 00616 } 00617 00618 next_field: 00619 cur_field++; 00620 cur_bytes = 0; 00621 } 00622 00623 ut_ad(cur_bytes == 0); 00624 00625 ret = 0; /* If we ran out of fields, dtuple was equal to rec 00626 up to the common fields */ 00627 order_resolved: 00628 ut_ad((ret >= - 1) && (ret <= 1)); 00629 ut_ad(ret == cmp_debug_dtuple_rec_with_match(dtuple, rec, offsets, 00630 matched_fields)); 00631 ut_ad(*matched_fields == cur_field); /* In the debug version, the 00632 above cmp_debug_... sets 00633 *matched_fields to a value */ 00634 *matched_fields = cur_field; 00635 *matched_bytes = cur_bytes; 00636 00637 return(ret); 00638 #else /* !UNIV_HOTBACKUP */ 00639 /* This function depends on MySQL code that is not included in 00640 InnoDB Hot Backup builds. Besides, this function should never 00641 be called in InnoDB Hot Backup. */ 00642 ut_error; 00643 return(0); 00644 #endif /* !UNIV_HOTBACKUP */ 00645 }
Here is the call graph for this function:

Here is the caller graph for this function:

| UNIV_INLINE int cmp_rec_rec | ( | rec_t * | rec1, | |
| rec_t * | rec2, | |||
| const ulint * | offsets1, | |||
| const ulint * | offsets2, | |||
| dict_index_t * | index | |||
| ) |
Referenced by btr_pcur_restore_position(), btr_validate_level(), and page_validate().
Here is the caller graph for this function:

| int cmp_rec_rec_with_match | ( | rec_t * | rec1, | |
| rec_t * | rec2, | |||
| const ulint * | offsets1, | |||
| const ulint * | offsets2, | |||
| dict_index_t * | index, | |||
| ulint * | matched_fields, | |||
| ulint * | matched_bytes | |||
| ) |
Definition at line 714 of file rem0cmp.c.
References cmp_collate(), cmp_whole_field(), DATA_BINARY_TYPE, DATA_BLOB, DATA_CHAR, DATA_FLOAT, DATA_MYSQL_LATIN1_SWEDISH_CHARSET_COLL, dict_col_get_type(), dict_field_get_col(), dict_index_get_nth_field(), DICT_UNIVERSAL, dtype_binary, dtype_get_charset_coll(), dtype_get_pad_char(), index(), dtype_struct::mtype, dtype_struct::prtype, rec_get_info_bits(), rec_get_nth_field(), REC_INFO_MIN_REC_FLAG, rec_offs_comp(), rec_offs_n_fields(), rec_offs_nth_extern(), rec_offs_validate(), ut_ad, and ut_error.
Referenced by btr_estimate_number_of_different_key_vals().
00716 : 1, 0 , -1 if rec1 is greater, equal, 00717 less, respectively, than rec2; only the common 00718 first fields are compared */ 00719 rec_t* rec1, /* in: physical record */ 00720 rec_t* rec2, /* in: physical record */ 00721 const ulint* offsets1,/* in: rec_get_offsets(rec1, index) */ 00722 const ulint* offsets2,/* in: rec_get_offsets(rec2, index) */ 00723 dict_index_t* index, /* in: data dictionary index */ 00724 ulint* matched_fields, /* in/out: number of already completely 00725 matched fields; when the function returns, 00726 contains the value the for current 00727 comparison */ 00728 ulint* matched_bytes) /* in/out: number of already matched 00729 bytes within the first field not completely 00730 matched; when the function returns, contains 00731 the value for the current comparison */ 00732 { 00733 #ifndef UNIV_HOTBACKUP 00734 dtype_t* cur_type; /* pointer to type struct of the 00735 current field in index */ 00736 ulint rec1_n_fields; /* the number of fields in rec */ 00737 ulint rec1_f_len; /* length of current field in rec */ 00738 byte* rec1_b_ptr; /* pointer to the current byte in rec field */ 00739 ulint rec1_byte; /* value of current byte to be compared in 00740 rec */ 00741 ulint rec2_n_fields; /* the number of fields in rec */ 00742 ulint rec2_f_len; /* length of current field in rec */ 00743 byte* rec2_b_ptr; /* pointer to the current byte in rec field */ 00744 ulint rec2_byte; /* value of current byte to be compared in 00745 rec */ 00746 ulint cur_field; /* current field number */ 00747 ulint cur_bytes; /* number of already matched bytes in current 00748 field */ 00749 int ret = 3333; /* return value */ 00750 ulint comp; 00751 00752 ut_ad(rec1 && rec2 && index); 00753 ut_ad(rec_offs_validate(rec1, index, offsets1)); 00754 ut_ad(rec_offs_validate(rec2, index, offsets2)); 00755 ut_ad(rec_offs_comp(offsets1) == rec_offs_comp(offsets2)); 00756 00757 comp = rec_offs_comp(offsets1); 00758 rec1_n_fields = rec_offs_n_fields(offsets1); 00759 rec2_n_fields = rec_offs_n_fields(offsets2); 00760 00761 cur_field = *matched_fields; 00762 cur_bytes = *matched_bytes; 00763 00764 /* Match fields in a loop */ 00765 00766 while ((cur_field < rec1_n_fields) && (cur_field < rec2_n_fields)) { 00767 00768 if (index->type & DICT_UNIVERSAL) { 00769 cur_type = dtype_binary; 00770 } else { 00771 cur_type = dict_col_get_type( 00772 dict_field_get_col( 00773 dict_index_get_nth_field(index, cur_field))); 00774 } 00775 00776 rec1_b_ptr = rec_get_nth_field(rec1, offsets1, 00777 cur_field, &rec1_f_len); 00778 rec2_b_ptr = rec_get_nth_field(rec2, offsets2, 00779 cur_field, &rec2_f_len); 00780 00781 if (cur_bytes == 0) { 00782 if (cur_field == 0) { 00783 /* Test if rec is the predefined minimum 00784 record */ 00785 if (rec_get_info_bits(rec1, comp) 00786 & REC_INFO_MIN_REC_FLAG) { 00787 00788 if (rec_get_info_bits(rec2, comp) 00789 & REC_INFO_MIN_REC_FLAG) { 00790 ret = 0; 00791 } else { 00792 ret = -1; 00793 } 00794 00795 goto order_resolved; 00796 00797 } else if (rec_get_info_bits(rec2, comp) 00798 & REC_INFO_MIN_REC_FLAG) { 00799 00800 ret = 1; 00801 00802 goto order_resolved; 00803 } 00804 } 00805 00806 if (rec_offs_nth_extern(offsets1, cur_field) 00807 || rec_offs_nth_extern(offsets2, cur_field)) { 00808 /* We do not compare to an externally 00809 stored field */ 00810 00811 ret = 0; 00812 00813 goto order_resolved; 00814 } 00815 00816 if (rec1_f_len == UNIV_SQL_NULL 00817 || rec2_f_len == UNIV_SQL_NULL) { 00818 00819 if (rec1_f_len == rec2_f_len) { 00820 00821 goto next_field; 00822 00823 } else if (rec2_f_len == UNIV_SQL_NULL) { 00824 00825 /* We define the SQL null to be the 00826 smallest possible value of a field 00827 in the alphabetical order */ 00828 00829 ret = 1; 00830 } else { 00831 ret = -1; 00832 } 00833 00834 goto order_resolved; 00835 } 00836 } 00837 00838 if (cur_type->mtype >= DATA_FLOAT 00839 || (cur_type->mtype == DATA_BLOB 00840 && 0 == (cur_type->prtype & DATA_BINARY_TYPE) 00841 && dtype_get_charset_coll(cur_type->prtype) != 00842 DATA_MYSQL_LATIN1_SWEDISH_CHARSET_COLL)) { 00843 00844 ret = cmp_whole_field(cur_type, 00845 rec1_b_ptr, (unsigned) rec1_f_len, 00846 rec2_b_ptr, (unsigned) rec2_f_len); 00847 if (ret != 0) { 00848 cur_bytes = 0; 00849 00850 goto order_resolved; 00851 } else { 00852 goto next_field; 00853 } 00854 } 00855 00856 /* Set the pointers at the current byte */ 00857 rec1_b_ptr = rec1_b_ptr + cur_bytes; 00858 rec2_b_ptr = rec2_b_ptr + cur_bytes; 00859 00860 /* Compare then the fields */ 00861 for (;;) { 00862 if (rec2_f_len <= cur_bytes) { 00863 00864 if (rec1_f_len <= cur_bytes) { 00865 00866 goto next_field; 00867 } 00868 00869 rec2_byte = dtype_get_pad_char(cur_type); 00870 00871 if (rec2_byte == ULINT_UNDEFINED) { 00872 ret = 1; 00873 00874 goto order_resolved; 00875 } 00876 } else { 00877 rec2_byte = *rec2_b_ptr; 00878 } 00879 00880 if (rec1_f_len <= cur_bytes) { 00881 rec1_byte = dtype_get_pad_char(cur_type); 00882 00883 if (rec1_byte == ULINT_UNDEFINED) { 00884 ret = -1; 00885 00886 goto order_resolved; 00887 } 00888 } else { 00889 rec1_byte = *rec1_b_ptr; 00890 } 00891 00892 if (rec1_byte == rec2_byte) { 00893 /* If the bytes are equal, they will remain 00894 such even after the collation transformation 00895 below */ 00896 00897 goto next_byte; 00898 } 00899 00900 if (cur_type->mtype <= DATA_CHAR 00901 || (cur_type->mtype == DATA_BLOB 00902 && 0 == 00903 (cur_type->prtype & DATA_BINARY_TYPE))) { 00904 00905 rec1_byte = cmp_collate(rec1_byte); 00906 rec2_byte = cmp_collate(rec2_byte); 00907 } 00908 00909 if (rec1_byte < rec2_byte) { 00910 ret = -1; 00911 goto order_resolved; 00912 } else if (rec1_byte > rec2_byte) { 00913 ret = 1; 00914 goto order_resolved; 00915 } 00916 next_byte: 00917 /* Next byte */ 00918 00919 cur_bytes++; 00920 rec1_b_ptr++; 00921 rec2_b_ptr++; 00922 } 00923 00924 next_field: 00925 cur_field++; 00926 cur_bytes = 0; 00927 } 00928 00929 ut_ad(cur_bytes == 0); 00930 00931 ret = 0; /* If we ran out of fields, rec1 was equal to rec2 up 00932 to the common fields */ 00933 order_resolved: 00934 00935 ut_ad((ret >= - 1) && (ret <= 1)); 00936 00937 *matched_fields = cur_field; 00938 *matched_bytes = cur_bytes; 00939 00940 return(ret); 00941 #else /* !UNIV_HOTBACKUP */ 00942 /* This function depends on MySQL code that is not included in 00943 InnoDB Hot Backup builds. Besides, this function should never 00944 be called in InnoDB Hot Backup. */ 00945 ut_error; 00946 return(0); 00947 #endif /* !UNIV_HOTBACKUP */ 00948 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 98 of file rem0cmp.c.
References DATA_INT, DATA_UNSIGNED, dtype_get_charset_coll(), dtype_is_binary_string_type(), dtype_is_non_binary_string_type(), FALSE, dtype_struct::len, dtype_struct::mtype, dtype_struct::prtype, and TRUE.
Referenced by dict_foreign_find_index().
00100 : TRUE if the types are considered 00101 equal in comparisons */ 00102 dtype_t* type1, /* in: type 1 */ 00103 dtype_t* type2, /* in: type 2 */ 00104 ibool check_charsets) /* in: whether to check charsets */ 00105 { 00106 if (dtype_is_non_binary_string_type(type1->mtype, type1->prtype) 00107 && dtype_is_non_binary_string_type(type2->mtype, type2->prtype)) { 00108 00109 /* Both are non-binary string types: they can be compared if 00110 and only if the charset-collation is the same */ 00111 00112 if (check_charsets) { 00113 return(dtype_get_charset_coll(type1->prtype) 00114 == dtype_get_charset_coll(type2->prtype)); 00115 } else { 00116 return(TRUE); 00117 } 00118 } 00119 00120 if (dtype_is_binary_string_type(type1->mtype, type1->prtype) 00121 && dtype_is_binary_string_type(type2->mtype, type2->prtype)) { 00122 00123 /* Both are binary string types: they can be compared */ 00124 00125 return(TRUE); 00126 } 00127 00128 if (type1->mtype != type2->mtype) { 00129 00130 return(FALSE); 00131 } 00132 00133 if (type1->mtype == DATA_INT 00134 && (type1->prtype & DATA_UNSIGNED) 00135 != (type2->prtype & DATA_UNSIGNED)) { 00136 00137 /* The storage format of an unsigned integer is different 00138 from a signed integer: in a signed integer we OR 00139 0x8000... to the value of positive integers. */ 00140 00141 return(FALSE); 00142 } 00143 00144 if (type1->mtype == DATA_INT && type1->len != type2->len) { 00145 00146 return(FALSE); 00147 } 00148 00149 return(TRUE); 00150 }
Here is the call graph for this function:

Here is the caller graph for this function:

1.4.7

