63 cmp_debug_dtuple_rec_with_match(
71 ulint* matched_fields);
87 const unsigned char* a,
88 unsigned int a_length,
90 const unsigned char* b,
91 unsigned int b_length);
104 return((ulint) srv_latin1_ordering[code]);
116 ibool check_charsets)
119 if (dtype_is_non_binary_string_type(col1->
mtype, col1->
prtype)
120 && dtype_is_non_binary_string_type(col2->
mtype, col2->
prtype)) {
125 if (check_charsets) {
133 if (dtype_is_binary_string_type(col1->
mtype, col1->
prtype)
134 && dtype_is_binary_string_type(col2->
mtype, col2->
prtype)) {
146 if (col1->
mtype == DATA_INT
147 && (col1->
prtype & DATA_UNSIGNED)
148 != (col2->
prtype & DATA_UNSIGNED)) {
157 return(col1->
mtype != DATA_INT || col1->
len == col2->
len);
171 unsigned int a_length,
174 unsigned int b_length)
187 for (; a_length && *a ==
' '; a++, a_length--) {}
188 for (; b_length && *b ==
' '; b++, b_length--) {}
201 }
else if (*b ==
'-') {
206 while (a_length > 0 && (*a ==
'+' || *a ==
'0')) {
210 while (b_length > 0 && (*b ==
'+' || *b ==
'0')) {
214 if (a_length != b_length) {
215 if (a_length < b_length) {
222 while (a_length > 0 && *a == *b) {
224 a++; b++; a_length--;
243 }
else if (d_2 > d_1) {
255 }
else if (f_2 > f_1) {
261 if (prtype & DATA_BINARY_TYPE) {
265 " InnoDB: Error: comparing a binary BLOB"
266 " with a character set sensitive\n"
267 "InnoDB: comparison!\n");
273 (
int)(prtype & DATA_MYSQL_TYPE_MASK),
275 a, a_length, b, b_length));
278 "InnoDB: unknown type number %lu\n",
307 if (len1 == UNIV_SQL_NULL || len2 == UNIV_SQL_NULL) {
314 if (len1 == UNIV_SQL_NULL) {
324 if (mtype >= DATA_FLOAT
325 || (mtype == DATA_BLOB
326 && 0 == (prtype & DATA_BINARY_TYPE)
328 != DATA_MYSQL_LATIN1_SWEDISH_CHARSET_COLL)) {
330 return(cmp_whole_field(mtype, prtype,
331 data1, (
unsigned) len1,
332 data2, (
unsigned) len2));
340 if (len1 <= cur_bytes) {
341 if (len2 <= cur_bytes) {
348 if (data1_byte == ULINT_UNDEFINED) {
356 if (len2 <= cur_bytes) {
359 if (data2_byte == ULINT_UNDEFINED) {
367 if (data1_byte == data2_byte) {
374 if (mtype <= DATA_CHAR
375 || (mtype == DATA_BLOB
376 && 0 == (prtype & DATA_BINARY_TYPE))) {
378 data1_byte = cmp_collate(data1_byte);
379 data2_byte = cmp_collate(data2_byte);
382 if (data1_byte > data2_byte) {
385 }
else if (data1_byte < data2_byte) {
418 const ulint* offsets,
419 ulint* matched_fields,
422 ulint* matched_bytes)
430 const byte* dtuple_b_ptr;
435 const byte* rec_b_ptr;
444 ut_ad(dtuple && rec && matched_fields && matched_bytes);
448 cur_field = *matched_fields;
449 cur_bytes = *matched_bytes;
454 if (cur_bytes == 0 && cur_field == 0) {
459 if (UNIV_UNLIKELY(rec_info & REC_INFO_MIN_REC_FLAG)) {
460 ret = !(tup_info & REC_INFO_MIN_REC_FLAG);
462 }
else if (UNIV_UNLIKELY(tup_info & REC_INFO_MIN_REC_FLAG)) {
476 dtuple_field = dtuple_get_nth_field(dtuple, cur_field);
479 = dfield_get_type(dtuple_field);
487 rec_b_ptr = rec_get_nth_field(rec, offsets,
488 cur_field, &rec_f_len);
495 if (UNIV_LIKELY(cur_bytes == 0)) {
505 if (dtuple_f_len == UNIV_SQL_NULL) {
506 if (rec_f_len == UNIV_SQL_NULL) {
513 }
else if (rec_f_len == UNIV_SQL_NULL) {
523 if (mtype >= DATA_FLOAT
524 || (mtype == DATA_BLOB
525 && 0 == (prtype & DATA_BINARY_TYPE)
527 != DATA_MYSQL_LATIN1_SWEDISH_CHARSET_COLL)) {
529 ret = cmp_whole_field(mtype, prtype,
530 static_cast<const unsigned char *>(dfield_get_data(dtuple_field)),
531 (
unsigned) dtuple_f_len,
532 rec_b_ptr, (
unsigned) rec_f_len);
545 rec_b_ptr = rec_b_ptr + cur_bytes;
546 dtuple_b_ptr = (byte*)dfield_get_data(dtuple_field)
551 if (UNIV_UNLIKELY(rec_f_len <= cur_bytes)) {
552 if (dtuple_f_len <= cur_bytes) {
559 if (rec_byte == ULINT_UNDEFINED) {
565 rec_byte = *rec_b_ptr;
568 if (UNIV_UNLIKELY(dtuple_f_len <= cur_bytes)) {
572 if (dtuple_byte == ULINT_UNDEFINED) {
578 dtuple_byte = *dtuple_b_ptr;
581 if (dtuple_byte == rec_byte) {
589 if (mtype <= DATA_CHAR
590 || (mtype == DATA_BLOB
591 && !(prtype & DATA_BINARY_TYPE))) {
593 rec_byte = cmp_collate(rec_byte);
594 dtuple_byte = cmp_collate(dtuple_byte);
597 ret = (int) (dtuple_byte - rec_byte);
598 if (UNIV_LIKELY(ret)) {
619 ut_ad(cur_bytes == 0);
624 ut_ad((ret >= - 1) && (ret <= 1));
625 ut_ad(ret == cmp_debug_dtuple_rec_with_match(dtuple, rec, offsets,
627 ut_ad(*matched_fields == cur_field);
630 *matched_fields = cur_field;
631 *matched_bytes = cur_bytes;
646 const ulint* offsets)
648 ulint matched_fields = 0;
649 ulint matched_bytes = 0;
653 &matched_fields, &matched_bytes));
666 const ulint* offsets)
669 ulint matched_fields = 0;
670 ulint matched_bytes = 0;
681 &matched_fields, &matched_bytes);
682 if (matched_fields == n_fields) {
687 if (matched_fields == n_fields - 1
689 dtuple_get_nth_field(dtuple, n_fields - 1))) {
706 const ulint* offsets1,
707 const ulint* offsets2,
713 const byte* rec1_b_ptr;
718 const byte* rec2_b_ptr;
731 for (cur_field = 0; cur_field < n_uniq; cur_field++) {
748 rec1_b_ptr = rec_get_nth_field(rec1, offsets1,
749 cur_field, &rec1_f_len);
750 rec2_b_ptr = rec_get_nth_field(rec2, offsets2,
751 cur_field, &rec2_f_len);
753 if (rec1_f_len == UNIV_SQL_NULL
754 || rec2_f_len == UNIV_SQL_NULL) {
756 if (rec1_f_len == rec2_f_len) {
763 }
else if (rec2_f_len == UNIV_SQL_NULL) {
775 if (mtype >= DATA_FLOAT
776 || (mtype == DATA_BLOB
777 && 0 == (prtype & DATA_BINARY_TYPE)
779 != DATA_MYSQL_LATIN1_SWEDISH_CHARSET_COLL)) {
780 int ret = cmp_whole_field(mtype, prtype,
782 (
unsigned) rec1_f_len,
784 (
unsigned) rec2_f_len);
793 for (cur_bytes = 0;; cur_bytes++, rec1_b_ptr++, rec2_b_ptr++) {
794 if (rec2_f_len <= cur_bytes) {
796 if (rec1_f_len <= cur_bytes) {
803 if (rec2_byte == ULINT_UNDEFINED) {
807 rec2_byte = *rec2_b_ptr;
810 if (rec1_f_len <= cur_bytes) {
813 if (rec1_byte == ULINT_UNDEFINED) {
817 rec1_byte = *rec1_b_ptr;
820 if (rec1_byte == rec2_byte) {
828 if (mtype <= DATA_CHAR
829 || (mtype == DATA_BLOB
830 && !(prtype & DATA_BINARY_TYPE))) {
832 rec1_byte = cmp_collate(rec1_byte);
833 rec2_byte = cmp_collate(rec2_byte);
836 if (rec1_byte < rec2_byte) {
838 }
else if (rec1_byte > rec2_byte) {
861 const ulint* offsets1,
862 const ulint* offsets2,
868 ulint* matched_fields,
872 ulint* matched_bytes)
879 const byte* rec1_b_ptr;
885 const byte* rec2_b_ptr;
895 ut_ad(rec1 && rec2 && index);
904 cur_field = *matched_fields;
905 cur_bytes = *matched_bytes;
909 while ((cur_field < rec1_n_fields) && (cur_field < rec2_n_fields)) {
926 rec1_b_ptr = rec_get_nth_field(rec1, offsets1,
927 cur_field, &rec1_f_len);
928 rec2_b_ptr = rec_get_nth_field(rec2, offsets2,
929 cur_field, &rec2_f_len);
931 if (cur_bytes == 0) {
932 if (cur_field == 0) {
936 & REC_INFO_MIN_REC_FLAG)) {
939 & REC_INFO_MIN_REC_FLAG)) {
945 }
else if (UNIV_UNLIKELY
947 & REC_INFO_MIN_REC_FLAG)) {
963 if (rec1_f_len == UNIV_SQL_NULL
964 || rec2_f_len == UNIV_SQL_NULL) {
966 if (rec1_f_len == rec2_f_len) {
974 }
else if (rec2_f_len == UNIV_SQL_NULL) {
989 if (mtype >= DATA_FLOAT
990 || (mtype == DATA_BLOB
991 && 0 == (prtype & DATA_BINARY_TYPE)
993 != DATA_MYSQL_LATIN1_SWEDISH_CHARSET_COLL)) {
995 ret = cmp_whole_field(mtype, prtype,
997 (
unsigned) rec1_f_len,
999 (
unsigned) rec2_f_len);
1003 goto order_resolved;
1010 rec1_b_ptr = rec1_b_ptr + cur_bytes;
1011 rec2_b_ptr = rec2_b_ptr + cur_bytes;
1015 if (rec2_f_len <= cur_bytes) {
1017 if (rec1_f_len <= cur_bytes) {
1024 if (rec2_byte == ULINT_UNDEFINED) {
1027 goto order_resolved;
1030 rec2_byte = *rec2_b_ptr;
1033 if (rec1_f_len <= cur_bytes) {
1036 if (rec1_byte == ULINT_UNDEFINED) {
1039 goto order_resolved;
1042 rec1_byte = *rec1_b_ptr;
1045 if (rec1_byte == rec2_byte) {
1053 if (mtype <= DATA_CHAR
1054 || (mtype == DATA_BLOB
1055 && !(prtype & DATA_BINARY_TYPE))) {
1057 rec1_byte = cmp_collate(rec1_byte);
1058 rec2_byte = cmp_collate(rec2_byte);
1061 if (rec1_byte < rec2_byte) {
1063 goto order_resolved;
1064 }
else if (rec1_byte > rec2_byte) {
1066 goto order_resolved;
1081 ut_ad(cur_bytes == 0);
1088 ut_ad((ret >= - 1) && (ret <= 1));
1090 *matched_fields = cur_field;
1091 *matched_bytes = cur_bytes;
1107 cmp_debug_dtuple_rec_with_match(
1114 const ulint* offsets,
1115 ulint* matched_fields)
1123 const byte* dtuple_f_data;
1126 const byte* rec_f_data;
1130 ut_ad(dtuple && rec && matched_fields);
1137 cur_field = *matched_fields;
1139 if (cur_field == 0) {
1142 & REC_INFO_MIN_REC_FLAG)) {
1145 & REC_INFO_MIN_REC_FLAG);
1147 goto order_resolved;
1154 goto order_resolved;
1165 dtuple_field = dtuple_get_nth_field(dtuple, cur_field);
1168 = dfield_get_type(dtuple_field);
1170 mtype = type->
mtype;
1174 dtuple_f_data = dfield_get_data(dtuple_field);
1177 rec_f_data = rec_get_nth_field(rec, offsets,
1178 cur_field, &rec_f_len);
1185 goto order_resolved;
1188 ret =
cmp_data_data(mtype, prtype, dtuple_f_data, dtuple_f_len,
1189 rec_f_data, rec_f_len);
1191 goto order_resolved;
1200 ut_ad((ret >= - 1) && (ret <= 1));
1202 *matched_fields = cur_field;