diff options
Diffstat (limited to 'storage/innobase/row/row0upd.cc')
-rw-r--r-- | storage/innobase/row/row0upd.cc | 145 |
1 files changed, 40 insertions, 105 deletions
diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc index 0d0e908fdc3..aefe7e6dc96 100644 --- a/storage/innobase/row/row0upd.cc +++ b/storage/innobase/row/row0upd.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2015, 2017, MariaDB Corporation. +Copyright (c) 2015, 2018, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -319,9 +319,20 @@ row_upd_check_references_constraints( But the counter on the table protects 'foreign' from being dropped while the check is running. */ + if (foreign_table) { + my_atomic_addlint( + &foreign_table->n_foreign_key_checks_running, + 1); + } + err = row_ins_check_foreign_constraint( FALSE, foreign, table, entry, thr); + if (foreign_table) { + my_atomic_addlint( + &foreign_table->n_foreign_key_checks_running, + -1); + } if (ref_table != NULL) { dict_table_close(ref_table, FALSE, FALSE); } @@ -342,11 +353,6 @@ func_exit: mem_heap_free(heap); DEBUG_SYNC_C("foreign_constraint_check_for_update_done"); - - DBUG_EXECUTE_IF("row_upd_cascade_lock_wait_err", - err = DB_LOCK_WAIT; - DBUG_SET("-d,row_upd_cascade_lock_wait_err");); - DBUG_RETURN(err); } @@ -469,9 +475,8 @@ wsrep_must_process_fk(const upd_node_t* node, const trx_t* trx) return false; } - const upd_node_t* parent = static_cast<const upd_node_t*>(node->common.parent); - - return parent->cascade_upd_nodes->empty(); + return static_cast<upd_node_t*>(node->common.parent)->cascade_node + == node; } #endif /* WITH_WSREP */ @@ -1261,7 +1266,7 @@ row_upd_index_replace_new_col_val( } len = dtype_get_at_most_n_mbchars(col->prtype, - col->mbminmaxlen, + col->mbminlen, col->mbmaxlen, field->prefix_len, len, (const char*) data); @@ -1514,12 +1519,7 @@ row_upd_replace_vcol( dfield_copy_data(dfield, upd_field->old_v_val); } - dfield_get_type(dfield)->mtype = - upd_field->new_val.type.mtype; - dfield_get_type(dfield)->prtype = - upd_field->new_val.type.prtype; - dfield_get_type(dfield)->mbminmaxlen = - upd_field->new_val.type.mbminmaxlen; + dfield->type = upd_field->new_val.type; break; } } @@ -2108,6 +2108,7 @@ row_upd_eval_new_vals( @param[in] update an update vector if it is update @param[in] thd mysql thread handle @param[in,out] mysql_table mysql table object */ +static void row_upd_store_v_row( upd_node_t* node, @@ -2155,7 +2156,6 @@ row_upd_store_v_row( cascade update. And virtual column can't be affected, so it is Ok to set it to NULL */ - ut_ad(!node->cascade_top); dfield_set_null(dfield); } else { dfield_t* vfield @@ -2250,25 +2250,6 @@ row_upd_store_row( } /***********************************************************//** -Print a MBR data from disk */ -static -void -srv_mbr_print(const byte* data) -{ - double a, b, c, d; - a = mach_double_read(data); - data += sizeof(double); - b = mach_double_read(data); - data += sizeof(double); - c = mach_double_read(data); - data += sizeof(double); - d = mach_double_read(data); - - ib::info() << "GIS MBR INFO: " << a << " and " << b << ", " << c - << ", " << d << "\n"; -} - -/***********************************************************//** Updates a secondary index entry of a row. @return DB_SUCCESS if operation successfully completed, else error code or DB_LOCK_WAIT */ @@ -2431,8 +2412,6 @@ row_upd_sec_index_entry( << " of table " << index->table->name << " was not found on update: " << *entry << " at: " << rec_index_print(rec, index); - if (entry->fields[0].data) - srv_mbr_print((unsigned char*)entry->fields[0].data); #ifdef UNIV_DEBUG mtr_commit(&mtr); mtr_start(&mtr); @@ -2663,7 +2642,9 @@ row_upd_clust_rec_by_insert( que_thr_t* thr, /*!< in: query thread */ ibool referenced,/*!< in: TRUE if index may be referenced in a foreign key constraint */ - ibool foreign, /*!< in: TRUE if index is foreign key index */ +#ifdef WITH_WSREP + bool foreign,/*!< in: whether this is a foreign key */ +#endif mtr_t* mtr) /*!< in/out: mtr; gets committed here */ { mem_heap_t* heap; @@ -2875,15 +2856,14 @@ row_upd_clust_rec( down the index tree */ mtr->start(); - mtr->set_named_space(index->space); - /* Disable REDO logging as lifetime of temp-tables is limited to - server or connection lifetime and so REDO information is not needed - on restart for recovery. - Disable locking as temp-tables are not shared across connection. */ - if (dict_table_is_temporary(index->table)) { + if (index->table->is_temporary()) { + /* Disable locking, because temporary tables are never + shared between transactions or connections. */ flags |= BTR_NO_LOCKING_FLAG; mtr->set_log_mode(MTR_LOG_NO_REDO); + } else { + mtr->set_named_space(index->space); } /* NOTE: this transaction has an s-lock or x-lock on the record and @@ -2952,7 +2932,9 @@ row_upd_del_mark_clust_rec( ibool referenced, /*!< in: TRUE if index may be referenced in a foreign key constraint */ - ibool foreign,/*!< in: TRUE if index is foreign key index */ +#ifdef WITH_WSREP + bool foreign,/*!< in: whether this is a foreign key */ +#endif mtr_t* mtr) /*!< in: mtr; gets committed here */ { btr_pcur_t* pcur; @@ -3044,7 +3026,6 @@ row_upd_clust_step( ulint* offsets; ibool referenced; ulint flags; - ibool foreign = FALSE; trx_t* trx = thr_get_trx(thr); rec_offs_init(offsets_); @@ -3054,8 +3035,7 @@ row_upd_clust_step( referenced = row_upd_index_is_referenced(index, trx); #ifdef WITH_WSREP - foreign = wsrep_row_upd_index_is_foreign( - index, thr_get_trx(thr)); + const bool foreign = wsrep_row_upd_index_is_foreign(index, trx); #endif pcur = node->pcur; @@ -3063,7 +3043,6 @@ row_upd_clust_step( /* We have to restore the cursor to its position */ mtr.start(); - mtr.set_named_space(index->space); if (dict_table_is_temporary(node->table)) { /* Disable locking, because temporary tables are @@ -3075,6 +3054,7 @@ row_upd_clust_step( mtr.set_log_mode(MTR_LOG_NO_REDO); } else { flags = node->table->no_rollback() ? BTR_NO_ROLLBACK : 0; + mtr.set_named_space(index->space); } /* If the restoration does not succeed, then the same @@ -3161,7 +3141,11 @@ row_upd_clust_step( if (node->is_delete) { err = row_upd_del_mark_clust_rec( - node, index, offsets, thr, referenced, foreign, &mtr); + node, index, offsets, thr, referenced, +#ifdef WITH_WSREP + foreign, +#endif + &mtr); if (err == DB_SUCCESS) { node->state = UPD_NODE_UPDATE_ALL_SEC; @@ -3207,7 +3191,11 @@ row_upd_clust_step( externally! */ err = row_upd_clust_rec_by_insert( - node, index, thr, referenced, foreign, &mtr); + node, index, thr, referenced, +#ifdef WITH_WSREP + foreign, +#endif + &mtr); if (err != DB_SUCCESS) { goto exit_func; @@ -3447,56 +3435,3 @@ error_handling: DBUG_RETURN(thr); } - -#ifndef DBUG_OFF - -/** Ensure that the member cascade_upd_nodes has only one update node -for each of the tables. This is useful for testing purposes. */ -void upd_node_t::check_cascade_only_once() -{ - DBUG_ENTER("upd_node_t::check_cascade_only_once"); - - dbug_trace(); - - for (upd_cascade_t::const_iterator i = cascade_upd_nodes->begin(); - i != cascade_upd_nodes->end(); ++i) { - - const upd_node_t* update_node = *i; - std::string table_name(update_node->table->name.m_name); - ulint count = 0; - - for (upd_cascade_t::const_iterator j - = cascade_upd_nodes->begin(); - j != cascade_upd_nodes->end(); ++j) { - - const upd_node_t* node = *j; - - if (table_name == node->table->name.m_name) { - DBUG_ASSERT(count++ == 0); - } - } - } - - DBUG_VOID_RETURN; -} - -/** Print information about this object into the trace log file. */ -void upd_node_t::dbug_trace() -{ - DBUG_ENTER("upd_node_t::dbug_trace"); - - for (upd_cascade_t::const_iterator i = cascade_upd_nodes->begin(); - i != cascade_upd_nodes->end(); ++i) { - DBUG_LOG("upd_node_t", "cascade_upd_nodes: Cascade to table: " - << (*i)->table->name); - } - - for (upd_cascade_t::const_iterator j = new_upd_nodes->begin(); - j != new_upd_nodes->end(); ++j) { - DBUG_LOG("upd_node_t", "new_upd_nodes: Cascade to table: " - << (*j)->table->name); - } - - DBUG_VOID_RETURN; -} -#endif /* !DBUG_OFF */ |