76 if (dict_index_is_univ(index)) {
86 for (i = 0; i < entry_len; i++) {
88 = dict_index_get_nth_field(index, i);
94 = dtuple_get_nth_field(entry, i);
96 = dtuple_get_nth_field(row, col_no);
100 # error "DATA_MISSING != 0"
102 if (UNIV_UNLIKELY(dfield_get_type(dfield2)->mtype
140 if (UNIV_LIKELY_NULL(buf)) {
178 static_cast<char*>(dfield_get_data(dfield)));
224 const ulint* col_map,
235 ulint* ext_cols = NULL;
240 ulint offsets_[REC_OFFS_NORMAL_SIZE];
241 rec_offs_init(offsets_);
243 ut_ad(index && rec && heap);
246 ut_ad(!col_map || col_table);
249 offsets = rec_get_offsets(rec, index, offsets_,
250 ULINT_UNDEFINED, &tmp_heap);
252 ut_ad(rec_offs_validate(rec, index, offsets));
255 #if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
268 if (type != ROW_COPY_POINTERS) {
270 buf =
static_cast<byte*
>(
280 ext_cols =
static_cast<ulint*
>(
285 rec_offs_make_valid(copy, index, const_cast<ulint*>(offsets));
290 col_table = index->
table;
299 dict_table_get_nth_col(col_table,
i),
300 dfield_get_type(dtuple_get_nth_field(row,
i)));
314 = dict_index_get_nth_field(index,
i);
332 col_no = col_map[col_no];
334 if (col_no == ULINT_UNDEFINED) {
340 dfield_t* dfield = dtuple_get_nth_field(row, col_no);
342 const byte* field = rec_get_nth_field(
343 copy, offsets,
i, &len);
350 col = dict_table_get_nth_col(col_table, col_no);
356 ext_cols[j++] = col_no;
361 rec_offs_make_valid(rec, index, const_cast<ulint*>(offsets));
412 ut_ad(rec && heap && index);
429 for (i = 0; i < rec_len; i++) {
431 dfield = dtuple_get_nth_field(entry, i);
432 field = rec_get_nth_field(rec, offsets, i, &len);
465 const rec_t* copy_rec;
467 ut_ad(rec && heap && index);
468 ut_ad(rec_offs_validate(rec, index, offsets));
471 buf =
static_cast<byte*
>(
474 copy_rec =
rec_copy(buf, rec, offsets);
476 rec_offs_make_valid(copy_rec, index, const_cast<ulint*>(offsets));
478 copy_rec, index, offsets, n_ext, heap);
479 rec_offs_make_valid(rec, index, const_cast<ulint*>(offsets));
519 ulint clust_col_prefix_len;
522 ulint offsets_[REC_OFFS_NORMAL_SIZE];
524 rec_offs_init(offsets_);
526 ut_ad(index && rec && heap);
529 offsets = rec_get_offsets(rec, index, offsets,
530 ULINT_UNDEFINED, &tmp_heap);
534 if (type == ROW_COPY_DATA) {
537 buf =
static_cast<byte*
>(
542 rec_offs_make_valid(rec, index, offsets);
545 table = index->
table;
547 clust_index = dict_table_get_first_index(table);
555 for (i = 0; i < ref_len; i++) {
556 dfield = dtuple_get_nth_field(ref, i);
560 ut_a(pos != ULINT_UNDEFINED);
562 field = rec_get_nth_field(rec, offsets, pos, &len);
571 clust_col_prefix_len = dict_index_get_nth_field(
572 clust_index, i)->prefix_len;
574 if (clust_col_prefix_len > 0) {
575 if (len != UNIV_SQL_NULL) {
578 = dfield_get_type(dfield);
584 clust_col_prefix_len,
585 len, (
char*) field));
626 ulint clust_col_prefix_len;
629 ulint offsets_[REC_OFFS_NORMAL_SIZE];
630 rec_offs_init(offsets_);
637 if (UNIV_UNLIKELY(!index->
table)) {
638 fputs(
"InnoDB: table ", stderr);
641 fputs(
" for index ", stderr);
643 fputs(
" not found\n", stderr);
647 clust_index = dict_table_get_first_index(index->
table);
649 if (UNIV_UNLIKELY(!clust_index)) {
650 fputs(
"InnoDB: clust index for table ", stderr);
655 offsets = rec_get_offsets(rec, index, offsets_,
656 ULINT_UNDEFINED, &heap);
658 ut_ad(rec_offs_validate(rec, index, offsets));
669 for (i = 0; i < ref_len; i++) {
670 dfield = dtuple_get_nth_field(ref, i);
674 ut_a(pos != ULINT_UNDEFINED);
676 field = rec_get_nth_field(rec, offsets, pos, &len);
685 clust_col_prefix_len = dict_index_get_nth_field(
686 clust_index, i)->prefix_len;
688 if (clust_col_prefix_len > 0) {
689 if (len != UNIV_SQL_NULL) {
692 = dfield_get_type(dfield);
698 clust_col_prefix_len,
699 len, (
char*) field));
705 if (UNIV_LIKELY_NULL(heap)) {
730 index = dict_table_get_first_index(table);
734 btr_pcur_open(index, ref, PAGE_CUR_LE, mode, pcur, mtr);
738 rec = btr_pcur_get_rec(pcur);
776 table = index->
table;
784 clust_rec = found ? btr_pcur_get_rec(&pcur) : NULL;
790 *clust_index = dict_table_get_first_index(table);
815 btr_pcur_open(index, entry, PAGE_CUR_LE, mode, pcur, mtr);
817 switch (btr_pcur_get_btr_cur(pcur)->flag) {
835 rec = btr_pcur_get_rec(pcur);
842 }
else if (low_match != n_fields) {
872 ibool* format_in_hex)
877 if (data_len <=
sizeof(ib_uint64_t)) {
880 ibool unsigned_type = prtype & DATA_UNSIGNED;
883 (
const byte*) data, data_len, unsigned_type);
887 unsigned_type ? UINT64PF : INT64PF, value) + 1;
890 *format_in_hex = TRUE;
894 return(
ut_min(ret, buf_size));
920 ibool* format_in_hex)
940 if (charset_coll == DATA_MYSQL_BINARY_CHARSET_COLL) {
942 *format_in_hex = TRUE;
981 if (data_len == UNIV_SQL_NULL) {
983 ret =
ut_snprintf((
char*) buf, buf_size,
"NULL") + 1;
985 return(
ut_min(ret, buf_size));
991 format_in_hex = FALSE;
996 ret = row_raw_format_int(data, data_len, prtype,
997 buf, buf_size, &format_in_hex);
1008 ret = row_raw_format_str(data, data_len, prtype,
1009 buf, buf_size, &format_in_hex);
1010 if (format_in_hex) {
1020 if (UNIV_LIKELY(buf_size > 2)) {
1022 memcpy(buf,
"0x", 2);
1037 #ifdef UNIV_COMPILE_TEST_FUNCS
1042 test_row_raw_format_int()
1046 ibool format_in_hex;
1050 #define CALL_AND_TEST(data, data_len, prtype, buf, buf_size,\
1051 ret_expected, buf_expected, format_in_hex_expected)\
1055 memset(buf, 'x', 10);\
1057 format_in_hex = FALSE;\
1058 fprintf(stderr, "TESTING \"\\x");\
1059 for (i = 0; i < data_len; i++) {\
1060 fprintf(stderr, "%02hhX", data[i]);\
1062 fprintf(stderr, "\", %lu, %lu, %lu\n",\
1063 (ulint) data_len, (ulint) prtype,\
1065 ret = row_raw_format_int(data, data_len, prtype,\
1066 buf, buf_size, &format_in_hex);\
1067 if (ret != ret_expected) {\
1068 fprintf(stderr, "expected ret %lu, got %lu\n",\
1069 (ulint) ret_expected, ret);\
1072 if (strcmp((char*) buf, buf_expected) != 0) {\
1073 fprintf(stderr, "expected buf \"%s\", got \"%s\"\n",\
1074 buf_expected, buf);\
1077 if (format_in_hex != format_in_hex_expected) {\
1078 fprintf(stderr, "expected format_in_hex %d, got %d\n",\
1079 (int) format_in_hex_expected,\
1080 (int) format_in_hex);\
1084 fprintf(stderr, "OK: %lu, \"%s\" %d\n\n",\
1085 (ulint) ret, buf, (int) format_in_hex);\
1094 CALL_AND_TEST(
"\x00", 1, 0,
1095 buf,
sizeof(buf), 5,
"-128", 0);
1097 CALL_AND_TEST(
"\x00\x00", 2, 0,
1098 buf,
sizeof(buf), 7,
"-32768", 0);
1100 CALL_AND_TEST(
"\x00\x00\x00", 3, 0,
1101 buf,
sizeof(buf), 9,
"-8388608", 0);
1103 CALL_AND_TEST(
"\x00\x00\x00\x00", 4, 0,
1104 buf,
sizeof(buf), 12,
"-2147483648", 0);
1106 CALL_AND_TEST(
"\x00\x00\x00\x00\x00", 5, 0,
1107 buf,
sizeof(buf), 14,
"-549755813888", 0);
1109 CALL_AND_TEST(
"\x00\x00\x00\x00\x00\x00", 6, 0,
1110 buf,
sizeof(buf), 17,
"-140737488355328", 0);
1112 CALL_AND_TEST(
"\x00\x00\x00\x00\x00\x00\x00", 7, 0,
1113 buf,
sizeof(buf), 19,
"-36028797018963968", 0);
1115 CALL_AND_TEST(
"\x00\x00\x00\x00\x00\x00\x00\x00", 8, 0,
1116 buf,
sizeof(buf), 21,
"-9223372036854775808", 0);
1120 CALL_AND_TEST(
"\x00", 1, DATA_UNSIGNED,
1121 buf,
sizeof(buf), 2,
"0", 0);
1123 CALL_AND_TEST(
"\x00\x00", 2, DATA_UNSIGNED,
1124 buf,
sizeof(buf), 2,
"0", 0);
1126 CALL_AND_TEST(
"\x00\x00\x00", 3, DATA_UNSIGNED,
1127 buf,
sizeof(buf), 2,
"0", 0);
1129 CALL_AND_TEST(
"\x00\x00\x00\x00", 4, DATA_UNSIGNED,
1130 buf,
sizeof(buf), 2,
"0", 0);
1132 CALL_AND_TEST(
"\x00\x00\x00\x00\x00", 5, DATA_UNSIGNED,
1133 buf,
sizeof(buf), 2,
"0", 0);
1135 CALL_AND_TEST(
"\x00\x00\x00\x00\x00\x00", 6, DATA_UNSIGNED,
1136 buf,
sizeof(buf), 2,
"0", 0);
1138 CALL_AND_TEST(
"\x00\x00\x00\x00\x00\x00\x00", 7, DATA_UNSIGNED,
1139 buf,
sizeof(buf), 2,
"0", 0);
1141 CALL_AND_TEST(
"\x00\x00\x00\x00\x00\x00\x00\x00", 8, DATA_UNSIGNED,
1142 buf,
sizeof(buf), 2,
"0", 0);
1146 CALL_AND_TEST(
"\xFF", 1, 0,
1147 buf,
sizeof(buf), 4,
"127", 0);
1149 CALL_AND_TEST(
"\xFF\xFF", 2, 0,
1150 buf,
sizeof(buf), 6,
"32767", 0);
1152 CALL_AND_TEST(
"\xFF\xFF\xFF", 3, 0,
1153 buf,
sizeof(buf), 8,
"8388607", 0);
1155 CALL_AND_TEST(
"\xFF\xFF\xFF\xFF", 4, 0,
1156 buf,
sizeof(buf), 11,
"2147483647", 0);
1158 CALL_AND_TEST(
"\xFF\xFF\xFF\xFF\xFF", 5, 0,
1159 buf,
sizeof(buf), 13,
"549755813887", 0);
1161 CALL_AND_TEST(
"\xFF\xFF\xFF\xFF\xFF\xFF", 6, 0,
1162 buf,
sizeof(buf), 16,
"140737488355327", 0);
1164 CALL_AND_TEST(
"\xFF\xFF\xFF\xFF\xFF\xFF\xFF", 7, 0,
1165 buf,
sizeof(buf), 18,
"36028797018963967", 0);
1167 CALL_AND_TEST(
"\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF", 8, 0,
1168 buf,
sizeof(buf), 20,
"9223372036854775807", 0);
1172 CALL_AND_TEST(
"\xFF", 1, DATA_UNSIGNED,
1173 buf,
sizeof(buf), 4,
"255", 0);
1175 CALL_AND_TEST(
"\xFF\xFF", 2, DATA_UNSIGNED,
1176 buf,
sizeof(buf), 6,
"65535", 0);
1178 CALL_AND_TEST(
"\xFF\xFF\xFF", 3, DATA_UNSIGNED,
1179 buf,
sizeof(buf), 9,
"16777215", 0);
1181 CALL_AND_TEST(
"\xFF\xFF\xFF\xFF", 4, DATA_UNSIGNED,
1182 buf,
sizeof(buf), 11,
"4294967295", 0);
1184 CALL_AND_TEST(
"\xFF\xFF\xFF\xFF\xFF", 5, DATA_UNSIGNED,
1185 buf,
sizeof(buf), 14,
"1099511627775", 0);
1187 CALL_AND_TEST(
"\xFF\xFF\xFF\xFF\xFF\xFF", 6, DATA_UNSIGNED,
1188 buf,
sizeof(buf), 16,
"281474976710655", 0);
1190 CALL_AND_TEST(
"\xFF\xFF\xFF\xFF\xFF\xFF\xFF", 7, DATA_UNSIGNED,
1191 buf,
sizeof(buf), 18,
"72057594037927935", 0);
1193 CALL_AND_TEST(
"\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF", 8, DATA_UNSIGNED,
1194 buf,
sizeof(buf), 21,
"18446744073709551615", 0);
1198 CALL_AND_TEST(
"\x52", 1, 0,
1199 buf,
sizeof(buf), 4,
"-46", 0);
1201 CALL_AND_TEST(
"\x0E", 1, DATA_UNSIGNED,
1202 buf,
sizeof(buf), 3,
"14", 0);
1204 CALL_AND_TEST(
"\x62\xCE", 2, 0,
1205 buf,
sizeof(buf), 6,
"-7474", 0);
1207 CALL_AND_TEST(
"\x29\xD6", 2, DATA_UNSIGNED,
1208 buf,
sizeof(buf), 6,
"10710", 0);
1210 CALL_AND_TEST(
"\x7F\xFF\x90", 3, 0,
1211 buf,
sizeof(buf), 5,
"-112", 0);
1213 CALL_AND_TEST(
"\x00\xA1\x16", 3, DATA_UNSIGNED,
1214 buf,
sizeof(buf), 6,
"41238", 0);
1216 CALL_AND_TEST(
"\x7F\xFF\xFF\xF7", 4, 0,
1217 buf,
sizeof(buf), 3,
"-9", 0);
1219 CALL_AND_TEST(
"\x00\x00\x00\x5C", 4, DATA_UNSIGNED,
1220 buf,
sizeof(buf), 3,
"92", 0);
1222 CALL_AND_TEST(
"\x7F\xFF\xFF\xFF\xFF\xFF\xDC\x63", 8, 0,
1223 buf,
sizeof(buf), 6,
"-9117", 0);
1225 CALL_AND_TEST(
"\x00\x00\x00\x00\x00\x01\x64\x62", 8, DATA_UNSIGNED,
1226 buf,
sizeof(buf), 6,
"91234", 0);
1231 speedo_reset(&speedo);
1233 for (i = 0; i < 1000000; i++) {
1234 row_raw_format_int(
"\x23", 1,
1235 0, buf,
sizeof(buf),
1237 row_raw_format_int(
"\x23", 1,
1238 DATA_UNSIGNED, buf,
sizeof(buf),
1241 row_raw_format_int(
"\x00\x00\x00\x00\x00\x01\x64\x62", 8,
1242 0, buf,
sizeof(buf),
1244 row_raw_format_int(
"\x00\x00\x00\x00\x00\x01\x64\x62", 8,
1245 DATA_UNSIGNED, buf,
sizeof(buf),
1249 speedo_show(&speedo);