35 #ifndef UNIV_HOTBACKUP
122 row_upd_changes_first_fields_binary(
141 row_upd_index_is_referenced(
148 ibool froze_data_dict = FALSE;
149 ibool is_referenced = FALSE;
157 row_mysql_freeze_data_dictionary(trx);
158 froze_data_dict = TRUE;
166 is_referenced = TRUE;
174 if (froze_data_dict) {
178 return(is_referenced);
191 row_upd_check_references_constraints(
209 ibool got_s_lock = FALSE;
233 row_mysql_freeze_data_dictionary(trx);
246 || row_upd_changes_first_fields_binary(
247 entry, index, node->
update,
256 mutex_enter(&(dict_sys->
mutex));
261 mutex_exit(&(dict_sys->
mutex));
270 FALSE, foreign, table, entry, thr);
273 mutex_enter(&(dict_sys->
mutex));
281 mutex_exit(&(dict_sys->
mutex));
284 if (err != DB_SUCCESS) {
319 node->
state = UPD_NODE_UPDATE_CLUSTERED;
320 node->in_mysql_interface = FALSE;
324 node->upd_row = NULL;
325 node->upd_ext = NULL;
329 node->foreign = NULL;
330 node->cascade_heap = NULL;
331 node->cascade_node = NULL;
336 node->magic_n = UPD_NODE_MAGIC_N;
353 const ulint* offsets,
360 if (UNIV_LIKELY_NULL(page_zip)) {
362 page_zip, rec, offsets, pos, trx_id, roll_ptr);
367 field = rec_get_nth_field(rec, offsets, pos, &len);
368 ut_ad(len == DATA_TRX_ID_LEN);
369 #if DATA_TRX_ID + 1 != DATA_ROLL_PTR
370 # error "DATA_TRX_ID + 1 != DATA_ROLL_PTR"
377 #ifndef UNIV_HOTBACKUP
400 dfield = dtuple_get_nth_field(entry, pos);
401 field =
static_cast<byte *
>(dfield_get_data(dfield));
403 if (type == DATA_TRX_ID) {
406 ut_ad(type == DATA_ROLL_PTR);
421 const ulint* offsets,
434 for (i = 0; i < n_fields; i++) {
435 upd_field = upd_get_nth_field(update, i);
437 new_val = &(upd_field->
new_val);
464 old_len = UNIV_SQL_NULL;
490 const ulint* offsets,
510 for (i = 0; i < n_fields; i++) {
511 upd_field = upd_get_nth_field(update, i);
512 new_val = &(upd_field->
new_val);
517 dfield_get_data(new_val),
521 if (UNIV_LIKELY_NULL(page_zip)) {
526 #ifndef UNIV_HOTBACKUP
547 index, DATA_TRX_ID));
550 log_ptr += DATA_ROLL_PTR_LEN;
578 if (end_ptr < ptr + DATA_ROLL_PTR_LEN) {
584 ptr += DATA_ROLL_PTR_LEN;
591 #ifndef UNIV_HOTBACKUP
614 buf_end = log_ptr + MLOG_BUF_MARGIN;
620 for (i = 0; i < n_fields; i++) {
622 #if MLOG_BUF_MARGIN <= 30
623 # error "MLOG_BUF_MARGIN <= 30"
626 if (log_ptr + 30 > buf_end) {
629 log_ptr =
mlog_open(mtr, MLOG_BUF_MARGIN);
630 buf_end = log_ptr + MLOG_BUF_MARGIN;
633 upd_field = upd_get_nth_field(update, i);
635 new_val = &(upd_field->
new_val);
642 if (len != UNIV_SQL_NULL) {
643 if (log_ptr + len < buf_end) {
644 memcpy(log_ptr, dfield_get_data(new_val), len);
651 static_cast<byte *>(dfield_get_data(new_val)),
654 log_ptr =
mlog_open(mtr, MLOG_BUF_MARGIN);
655 buf_end = log_ptr + MLOG_BUF_MARGIN;
685 if (end_ptr < ptr + 1) {
702 for (i = 0; i < n_fields; i++) {
704 upd_field = upd_get_nth_field(update, i);
705 new_val = &(upd_field->
new_val);
723 if (len != UNIV_SQL_NULL) {
725 if (end_ptr < ptr + len) {
738 *update_out = update;
743 #ifndef UNIV_HOTBACKUP
766 ulint offsets_[REC_OFFS_SMALL_SIZE];
767 const ulint* offsets;
768 rec_offs_init(offsets_);
776 offsets = rec_get_offsets(rec, index, offsets_,
777 ULINT_UNDEFINED, &heap);
781 data = rec_get_nth_field(rec, offsets, i, &len);
783 dfield = dtuple_get_nth_field(entry, i);
796 if (!dfield_data_is_binary_equal(dfield, len, data)) {
798 upd_field = upd_get_nth_field(update, n_diff);
838 ulint offsets_[REC_OFFS_NORMAL_SIZE];
839 const ulint* offsets;
840 rec_offs_init(offsets_);
852 offsets = rec_get_offsets(rec, index, offsets_,
853 ULINT_UNDEFINED, &heap);
857 data = rec_get_nth_field(rec, offsets, i, &len);
859 dfield = dtuple_get_nth_field(entry, i);
864 if (i == trx_id_pos || i == roll_ptr_pos) {
871 || !dfield_data_is_binary_equal(dfield, len, data)) {
873 upd_field = upd_get_nth_field(update, n_diff);
912 *len = btr_copy_externally_stored_field_prefix(buf, *len,
926 row_upd_index_replace_new_col_val(
948 data =
static_cast<const byte *
>(dfield_get_data(dfield));
960 data = row_upd_ext_fetch(data, l, zip_size,
964 len = dtype_get_at_most_n_mbchars(col->
prtype,
1027 const upd_t* update,
1051 for (i = 0; i < n_fields; i++) {
1056 field = dict_index_get_nth_field(index, i);
1061 row_upd_index_replace_new_col_val(
1062 dtuple_get_nth_field(entry, i),
1063 field, col, uf, heap, zip_size);
1081 const upd_t* update,
1089 = dict_table_get_first_index(index->
table);
1090 const ulint zip_size
1100 field = dict_index_get_nth_field(index, i);
1106 row_upd_index_replace_new_col_val(
1107 dtuple_get_nth_field(entry, i),
1108 field, col, uf, heap, zip_size);
1127 const upd_t* update,
1146 table = index->
table;
1149 ext_cols =
static_cast<ulint *
>(
mem_heap_alloc(heap, n_cols *
sizeof *ext_cols));
1154 for (col_no = 0; col_no < n_cols; col_no++) {
1157 = dict_table_get_nth_col(table, col_no);
1158 const ulint clust_pos
1162 if (UNIV_UNLIKELY(clust_pos == ULINT_UNDEFINED)) {
1167 dfield = dtuple_get_nth_field(row, col_no);
1172 = upd_get_nth_field(update, i);
1174 if (upd_field->
field_no != clust_pos) {
1184 ext_cols[n_ext_cols++] = col_no;
1212 const upd_t* update)
1221 ut_ad(update && index);
1226 clust_index = dict_table_get_first_index(index->
table);
1228 for (i = 0; i < n_unique; i++) {
1235 ind_field = dict_index_get_nth_field(index, i);
1240 for (j = 0; j < n_upd_fields; j++) {
1243 = upd_get_nth_field(update, j);
1254 dtuple_get_nth_field(row, col_no),
1275 const upd_t* update)
1281 index = dict_table_get_first_index(table);
1285 upd_field = upd_get_nth_field(update, i);
1305 row_upd_changes_first_fields_binary(
1309 const upd_t* update,
1316 ut_ad(update && index);
1320 clust_index = dict_table_get_first_index(index->
table);
1322 for (i = 0; i < n; i++) {
1328 ind_field = dict_index_get_nth_field(index, i);
1334 for (j = 0; j < n_upd_fields; j++) {
1337 = upd_get_nth_field(update, j);
1341 dtuple_get_nth_field(entry, i),
1356 row_upd_copy_columns(
1359 const ulint* offsets,
1367 data = rec_get_nth_field(rec, offsets,
1381 row_upd_eval_new_vals(
1392 for (i = 0; i < n_fields; i++) {
1393 upd_field = upd_get_nth_field(update, i);
1395 exp = upd_field->
exp;
1415 ulint offsets_[REC_OFFS_NORMAL_SIZE];
1416 const ulint* offsets;
1417 rec_offs_init(offsets_);
1421 if (node->
row != NULL) {
1425 clust_index = dict_table_get_first_index(node->
table);
1429 offsets = rec_get_offsets(rec, clust_index, offsets_,
1430 ULINT_UNDEFINED, &heap);
1445 node->
row =
row_build(ROW_COPY_DATA, clust_index, rec, offsets,
1446 NULL, ext, node->
heap);
1447 if (node->is_delete) {
1448 node->upd_row = NULL;
1449 node->upd_ext = NULL;
1456 if (UNIV_LIKELY_NULL(heap)) {
1467 row_upd_sec_index_entry(
1480 ulint err = DB_SUCCESS;
1485 index = node->
index;
1487 referenced = row_upd_index_is_referenced(index, trx);
1499 btr_pcur_get_btr_cur(&pcur)->thr = thr;
1511 btr_cur = btr_pcur_get_btr_cur(&pcur);
1515 switch (search_result) {
1524 fputs(
"InnoDB: error in sec index entry update in\n"
1525 "InnoDB: ", stderr);
1526 dict_index_name_print(stderr, trx, index);
1528 "InnoDB: tuple ", stderr);
1529 dtuple_print(stderr, entry);
1531 "InnoDB: record ", stderr);
1538 "InnoDB: Submit a detailed bug report"
1539 " to http://bugs.mysql.com\n", stderr);
1549 err = btr_cur_del_mark_set_sec_rec(
1550 0, btr_cur, TRUE, thr, &mtr);
1552 if (err == DB_SUCCESS && referenced) {
1556 offsets = rec_get_offsets(
1557 rec, index, NULL, ULINT_UNDEFINED,
1562 err = row_upd_check_references_constraints(
1563 node, &pcur, index->
table,
1564 index, offsets, thr, &mtr);
1573 if (node->is_delete || err != DB_SUCCESS) {
1604 ut_ad((node->
state == UPD_NODE_UPDATE_ALL_SEC)
1605 || (node->
state == UPD_NODE_UPDATE_SOME_SEC));
1608 if (node->
state == UPD_NODE_UPDATE_ALL_SEC
1611 return(row_upd_sec_index_entry(node, thr));
1626 row_upd_clust_rec_by_insert(
1642 ibool change_ownership = FALSE;
1648 table = node->
table;
1650 btr_cur = btr_pcur_get_btr_cur(pcur);
1652 if (node->
state != UPD_NODE_INSERT_CLUSTERED) {
1655 ulint offsets_[REC_OFFS_NORMAL_SIZE];
1657 rec_offs_init(offsets_);
1659 err = btr_cur_del_mark_set_clust_rec(BTR_NO_LOCKING_FLAG,
1660 btr_cur, TRUE, thr, mtr);
1661 if (err != DB_SUCCESS) {
1672 node_index = dict_table_get_first_index(table);
1673 offsets = rec_get_offsets(rec, node_index, offsets_,
1674 ULINT_UNDEFINED, &heap);
1675 change_ownership = btr_cur_mark_extern_inherited_fields(
1682 err = row_upd_check_references_constraints(
1683 node, pcur, table, node_index, offsets, thr, mtr);
1685 if (err != DB_SUCCESS) {
1689 if (UNIV_LIKELY_NULL(heap)) {
1703 node->
state = UPD_NODE_INSERT_CLUSTERED;
1711 if (change_ownership) {
1717 btr_cur_unmark_dtuple_extern_fields(entry);
1722 btr_cur_mark_dtuple_inherited_extern(entry, node->
update);
1726 node->upd_ext ? node->upd_ext->
n_ext : 0,
1757 btr_cur = btr_pcur_get_btr_cur(pcur);
1766 if (node->cmpl_info & UPD_NODE_NO_SIZE_CHANGE) {
1767 err = btr_cur_update_in_place(BTR_NO_LOCKING_FLAG,
1769 node->cmpl_info, thr, mtr);
1771 err = btr_cur_optimistic_update(BTR_NO_LOCKING_FLAG,
1773 node->cmpl_info, thr, mtr);
1778 if (UNIV_LIKELY(err == DB_SUCCESS)) {
1783 if (buf_LRU_buf_pool_running_out()) {
1785 return(DB_LOCK_TABLE_FULL);
1803 err = btr_cur_pessimistic_update(BTR_NO_LOCKING_FLAG, btr_cur,
1804 &heap, &big_rec, node->
update,
1805 node->cmpl_info, thr, mtr);
1808 if (err == DB_SUCCESS && big_rec) {
1809 ulint offsets_[REC_OFFS_NORMAL_SIZE];
1811 rec_offs_init(offsets_);
1817 err = btr_store_big_rec_extern_fields(
1819 rec_get_offsets(rec, index, offsets_,
1820 ULINT_UNDEFINED, &heap),
1825 if (UNIV_LIKELY_NULL(heap)) {
1841 row_upd_del_mark_clust_rec(
1859 ut_ad(node->is_delete);
1862 btr_cur = btr_pcur_get_btr_cur(pcur);
1867 row_upd_store_row(node);
1872 err = btr_cur_del_mark_set_clust_rec(BTR_NO_LOCKING_FLAG,
1873 btr_cur, TRUE, thr, mtr);
1874 if (err == DB_SUCCESS && referenced) {
1877 err = row_upd_check_references_constraints(
1878 node, pcur, index->
table, index, offsets, thr, mtr);
1905 ulint offsets_[REC_OFFS_NORMAL_SIZE];
1908 rec_offs_init(offsets_);
1910 index = dict_table_get_first_index(node->
table);
1912 referenced = row_upd_index_is_referenced(index,
thr_get_trx(thr));
1934 err = DB_RECORD_NOT_FOUND;
1945 if (node->is_delete && node->
table->
id == DICT_INDEXES_ID) {
1965 offsets = rec_get_offsets(rec, index, offsets_,
1966 ULINT_UNDEFINED, &heap);
1968 if (!node->has_clust_rec_x_lock) {
1971 rec, index, offsets, thr);
1972 if (err != DB_SUCCESS) {
1980 if (node->is_delete) {
1981 err = row_upd_del_mark_clust_rec(
1982 node, index, offsets, thr, referenced, mtr);
1984 if (err == DB_SUCCESS) {
1985 node->
state = UPD_NODE_UPDATE_ALL_SEC;
1986 node->
index = dict_table_get_next_index(index);
1989 if (UNIV_LIKELY_NULL(heap)) {
1998 if (UNIV_UNLIKELY(!node->in_mysql_interface)) {
2001 row_upd_copy_columns(rec, offsets,
2003 row_upd_eval_new_vals(node->
update);
2006 if (UNIV_LIKELY_NULL(heap)) {
2010 if (node->cmpl_info & UPD_NODE_NO_ORD_CHANGE) {
2012 err = row_upd_clust_rec(node, index, thr, mtr);
2016 row_upd_store_row(node);
2031 err = row_upd_clust_rec_by_insert(
2032 node, index, thr, referenced, mtr);
2034 if (err != DB_SUCCESS) {
2039 node->
state = UPD_NODE_UPDATE_ALL_SEC;
2041 err = row_upd_clust_rec(node, index, thr, mtr);
2043 if (err != DB_SUCCESS) {
2048 node->
state = UPD_NODE_UPDATE_SOME_SEC;
2051 node->
index = dict_table_get_next_index(index);
2069 ulint err = DB_SUCCESS;
2073 if (UNIV_LIKELY(node->in_mysql_interface)) {
2081 node->cmpl_info = 0;
2083 node->cmpl_info = UPD_NODE_NO_ORD_CHANGE;
2087 if (node->
state == UPD_NODE_UPDATE_CLUSTERED
2088 || node->
state == UPD_NODE_INSERT_CLUSTERED) {
2091 err = row_upd_clust_step(node, thr);
2093 if (err != DB_SUCCESS) {
2099 if (!node->is_delete && (node->cmpl_info & UPD_NODE_NO_ORD_CHANGE)) {
2104 while (node->
index != NULL) {
2107 err = row_upd_sec_step(node, thr);
2109 if (err != DB_SUCCESS) {
2114 node->
index = dict_table_get_next_index(node->
index);
2118 if (err == DB_SUCCESS) {
2121 if (node->
row != NULL) {
2124 node->upd_row = NULL;
2125 node->upd_ext = NULL;
2129 node->
state = UPD_NODE_UPDATE_CLUSTERED;
2148 ulint err = DB_SUCCESS;
2166 node->
state = UPD_NODE_SET_IX_LOCK;
2169 if (node->
state == UPD_NODE_SET_IX_LOCK) {
2171 if (!node->has_clust_rec_x_lock) {
2177 if (err != DB_SUCCESS) {
2179 goto error_handling;
2183 node->
state = UPD_NODE_UPDATE_CLUSTERED;
2185 if (node->searched_update) {
2201 if (!node->searched_update) {
2209 goto error_handling;
2224 err = row_upd(node, thr);
2229 if (err != DB_SUCCESS) {
2235 if (node->searched_update) {
2245 node->
state = UPD_NODE_UPDATE_CLUSTERED;