Skip to content

Commit

Permalink
IB: VTQ cleanups [#305]
Browse files Browse the repository at this point in the history
* btr_pcur_move_to_prev_user_rec() removed
* usage of ut_usectime() removed
* other VTQ-related leftovers
  • Loading branch information
kevgs authored and midenok committed Nov 17, 2017
1 parent ad69c4b commit 90c809a
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 175 deletions.
7 changes: 3 additions & 4 deletions storage/innobase/btr/btr0pcur.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(
/*=============================*/
Expand Down Expand Up @@ -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;
}
}
24 changes: 5 additions & 19 deletions storage/innobase/dict/dict0load.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Created 4/24/1996 Heikki Tuuri
#include <set>

/** 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",
Expand All @@ -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.
Expand Down Expand Up @@ -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);

Expand All @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -815,15 +810,6 @@ dict_process_sys_datafiles(
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)
Expand Down
4 changes: 3 additions & 1 deletion storage/innobase/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1713,7 +1713,9 @@ thd_start_time_in_secs(
/*===================*/
THD* thd) /*!< in: thread handle, or NULL */
{
return(static_cast<ulint>(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
Expand Down
47 changes: 0 additions & 47 deletions storage/innobase/handler/i_s.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ Modified Dec 29, 2014 Jan Lindström (Added sys_semaphore_waits)
#include "ha_prototypes.h"
#include <mysql_version.h>
#include <field.h>
#include <tztime.h>

#include "univ.i"

#include <sql_acl.h>
Expand Down Expand Up @@ -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[] =
{
Expand Down
27 changes: 0 additions & 27 deletions storage/innobase/include/btr0pcur.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.
Expand Down
36 changes: 0 additions & 36 deletions storage/innobase/include/btr0pcur.ic
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
Expand Down
7 changes: 4 additions & 3 deletions storage/innobase/include/data0type.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions storage/innobase/include/dict0boot.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 1 addition & 3 deletions storage/innobase/include/dict0load.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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. */
Expand Down
3 changes: 3 additions & 0 deletions storage/innobase/include/que0que.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
9 changes: 0 additions & 9 deletions storage/innobase/include/trx0trx.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
6 changes: 1 addition & 5 deletions storage/innobase/row/row0ins.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -3986,4 +3983,3 @@ row_ins_step(

return(thr);
}

2 changes: 1 addition & 1 deletion storage/innobase/row/row0mysql.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2212,7 +2212,7 @@ row_update_for_mysql(

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;
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/trx/trx0purge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
24 changes: 5 additions & 19 deletions storage/innobase/trx/trx0trx.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 90c809a

Please sign in to comment.