diff --git a/storage/innobase/btr/btr0pcur.cc b/storage/innobase/btr/btr0pcur.cc index 7342aee2f7e..2b85c764a3b 100644 --- a/storage/innobase/btr/btr0pcur.cc +++ b/storage/innobase/btr/btr0pcur.cc @@ -471,7 +471,7 @@ alphabetical position of the cursor is guaranteed to be sensible on return, but it may happen that the cursor is not positioned on the last record of any page, because the structure of the tree may have changed during the time when the cursor had no latches. */ -UNIV_INTERN +static void btr_pcur_move_backward_from_page( /*=============================*/ @@ -607,9 +607,8 @@ btr_pcur_open_on_user_rec_func( } else { ut_ad((mode == PAGE_CUR_LE) || (mode == PAGE_CUR_L)); - if (btr_pcur_is_before_first_on_page(cursor)) { + /* Not implemented yet */ - btr_pcur_move_to_prev_user_rec(cursor, mtr); - } + ut_error; } } diff --git a/storage/innobase/dict/dict0load.cc b/storage/innobase/dict/dict0load.cc index a80dc8e21b1..0e55e353837 100644 --- a/storage/innobase/dict/dict0load.cc +++ b/storage/innobase/dict/dict0load.cc @@ -50,7 +50,7 @@ Created 4/24/1996 Heikki Tuuri #include /** Following are the InnoDB system tables. The positions in -this array are referenced by enum dict_system_id_t. */ +this array are referenced by enum dict_system_table_id. */ static const char* SYSTEM_TABLE_NAME[] = { "SYS_TABLES", "SYS_INDEXES", @@ -60,8 +60,7 @@ static const char* SYSTEM_TABLE_NAME[] = { "SYS_FOREIGN_COLS", "SYS_TABLESPACES", "SYS_DATAFILES", - "SYS_VIRTUAL", - "SYS_VTQ" + "SYS_VIRTUAL" }; /** Loads a table definition and also all its index definitions. @@ -308,10 +307,7 @@ dict_getnext_system_low( rec_t* rec = NULL; while (!rec || rec_get_deleted_flag(rec, 0)) { - if (pcur->search_mode == PAGE_CUR_L) - btr_pcur_move_to_prev_user_rec(pcur, mtr); - else - btr_pcur_move_to_next_user_rec(pcur, mtr); + btr_pcur_move_to_next_user_rec(pcur, mtr); rec = btr_pcur_get_rec(pcur); @@ -338,8 +334,7 @@ dict_startscan_system( btr_pcur_t* pcur, /*!< out: persistent cursor to the record */ mtr_t* mtr, /*!< in: the mini-transaction */ - dict_system_id_t system_id, /*!< in: which system table to open */ - bool from_left) + dict_system_id_t system_id) /*!< in: which system table to open */ { dict_table_t* system_table; dict_index_t* clust_index; @@ -351,7 +346,7 @@ dict_startscan_system( clust_index = UT_LIST_GET_FIRST(system_table->indexes); - btr_pcur_open_at_index_side(from_left, clust_index, BTR_SEARCH_LEAF, pcur, + btr_pcur_open_at_index_side(true, clust_index, BTR_SEARCH_LEAF, pcur, true, 0, mtr); rec = dict_getnext_system_low(pcur, mtr); @@ -815,15 +810,6 @@ err_len: return(NULL); } - -inline -const char* dict_print_error(mem_heap_t* heap, ulint col, ulint len, ulint expected) -{ - return mem_heap_printf(heap, - "incorrect column %lu length in SYS_VTQ; got: %lu, expected: %lu", - col, len, expected); -} - /** Get the first filepath from SYS_DATAFILES for a given space_id. @param[in] space_id Tablespace ID @return First filepath (caller must invoke ut_free() on it) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 37b62f9fee5..3fa1fbd1cc0 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -1713,7 +1713,9 @@ thd_start_time_in_secs( /*===================*/ THD* thd) /*!< in: thread handle, or NULL */ { - return(static_cast(thd_start_time(thd))); + // FIXME: This function should be added to the server code. + //return(thd_start_time(thd)); + return(ulint(ut_time())); } /** Enter InnoDB engine after checking the max number of user threads diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc index f8319eba4fc..b597b9224fa 100644 --- a/storage/innobase/handler/i_s.cc +++ b/storage/innobase/handler/i_s.cc @@ -28,8 +28,6 @@ Modified Dec 29, 2014 Jan Lindström (Added sys_semaphore_waits) #include "ha_prototypes.h" #include #include -#include - #include "univ.i" #include @@ -349,51 +347,6 @@ field_store_ulint( # define I_S_AHI 0 /* Omit the IS_HASHED column */ #endif -/*******************************************************************//** -Auxiliary function to store ulint value in MYSQL_TYPE_LONGLONG field. -If the value is UINT64_UNDEFINED then the field it set to NULL. -@return 0 on success */ -int -field_store_uint64_t( -/*==============*/ - Field* field, /*!< in/out: target field for storage */ - uint64_t n) /*!< in: value to store */ -{ - int ret; - - if (n != UINT64_UNDEFINED) { - ret = field->store(n, 1); - field->set_notnull(); - } else { - ret = 0; /* success */ - field->set_null(); - } - - return(ret); -} - -/*******************************************************************//** -Auxiliary function to store packed timestamp value in MYSQL_TYPE_DATETIME field. -If the value is ULINT_UNDEFINED then the field it set to NULL. -@return 0 on success */ -int -field_store_timeval( -/*==============*/ -Field* field, /*!< in/out: target field for storage */ -timeval t, /*!< in: value to store */ -THD* thd) -{ - int ret; - MYSQL_TIME tmp; - - thd_get_timezone(thd)->gmt_sec_to_TIME(&tmp, t.tv_sec); - tmp.second_part = t.tv_usec; - ret = field->store_time(&tmp); - field->set_notnull(); - - return(ret); -} - /* Fields of the dynamic table INFORMATION_SCHEMA.innodb_trx */ static ST_FIELD_INFO innodb_trx_fields_info[] = { diff --git a/storage/innobase/include/btr0pcur.h b/storage/innobase/include/btr0pcur.h index 6f89eed2f9d..fab934ca0ee 100644 --- a/storage/innobase/include/btr0pcur.h +++ b/storage/innobase/include/btr0pcur.h @@ -337,17 +337,6 @@ btr_pcur_move_to_next_user_rec( function may release the page latch */ mtr_t* mtr); /*!< in: mtr */ /*********************************************************//** -Moves the persistent cursor to the previous user record in the tree. If no user -records are left, the cursor ends up 'before first in tree'. -@return TRUE if the cursor moved forward, ending on a user record */ -UNIV_INLINE -ibool -btr_pcur_move_to_prev_user_rec( -/*===========================*/ - btr_pcur_t* cursor, /*!< in: persistent cursor; NOTE that the - function may release the page latch */ - mtr_t* mtr); /*!< in: mtr */ -/*********************************************************//** Moves the persistent cursor to the first record on the next page. Releases the latch on the current page, and bufferunfixes it. Note that there must not be modifications on the current page, @@ -358,22 +347,6 @@ btr_pcur_move_to_next_page( btr_pcur_t* cursor, /*!< in: persistent cursor; must be on the last record of the current page */ mtr_t* mtr); /*!< in: mtr */ -/*********************************************************//** -Moves the persistent cursor backward if it is on the first record -of the page. Releases the latch on the current page, and bufferunfixes -it. Note that to prevent a possible deadlock, the operation first -stores the position of the cursor, releases the leaf latch, acquires -necessary latches and restores the cursor position again before returning. -The alphabetical position of the cursor is guaranteed to be sensible -on return, but it may happen that the cursor is not positioned on the -last record of any page, because the structure of the tree may have -changed while the cursor had no latches. */ -void -btr_pcur_move_backward_from_page( -/*=============================*/ - btr_pcur_t* cursor, /*!< in: persistent cursor, must be on the - first record of the current page */ - mtr_t* mtr); /*!< in: mtr */ #ifdef UNIV_DEBUG /*********************************************************//** Returns the btr cursor component of a persistent cursor. diff --git a/storage/innobase/include/btr0pcur.ic b/storage/innobase/include/btr0pcur.ic index 1de99a2b0eb..4490942a2bb 100644 --- a/storage/innobase/include/btr0pcur.ic +++ b/storage/innobase/include/btr0pcur.ic @@ -334,42 +334,6 @@ loop: goto loop; } -/*********************************************************//** -Moves the persistent cursor to the previous user record in the tree. If no user -records are left, the cursor ends up 'before first in tree'. -@return TRUE if the cursor moved forward, ending on a user record */ -UNIV_INLINE -ibool -btr_pcur_move_to_prev_user_rec( -/*===========================*/ - btr_pcur_t* cursor, /*!< in: persistent cursor; NOTE that the - function may release the page latch */ - mtr_t* mtr) /*!< in: mtr */ -{ - ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); - ut_ad(cursor->latch_mode != BTR_NO_LATCHES); - cursor->old_stored = false; -loop: - if (btr_pcur_is_before_first_on_page(cursor)) { - - if (btr_pcur_is_before_first_in_tree(cursor, mtr)) { - - return(FALSE); - } - - btr_pcur_move_to_prev(cursor, mtr); - } else { - btr_pcur_move_to_prev_on_page(cursor); - } - - if (btr_pcur_is_on_user_rec(cursor)) { - - return(TRUE); - } - - goto loop; -} - /*********************************************************//** Moves the persistent cursor to the next record in the tree. If no records are left, the cursor stays 'after last in tree'. diff --git a/storage/innobase/include/data0type.h b/storage/innobase/include/data0type.h index a67ab8e8867..d9c1cc24d24 100644 --- a/storage/innobase/include/data0type.h +++ b/storage/innobase/include/data0type.h @@ -189,12 +189,13 @@ be less than 256 */ for shorter VARCHARs MySQL uses only 1 byte */ #define DATA_VIRTUAL 8192U /* Virtual column */ +/** System Versioning */ +#define DATA_VERS_START 16384U /* start system field */ +#define DATA_VERS_END 32768U /* end system field */ + /** Check whether locking is disabled (never). */ #define dict_table_is_locking_disabled(table) false -/** 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/dict0boot.h b/storage/innobase/include/dict0boot.h index f2af7a71beb..25aced44b2e 100644 --- a/storage/innobase/include/dict0boot.h +++ b/storage/innobase/include/dict0boot.h @@ -325,6 +325,7 @@ enum dict_fld_sys_datafiles_enum { DICT_FLD__SYS_DATAFILES__PATH = 3, DICT_NUM_FIELDS__SYS_DATAFILES = 4 }; + /* The columns in SYS_VIRTUAL */ enum dict_col_sys_virtual_enum { DICT_COL__SYS_VIRTUAL__TABLE_ID = 0, diff --git a/storage/innobase/include/dict0load.h b/storage/innobase/include/dict0load.h index 2b62f150bf9..22fd27c2484 100644 --- a/storage/innobase/include/dict0load.h +++ b/storage/innobase/include/dict0load.h @@ -52,7 +52,6 @@ enum dict_system_id_t { SYS_TABLESPACES, SYS_DATAFILES, SYS_VIRTUAL, - SYS_VTQ, /* This must be last item. Defines the number of system tables. */ SYS_NUM_SYSTEM_TABLES @@ -182,8 +181,7 @@ dict_startscan_system( btr_pcur_t* pcur, /*!< out: persistent cursor to the record */ mtr_t* mtr, /*!< in: the mini-transaction */ - dict_system_id_t system_id, /*!< in: which system table to open */ - bool from_left = true); + dict_system_id_t system_id); /*!< in: which system table to open */ /********************************************************************//** This function get the next system table record as we scan the table. @return the record if found, NULL if end of scan. */ diff --git a/storage/innobase/include/que0que.h b/storage/innobase/include/que0que.h index 13be7291f00..763b16820d8 100644 --- a/storage/innobase/include/que0que.h +++ b/storage/innobase/include/que0que.h @@ -380,6 +380,9 @@ struct que_thr_t{ UT_LIST_NODE_T(que_thr_t) thrs; /*!< list of thread nodes of the fork node */ + UT_LIST_NODE_T(que_thr_t) + trx_thrs; /*!< lists of threads in wait list of + the trx */ UT_LIST_NODE_T(que_thr_t) queue; /*!< list of runnable thread nodes in the server task queue */ diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h index 13c13fd2101..888994abb3a 100644 --- a/storage/innobase/include/trx0trx.h +++ b/storage/innobase/include/trx0trx.h @@ -1303,15 +1303,6 @@ struct trx_t { return(assign_temp_rseg()); } - void init_start_time() - { - ulint secs; - ulint usecs; - ut_usectime(&secs, &usecs); - start_time = secs; - start_time_micro = usecs + (ib_uint64_t) secs * 1000000; - } - private: /** Assign a rollback segment for modifying temporary tables. @return the assigned rollback segment */ diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index f9bc919b54a..89c25447fd2 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -2782,10 +2782,7 @@ row_ins_clust_index_entry_low( if (flags == (BTR_CREATE_FLAG | BTR_NO_LOCKING_FLAG - | BTR_NO_UNDO_LOG_FLAG | BTR_KEEP_SYS_FLAG) || !thr) { - // thr == 0 for SYS_VTQ table - ut_ad(thr || flags & - (BTR_NO_LOCKING_FLAG | BTR_NO_UNDO_LOG_FLAG | BTR_KEEP_SYS_FLAG)); + | BTR_NO_UNDO_LOG_FLAG | BTR_KEEP_SYS_FLAG)) { /* Set no locks when applying log in online table rebuild. Only check for duplicates. */ err = row_ins_duplicate_error_in_clust_online( @@ -3986,4 +3983,3 @@ error_handling: return(thr); } - diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index f26f99f46f4..f64de9433ca 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -2212,7 +2212,7 @@ run_again: if (node->table->versioned() && (node->versioned || node->vers_delete || - // TODO: imrove this check (check if we touch only + // TODO: improve this check (check if we touch only // unversioned fields in foreigh table) node->foreign)) { trx->vers_update_trt = true; diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index 64757c3f956..738f713298b 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -180,7 +180,7 @@ trx_purge_graph_build(sess_t* sess) ut_ad(trx->sess == sess); trx->id = 0; - trx->init_start_time(); + trx->start_time = ut_time(); trx->state = TRX_STATE_ACTIVE; trx->op_info = "purge trx"; diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 59d8620dbc9..fb01b9ded2a 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -864,14 +864,6 @@ trx_resurrect_insert( trx->no = TRX_ID_MAX; } - /* trx_start_low() is not called with resurrect, so need to initialize - start time here.*/ - if (trx->state == TRX_STATE_ACTIVE - || trx->state == TRX_STATE_PREPARED) { - - trx->init_start_time(); - } - if (undo->dict_operation) { trx_set_dict_operation(trx, TRX_DICT_OP_TABLE); trx->table_id = undo->table_id; @@ -955,13 +947,6 @@ trx_resurrect_update( trx->no = TRX_ID_MAX; } - /* trx_start_low() is not called with resurrect, so need to initialize - start time here.*/ - if (trx->state == TRX_STATE_ACTIVE - || trx->state == TRX_STATE_PREPARED) { - trx->init_start_time(); - } - if (undo->dict_operation) { trx_set_dict_operation(trx, TRX_DICT_OP_TABLE); trx->table_id = undo->table_id; @@ -1330,12 +1315,13 @@ trx_start_low( } } - if (trx->mysql_thd != NULL && - (trx->start_time_micro = thd_query_start_micro(trx->mysql_thd))) { - trx->start_time = trx->start_time_micro / 1000000; + if (trx->mysql_thd != NULL) { + trx->start_time = thd_start_time_in_secs(trx->mysql_thd); + trx->start_time_micro = thd_query_start_micro(trx->mysql_thd); } else { - trx->init_start_time(); + trx->start_time = ut_time(); + trx->start_time_micro = 0; } ut_a(trx->error_state == DB_SUCCESS);