diff --git a/storage/innobase/dict/dict0mem.cc b/storage/innobase/dict/dict0mem.cc index b988affac5b..372cd1bb754 100644 --- a/storage/innobase/dict/dict0mem.cc +++ b/storage/innobase/dict/dict0mem.cc @@ -304,12 +304,12 @@ dict_mem_table_add_col( dict_mem_fill_column_struct(col, i, mtype, prtype, len); - if (prtype & DATA_VERS_ROW_START) { - ut_ad(!(prtype & DATA_VERS_ROW_END)); - table->vers_row_start = i; - } else if (prtype & DATA_VERS_ROW_END) { - ut_ad(!(prtype & DATA_VERS_ROW_START)); - table->vers_row_end = i; + if (prtype & DATA_VERS_START) { + ut_ad(!(prtype & DATA_VERS_END)); + table->vers_start = i; + } else if (prtype & DATA_VERS_END) { + ut_ad(!(prtype & DATA_VERS_START)); + table->vers_end = i; } } diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 7d1124cbd00..feeb11f3d17 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -11400,9 +11400,9 @@ create_table_info_t::create_table_def() if (m_form->versioned()) { if (i == m_form->s->row_start_field) { - vers_row_start = DATA_VERS_ROW_START; + vers_row_start = DATA_VERS_START; } else if (i == m_form->s->row_end_field) { - vers_row_end = DATA_VERS_ROW_END; + vers_row_end = DATA_VERS_END; } } diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index b2dca973586..984c5f908b1 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -4971,10 +4971,10 @@ new_clustered_failed: if (altered_table->versioned()) { if (i == altered_table->s->row_start_field) { - field_type |= DATA_VERS_ROW_START; + field_type |= DATA_VERS_START; } else if (i == altered_table->s->row_end_field) { - field_type |= DATA_VERS_ROW_END; + field_type |= DATA_VERS_END; } } diff --git a/storage/innobase/include/data0type.h b/storage/innobase/include/data0type.h index 5037bc48bda..a67ab8e8867 100644 --- a/storage/innobase/include/data0type.h +++ b/storage/innobase/include/data0type.h @@ -192,8 +192,9 @@ be less than 256 */ /** Check whether locking is disabled (never). */ #define dict_table_is_locking_disabled(table) false -#define DATA_VERS_ROW_START 0x4000 /* System Versioning row start */ -#define DATA_VERS_ROW_END 0x8000 /* System Versioning row end */ +/** System Versioning */ +#define DATA_VERS_START 0x4000 /* start system field */ +#define DATA_VERS_END 0x8000 /* end system field */ /*-------------------------------------------*/ /* This many bytes we need to store the type information affecting the diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h index 891998d79c1..bb865098bec 100644 --- a/storage/innobase/include/dict0mem.h +++ b/storage/innobase/include/dict0mem.h @@ -1489,7 +1489,7 @@ struct dict_table_t { /** Add the table definition to the data dictionary cache */ void add_to_cache(); - bool with_versioning() const { return vers_row_start || vers_row_end; } + bool with_versioning() const { return vers_start || vers_end; } /** Id of the table. */ table_id_t id; @@ -1604,9 +1604,9 @@ struct dict_table_t { /** Virtual column names */ const char* v_col_names; - unsigned vers_row_start:10; + unsigned vers_start:10; /*!< System Versioning: row start col index */ - unsigned vers_row_end:10; + unsigned vers_end:10; /*!< System Versioning: row end col index */ bool is_system_db; /*!< True if the table belongs to a system diff --git a/storage/innobase/include/row0ins.h b/storage/innobase/include/row0ins.h index 561f6f2d8fe..389baf9d8f8 100644 --- a/storage/innobase/include/row0ins.h +++ b/storage/innobase/include/row0ins.h @@ -235,8 +235,57 @@ struct ins_node_t{ #define INS_NODE_INSERT_ENTRIES 3 /* index entries should be built and inserted */ -#ifndef UNIV_NONINL -#include "row0ins.ic" -#endif +UNIV_INLINE +void row_ins_set_tuple_col_8( + dtuple_t* tuple, + int col, + ib_uint64_t data, + mem_heap_t* heap) +{ + static const ulint fsize = sizeof(data); + dfield_t* dfield = dtuple_get_nth_field(tuple, col); + ut_ad(dfield->type.len == fsize); + if (dfield->len == UNIV_SQL_NULL) { + byte* buf = reinterpret_cast(mem_heap_alloc(heap, fsize)); + dfield_set_data(dfield, buf, fsize); + } + ut_ad(dfield->len == dfield->type.len && dfield->data); + mach_write_to_8(dfield->data, data); +} + +UNIV_INLINE +void row_ins_set_tuple_col_8( + dtuple_t* tuple, + int col, + timeval& data, + mem_heap_t* heap) +{ + dfield_t* dfield = dtuple_get_nth_field(tuple, col); + ut_ad(dfield->type.len == 8); + if (dfield->len == UNIV_SQL_NULL) { + byte* buf = reinterpret_cast(mem_heap_alloc(heap, 8)); + dfield_set_data(dfield, buf, 8); + } + ut_ad(dfield->len == dfield->type.len && dfield->data); + mach_write_to_4(reinterpret_cast(dfield->data), (ulint) data.tv_sec); + mach_write_to_4(reinterpret_cast(dfield->data) + 4, (ulint) data.tv_usec); +} + +UNIV_INLINE +void row_ins_set_tuple_col_1( + dtuple_t* tuple, + int col, + byte data, + mem_heap_t* heap) +{ + dfield_t* dfield = dtuple_get_nth_field(tuple, col); + ut_ad(dfield->type.len == 1); + if (dfield->len == UNIV_SQL_NULL) { + byte* buf = reinterpret_cast(mem_heap_alloc(heap, 1)); + dfield_set_data(dfield, buf, 1); + } + ut_ad(dfield->len == dfield->type.len && dfield->data); + *(byte*)(dfield->data) = data; +} #endif diff --git a/storage/innobase/include/row0ins.ic b/storage/innobase/include/row0ins.ic deleted file mode 100644 index 9f951bda2be..00000000000 --- a/storage/innobase/include/row0ins.ic +++ /dev/null @@ -1,78 +0,0 @@ -/***************************************************************************** - -Copyright (c) 1996, 2009, Oracle and/or its affiliates. All Rights Reserved. - -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 -Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA - -*****************************************************************************/ - -/**************************************************//** -@file include/row0ins.ic -Insert into a table - -Created 4/20/1996 Heikki Tuuri -*******************************************************/ - - -UNIV_INLINE -void set_tuple_col_8( - dtuple_t* tuple, - int col, - ib_uint64_t data, - mem_heap_t* heap) -{ - static const ulint fsize = sizeof(data); - dfield_t* dfield = dtuple_get_nth_field(tuple, col); - ut_ad(dfield->type.len == fsize); - if (dfield->len == UNIV_SQL_NULL) { - byte* buf = reinterpret_cast(mem_heap_alloc(heap, fsize)); - dfield_set_data(dfield, buf, fsize); - } - ut_ad(dfield->len == dfield->type.len && dfield->data); - mach_write_to_8(dfield->data, data); -} - -UNIV_INLINE -void set_tuple_col_8( - dtuple_t* tuple, - int col, - timeval& data, - mem_heap_t* heap) -{ - dfield_t* dfield = dtuple_get_nth_field(tuple, col); - ut_ad(dfield->type.len == 8); - if (dfield->len == UNIV_SQL_NULL) { - byte* buf = reinterpret_cast(mem_heap_alloc(heap, 8)); - dfield_set_data(dfield, buf, 8); - } - ut_ad(dfield->len == dfield->type.len && dfield->data); - mach_write_to_4(reinterpret_cast(dfield->data), (ulint) data.tv_sec); - mach_write_to_4(reinterpret_cast(dfield->data) + 4, (ulint) data.tv_usec); -} - -UNIV_INLINE -void set_tuple_col_1( - dtuple_t* tuple, - int col, - byte data, - mem_heap_t* heap) -{ - dfield_t* dfield = dtuple_get_nth_field(tuple, col); - ut_ad(dfield->type.len == 1); - if (dfield->len == UNIV_SQL_NULL) { - byte* buf = reinterpret_cast(mem_heap_alloc(heap, 1)); - dfield_set_data(dfield, buf, 1); - } - ut_ad(dfield->len == dfield->type.len && dfield->data); - *(byte*)(dfield->data) = data; -} diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index 87157255835..91ace884727 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -27,11 +27,6 @@ Created 4/20/1996 Heikki Tuuri #include "ha_prototypes.h" #include "row0ins.h" - -#ifdef UNIV_NONINL -#include "row0ins.ic" -#endif - #include "dict0dict.h" #include "dict0boot.h" #include "trx0rec.h" @@ -1593,7 +1588,7 @@ row_ins_get_sys_trx_end( ulint len; ulint nfield = dict_col_get_clust_pos( - &index->table->cols[index->table->vers_row_end], index); + &index->table->cols[index->table->vers_end], index); const byte *field = rec_get_nth_field(rec, offsets, nfield, &len); ut_a(len == 8); return(mach_read_from_8(field)); @@ -1706,7 +1701,7 @@ row_ins_check_foreign_constraint( /* System Versioning: if sys_trx_end != Inf, we suppress the foreign key check */ if (table->with_versioning() && - dfield_get_type(field)->prtype & DATA_VERS_ROW_END) { + dfield_get_type(field)->prtype & DATA_VERS_END) { byte* data = static_cast(dfield_get_data(field)); ut_ad(data); trx_id_t end_trx_id = mach_read_from_8(data); @@ -4064,12 +4059,12 @@ void vers_notify_vtq(trx_t* trx) mutex_exit(&trx_sys->mutex); dict_table_copy_types(tuple, dict_sys->sys_vtq); - set_tuple_col_8(tuple, DICT_COL__SYS_VTQ__TRX_ID, trx->id, heap); - set_tuple_col_8(tuple, DICT_COL__SYS_VTQ__COMMIT_ID, commit_id, heap); - set_tuple_col_8(tuple, DICT_COL__SYS_VTQ__BEGIN_TS, begin_ts, heap); - set_tuple_col_8(tuple, DICT_COL__SYS_VTQ__COMMIT_TS, commit_ts, heap); + row_ins_set_tuple_col_8(tuple, DICT_COL__SYS_VTQ__TRX_ID, trx->id, heap); + row_ins_set_tuple_col_8(tuple, DICT_COL__SYS_VTQ__COMMIT_ID, commit_id, heap); + row_ins_set_tuple_col_8(tuple, DICT_COL__SYS_VTQ__BEGIN_TS, begin_ts, heap); + row_ins_set_tuple_col_8(tuple, DICT_COL__SYS_VTQ__COMMIT_TS, commit_ts, heap); ut_ad(trx->isolation_level < 256); - set_tuple_col_1(tuple, DICT_COL__SYS_VTQ__ISOLATION_LEVEL, trx->isolation_level, heap); + row_ins_set_tuple_col_1(tuple, DICT_COL__SYS_VTQ__ISOLATION_LEVEL, trx->isolation_level, heap); err = vers_row_ins_vtq_low(trx, heap, tuple); if (DB_SUCCESS != err) diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index 08bc78e54b4..f57f9accedd 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -2243,7 +2243,7 @@ end_of_index: bool historical_row = false; if (new_table->with_versioning()) { const dfield_t *dfield = dtuple_get_nth_field( - row, new_table->vers_row_end); + row, new_table->vers_end); const byte *data = static_cast( dfield_get_data(dfield)); ut_ad(dfield_get_len(dfield) == 8); @@ -2306,13 +2306,13 @@ end_of_index: if (old_table->with_versioning()) { if (new_table->with_versioning() && !drop_historical) { dfield_t *end = dtuple_get_nth_field( - row, new_table->vers_row_end); + row, new_table->vers_end); byte *data = static_cast( dfield_get_data(end)); ut_ad(data); if (mach_read_from_8(data) == TRX_ID_MAX) { dfield_t *start = dtuple_get_nth_field( - row, new_table->vers_row_start); + row, new_table->vers_start); void *data = dfield_get_data(start); ut_ad(data); mach_write_to_8(data, trx->id); @@ -2320,7 +2320,7 @@ end_of_index: } else { const dict_col_t *col = &old_table->cols - [old_table->vers_row_end]; + [old_table->vers_end]; const ulint nfield = dict_col_get_clust_pos( col, clust_index); ulint len = 0; @@ -2336,9 +2336,9 @@ end_of_index: mach_write_to_8(sys_trx_start, trx->id); mach_write_to_8(sys_trx_end, TRX_ID_MAX); dfield_t *start = dtuple_get_nth_field( - row, new_table->vers_row_start); + row, new_table->vers_start); dfield_t *end = dtuple_get_nth_field( - row, new_table->vers_row_end); + row, new_table->vers_end); dfield_set_data(start, sys_trx_start, 8); dfield_set_data(end, sys_trx_end, 8); } diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index 0a4151a2b22..007c3bf5ce6 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -1497,21 +1497,21 @@ row_insert_for_mysql( if (ins_mode != ROW_INS_NORMAL) { - ut_ad(table->vers_row_start != table->vers_row_end); + ut_ad(table->vers_start != table->vers_end); /* Return back modified fields into mysql_rec, so that upper logic may benefit from it (f.ex. 'on duplicate key'). */ - const mysql_row_templ_t* t = &prebuilt->mysql_template[table->vers_row_end]; + const mysql_row_templ_t* t = &prebuilt->mysql_template[table->vers_end]; ut_ad(t->mysql_col_len == 8); if (ins_mode == ROW_INS_HISTORICAL) { - set_tuple_col_8(node->row, table->vers_row_end, trx->id, node->entry_sys_heap); + row_ins_set_tuple_col_8(node->row, table->vers_end, trx->id, node->entry_sys_heap); } else /* ROW_INS_VERSIONED */ { - set_tuple_col_8(node->row, table->vers_row_end, IB_UINT64_MAX, node->entry_sys_heap); + row_ins_set_tuple_col_8(node->row, table->vers_end, IB_UINT64_MAX, node->entry_sys_heap); int8store(&mysql_rec[t->mysql_col_offset], IB_UINT64_MAX); - t = &prebuilt->mysql_template[table->vers_row_start]; + t = &prebuilt->mysql_template[table->vers_start]; ut_ad(t->mysql_col_len == 8); - set_tuple_col_8(node->row, table->vers_row_start, trx->id, node->entry_sys_heap); + row_ins_set_tuple_col_8(node->row, table->vers_start, trx->id, node->entry_sys_heap); int8store(&mysql_rec[t->mysql_col_offset], trx->id); } } @@ -1865,7 +1865,7 @@ public: @param[in,out] prebuilt prebuilt struct in MySQL handle @return error code or DB_SUCCESS */ dberr_t -row_update_for_mysql_using_upd_graph( +row_update_for_mysql( row_prebuilt_t* prebuilt, bool vers_set_fields) { @@ -2008,11 +2008,11 @@ run_again: uvect->n_fields = 0; node->is_delete = false; node->vers_delete = true; - col_idx = table->vers_row_end; + col_idx = table->vers_end; } else { ut_ad(uvect->n_fields < table->n_cols); ufield = &uvect->fields[uvect->n_fields]; - col_idx = table->vers_row_start; + col_idx = table->vers_start; } col = &table->cols[col_idx]; UNIV_MEM_INVALID(ufield, sizeof *ufield); @@ -2050,6 +2050,7 @@ run_again: err = trx->error_state; if (err != DB_SUCCESS) { + que_thr_stop_for_mysql(thr); if (err == DB_RECORD_NOT_FOUND) { @@ -2260,20 +2261,6 @@ error: DBUG_RETURN(err); } -/** Does an update or delete of a row for MySQL. -@param[in] mysql_rec row in the MySQL format -@param[in,out] prebuilt prebuilt struct in MySQL handle -@return error code or DB_SUCCESS */ -dberr_t -row_update_for_mysql( - row_prebuilt_t* prebuilt, - bool vers_set_fields) -{ - ut_a(prebuilt->template_type == ROW_MYSQL_WHOLE_ROW); - return (row_update_for_mysql_using_upd_graph( - prebuilt, vers_set_fields)); -} - /** This can only be used when srv_locks_unsafe_for_binlog is TRUE or this session is using a READ COMMITTED or READ UNCOMMITTED isolation level. Before calling this function row_search_for_mysql() must have diff --git a/storage/innobase/vers/vers0vtq.cc b/storage/innobase/vers/vers0vtq.cc index 343fd0e5516..7fb63847316 100644 --- a/storage/innobase/vers/vers0vtq.cc +++ b/storage/innobase/vers/vers0vtq.cc @@ -19,7 +19,7 @@ #include "btr0pcur.h" #include "dict0load.h" #include "ha_innodb.h" -#include "row0ins.ic" +#include "row0ins.h" #include "row0row.h" #include "trx0trx.h" #include "trx0types.h" @@ -347,7 +347,7 @@ vtq_query_commit_ts( tuple = dtuple_create(heap, 1); dict_index_copy_types(tuple, index, 1); dtuple_get_nth_field(tuple, 0)->len = UNIV_SQL_NULL; - set_tuple_col_8(tuple, 0, commit_ts, heap); + row_ins_set_tuple_col_8(tuple, 0, commit_ts, heap); mtr_start_trx(&mtr, trx); btr_pcur_open_on_user_rec(index, tuple, mode,