1
0
mirror of https://github.com/MariaDB/server.git synced 2025-12-01 17:39:21 +03:00

IB: VTQ cleanups [#305]

* btr_pcur_move_to_prev_user_rec() removed
* usage of ut_usectime() removed
* other VTQ-related leftovers
This commit is contained in:
Eugene Kosov
2017-11-14 15:04:18 +03:00
committed by Aleksey Midenkov
parent ad69c4b722
commit 90c809a61d
15 changed files with 28 additions and 175 deletions

View File

@@ -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 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 record of any page, because the structure of the tree may have changed
during the time when the cursor had no latches. */ during the time when the cursor had no latches. */
UNIV_INTERN static
void void
btr_pcur_move_backward_from_page( btr_pcur_move_backward_from_page(
/*=============================*/ /*=============================*/
@@ -607,9 +607,8 @@ btr_pcur_open_on_user_rec_func(
} else { } else {
ut_ad((mode == PAGE_CUR_LE) || (mode == PAGE_CUR_L)); 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;
}
} }
} }

View File

@@ -50,7 +50,7 @@ Created 4/24/1996 Heikki Tuuri
#include <set> #include <set>
/** Following are the InnoDB system tables. The positions in /** 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[] = { static const char* SYSTEM_TABLE_NAME[] = {
"SYS_TABLES", "SYS_TABLES",
"SYS_INDEXES", "SYS_INDEXES",
@@ -60,8 +60,7 @@ static const char* SYSTEM_TABLE_NAME[] = {
"SYS_FOREIGN_COLS", "SYS_FOREIGN_COLS",
"SYS_TABLESPACES", "SYS_TABLESPACES",
"SYS_DATAFILES", "SYS_DATAFILES",
"SYS_VIRTUAL", "SYS_VIRTUAL"
"SYS_VTQ"
}; };
/** Loads a table definition and also all its index definitions. /** Loads a table definition and also all its index definitions.
@@ -308,10 +307,7 @@ dict_getnext_system_low(
rec_t* rec = NULL; rec_t* rec = NULL;
while (!rec || rec_get_deleted_flag(rec, 0)) { while (!rec || rec_get_deleted_flag(rec, 0)) {
if (pcur->search_mode == PAGE_CUR_L) btr_pcur_move_to_next_user_rec(pcur, mtr);
btr_pcur_move_to_prev_user_rec(pcur, mtr);
else
btr_pcur_move_to_next_user_rec(pcur, mtr);
rec = btr_pcur_get_rec(pcur); rec = btr_pcur_get_rec(pcur);
@@ -338,8 +334,7 @@ dict_startscan_system(
btr_pcur_t* pcur, /*!< out: persistent cursor to btr_pcur_t* pcur, /*!< out: persistent cursor to
the record */ the record */
mtr_t* mtr, /*!< in: the mini-transaction */ mtr_t* mtr, /*!< in: the mini-transaction */
dict_system_id_t system_id, /*!< in: which system table to open */ dict_system_id_t system_id) /*!< in: which system table to open */
bool from_left)
{ {
dict_table_t* system_table; dict_table_t* system_table;
dict_index_t* clust_index; dict_index_t* clust_index;
@@ -351,7 +346,7 @@ dict_startscan_system(
clust_index = UT_LIST_GET_FIRST(system_table->indexes); 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); true, 0, mtr);
rec = dict_getnext_system_low(pcur, mtr); rec = dict_getnext_system_low(pcur, mtr);
@@ -815,15 +810,6 @@ err_len:
return(NULL); 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. /** Get the first filepath from SYS_DATAFILES for a given space_id.
@param[in] space_id Tablespace ID @param[in] space_id Tablespace ID
@return First filepath (caller must invoke ut_free() on it) @return First filepath (caller must invoke ut_free() on it)

View File

@@ -1713,7 +1713,9 @@ thd_start_time_in_secs(
/*===================*/ /*===================*/
THD* thd) /*!< in: thread handle, or NULL */ 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 /** Enter InnoDB engine after checking the max number of user threads

View File

@@ -28,8 +28,6 @@ Modified Dec 29, 2014 Jan Lindström (Added sys_semaphore_waits)
#include "ha_prototypes.h" #include "ha_prototypes.h"
#include <mysql_version.h> #include <mysql_version.h>
#include <field.h> #include <field.h>
#include <tztime.h>
#include "univ.i" #include "univ.i"
#include <sql_acl.h> #include <sql_acl.h>
@@ -349,51 +347,6 @@ field_store_ulint(
# define I_S_AHI 0 /* Omit the IS_HASHED column */ # define I_S_AHI 0 /* Omit the IS_HASHED column */
#endif #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 */ /* Fields of the dynamic table INFORMATION_SCHEMA.innodb_trx */
static ST_FIELD_INFO innodb_trx_fields_info[] = static ST_FIELD_INFO innodb_trx_fields_info[] =
{ {

View File

@@ -337,17 +337,6 @@ btr_pcur_move_to_next_user_rec(
function may release the page latch */ function may release the page latch */
mtr_t* mtr); /*!< in: mtr */ 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. Moves the persistent cursor to the first record on the next page.
Releases the latch on the current page, and bufferunfixes it. Releases the latch on the current page, and bufferunfixes it.
Note that there must not be modifications on the current page, 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 btr_pcur_t* cursor, /*!< in: persistent cursor; must be on the
last record of the current page */ last record of the current page */
mtr_t* mtr); /*!< in: mtr */ 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 #ifdef UNIV_DEBUG
/*********************************************************//** /*********************************************************//**
Returns the btr cursor component of a persistent cursor. Returns the btr cursor component of a persistent cursor.

View File

@@ -334,42 +334,6 @@ loop:
goto 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 Moves the persistent cursor to the next record in the tree. If no records are
left, the cursor stays 'after last in tree'. left, the cursor stays 'after last in tree'.

View File

@@ -189,12 +189,13 @@ be less than 256 */
for shorter VARCHARs MySQL uses only 1 byte */ for shorter VARCHARs MySQL uses only 1 byte */
#define DATA_VIRTUAL 8192U /* Virtual column */ #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). */ /** Check whether locking is disabled (never). */
#define dict_table_is_locking_disabled(table) false #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 /* This many bytes we need to store the type information affecting the

View File

@@ -325,6 +325,7 @@ enum dict_fld_sys_datafiles_enum {
DICT_FLD__SYS_DATAFILES__PATH = 3, DICT_FLD__SYS_DATAFILES__PATH = 3,
DICT_NUM_FIELDS__SYS_DATAFILES = 4 DICT_NUM_FIELDS__SYS_DATAFILES = 4
}; };
/* The columns in SYS_VIRTUAL */ /* The columns in SYS_VIRTUAL */
enum dict_col_sys_virtual_enum { enum dict_col_sys_virtual_enum {
DICT_COL__SYS_VIRTUAL__TABLE_ID = 0, DICT_COL__SYS_VIRTUAL__TABLE_ID = 0,

View File

@@ -52,7 +52,6 @@ enum dict_system_id_t {
SYS_TABLESPACES, SYS_TABLESPACES,
SYS_DATAFILES, SYS_DATAFILES,
SYS_VIRTUAL, SYS_VIRTUAL,
SYS_VTQ,
/* This must be last item. Defines the number of system tables. */ /* This must be last item. Defines the number of system tables. */
SYS_NUM_SYSTEM_TABLES SYS_NUM_SYSTEM_TABLES
@@ -182,8 +181,7 @@ dict_startscan_system(
btr_pcur_t* pcur, /*!< out: persistent cursor to btr_pcur_t* pcur, /*!< out: persistent cursor to
the record */ the record */
mtr_t* mtr, /*!< in: the mini-transaction */ mtr_t* mtr, /*!< in: the mini-transaction */
dict_system_id_t system_id, /*!< in: which system table to open */ dict_system_id_t system_id); /*!< in: which system table to open */
bool from_left = true);
/********************************************************************//** /********************************************************************//**
This function get the next system table record as we scan the table. This function get the next system table record as we scan the table.
@return the record if found, NULL if end of scan. */ @return the record if found, NULL if end of scan. */

View File

@@ -380,6 +380,9 @@ struct que_thr_t{
UT_LIST_NODE_T(que_thr_t) UT_LIST_NODE_T(que_thr_t)
thrs; /*!< list of thread nodes of the fork thrs; /*!< list of thread nodes of the fork
node */ 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) UT_LIST_NODE_T(que_thr_t)
queue; /*!< list of runnable thread nodes in queue; /*!< list of runnable thread nodes in
the server task queue */ the server task queue */

View File

@@ -1303,15 +1303,6 @@ struct trx_t {
return(assign_temp_rseg()); 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: private:
/** Assign a rollback segment for modifying temporary tables. /** Assign a rollback segment for modifying temporary tables.
@return the assigned rollback segment */ @return the assigned rollback segment */

View File

@@ -2782,10 +2782,7 @@ row_ins_clust_index_entry_low(
if (flags if (flags
== (BTR_CREATE_FLAG | BTR_NO_LOCKING_FLAG == (BTR_CREATE_FLAG | BTR_NO_LOCKING_FLAG
| BTR_NO_UNDO_LOG_FLAG | BTR_KEEP_SYS_FLAG) || !thr) { | BTR_NO_UNDO_LOG_FLAG | BTR_KEEP_SYS_FLAG)) {
// thr == 0 for SYS_VTQ table
ut_ad(thr || flags &
(BTR_NO_LOCKING_FLAG | BTR_NO_UNDO_LOG_FLAG | BTR_KEEP_SYS_FLAG));
/* Set no locks when applying log /* Set no locks when applying log
in online table rebuild. Only check for duplicates. */ in online table rebuild. Only check for duplicates. */
err = row_ins_duplicate_error_in_clust_online( err = row_ins_duplicate_error_in_clust_online(
@@ -3986,4 +3983,3 @@ error_handling:
return(thr); return(thr);
} }

View File

@@ -2212,7 +2212,7 @@ run_again:
if (node->table->versioned() && if (node->table->versioned() &&
(node->versioned || node->vers_delete || (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) // unversioned fields in foreigh table)
node->foreign)) { node->foreign)) {
trx->vers_update_trt = true; trx->vers_update_trt = true;

View File

@@ -180,7 +180,7 @@ trx_purge_graph_build(sess_t* sess)
ut_ad(trx->sess == sess); ut_ad(trx->sess == sess);
trx->id = 0; trx->id = 0;
trx->init_start_time(); trx->start_time = ut_time();
trx->state = TRX_STATE_ACTIVE; trx->state = TRX_STATE_ACTIVE;
trx->op_info = "purge trx"; trx->op_info = "purge trx";

View File

@@ -864,14 +864,6 @@ trx_resurrect_insert(
trx->no = TRX_ID_MAX; 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) { if (undo->dict_operation) {
trx_set_dict_operation(trx, TRX_DICT_OP_TABLE); trx_set_dict_operation(trx, TRX_DICT_OP_TABLE);
trx->table_id = undo->table_id; trx->table_id = undo->table_id;
@@ -955,13 +947,6 @@ trx_resurrect_update(
trx->no = TRX_ID_MAX; 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) { if (undo->dict_operation) {
trx_set_dict_operation(trx, TRX_DICT_OP_TABLE); trx_set_dict_operation(trx, TRX_DICT_OP_TABLE);
trx->table_id = undo->table_id; trx->table_id = undo->table_id;
@@ -1330,12 +1315,13 @@ trx_start_low(
} }
} }
if (trx->mysql_thd != NULL && if (trx->mysql_thd != NULL) {
(trx->start_time_micro = thd_query_start_micro(trx->mysql_thd))) { trx->start_time = thd_start_time_in_secs(trx->mysql_thd);
trx->start_time = trx->start_time_micro / 1000000; trx->start_time_micro = thd_query_start_micro(trx->mysql_thd);
} else { } else {
trx->init_start_time(); trx->start_time = ut_time();
trx->start_time_micro = 0;
} }
ut_a(trx->error_state == DB_SUCCESS); ut_a(trx->error_state == DB_SUCCESS);