212 #define INNOBASE_WAKE_INTERVAL 32
223 return(pcur->
old_stored == BTR_PCUR_OLD_STORED
224 && (pcur->
pos_state == BTR_PCUR_IS_POSITIONED
225 || pcur->
pos_state == BTR_PCUR_WAS_POSITIONED));
287 ib_lookup_table_by_name(
312 static ulint ib_signal_counter = 0;
336 for (i = 0; i < n_fields; ++
i) {
357 ib_bool_t page_format,
364 ulint n_index_fields;
365 ulint offsets_[REC_OFFS_NORMAL_SIZE];
370 rec_offs_init(offsets_);
372 offsets = rec_get_offsets(
373 rec, index, offsets, ULINT_UNDEFINED, &tuple->
heap);
385 for (i = 0; i < n_index_fields; ++
i) {
395 index_field = dict_index_get_nth_field(index, i);
399 dfield = dtuple_get_nth_field(dtuple, col_no);
401 dfield = dtuple_get_nth_field(dtuple, i);
404 data = rec_get_nth_field(copy, offsets, i, &len);
414 copy, offsets, zip_size, i, &len,
417 ut_a(len != UNIV_SQL_NULL);
429 ib_key_tuple_new_low(
462 for (i = 0; i < n_cols; i++) {
466 dfield = dtuple_get_nth_field(tuple->
ptr, i);
495 return(ib_key_tuple_new_low(index, n_cols, heap));
503 ib_row_tuple_new_low(
548 return(ib_row_tuple_new_low(index, n_cols, heap));
567 trx_start_if_not_started(trx);
622 return(static_cast<ib_u64_t>(trx->
start_time));
654 if (trx->
state == TRX_STATE_NOT_STARTED) {
662 ut_a(err == DB_SUCCESS);
683 ut_a(err == DB_SUCCESS);
686 ut_a(err == DB_SUCCESS);
705 for (i = 0; i < ib_vector_size(indexes); ++
i) {
730 prtype |= DATA_UNSIGNED;
736 prtype |= DATA_NOT_NULL;
768 for (i = 0; i < ib_vector_size(cols); ++
i) {
771 ib_col =
static_cast<const ib_col_t*
>(
794 for (i = 0; i < ib_vector_size(cols); ++
i) {
817 *ptr = tolower(*ptr);
834 ib_normalize_table_name(
840 const char* ptr =
name;
847 while (ptr >= name && *ptr !=
'\\' && *ptr !=
'/' && ptr > name) {
859 table_name = ptr + 1;
863 while (ptr >= name && *ptr !=
'\\' && *ptr !=
'/') {
869 memcpy(norm_name, db_name,
872 norm_name[table_name - db_name - 1] =
'/';
874 ib_to_lower_case(norm_name);
891 const char* slash = NULL;
896 || name[len - 1] ==
'/'
897 || (name[0] ==
'.' && name[1] ==
'/')
898 || (name[0] ==
'.' && name[1] ==
'.' && name[2] ==
'/')) {
941 n_indexes = ib_vector_size(indexes);
943 for (i = 0; i < n_indexes; ++
i) {
950 return(ib_index_def);
964 const char* table_name,
965 ib_id_u64_t* table_id)
972 table = ib_lookup_table_by_name(table_name);
975 *table_id = (table->
id);
1014 return(DB_OUT_OF_MEMORY);
1033 if (prebuilt->
trx != NULL) {
1048 err = DB_OUT_OF_MEMORY;
1060 ib_create_cursor_with_index_id(
1064 ib_id_u64_t index_id,
1069 if (index_id != 0) {
1074 index = dict_table_get_first_index(table);
1077 return(ib_create_cursor(ib_crsr, table, index, trx));
1087 ib_id_u64_t table_id,
1096 table = ib_open_table_by_id(table_id, FALSE);
1098 table = ib_open_table_by_id(table_id, TRUE);
1101 if (table == NULL) {
1103 return(DB_TABLE_NOT_FOUND);
1106 err = ib_create_cursor_with_index_id(ib_crsr, table, 0,
1119 ib_id_u64_t index_id,
1126 ulint table_id = (ulint)( index_id >> 32);
1129 table = ib_open_table_by_id(table_id, FALSE);
1131 table = ib_open_table_by_id(table_id, TRUE);
1134 if (table == NULL) {
1136 return(DB_TABLE_NOT_FOUND);
1140 err = ib_create_cursor_with_index_id(
1141 ib_crsr, table, index_id, (
trx_t*) ib_trx);
1143 if (ib_crsr != NULL) {
1152 ut_a(crsr_err == DB_SUCCESS);
1169 const char* index_name,
1172 ib_id_u64_t* idx_id)
1176 index_id_t index_id = 0;
1187 ut_a(table != NULL);
1190 index = dict_table_get_first_index(table);
1193 while (index != NULL) {
1195 index_id = index->
id;
1196 *idx_type = index->
type;
1210 err = ib_create_cursor(
1214 if (*ib_crsr != NULL) {
1221 ut_a(err == DB_SUCCESS);
1243 char* normalized_name;
1245 normalized_name =
static_cast<char*
>(mem_alloc(
ut_strlen(name) + 1));
1246 ib_normalize_table_name(normalized_name, name);
1248 if (ib_trx != NULL) {
1254 table = ib_lookup_table_by_name(normalized_name);
1261 normalized_name = NULL;
1266 if (table != NULL && dict_table_get_first_index(table) == NULL) {
1270 if (table != NULL) {
1271 err = ib_create_cursor_with_index_id(ib_crsr, table, 0,
1274 err = DB_TABLE_NOT_FOUND;
1292 memset(q_proc, 0x0,
sizeof(*q_proc));
1328 ib_qry_proc_free(&cursor->
q_proc);
1356 ib_qry_proc_free(&cursor->
q_proc);
1378 prebuilt->
trx = NULL;
1401 trx = prebuilt->
trx;
1403 ib_qry_proc_free(&cursor->
q_proc);
1433 if (prebuilt && prebuilt->
table) {
1453 ib_bool_t lock_wait;
1465 if (err != DB_SUCCESS) {
1474 }
while (lock_wait);
1484 ib_execute_insert_query_graph(
1495 trx = ins_graph->
trx;
1505 if (err == DB_SUCCESS) {
1522 ib_insert_query_graph_create(
1530 ut_a(trx->
state != TRX_STATE_NOT_STARTED);
1532 if (node->
ins == NULL) {
1541 node->
ins->values_list = NULL;
1553 grph->
ins->
state = QUE_FORK_ACTIVE;
1576 ib_insert_query_graph_create(cursor);
1580 q_proc = &cursor->
q_proc;
1581 node = &q_proc->
node;
1583 node->
ins->
state = INS_NODE_ALLOC_ROW_ID;
1584 dst_dtuple = node->
ins->
row;
1591 for (i = 0; i < n_fields; i++) {
1596 src_field = dtuple_get_nth_field(src_tuple->
ptr, i);
1601 if (mtype != DATA_SYS) {
1606 if ((prtype & DATA_NOT_NULL)
1613 dst_field = dtuple_get_nth_field(dst_dtuple, i);
1619 dst_field, src_field->
data, src_field->
len);
1622 UNIV_MEM_ASSERT_RW(dst_field->
data,
1628 if (err == DB_SUCCESS) {
1629 err = ib_execute_insert_query_graph(
1654 ut_a(trx->
state != TRX_STATE_NOT_STARTED);
1656 if (node->
upd == NULL) {
1665 grph->
upd->
state = QUE_FORK_ACTIVE;
1684 dict_index_t* index = dict_table_get_first_index(table);
1688 if (data_len == UNIV_SQL_NULL) {
1694 upd_field->
exp = NULL;
1699 &table->
cols[col_no], index);
1716 ulint n_changed = 0;
1724 for (i = 0; i < n_fields; ++
i) {
1731 new_dfield = dtuple_get_nth_field(new_tuple->
ptr, i);
1732 old_dfield = dtuple_get_nth_field(old_tuple->
ptr, i);
1738 if (mtype == DATA_SYS) {
1741 }
else if ((prtype & DATA_NOT_NULL)
1750 && memcmp(dfield_get_data(new_dfield),
1751 dfield_get_data(old_dfield),
1754 upd_field = &upd->
fields[n_changed];
1756 ib_update_col(cursor, upd_field, i, new_dfield);
1762 if (err == DB_SUCCESS) {
1785 ib_bool_t lock_wait;
1797 if (err != DB_SUCCESS) {
1800 if (err != DB_RECORD_NOT_FOUND) {
1804 &err, trx, thr, savept);
1813 }
while (lock_wait);
1837 ut_a(trx->
state != TRX_STATE_NOT_STARTED);
1850 node->
state = UPD_NODE_UPDATE_CLUSTERED;
1856 if (err == DB_SUCCESS) {
1860 if (node->is_delete) {
1869 }
else if (err == DB_RECORD_NOT_FOUND) {
1910 err = ib_calc_diff(cursor, upd, old_tuple, new_tuple);
1912 if (err == DB_SUCCESS) {
1942 ib_bool_t page_format;
1944 dict_index_t* index = dict_table_get_first_index(table);
1947 ib_tpl = ib_key_tuple_new(index, n_cols);
1950 return(DB_OUT_OF_MEMORY);
1958 ib_read_tuple(rec, page_format, tuple);
1966 dfield = dtuple_get_nth_field(tuple->
ptr, i);
1970 upd_field->
exp = NULL;
1977 &table->
cols[i], index);
2005 index = dict_table_get_first_index(prebuilt->
index->
table);
2008 if (index != prebuilt->
index) {
2015 pcur = &prebuilt->
pcur;
2020 ib_bool_t page_format;
2027 if (btr_pcur_restore_position(
2030 rec = btr_pcur_get_rec(pcur);
2038 err = ib_delete_row(cursor, pcur, rec);
2040 err = DB_RECORD_NOT_FOUND;
2043 err = DB_RECORD_NOT_FOUND;
2071 err = DB_RECORD_NOT_FOUND;
2081 pcur = &prebuilt->
pcur;
2092 ib_bool_t page_format;
2095 rec = btr_pcur_get_rec(pcur);
2103 ib_read_tuple(rec, page_format, tuple);
2106 err = DB_RECORD_NOT_FOUND;
2110 err = DB_RECORD_NOT_FOUND;
2133 buf =
static_cast<unsigned char*
>(mem_alloc(UNIV_PAGE_SIZE));
2140 buf, mode, prebuilt, 0, 0));
2187 byte
buf[UNIV_PAGE_SIZE_MAX];
2226 for (i = 0; i < n_fields; ++
i) {
2227 dfield_copy(dtuple_get_nth_field(search_tuple, i),
2228 dtuple_get_nth_field(tuple->
ptr, i));
2235 buf =
static_cast<unsigned char*
>(mem_alloc(UNIV_PAGE_SIZE));
2238 buf, ib_srch_mode, prebuilt, cursor->
match_mode, 0));
2271 dfield = dtuple_get_nth_field(tuple->
ptr, col_no);
2285 return(static_cast<ib_err_t>(
2322 dtype = dfield_get_type(dfield);
2330 dst = dfield_get_data(dfield);
2337 len =
ut_min(len, col_len);
2348 return(DB_OUT_OF_MEMORY);
2354 if (col_len == len) {
2359 static_cast<const byte*>(src),
2369 if (len ==
sizeof(
float)) {
2377 if (len ==
sizeof(
double)) {
2390 ulint pad_char = ULINT_UNDEFINED;
2395 ut_a(pad_char != ULINT_UNDEFINED);
2397 memset((byte*) dst + len,
2401 memcpy(dst, src, len);
2410 case DATA_FIXBINARY:
2412 memcpy(dst, src, len);
2415 dst = dfield_get_data(dfield);
2420 case DATA_VARMYSQL: {
2424 ulint true_len = len;
2430 cs = all_charsets[cset];
2432 uint pos = (uint)(col_len / cs->mbmaxlen);
2434 if (len > 0 && cs->mbmaxlen > 1) {
2436 cs->cset->well_formed_len(
2439 (
const char*)src + len,
2443 if (true_len < len) {
2452 memcpy(dst, src, len);
2459 if (len < col_len) {
2460 ulint pad_len = col_len - len;
2463 ut_a(!(pad_len % cs->mbminlen));
2465 cs->cset->fill(cs, (
char*)dst + len,
2480 while (col_len > n_chars
2481 && ((
char*)dst)[col_len - 1] == 0x20) {
2494 if (dst != dfield_get_data(dfield)) {
2521 return(data_len == UNIV_SQL_NULL ?
IB_SQL_NULL : data_len);
2543 data = dfield_get_data(dfield);
2546 if (data_len != UNIV_SQL_NULL) {
2548 const dtype_t* dtype = dfield_get_type(dfield);
2555 ut_a(data_len == len);
2564 }
else if (len == 2) {
2566 }
else if (len == 4) {
2574 }
else if (len == 2) {
2576 }
else if (len == 4) {
2586 if (len == data_len) {
2589 ut_a(data_len ==
sizeof(f));
2592 memcpy(dst, &f,
sizeof(f));
2598 if (len == data_len) {
2601 ut_a(data_len ==
sizeof(d));
2604 memcpy(dst, &d,
sizeof(d));
2610 data_len =
ut_min(data_len, len);
2611 memcpy(dst, data, data_len);
2646 if (prtype & DATA_UNSIGNED) {
2650 if (prtype & DATA_NOT_NULL) {
2670 dict_col_t* col = dict_table_get_nth_col(table, i);
2693 field = dict_index_get_nth_field(cursor->
prebuilt->
index, i);
2696 return(field->
name);
2732 ib_col_meta->
client_type = prtype & DATA_MYSQL_TYPE_MASK;
2755 return(DB_UNDERFLOW);
2756 }
else if (ib_col_meta.
type_len != size) {
2780 if (err == DB_SUCCESS) {
2802 if (err == DB_SUCCESS) {
2824 if (err == DB_SUCCESS) {
2846 if (err == DB_SUCCESS) {
2868 if (err == DB_SUCCESS) {
2890 if (err == DB_SUCCESS) {
2912 if (err == DB_SUCCESS) {
2934 if (err == DB_SUCCESS) {
2958 data = dfield_get_data(dfield);
2961 return(data_len != UNIV_SQL_NULL ? data : NULL);
2993 index = tuple->
index;
2999 return(ib_row_tuple_new_low(index, n_cols, heap));
3001 return(ib_key_tuple_new_low(index, n_cols, heap));
3026 clust_index = dict_table_get_first_index(cursor->
prebuilt->
table);
3034 }
else if (src_tuple->
index == clust_index) {
3042 return(DB_OUT_OF_MEMORY);
3051 for (i = 0; i < n_fields; i++) {
3059 ut_a(pos != ULINT_UNDEFINED);
3061 src_field = dtuple_get_nth_field(src_tuple->
ptr, pos);
3062 dst_field = dtuple_get_nth_field(dst_tuple->
ptr, i);
3065 UNIV_MEM_ASSERT_RW(src_field->
data, src_field->
len);
3072 dst_field->
len = src_field->
len;
3099 ut_a(src_tuple != dst_tuple);
3102 if (src_tuple->
type != dst_tuple->
type
3112 for (i = 0; i < n_fields; ++
i) {
3116 src_field = dtuple_get_nth_field(src_tuple->
ptr, i);
3117 dst_field = dtuple_get_nth_field(dst_tuple->
ptr, i);
3120 UNIV_MEM_ASSERT_RW(src_field->
data, src_field->
len);
3127 dst_field->
len = src_field->
len;
3150 return(ib_key_tuple_new(index, n_cols));
3167 return(ib_row_tuple_new(index, n_cols));
3183 index = dict_table_get_first_index(cursor->
prebuilt->
table);
3186 return(ib_key_tuple_new(index, n_cols));
3202 index = dict_table_get_first_index(cursor->
prebuilt->
table);
3205 return(ib_row_tuple_new(index, n_cols));
3264 const char* table_name,
3265 ib_id_u64_t* table_id)
3271 err = ib_table_get_id_low(table_name, table_id);
3285 const char* table_name,
3286 const char* index_name,
3287 ib_id_u64_t* index_id)
3290 char* normalized_name;
3295 normalized_name =
static_cast<char*
>(
3297 ib_normalize_table_name(normalized_name, table_name);
3299 table = ib_lookup_table_by_name(normalized_name);
3302 normalized_name = NULL;
3304 if (table != NULL) {
3309 if (index != NULL) {
3313 *index_id = (table->
id);
3315 *index_id |= (index->
id);
3325 #define SRV_PATH_SEPARATOR '\\'
3327 #define SRV_PATH_SEPARATOR '/'
3391 trx, table, (
enum lock_mode) ib_lck_mode));
3402 ib_id_u64_t table_id,
3412 ut_a(trx->
state != TRX_STATE_NOT_STARTED);
3414 table = ib_open_table_by_id(table_id, FALSE);
3416 if (table == NULL) {
3417 return(DB_TABLE_NOT_FOUND);
3420 ut_a(ib_lck_mode <= static_cast<ib_lck_mode_t>(LOCK_NUM));
3431 trx->
op_info =
"setting table lock";
3435 lock_table(0, table, (
enum lock_mode) ib_lck_mode, thr));
3480 ut_a(ib_lck_mode <= static_cast<ib_lck_mode_t>(LOCK_NUM));
3488 if (err == DB_SUCCESS) {
3535 || value_len != data_len) {
3694 &val,
sizeof(val),
true));
3745 &val,
sizeof(val),
true));
3788 ib_id_u64_t* table_id)
3798 if (err == DB_SUCCESS) {
3804 trx = prebuilt->
trx;
3806 ut_a(err == DB_SUCCESS);
3812 if (trx->
state == TRX_STATE_ACTIVE) {
3814 trx->start_file = 0;
3824 if (err == DB_SUCCESS) {
3825 *table_id = (table->
id);
3839 const char* table_name,
3840 ib_id_u64_t* table_id)
3855 if (table != NULL && dict_table_get_first_index(table)) {
3856 err = ib_create_cursor_with_index_id(&ib_crsr, table, 0,
3859 err = DB_TABLE_NOT_FOUND;
3864 if (err == DB_SUCCESS) {
3866 ut_a(err == DB_SUCCESS);
3871 if (ib_crsr != NULL) {
3873 ut_a(err == DB_SUCCESS);
3876 if (trunc_err == DB_SUCCESS) {
3878 TRX_STATE_NOT_STARTED));
3881 ut_a(err == DB_SUCCESS);
3884 ut_a(err == DB_SUCCESS);
3940 cfg_status |= IB_CFG_MDL_ENABLED;
3944 cfg_status |= IB_CFG_DISABLE_ROWLOCK;