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,
864 ulint* matched_fields,
868 ulint* matched_bytes)
875 const byte* rec1_b_ptr;
881 const byte* rec2_b_ptr;
891 ut_ad(rec1 && rec2 && index);
900 cur_field = *matched_fields;
901 cur_bytes = *matched_bytes;
905 while ((cur_field < rec1_n_fields) && (cur_field < rec2_n_fields)) {
922 rec1_b_ptr = rec_get_nth_field(rec1, offsets1,
923 cur_field, &rec1_f_len);
924 rec2_b_ptr = rec_get_nth_field(rec2, offsets2,
925 cur_field, &rec2_f_len);
927 if (cur_bytes == 0) {
928 if (cur_field == 0) {
932 & REC_INFO_MIN_REC_FLAG)) {
935 & REC_INFO_MIN_REC_FLAG)) {
941 }
else if (UNIV_UNLIKELY
943 & REC_INFO_MIN_REC_FLAG)) {
959 if (rec1_f_len == UNIV_SQL_NULL
960 || rec2_f_len == UNIV_SQL_NULL) {
962 if (rec1_f_len == rec2_f_len) {
966 }
else if (rec2_f_len == UNIV_SQL_NULL) {
981 if (mtype >= DATA_FLOAT
982 || (mtype == DATA_BLOB
983 && 0 == (prtype & DATA_BINARY_TYPE)
985 != DATA_MYSQL_LATIN1_SWEDISH_CHARSET_COLL)) {
987 ret = cmp_whole_field(mtype, prtype,
989 (
unsigned) rec1_f_len,
991 (
unsigned) rec2_f_len);
1002 rec1_b_ptr = rec1_b_ptr + cur_bytes;
1003 rec2_b_ptr = rec2_b_ptr + cur_bytes;
1007 if (rec2_f_len <= cur_bytes) {
1009 if (rec1_f_len <= cur_bytes) {
1016 if (rec2_byte == ULINT_UNDEFINED) {
1019 goto order_resolved;
1022 rec2_byte = *rec2_b_ptr;
1025 if (rec1_f_len <= cur_bytes) {
1028 if (rec1_byte == ULINT_UNDEFINED) {
1031 goto order_resolved;
1034 rec1_byte = *rec1_b_ptr;
1037 if (rec1_byte == rec2_byte) {
1045 if (mtype <= DATA_CHAR
1046 || (mtype == DATA_BLOB
1047 && !(prtype & DATA_BINARY_TYPE))) {
1049 rec1_byte = cmp_collate(rec1_byte);
1050 rec2_byte = cmp_collate(rec2_byte);
1053 if (rec1_byte < rec2_byte) {
1055 goto order_resolved;
1056 }
else if (rec1_byte > rec2_byte) {
1058 goto order_resolved;
1073 ut_ad(cur_bytes == 0);
1080 ut_ad((ret >= - 1) && (ret <= 1));
1082 *matched_fields = cur_field;
1083 *matched_bytes = cur_bytes;
1099 cmp_debug_dtuple_rec_with_match(
1106 const ulint* offsets,
1107 ulint* matched_fields)
1115 const byte* dtuple_f_data;
1118 const byte* rec_f_data;
1122 ut_ad(dtuple && rec && matched_fields);
1129 cur_field = *matched_fields;
1131 if (cur_field == 0) {
1134 & REC_INFO_MIN_REC_FLAG)) {
1137 & REC_INFO_MIN_REC_FLAG);
1139 goto order_resolved;
1146 goto order_resolved;
1157 dtuple_field = dtuple_get_nth_field(dtuple, cur_field);
1160 = dfield_get_type(dtuple_field);
1162 mtype = type->
mtype;
1166 dtuple_f_data = dfield_get_data(dtuple_field);
1169 rec_f_data = rec_get_nth_field(rec, offsets,
1170 cur_field, &rec_f_len);
1177 goto order_resolved;
1180 ret =
cmp_data_data(mtype, prtype, dtuple_f_data, dtuple_f_len,
1181 rec_f_data, rec_f_len);
1183 goto order_resolved;
1192 ut_ad((ret >= - 1) && (ret <= 1));
1194 *matched_fields = cur_field;