#include "data0data.h"#include "rem0rec.h"#include "rem0cmp.h"#include "page0page.h"#include "dict0dict.h"#include "btr0cur.h"Include dependency graph for data0data.c:

Go to the source code of this file.
| ibool dfield_check_typed | ( | dfield_t * | field | ) |
Definition at line 244 of file data0data.c.
References DATA_MYSQL, DATA_VARCHAR, dfield_get_len(), dfield_get_type(), TRUE, and ut_error.
Referenced by dtuple_check_typed().
00246 : TRUE if ok */ 00247 dfield_t* field) /* in: data field */ 00248 { 00249 if (dfield_get_type(field)->mtype > DATA_MYSQL 00250 || dfield_get_type(field)->mtype < DATA_VARCHAR) { 00251 00252 fprintf(stderr, 00253 "InnoDB: Error: data field type %lu, len %lu\n", 00254 (ulong) dfield_get_type(field)->mtype, 00255 (ulong) dfield_get_len(field)); 00256 00257 ut_error; 00258 } 00259 00260 return(TRUE); 00261 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static ibool dfield_check_typed_no_assert | ( | dfield_t * | field | ) | [static] |
Definition at line 186 of file data0data.c.
References DATA_MYSQL, DATA_VARCHAR, dfield_get_len(), dfield_get_type(), FALSE, and TRUE.
Referenced by dtuple_check_typed_no_assert().
00188 : TRUE if ok */ 00189 dfield_t* field) /* in: data field */ 00190 { 00191 if (dfield_get_type(field)->mtype > DATA_MYSQL 00192 || dfield_get_type(field)->mtype < DATA_VARCHAR) { 00193 00194 fprintf(stderr, 00195 "InnoDB: Error: data field type %lu, len %lu\n", 00196 (ulong) dfield_get_type(field)->mtype, 00197 (ulong) dfield_get_len(field)); 00198 return(FALSE); 00199 } 00200 00201 return(TRUE); 00202 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 68 of file data0data.c.
References dfield_struct::data, FALSE, dfield_struct::len, TRUE, and ut_memcmp().
Referenced by row_upd_build_difference_binary(), and row_upd_build_sec_rec_difference_binary().
00070 : TRUE if equal */ 00071 dfield_t* field, /* in: field */ 00072 ulint len, /* in: data length or UNIV_SQL_NULL */ 00073 byte* data) /* in: data */ 00074 { 00075 if (len != field->len) { 00076 00077 return(FALSE); 00078 } 00079 00080 if (len == UNIV_SQL_NULL) { 00081 00082 return(TRUE); 00083 } 00084 00085 if (0 != ut_memcmp(field->data, data, len)) { 00086 00087 return(FALSE); 00088 } 00089 00090 return(TRUE); 00091 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void* dfield_get_data_noninline | ( | dfield_t * | field | ) |
Definition at line 39 of file data0data.c.
References dfield_get_data().
00040 : field */ 00041 { 00042 return(dfield_get_data(field)); 00043 }
Here is the call graph for this function:

Definition at line 45 of file data0data.c.
References dfield_get_len().
00046 : field */ 00047 { 00048 return(dfield_get_len(field)); 00049 }
Here is the call graph for this function:

| void dfield_print | ( | dfield_t * | dfield | ) |
Definition at line 339 of file data0data.c.
References DATA_CHAR, DATA_INT, DATA_VARCHAR, dfield_get_data(), dfield_get_len(), dfield_get_type(), dtype_get_mtype(), mach_read_from_4(), ut_a, and ut_error.
Referenced by eval_predefined_2().
00341 : dfield */ 00342 { 00343 byte* data; 00344 ulint len; 00345 ulint mtype; 00346 ulint i; 00347 00348 len = dfield_get_len(dfield); 00349 data = dfield_get_data(dfield); 00350 00351 if (len == UNIV_SQL_NULL) { 00352 fputs("NULL", stderr); 00353 00354 return; 00355 } 00356 00357 mtype = dtype_get_mtype(dfield_get_type(dfield)); 00358 00359 if ((mtype == DATA_CHAR) || (mtype == DATA_VARCHAR)) { 00360 00361 for (i = 0; i < len; i++) { 00362 int c = *data++; 00363 putc(isprint(c) ? c : ' ', stderr); 00364 } 00365 } else if (mtype == DATA_INT) { 00366 ut_a(len == 4); /* only works for 32-bit integers */ 00367 fprintf(stderr, "%d", (int)mach_read_from_4(data)); 00368 } else { 00369 ut_error; 00370 } 00371 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void dfield_print_also_hex | ( | dfield_t * | dfield | ) |
Definition at line 378 of file data0data.c.
References DATA_CHAR, DATA_INT, DATA_VARCHAR, dfield_get_data(), dfield_get_len(), dfield_get_type(), dtype_get_mtype(), FALSE, mach_read_from_4(), TRUE, ut_a, and ut_error.
Referenced by row_printf_step().
00380 : dfield */ 00381 { 00382 byte* data; 00383 ulint len; 00384 ulint mtype; 00385 ulint i; 00386 ibool print_also_hex; 00387 00388 len = dfield_get_len(dfield); 00389 data = dfield_get_data(dfield); 00390 00391 if (len == UNIV_SQL_NULL) { 00392 fputs("NULL", stderr); 00393 00394 return; 00395 } 00396 00397 mtype = dtype_get_mtype(dfield_get_type(dfield)); 00398 00399 if ((mtype == DATA_CHAR) || (mtype == DATA_VARCHAR)) { 00400 00401 print_also_hex = FALSE; 00402 00403 for (i = 0; i < len; i++) { 00404 int c = *data++; 00405 if (!isprint(c)) { 00406 print_also_hex = TRUE; 00407 c = ' '; 00408 } 00409 putc(c, stderr); 00410 } 00411 00412 if (!print_also_hex) { 00413 00414 return; 00415 } 00416 00417 fputs(" Hex: ", stderr); 00418 00419 data = dfield_get_data(dfield); 00420 00421 for (i = 0; i < len; i++) { 00422 fprintf(stderr, "%02lx", (ulint)*data); 00423 00424 data++; 00425 } 00426 } else if (mtype == DATA_INT) { 00427 ut_a(len == 4); /* only works for 32-bit integers */ 00428 fprintf(stderr, "%d", (int)mach_read_from_4(data)); 00429 } else { 00430 ut_error; 00431 } 00432 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void dfield_print_raw | ( | FILE * | f, | |
| dfield_t * | dfield | |||
| ) |
Definition at line 438 of file data0data.c.
References dfield_struct::data, dfield_struct::len, and ut_print_buf().
Referenced by dtuple_print().
00440 : output stream */ 00441 dfield_t* dfield) /* in: dfield */ 00442 { 00443 if (dfield->len != UNIV_SQL_NULL) { 00444 ut_print_buf(f, dfield->data, dfield->len); 00445 } else { 00446 fputs(" SQL NULL", f); 00447 } 00448 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 31 of file data0data.c.
References dfield_set_data().
00032 : field */ 00033 void* data, /* in: data */ 00034 ulint len) /* in: length or UNIV_SQL_NULL */ 00035 { 00036 dfield_set_data(field, data, len); 00037 }
Here is the call graph for this function:

| void dtuple_big_rec_free | ( | big_rec_t * | vector | ) |
Definition at line 667 of file data0data.c.
References big_rec_struct::heap, and mem_heap_free.
Referenced by row_ins_index_entry_low(), and row_upd_clust_rec().
00669 : big rec vector; it is 00670 freed in this function */ 00671 { 00672 mem_heap_free(vector->heap); 00673 }
Here is the caller graph for this function:

| ibool dtuple_check_typed | ( | dtuple_t * | tuple | ) |
Definition at line 267 of file data0data.c.
References dfield_check_typed(), dtuple_get_n_fields(), dtuple_get_nth_field(), TRUE, and ut_a.
Referenced by btr_cur_insert_if_possible(), btr_cur_pessimistic_insert(), btr_cur_search_to_nth_level(), cmp_dtuple_rec_with_match(), dict_tree_build_data_tuple(), dict_tree_build_node_ptr(), dtuple_datas_are_ordering_equal(), ibuf_insert(), ibuf_insert_low(), ibuf_insert_to_index_page(), page_cur_insert_rec_low(), page_cur_search_with_match(), rec_convert_dtuple_to_rec(), rec_convert_dtuple_to_rec_old(), rec_copy_prefix_to_dtuple(), row_build_index_entry(), row_build_row_ref(), row_build_row_ref_from_row(), row_build_row_ref_in_tuple(), row_ins_index_entry_step(), row_rec_to_index_entry(), row_search_index_entry(), and row_search_on_row_ref().
00269 : TRUE if ok */ 00270 dtuple_t* tuple) /* in: tuple */ 00271 { 00272 dfield_t* field; 00273 ulint i; 00274 00275 for (i = 0; i < dtuple_get_n_fields(tuple); i++) { 00276 00277 field = dtuple_get_nth_field(tuple, i); 00278 00279 ut_a(dfield_check_typed(field)); 00280 } 00281 00282 return(TRUE); 00283 }
Here is the call graph for this function:

Here is the caller graph for this function:

| ibool dtuple_check_typed_no_assert | ( | dtuple_t * | tuple | ) |
Definition at line 208 of file data0data.c.
References dfield_check_typed_no_assert(), dtuple_get_n_fields(), dtuple_get_nth_field(), dtuple_print(), dump, FALSE, REC_MAX_N_FIELDS, and TRUE.
Referenced by btr_cur_optimistic_insert(), and dtuple_convert_big_rec().
00210 : TRUE if ok */ 00211 dtuple_t* tuple) /* in: tuple */ 00212 { 00213 dfield_t* field; 00214 ulint i; 00215 00216 if (dtuple_get_n_fields(tuple) > REC_MAX_N_FIELDS) { 00217 fprintf(stderr, 00218 "InnoDB: Error: index entry has %lu fields\n", 00219 (ulong) dtuple_get_n_fields(tuple)); 00220 dump: 00221 fputs("InnoDB: Tuple contents: ", stderr); 00222 dtuple_print(stderr, tuple); 00223 putc('\n', stderr); 00224 00225 return(FALSE); 00226 } 00227 00228 for (i = 0; i < dtuple_get_n_fields(tuple); i++) { 00229 00230 field = dtuple_get_nth_field(tuple, i); 00231 00232 if (!dfield_check_typed_no_assert(field)) { 00233 goto dump; 00234 } 00235 } 00236 00237 return(TRUE); 00238 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void dtuple_convert_back_big_rec | ( | dict_index_t *index | __attribute__((unused)), | |
| dtuple_t * | entry, | |||
| big_rec_t * | vector | |||
| ) |
Definition at line 636 of file data0data.c.
References BTR_EXTERN_FIELD_REF_SIZE, big_rec_field_struct::data, dfield_struct::data, dtuple_get_nth_field(), big_rec_field_struct::field_no, big_rec_struct::fields, big_rec_struct::heap, big_rec_field_struct::len, dfield_struct::len, mem_heap_free, big_rec_struct::n_fields, and ut_memcpy().
Referenced by btr_cur_optimistic_insert(), and row_ins_index_entry_low().
00638 : index */ 00639 dtuple_t* entry, /* in: entry whose data was put to vector */ 00640 big_rec_t* vector) /* in, own: big rec vector; it is 00641 freed in this function */ 00642 { 00643 dfield_t* dfield; 00644 ulint i; 00645 00646 for (i = 0; i < vector->n_fields; i++) { 00647 00648 dfield = dtuple_get_nth_field(entry, 00649 vector->fields[i].field_no); 00650 /* Copy data from big rec vector */ 00651 00652 ut_memcpy(((byte*)dfield->data) 00653 + dfield->len - BTR_EXTERN_FIELD_REF_SIZE, 00654 vector->fields[i].data, 00655 vector->fields[i].len); 00656 dfield->len = dfield->len + vector->fields[i].len 00657 - BTR_EXTERN_FIELD_REF_SIZE; 00658 } 00659 00660 mem_heap_free(vector->heap); 00661 }
Here is the call graph for this function:

Here is the caller graph for this function:

| big_rec_t* dtuple_convert_big_rec | ( | dict_index_t * | index, | |
| dtuple_t * | entry, | |||
| ulint * | ext_vec, | |||
| ulint | n_ext_vec | |||
| ) |
Definition at line 485 of file data0data.c.
References BTR_EXTERN_FIELD_REF_SIZE, big_rec_field_struct::data, dfield_struct::data, dict_index_get_n_unique_in_tree(), DICT_MAX_INDEX_COL_LEN, dict_table_is_comp(), dtuple_check_typed_no_assert(), dtuple_get_n_fields(), dtuple_get_nth_field(), dtuple_print(), FALSE, big_rec_field_struct::field_no, big_rec_struct::fields, big_rec_struct::heap, index(), dfield_struct::len, big_rec_field_struct::len, mem_heap_alloc(), mem_heap_create, mem_heap_free, memset, NULL, page_get_free_space_of_empty(), rec_get_converted_size(), REC_MAX_DATA_SIZE, TRUE, ut_a, ut_memcpy(), and ut_min().
Referenced by btr_cur_optimistic_insert(), btr_cur_pessimistic_insert(), and btr_cur_pessimistic_update().
00487 : created big record vector, 00488 NULL if we are not able to shorten 00489 the entry enough, i.e., if there are 00490 too many short fields in entry */ 00491 dict_index_t* index, /* in: index */ 00492 dtuple_t* entry, /* in: index entry */ 00493 ulint* ext_vec,/* in: array of externally stored fields, 00494 or NULL: if a field already is externally 00495 stored, then we cannot move it to the vector 00496 this function returns */ 00497 ulint n_ext_vec)/* in: number of elements is ext_vec */ 00498 { 00499 mem_heap_t* heap; 00500 big_rec_t* vector; 00501 dfield_t* dfield; 00502 ulint size; 00503 ulint n_fields; 00504 ulint longest; 00505 ulint longest_i = ULINT_MAX; 00506 ibool is_externally_stored; 00507 ulint i; 00508 ulint j; 00509 00510 ut_a(dtuple_check_typed_no_assert(entry)); 00511 00512 size = rec_get_converted_size(index, entry); 00513 00514 if (UNIV_UNLIKELY(size > 1000000000)) { 00515 fprintf(stderr, 00516 "InnoDB: Warning: tuple size very big: %lu\n", (ulong) size); 00517 fputs("InnoDB: Tuple contents: ", stderr); 00518 dtuple_print(stderr, entry); 00519 putc('\n', stderr); 00520 } 00521 00522 heap = mem_heap_create(size + dtuple_get_n_fields(entry) 00523 * sizeof(big_rec_field_t) + 1000); 00524 00525 vector = mem_heap_alloc(heap, sizeof(big_rec_t)); 00526 00527 vector->heap = heap; 00528 vector->fields = mem_heap_alloc(heap, dtuple_get_n_fields(entry) 00529 * sizeof(big_rec_field_t)); 00530 00531 /* Decide which fields to shorten: the algorithm is to look for 00532 the longest field whose type is DATA_BLOB */ 00533 00534 n_fields = 0; 00535 00536 while (rec_get_converted_size(index, entry) 00537 >= ut_min(page_get_free_space_of_empty( 00538 dict_table_is_comp(index->table)) / 2, 00539 REC_MAX_DATA_SIZE)) { 00540 00541 longest = 0; 00542 for (i = dict_index_get_n_unique_in_tree(index); 00543 i < dtuple_get_n_fields(entry); i++) { 00544 00545 /* Skip over fields which already are externally 00546 stored */ 00547 00548 is_externally_stored = FALSE; 00549 00550 if (ext_vec) { 00551 for (j = 0; j < n_ext_vec; j++) { 00552 if (ext_vec[j] == i) { 00553 is_externally_stored = TRUE; 00554 } 00555 } 00556 } 00557 00558 if (!is_externally_stored) { 00559 00560 dfield = dtuple_get_nth_field(entry, i); 00561 00562 if (dfield->len != UNIV_SQL_NULL && 00563 dfield->len > longest) { 00564 00565 longest = dfield->len; 00566 00567 longest_i = i; 00568 } 00569 } 00570 } 00571 00572 /* We do not store externally fields which are smaller than 00573 DICT_MAX_INDEX_COL_LEN */ 00574 00575 #if DICT_MAX_INDEX_COL_LEN <= REC_1BYTE_OFFS_LIMIT 00576 # error "DICT_MAX_INDEX_COL_LEN <= REC_1BYTE_OFFS_LIMIT" 00577 #endif 00578 00579 if (longest < BTR_EXTERN_FIELD_REF_SIZE + 10 00580 + DICT_MAX_INDEX_COL_LEN) { 00581 /* Cannot shorten more */ 00582 00583 mem_heap_free(heap); 00584 00585 return(NULL); 00586 } 00587 00588 /* Move data from field longest_i to big rec vector; 00589 we do not let data size of the remaining entry 00590 drop below 128 which is the limit for the 2-byte 00591 offset storage format in a physical record. This 00592 we accomplish by storing 128 bytes of data in entry 00593 itself, and only the remaining part to big rec vec. 00594 00595 We store the first bytes locally to the record. Then 00596 we can calculate all ordering fields in all indexes 00597 from locally stored data. */ 00598 00599 dfield = dtuple_get_nth_field(entry, longest_i); 00600 vector->fields[n_fields].field_no = longest_i; 00601 00602 ut_a(dfield->len > DICT_MAX_INDEX_COL_LEN); 00603 00604 vector->fields[n_fields].len = dfield->len 00605 - DICT_MAX_INDEX_COL_LEN; 00606 00607 vector->fields[n_fields].data = mem_heap_alloc(heap, 00608 vector->fields[n_fields].len); 00609 00610 /* Copy data (from the end of field) to big rec vector */ 00611 00612 ut_memcpy(vector->fields[n_fields].data, 00613 ((byte*)dfield->data) + dfield->len 00614 - vector->fields[n_fields].len, 00615 vector->fields[n_fields].len); 00616 dfield->len = dfield->len - vector->fields[n_fields].len 00617 + BTR_EXTERN_FIELD_REF_SIZE; 00618 00619 /* Set the extern field reference in dfield to zero */ 00620 memset(((byte*)dfield->data) 00621 + dfield->len - BTR_EXTERN_FIELD_REF_SIZE, 00622 0, BTR_EXTERN_FIELD_REF_SIZE); 00623 n_fields++; 00624 } 00625 00626 vector->n_fields = n_fields; 00627 return(vector); 00628 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 144 of file data0data.c.
References dtuple_create(), and mem_heap_create.
00147 : created memory heap */ 00148 ulint n_fields) /* in: number of fields */ 00149 { 00150 *heap = (void*)mem_heap_create(500); 00151 00152 return(dtuple_create(*((mem_heap_t**)heap), n_fields)); 00153 }
Here is the call graph for this function:

Definition at line 99 of file data0data.c.
References cmp_dfield_dfield(), DATA_TUPLE_MAGIC_N, dtuple_check_typed(), dtuple_get_n_fields(), dtuple_get_nth_field(), FALSE, dtuple_struct::magic_n, TRUE, and ut_ad.
Referenced by row_vers_old_has_index_entry().
00101 : TRUE if length and fieds are equal 00102 when compared with cmp_data_data: 00103 NOTE: in character type fields some letters 00104 are identified with others! (collation) */ 00105 dtuple_t* tuple1, /* in: tuple 1 */ 00106 dtuple_t* tuple2) /* in: tuple 2 */ 00107 { 00108 dfield_t* field1; 00109 dfield_t* field2; 00110 ulint n_fields; 00111 ulint i; 00112 00113 ut_ad(tuple1 && tuple2); 00114 ut_ad(tuple1->magic_n == DATA_TUPLE_MAGIC_N); 00115 ut_ad(tuple2->magic_n == DATA_TUPLE_MAGIC_N); 00116 ut_ad(dtuple_check_typed(tuple1)); 00117 ut_ad(dtuple_check_typed(tuple2)); 00118 00119 n_fields = dtuple_get_n_fields(tuple1); 00120 00121 if (n_fields != dtuple_get_n_fields(tuple2)) { 00122 00123 return(FALSE); 00124 } 00125 00126 for (i = 0; i < n_fields; i++) { 00127 00128 field1 = dtuple_get_nth_field(tuple1, i); 00129 field2 = dtuple_get_nth_field(tuple2, i); 00130 00131 if (0 != cmp_dfield_dfield(field1, field2)) { 00132 00133 return(FALSE); 00134 } 00135 } 00136 00137 return(TRUE); 00138 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void dtuple_free_for_mysql | ( | void * | heap | ) |
Definition at line 159 of file data0data.c.
References mem_heap_free.
00161 : memory heap where tuple was created */ 00162 { 00163 mem_heap_free((mem_heap_t*)heap); 00164 }
Definition at line 51 of file data0data.c.
References dtuple_get_n_fields().
00052 : tuple */ 00053 { 00054 return(dtuple_get_n_fields(tuple)); 00055 }
Here is the call graph for this function:

Definition at line 57 of file data0data.c.
References dtuple_get_nth_field().
00058 : tuple */ 00059 ulint n) /* in: index of field */ 00060 { 00061 return(dtuple_get_nth_field(tuple, n)); 00062 }
Here is the call graph for this function:

| void dtuple_print | ( | FILE * | f, | |
| dtuple_t * | tuple | |||
| ) |
Definition at line 454 of file data0data.c.
References dfield_print_raw(), dtuple_get_n_fields(), dtuple_get_nth_field(), and ut_ad.
Referenced by btr_cur_optimistic_insert(), dtuple_check_typed_no_assert(), dtuple_convert_big_rec(), ibuf_delete_rec(), ibuf_insert_to_index_page(), row_ins_foreign_report_add_err(), row_ins_foreign_report_err(), row_scan_and_check_index(), row_undo_mod_del_unmark_sec_and_undo_update(), and row_upd_sec_index_entry().
00456 : output stream */ 00457 dtuple_t* tuple) /* in: tuple */ 00458 { 00459 ulint n_fields; 00460 ulint i; 00461 00462 n_fields = dtuple_get_n_fields(tuple); 00463 00464 fprintf(f, "DATA TUPLE: %lu fields;\n", (ulong) n_fields); 00465 00466 for (i = 0; i < n_fields; i++) { 00467 fprintf(f, " %lu:", (ulong) i); 00468 00469 dfield_print_raw(f, dtuple_get_nth_field(tuple, i)); 00470 00471 putc(';', f); 00472 } 00473 00474 putc('\n', f); 00475 ut_ad(dtuple_validate(tuple)); 00476 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 171 of file data0data.c.
References dtuple_struct::n_fields, dtuple_struct::n_fields_cmp, and ut_ad.
Referenced by row_scan_and_check_index(), and row_sel_convert_mysql_key_to_innobase().
00173 : tuple */ 00174 ulint n_fields) /* in: number of fields */ 00175 { 00176 ut_ad(tuple); 00177 00178 tuple->n_fields = n_fields; 00179 tuple->n_fields_cmp = n_fields; 00180 }
Here is the caller graph for this function:

1.4.7

