IB: style changes [closes #306]
This commit is contained in:
parent
8972291ac1
commit
fa79f6ac86
@ -223,9 +223,6 @@ public:
|
||||
|
||||
ha_rows estimate_rows_upper_bound();
|
||||
|
||||
// JAN: TODO: MySQL 5.7
|
||||
ha_rows records_new(); // FIXME: rename to records(), fix main.bug39022
|
||||
|
||||
void update_create_info(HA_CREATE_INFO* create_info);
|
||||
|
||||
int create(
|
||||
@ -458,7 +455,7 @@ protected:
|
||||
void reset_template();
|
||||
|
||||
protected:
|
||||
void update_thd(THD* thd);
|
||||
inline void update_thd(THD* thd);
|
||||
void update_thd();
|
||||
|
||||
int general_fetch(uchar* buf, uint direction, uint match_mode);
|
||||
|
@ -31,7 +31,6 @@ Created 4/24/1996 Heikki Tuuri
|
||||
#include "univ.i"
|
||||
#include "dict0types.h"
|
||||
#include "trx0types.h"
|
||||
#include "trx0vtq.h"
|
||||
#include "ut0byte.h"
|
||||
#include "mem0mem.h"
|
||||
#include "btr0types.h"
|
||||
@ -39,6 +38,8 @@ Created 4/24/1996 Heikki Tuuri
|
||||
|
||||
#include <deque>
|
||||
|
||||
struct vtq_record_t;
|
||||
|
||||
/** A stack of table names related through foreign key constraints */
|
||||
typedef std::deque<const char*, ut_allocator<const char*> > dict_names_t;
|
||||
|
||||
@ -317,17 +318,19 @@ dict_process_sys_datafiles(
|
||||
const rec_t* rec, /*!< in: current SYS_DATAFILES rec */
|
||||
ulint* space, /*!< out: pace id */
|
||||
const char** path); /*!< out: datafile path */
|
||||
/********************************************************************//**
|
||||
This function parses a SYS_VTQ record, extracts necessary
|
||||
|
||||
/** This function parses a SYS_VTQ record, extracts necessary
|
||||
information from the record and returns it to the caller.
|
||||
@param[in,out] heap Heap memory
|
||||
@param[in] rec Current record
|
||||
@param[out] fields Field values
|
||||
@return error message, or NULL on success */
|
||||
UNIV_INTERN
|
||||
const char*
|
||||
dict_process_sys_vtq(
|
||||
/*=======================*/
|
||||
mem_heap_t* heap, /*!< in/out: heap memory */
|
||||
const rec_t* rec, /*!< in: current rec */
|
||||
vtq_record_t& fields /*!< out: field values */
|
||||
mem_heap_t* heap, /*!< in/out: heap memory */
|
||||
const rec_t* rec, /*!< in: current rec */
|
||||
vtq_record_t& fields /*!< out: field values */
|
||||
);
|
||||
|
||||
/** Update the record for space_id in SYS_TABLESPACES to this filepath.
|
||||
|
@ -325,6 +325,7 @@ this function and it will be passed to other functions for further accounting.
|
||||
@param[in] add_v new virtual columns added along with indexes
|
||||
@param[in] eval_table mysql table used to evaluate virtual column
|
||||
value, see innobase_get_computed_value().
|
||||
@param[in] drop_historical whether to drop historical system rows
|
||||
@return DB_SUCCESS or error code */
|
||||
dberr_t
|
||||
row_merge_build_indexes(
|
||||
|
@ -235,18 +235,17 @@ row_lock_table_for_mysql(
|
||||
(ignored if table==NULL) */
|
||||
MY_ATTRIBUTE((nonnull(1)));
|
||||
|
||||
/* System Versioning: row_insert_for_mysql() modes */
|
||||
/** System Versioning: row_insert_for_mysql() modes */
|
||||
enum ins_mode_t {
|
||||
ROW_INS_NORMAL = 0,
|
||||
// insert versioned row: sys_trx_start = TRX_ID, sys_trx_end = MAX
|
||||
ROW_INS_VERSIONED,
|
||||
// insert historical row: sys_trx_end = TRX_ID
|
||||
ROW_INS_HISTORICAL
|
||||
ROW_INS_NORMAL = 0, ///< plain row (without versioning)
|
||||
ROW_INS_VERSIONED, ///< sys_trx_start = TRX_ID, sys_trx_end = MAX
|
||||
ROW_INS_HISTORICAL ///< sys_trx_end = TRX_ID
|
||||
};
|
||||
|
||||
/** Does an insert for MySQL.
|
||||
@param[in] mysql_rec row in the MySQL format
|
||||
@param[in,out] prebuilt prebuilt struct in MySQL handle
|
||||
@param[in] ins_mode what row type we're inserting
|
||||
@return error code or DB_SUCCESS*/
|
||||
dberr_t
|
||||
row_insert_for_mysql(
|
||||
@ -274,6 +273,7 @@ row_get_prebuilt_update_vector(
|
||||
handle */
|
||||
/** Does an update or delete of a row for MySQL.
|
||||
@param[in,out] prebuilt prebuilt struct in MySQL handle
|
||||
@param[in] vers_set_fields working with system versioned table
|
||||
@return error code or DB_SUCCESS */
|
||||
dberr_t
|
||||
row_update_for_mysql(
|
||||
|
@ -573,8 +573,10 @@ struct upd_node_t{
|
||||
compilation; speeds up execution:
|
||||
UPD_NODE_NO_ORD_CHANGE and
|
||||
UPD_NODE_NO_SIZE_CHANGE, ORed */
|
||||
bool versioned;/* update is versioned */
|
||||
bool vers_delete;/* versioned delete */
|
||||
/** working with system versioned table */
|
||||
bool versioned;
|
||||
/** set sys_trx_end = CUR_TRX_ID */
|
||||
bool vers_delete;
|
||||
/*----------------------*/
|
||||
/* Local storage for this graph node */
|
||||
ulint state; /*!< node execution state */
|
||||
|
@ -59,11 +59,7 @@ public:
|
||||
@param[in] id ID of the latch to track */
|
||||
Context(latch_id_t id)
|
||||
:
|
||||
latch_t(id),
|
||||
m_mutex(),
|
||||
m_filename(),
|
||||
m_line(),
|
||||
m_thread_id(os_thread_id_t(ULINT_UNDEFINED))
|
||||
latch_t(id)
|
||||
{
|
||||
ut_ad(id != LATCH_ID_NONE);
|
||||
}
|
||||
|
@ -42,7 +42,6 @@ Created 3/26/1996 Heikki Tuuri
|
||||
#include "que0types.h"
|
||||
#include "mem0mem.h"
|
||||
#include "trx0xa.h"
|
||||
#include "trx0vtq.h"
|
||||
#include "ut0vec.h"
|
||||
#include "fts0fts.h"
|
||||
#include "srv0srv.h"
|
||||
@ -884,6 +883,33 @@ struct TrxVersion {
|
||||
ulint m_version;
|
||||
};
|
||||
|
||||
/** Class which is used to query VTQ and also serves as a cache to VTQ of size 1
|
||||
*/
|
||||
class vtq_query_t
|
||||
{
|
||||
public:
|
||||
/** VTQ used to translate timestamps to nearest trx_id and this is
|
||||
a timestamp for a row we're caching now */
|
||||
timeval prev_query;
|
||||
/** We search for nearest trx_id on the left or on the right and
|
||||
we search forwards or backwards */
|
||||
bool backwards;
|
||||
|
||||
/** Cached row from VTQ */
|
||||
vtq_record_t result;
|
||||
|
||||
/** Parses record and stores its value in a result field
|
||||
but disables a cache */
|
||||
const char * cache_result(mem_heap_t* heap, const rec_t* rec);
|
||||
/** Parses record and stores its value in a result field and enables
|
||||
cache (prev_query, backward) */
|
||||
const char * cache_result(
|
||||
mem_heap_t* heap,
|
||||
const rec_t* rec,
|
||||
const timeval &_ts_query,
|
||||
bool _backwards);
|
||||
};
|
||||
|
||||
typedef std::list<TrxVersion, ut_allocator<TrxVersion> > hit_list_t;
|
||||
|
||||
struct trx_t {
|
||||
@ -1272,7 +1298,8 @@ struct trx_t {
|
||||
/* System Versioning */
|
||||
bool vtq_notify_on_commit;
|
||||
/*!< Notify VTQ for System Versioned update */
|
||||
vtq_query_t vtq_query;
|
||||
vtq_query_t vtq_query; /*!< Structure to query VTQ and store
|
||||
one row result */
|
||||
ulint magic_n;
|
||||
|
||||
/** @return whether any persistent undo log has been generated */
|
||||
|
@ -1,40 +0,0 @@
|
||||
#ifndef trx0vtq_h
|
||||
#define trx0vtq_h
|
||||
|
||||
/* Copyright (c) 2016, 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 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, Fifth Floor, Boston, MA 02110-1301, USA */
|
||||
|
||||
#include <vtq.h>
|
||||
#include "trx0types.h"
|
||||
#include "mem0mem.h"
|
||||
#include "rem0types.h"
|
||||
|
||||
class vtq_query_t
|
||||
{
|
||||
public:
|
||||
timeval prev_query;
|
||||
bool backwards;
|
||||
|
||||
vtq_record_t result;
|
||||
|
||||
const char * cache_result(mem_heap_t* heap, const rec_t* rec);
|
||||
const char * cache_result(
|
||||
mem_heap_t* heap,
|
||||
const rec_t* rec,
|
||||
const timeval &_ts_query,
|
||||
bool _backwards);
|
||||
};
|
||||
|
||||
#endif // trx0vtq_h
|
@ -1594,17 +1594,21 @@ row_ins_get_sys_trx_end(
|
||||
return(mach_read_from_8(field));
|
||||
}
|
||||
|
||||
/*********************************************************************//**
|
||||
/**
|
||||
Performs search at clustered index and returns sys_trx_end if row was found.
|
||||
@param[in] index secondary index of record
|
||||
@param[in] rec record in a secondary index
|
||||
@param[out] end_trx_id value from clustered index
|
||||
@return DB_SUCCESS, DB_NO_REFERENCED_ROW */
|
||||
static
|
||||
dberr_t
|
||||
row_ins_search_sys_trx_end(
|
||||
/*=======================*/
|
||||
dict_index_t *index, /*!< in: index of record */
|
||||
const rec_t *rec, /*!< in: record */
|
||||
trx_id_t *end_trx_id) /*!< out: end_trx_id */
|
||||
dict_index_t *index,
|
||||
const rec_t *rec,
|
||||
trx_id_t *end_trx_id)
|
||||
{
|
||||
ut_ad(!index->is_clust());
|
||||
|
||||
bool found = false;
|
||||
mem_heap_t *heap = mem_heap_create(256);
|
||||
dict_index_t *clust_index = NULL;
|
||||
@ -1629,7 +1633,8 @@ not_found:
|
||||
mtr_commit(&mtr);
|
||||
mem_heap_free(heap);
|
||||
if (!found) {
|
||||
fprintf(stderr, "InnoDB: foreign constraints: secondary index is out of sync\n");
|
||||
ib::error() << "foreign constraints: secondary index is out of "
|
||||
"sync";
|
||||
ut_ad(false && "secondary index is out of sync");
|
||||
return(DB_NO_REFERENCED_ROW);
|
||||
}
|
||||
@ -4014,7 +4019,7 @@ vers_row_ins_vtq_low(trx_t* trx, mem_heap_t* heap, dtuple_t* tuple)
|
||||
break;
|
||||
case DB_SUCCESS_LOCKED_REC:
|
||||
/* The row had already been copied to the table. */
|
||||
fprintf(stderr, "InnoDB: duplicate VTQ record!\n");
|
||||
ib::info() << "InnoDB: duplicate VTQ record!";
|
||||
return DB_SUCCESS;
|
||||
default:
|
||||
return err;
|
||||
@ -4068,7 +4073,8 @@ void vers_notify_vtq(trx_t* trx)
|
||||
|
||||
err = vers_row_ins_vtq_low(trx, heap, tuple);
|
||||
if (DB_SUCCESS != err)
|
||||
fprintf(stderr, "InnoDB: failed to insert VTQ record (error %d)\n", err);
|
||||
ib::error()
|
||||
<< "failed to insert VTQ record (error " << err << ")";
|
||||
|
||||
mem_heap_free(heap);
|
||||
}
|
||||
|
@ -4603,6 +4603,7 @@ this function and it will be passed to other functions for further accounting.
|
||||
@param[in] add_v new virtual columns added along with indexes
|
||||
@param[in] eval_table mysql table used to evaluate virtual column
|
||||
value, see innobase_get_computed_value().
|
||||
@param[in] drop_historical whether to drop historical system rows
|
||||
@return DB_SUCCESS or error code */
|
||||
dberr_t
|
||||
row_merge_build_indexes(
|
||||
|
@ -1863,6 +1863,7 @@ public:
|
||||
|
||||
/** Does an update or delete of a row for MySQL.
|
||||
@param[in,out] prebuilt prebuilt struct in MySQL handle
|
||||
@param[in] vers_set_fields working with system versioned table
|
||||
@return error code or DB_SUCCESS */
|
||||
dberr_t
|
||||
row_update_for_mysql(
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "row0row.h"
|
||||
#include "trx0trx.h"
|
||||
#include "trx0types.h"
|
||||
#include "trx0vtq.h"
|
||||
|
||||
|
||||
/** Field or record selector.
|
||||
@ -145,7 +144,9 @@ vtq_query_trx_id(THD* thd, void *out, ulonglong _in_trx_id, vtq_field_t field)
|
||||
{
|
||||
const char *err = trx->vtq_query.cache_result(heap, rec);
|
||||
if (err) {
|
||||
fprintf(stderr, "InnoDB: vtq_query_trx_id: get VTQ field failed: %s\n", err);
|
||||
ib::error()
|
||||
<< "vtq_query_trx_id: get VTQ field failed: "
|
||||
<< err;
|
||||
ut_ad(false && "get VTQ field failed");
|
||||
goto not_found;
|
||||
}
|
||||
@ -378,7 +379,8 @@ vtq_query_commit_ts(
|
||||
found:
|
||||
clust_rec = row_get_clust_rec(BTR_SEARCH_LEAF, rec, index, &clust_index, &mtr);
|
||||
if (!clust_rec) {
|
||||
fprintf(stderr, "InnoDB: vtq_query_commit_ts: secondary index is out of sync\n");
|
||||
ib::error() << "vtq_query_commit_ts: secondary index is out of "
|
||||
"sync";
|
||||
ut_ad(false && "secondary index is out of sync");
|
||||
goto not_found;
|
||||
}
|
||||
@ -391,7 +393,9 @@ found:
|
||||
rec_ts,
|
||||
backwards);
|
||||
if (err) {
|
||||
fprintf(stderr, "InnoDB: vtq_query_commit_ts: get VTQ field failed: %s\n", err);
|
||||
ib::error()
|
||||
<< "vtq_query_commit_ts: get VTQ field failed: "
|
||||
<< err;
|
||||
ut_ad(false && "get VTQ field failed");
|
||||
goto not_found;
|
||||
}
|
||||
@ -438,10 +442,11 @@ vtq_trx_sees(
|
||||
DBUG_RETURN(true);
|
||||
}
|
||||
|
||||
static const char* msg_cant_find = "InnoDB: vtq_trx_sees: can't find COMMIT_ID%c by TRX_ID: %llu\n";
|
||||
if (!commit_id1) {
|
||||
if (!vtq_query_trx_id(thd, NULL, trx_id1, VTQ_ALL)) {
|
||||
fprintf(stderr, msg_cant_find, '1', trx_id1);
|
||||
ib::info() << "vtq_trx_sees: can't find COMMIT_ID0 by "
|
||||
"TRX_ID: "
|
||||
<< trx_id1;
|
||||
DBUG_RETURN(false);
|
||||
}
|
||||
trx_t* trx = thd_to_trx(thd);
|
||||
@ -452,7 +457,9 @@ vtq_trx_sees(
|
||||
|
||||
if (!commit_id0) {
|
||||
if (!vtq_query_trx_id(thd, &commit_id0, trx_id0, VTQ_COMMIT_ID)) {
|
||||
fprintf(stderr, msg_cant_find, '0', trx_id0);
|
||||
ib::info() << "vtq_trx_sees: can't find COMMIT_ID1 by "
|
||||
"TRX_ID: "
|
||||
<< trx_id0;
|
||||
DBUG_RETURN(false);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user