74 ut_ad(len == DATA_TRX_ID_LEN);
101 ut_ad(row && index && heap);
117 for (i = 0; i < entry_len; i++) {
119 = dict_index_get_nth_field(index, i);
125 = dtuple_get_nth_field(entry, i);
127 = dtuple_get_nth_field(row, col_no);
141 if (UNIV_LIKELY_NULL(ext)) {
145 if (UNIV_LIKELY_NULL(buf)) {
160 ind_field->
prefix_len, len, static_cast<const char *>(dfield_get_data(dfield)));
194 const ulint* offsets,
214 ulint* ext_cols = NULL;
221 ulint offsets_[REC_OFFS_NORMAL_SIZE];
222 rec_offs_init(offsets_);
224 ut_ad(index && rec && heap);
228 offsets = rec_get_offsets(rec, index, offsets_,
229 ULINT_UNDEFINED, &tmp_heap);
234 if (type != ROW_COPY_POINTERS) {
239 rec_offs_make_valid(rec, index, (ulint*) offsets);
242 table = index->
table;
255 ext_cols =
static_cast<ulint *
>(
mem_heap_alloc(heap, n_ext_cols *
sizeof *ext_cols));
258 for (i = j = 0; i < n_fields; i++) {
260 = dict_index_get_nth_field(index, i);
266 = dtuple_get_nth_field(row, col_no);
270 const byte* field = rec_get_nth_field(
271 rec, offsets, i, &len);
279 if (UNIV_LIKELY_NULL(col_table)) {
282 col = dict_table_get_nth_col(
290 ext_cols[j++] = col_no;
328 const ulint* offsets,
341 ut_ad(rec && heap && index);
358 for (i = 0; i < rec_len; i++) {
360 dfield = dtuple_get_nth_field(entry, i);
361 field = rec_get_nth_field(rec, offsets, i, &len);
409 ut_ad(rec && heap && index);
412 if (type == ROW_COPY_DATA) {
417 rec_offs_make_valid(rec, index, offsets);
460 ulint clust_col_prefix_len;
463 ulint offsets_[REC_OFFS_NORMAL_SIZE];
464 ulint* offsets = offsets_;
465 rec_offs_init(offsets_);
467 ut_ad(index && rec && heap);
470 offsets = rec_get_offsets(rec, index, offsets,
471 ULINT_UNDEFINED, &tmp_heap);
475 if (type == ROW_COPY_DATA) {
482 rec_offs_make_valid(rec, index, offsets);
485 table = index->
table;
487 clust_index = dict_table_get_first_index(table);
495 for (i = 0; i < ref_len; i++) {
496 dfield = dtuple_get_nth_field(ref, i);
500 ut_a(pos != ULINT_UNDEFINED);
502 field = rec_get_nth_field(rec, offsets, pos, &len);
511 clust_col_prefix_len = dict_index_get_nth_field(
512 clust_index, i)->prefix_len;
514 if (clust_col_prefix_len > 0) {
515 if (len != UNIV_SQL_NULL) {
518 = dfield_get_type(dfield);
524 clust_col_prefix_len,
525 len, (
char*) field));
566 ulint clust_col_prefix_len;
569 ulint offsets_[REC_OFFS_NORMAL_SIZE];
570 rec_offs_init(offsets_);
577 if (UNIV_UNLIKELY(!index->
table)) {
578 fputs(
"InnoDB: table ", stderr);
581 fputs(
" for index ", stderr);
583 fputs(
" not found\n", stderr);
587 clust_index = dict_table_get_first_index(index->
table);
589 if (UNIV_UNLIKELY(!clust_index)) {
590 fputs(
"InnoDB: clust index for table ", stderr);
595 offsets = rec_get_offsets(rec, index, offsets_,
596 ULINT_UNDEFINED, &heap);
609 for (i = 0; i < ref_len; i++) {
610 dfield = dtuple_get_nth_field(ref, i);
614 ut_a(pos != ULINT_UNDEFINED);
616 field = rec_get_nth_field(rec, offsets, pos, &len);
625 clust_col_prefix_len = dict_index_get_nth_field(
626 clust_index, i)->prefix_len;
628 if (clust_col_prefix_len > 0) {
629 if (len != UNIV_SQL_NULL) {
632 = dfield_get_type(dfield);
638 clust_col_prefix_len,
639 len, (
char*) field));
645 if (UNIV_LIKELY_NULL(heap)) {
670 index = dict_table_get_first_index(table);
674 btr_pcur_open(index, ref, PAGE_CUR_LE, mode, pcur, mtr);
678 rec = btr_pcur_get_rec(pcur);
716 table = index->
table;
724 clust_rec = found ? btr_pcur_get_rec(&pcur) : NULL;
730 *clust_index = dict_table_get_first_index(table);
755 btr_pcur_open(index, entry, PAGE_CUR_LE, mode, pcur, mtr);
757 switch (btr_pcur_get_btr_cur(pcur)->flag) {
775 rec = btr_pcur_get_rec(pcur);
782 }
else if (low_match != n_fields) {
790 #if !defined(BUILD_DRIZZLE)
817 ibool* format_in_hex)
822 if (data_len <=
sizeof(ullint)) {
825 ibool unsigned_type = prtype & DATA_UNSIGNED;
828 data_len, unsigned_type);
837 (
long long) value) + 1;
842 *format_in_hex = TRUE;
846 return(
ut_min(ret, buf_size));
872 ibool* format_in_hex)
892 if (charset_coll == DATA_MYSQL_BINARY_CHARSET_COLL) {
894 *format_in_hex = TRUE;
933 if (data_len == UNIV_SQL_NULL) {
935 ret =
ut_snprintf((
char*) buf, buf_size,
"NULL") + 1;
937 return(
ut_min(ret, buf_size));
943 format_in_hex = FALSE;
948 ret = row_raw_format_int(data, data_len, prtype,
949 buf, buf_size, &format_in_hex);
960 ret = row_raw_format_str(data, data_len, prtype,
961 buf, buf_size, &format_in_hex);
972 if (UNIV_LIKELY(buf_size > 2)) {
974 memcpy(buf,
"0x", 2);
989 #ifdef UNIV_COMPILE_TEST_FUNCS
994 test_row_raw_format_int()
1000 #define CALL_AND_TEST(data, data_len, prtype, buf, buf_size,\
1001 ret_expected, buf_expected, format_in_hex_expected)\
1005 memset(buf, 'x', 10);\
1007 format_in_hex = FALSE;\
1008 fprintf(stderr, "TESTING \"\\x");\
1009 for (i = 0; i < data_len; i++) {\
1010 fprintf(stderr, "%02hhX", data[i]);\
1012 fprintf(stderr, "\", %lu, %lu, %lu\n",\
1013 (ulint) data_len, (ulint) prtype,\
1015 ret = row_raw_format_int(data, data_len, prtype,\
1016 buf, buf_size, &format_in_hex);\
1017 if (ret != ret_expected) {\
1018 fprintf(stderr, "expected ret %lu, got %lu\n",\
1019 (ulint) ret_expected, ret);\
1022 if (strcmp((char*) buf, buf_expected) != 0) {\
1023 fprintf(stderr, "expected buf \"%s\", got \"%s\"\n",\
1024 buf_expected, buf);\
1027 if (format_in_hex != format_in_hex_expected) {\
1028 fprintf(stderr, "expected format_in_hex %d, got %d\n",\
1029 (int) format_in_hex_expected,\
1030 (int) format_in_hex);\
1034 fprintf(stderr, "OK: %lu, \"%s\" %d\n\n",\
1035 (ulint) ret, buf, (int) format_in_hex);\
1044 CALL_AND_TEST(
"\x00", 1, 0,
1045 buf,
sizeof(buf), 5,
"-128", 0);
1047 CALL_AND_TEST(
"\x00\x00", 2, 0,
1048 buf,
sizeof(buf), 7,
"-32768", 0);
1050 CALL_AND_TEST(
"\x00\x00\x00", 3, 0,
1051 buf,
sizeof(buf), 9,
"-8388608", 0);
1053 CALL_AND_TEST(
"\x00\x00\x00\x00", 4, 0,
1054 buf,
sizeof(buf), 12,
"-2147483648", 0);
1056 CALL_AND_TEST(
"\x00\x00\x00\x00\x00", 5, 0,
1057 buf,
sizeof(buf), 14,
"-549755813888", 0);
1059 CALL_AND_TEST(
"\x00\x00\x00\x00\x00\x00", 6, 0,
1060 buf,
sizeof(buf), 17,
"-140737488355328", 0);
1062 CALL_AND_TEST(
"\x00\x00\x00\x00\x00\x00\x00", 7, 0,
1063 buf,
sizeof(buf), 19,
"-36028797018963968", 0);
1065 CALL_AND_TEST(
"\x00\x00\x00\x00\x00\x00\x00\x00", 8, 0,
1066 buf,
sizeof(buf), 21,
"-9223372036854775808", 0);
1070 CALL_AND_TEST(
"\x00", 1, DATA_UNSIGNED,
1071 buf,
sizeof(buf), 2,
"0", 0);
1073 CALL_AND_TEST(
"\x00\x00", 2, DATA_UNSIGNED,
1074 buf,
sizeof(buf), 2,
"0", 0);
1076 CALL_AND_TEST(
"\x00\x00\x00", 3, DATA_UNSIGNED,
1077 buf,
sizeof(buf), 2,
"0", 0);
1079 CALL_AND_TEST(
"\x00\x00\x00\x00", 4, DATA_UNSIGNED,
1080 buf,
sizeof(buf), 2,
"0", 0);
1082 CALL_AND_TEST(
"\x00\x00\x00\x00\x00", 5, DATA_UNSIGNED,
1083 buf,
sizeof(buf), 2,
"0", 0);
1085 CALL_AND_TEST(
"\x00\x00\x00\x00\x00\x00", 6, DATA_UNSIGNED,
1086 buf,
sizeof(buf), 2,
"0", 0);
1088 CALL_AND_TEST(
"\x00\x00\x00\x00\x00\x00\x00", 7, DATA_UNSIGNED,
1089 buf,
sizeof(buf), 2,
"0", 0);
1091 CALL_AND_TEST(
"\x00\x00\x00\x00\x00\x00\x00\x00", 8, DATA_UNSIGNED,
1092 buf,
sizeof(buf), 2,
"0", 0);
1096 CALL_AND_TEST(
"\xFF", 1, 0,
1097 buf,
sizeof(buf), 4,
"127", 0);
1099 CALL_AND_TEST(
"\xFF\xFF", 2, 0,
1100 buf,
sizeof(buf), 6,
"32767", 0);
1102 CALL_AND_TEST(
"\xFF\xFF\xFF", 3, 0,
1103 buf,
sizeof(buf), 8,
"8388607", 0);
1105 CALL_AND_TEST(
"\xFF\xFF\xFF\xFF", 4, 0,
1106 buf,
sizeof(buf), 11,
"2147483647", 0);
1108 CALL_AND_TEST(
"\xFF\xFF\xFF\xFF\xFF", 5, 0,
1109 buf,
sizeof(buf), 13,
"549755813887", 0);
1111 CALL_AND_TEST(
"\xFF\xFF\xFF\xFF\xFF\xFF", 6, 0,
1112 buf,
sizeof(buf), 16,
"140737488355327", 0);
1114 CALL_AND_TEST(
"\xFF\xFF\xFF\xFF\xFF\xFF\xFF", 7, 0,
1115 buf,
sizeof(buf), 18,
"36028797018963967", 0);
1117 CALL_AND_TEST(
"\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF", 8, 0,
1118 buf,
sizeof(buf), 20,
"9223372036854775807", 0);
1122 CALL_AND_TEST(
"\xFF", 1, DATA_UNSIGNED,
1123 buf,
sizeof(buf), 4,
"255", 0);
1125 CALL_AND_TEST(
"\xFF\xFF", 2, DATA_UNSIGNED,
1126 buf,
sizeof(buf), 6,
"65535", 0);
1128 CALL_AND_TEST(
"\xFF\xFF\xFF", 3, DATA_UNSIGNED,
1129 buf,
sizeof(buf), 9,
"16777215", 0);
1131 CALL_AND_TEST(
"\xFF\xFF\xFF\xFF", 4, DATA_UNSIGNED,
1132 buf,
sizeof(buf), 11,
"4294967295", 0);
1134 CALL_AND_TEST(
"\xFF\xFF\xFF\xFF\xFF", 5, DATA_UNSIGNED,
1135 buf,
sizeof(buf), 14,
"1099511627775", 0);
1137 CALL_AND_TEST(
"\xFF\xFF\xFF\xFF\xFF\xFF", 6, DATA_UNSIGNED,
1138 buf,
sizeof(buf), 16,
"281474976710655", 0);
1140 CALL_AND_TEST(
"\xFF\xFF\xFF\xFF\xFF\xFF\xFF", 7, DATA_UNSIGNED,
1141 buf,
sizeof(buf), 18,
"72057594037927935", 0);
1143 CALL_AND_TEST(
"\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF", 8, DATA_UNSIGNED,
1144 buf,
sizeof(buf), 21,
"18446744073709551615", 0);
1148 CALL_AND_TEST(
"\x52", 1, 0,
1149 buf,
sizeof(buf), 4,
"-46", 0);
1151 CALL_AND_TEST(
"\x0E", 1, DATA_UNSIGNED,
1152 buf,
sizeof(buf), 3,
"14", 0);
1154 CALL_AND_TEST(
"\x62\xCE", 2, 0,
1155 buf,
sizeof(buf), 6,
"-7474", 0);
1157 CALL_AND_TEST(
"\x29\xD6", 2, DATA_UNSIGNED,
1158 buf,
sizeof(buf), 6,
"10710", 0);
1160 CALL_AND_TEST(
"\x7F\xFF\x90", 3, 0,
1161 buf,
sizeof(buf), 5,
"-112", 0);
1163 CALL_AND_TEST(
"\x00\xA1\x16", 3, DATA_UNSIGNED,
1164 buf,
sizeof(buf), 6,
"41238", 0);
1166 CALL_AND_TEST(
"\x7F\xFF\xFF\xF7", 4, 0,
1167 buf,
sizeof(buf), 3,
"-9", 0);
1169 CALL_AND_TEST(
"\x00\x00\x00\x5C", 4, DATA_UNSIGNED,
1170 buf,
sizeof(buf), 3,
"92", 0);
1172 CALL_AND_TEST(
"\x7F\xFF\xFF\xFF\xFF\xFF\xDC\x63", 8, 0,
1173 buf,
sizeof(buf), 6,
"-9117", 0);
1175 CALL_AND_TEST(
"\x00\x00\x00\x00\x00\x01\x64\x62", 8, DATA_UNSIGNED,
1176 buf,
sizeof(buf), 6,
"91234", 0);
1184 speedo_reset(&speedo);
1186 for (i = 0; i < 1000000; i++) {
1187 row_raw_format_int(
"\x23", 1,
1188 0, buf,
sizeof(buf),
1190 row_raw_format_int(
"\x23", 1,
1191 DATA_UNSIGNED, buf,
sizeof(buf),
1194 row_raw_format_int(
"\x00\x00\x00\x00\x00\x01\x64\x62", 8,
1195 0, buf,
sizeof(buf),
1197 row_raw_format_int(
"\x00\x00\x00\x00\x00\x01\x64\x62", 8,
1198 DATA_UNSIGNED, buf,
sizeof(buf),
1202 speedo_show(&speedo);
UNIV_INTERN ulint row_get_trx_id_offset(const rec_t *rec, dict_index_t *index, const ulint *offsets)
UNIV_INTERN rec_t * row_get_clust_rec(ulint mode, const rec_t *rec, dict_index_t *index, dict_index_t **clust_index, mtr_t *mtr)
UNIV_INLINE ulint btr_pcur_get_low_match(const btr_pcur_t *cursor)
UNIV_INTERN row_ext_t * row_ext_create(ulint n_ext, const ulint *ext, const dtuple_t *tuple, ulint zip_size, mem_heap_t *heap)
UNIV_INTERN ulint dict_index_get_nth_field_pos(const dict_index_t *index, const dict_index_t *index2, ulint n)
UNIV_INLINE ulint dict_index_get_n_fields(const dict_index_t *index)
UNIV_INLINE void dfield_set_len(dfield_t *field, ulint len)
UNIV_INLINE dtuple_t * dtuple_create(mem_heap_t *heap, ulint n_fields)
UNIV_INLINE ulint rec_offs_any_extern(const ulint *offsets)
UNIV_INLINE ulint dfield_is_ext(const dfield_t *field)
UNIV_INTERN dtuple_t * row_build(ulint type, const dict_index_t *index, const rec_t *rec, const ulint *offsets, const dict_table_t *col_table, row_ext_t **ext, mem_heap_t *heap)
UNIV_INTERN ulint dtype_get_at_most_n_mbchars(ulint prtype, ulint mbminmaxlen, ulint prefix_len, ulint data_len, const char *str)
UNIV_INLINE ibool dict_table_is_comp(const dict_table_t *table)
UNIV_INLINE ulint rec_offs_nth_extern(const ulint *offsets, ulint n)
UNIV_INTERN dtuple_t * row_build_index_entry(const dtuple_t *row, row_ext_t *ext, dict_index_t *index, mem_heap_t *heap)
UNIV_INLINE rec_t * rec_copy(void *buf, const rec_t *rec, const ulint *offsets)
#define DICT_TF_FORMAT_ZIP
#define mem_heap_free(heap)
UNIV_INLINE void dfield_copy(dfield_t *field1, const dfield_t *field2)
UNIV_INTERN void dict_index_copy_types(dtuple_t *tuple, const dict_index_t *index, ulint n_fields)
UNIV_INLINE ulint dtuple_get_n_fields(const dtuple_t *tuple)
UNIV_INLINE void btr_pcur_close(btr_pcur_t *cursor)
UNIV_INTERN void dict_table_copy_types(dtuple_t *tuple, const dict_table_t *table)
UNIV_INLINE ulint ut_min(ulint n1, ulint n2)
UNIV_INLINE ulint dict_index_get_n_unique_in_tree(const dict_index_t *index)
UNIV_INLINE ulint rec_get_nth_field_offs(const ulint *offsets, ulint n, ulint *len)
UNIV_INLINE void dfield_set_data(dfield_t *field, const void *data, ulint len)
UNIV_INLINE ulint dict_table_zip_size(const dict_table_t *table)
UNIV_INLINE ulint dfield_get_len(const dfield_t *field)
UNIV_INLINE ulint dict_table_get_format(const dict_table_t *table)
UNIV_INLINE ulint rec_offs_comp(const ulint *offsets)
UNIV_INTERN ulint innobase_raw_format(const char *data, ulint data_len, ulint, char *buf, ulint buf_size)
UNIV_INTERN dtuple_t * row_rec_to_index_entry_low(const rec_t *rec, const dict_index_t *index, const ulint *offsets, ulint *n_ext, mem_heap_t *heap)
UNIV_INTERN ulint row_raw_format(const char *data, ulint data_len, const dict_field_t *dict_field, char *buf, ulint buf_size)
UNIV_INTERN enum row_search_result row_search_index_entry(dict_index_t *index, const dtuple_t *entry, ulint mode, btr_pcur_t *pcur, mtr_t *mtr)
UNIV_INLINE ulint dict_col_get_no(const dict_col_t *col)
UNIV_INLINE ulint dict_index_is_clust(const dict_index_t *index) __attribute__((pure))
UNIV_INLINE ibool dtype_is_utf8(ulint prtype)
UNIV_INTERN ibool dtuple_check_typed(const dtuple_t *tuple)
UNIV_INLINE void dtuple_set_info_bits(dtuple_t *tuple, ulint info_bits)
UNIV_INTERN void ut_print_name(FILE *f, struct trx_struct *trx, ibool table_id, const char *name)
UNIV_INLINE const dict_col_t * dict_field_get_col(const dict_field_t *field)
UNIV_INLINE void * mem_heap_alloc(mem_heap_t *heap, ulint n)
#define mem_heap_create(N)
UNIV_INTERN void row_build_row_ref_in_tuple(dtuple_t *ref, const rec_t *rec, const dict_index_t *index, ulint *offsets, trx_t *trx)
UNIV_INLINE ulint ut_str_sql_format(const char *str, ulint str_len, char *buf, ulint buf_size)
UNIV_INLINE ulint rec_offs_n_fields(const ulint *offsets)
UNIV_INLINE const byte * row_ext_lookup(const row_ext_t *ext, ulint col, ulint *len)
UNIV_INTERN dtuple_t * row_build_row_ref(ulint type, dict_index_t *index, const rec_t *rec, mem_heap_t *heap)
UNIV_INLINE ulint dfield_is_null(const dfield_t *field)
UNIV_INLINE void dtuple_set_n_fields_cmp(dtuple_t *tuple, ulint n_fields_cmp)
UNIV_INLINE ulint dict_table_get_n_cols(const dict_table_t *table)
#define BTR_EXTERN_FIELD_REF_SIZE
UNIV_INLINE ulint dict_index_get_n_unique(const dict_index_t *index)
UNIV_INLINE ulint rec_offs_n_extern(const ulint *offsets)
UNIV_INLINE ulint dtype_get_charset_coll(ulint prtype)
UNIV_INLINE ulint dict_index_get_sys_col_pos(const dict_index_t *index, ulint type)
UNIV_INLINE ulint rec_get_info_bits(const rec_t *rec, ulint comp)
UNIV_INLINE ibool page_rec_is_infimum(const rec_t *rec) __attribute__((const ))
UNIV_INTERN dtuple_t * row_rec_to_index_entry(ulint type, const rec_t *rec, const dict_index_t *index, ulint *offsets, ulint *n_ext, mem_heap_t *heap)
UNIV_INLINE ulint rec_offs_size(const ulint *offsets)
UNIV_INTERN ibool row_search_on_row_ref(btr_pcur_t *pcur, ulint mode, const dict_table_t *table, const dtuple_t *ref, mtr_t *mtr)
UNIV_INLINE void dfield_set_ext(dfield_t *field)
UNIV_INLINE ulint ut_raw_to_hex(const void *raw, ulint raw_size, char *hex, ulint hex_size)
const byte field_ref_zero[BTR_EXTERN_FIELD_REF_SIZE]
UNIV_INLINE ullint mach_read_int_type(const byte *src, ulint len, ibool unsigned_type)
UNIV_INLINE ibool rec_offs_validate(const rec_t *rec, const dict_index_t *index, const ulint *offsets)