Commit fa79f6ac authored by Eugene Kosov's avatar Eugene Kosov Committed by Aleksey Midenkov

IB: style changes [closes #306]

parent 8972291a
...@@ -223,9 +223,6 @@ class ha_innobase: public handler ...@@ -223,9 +223,6 @@ class ha_innobase: public handler
ha_rows estimate_rows_upper_bound(); 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); void update_create_info(HA_CREATE_INFO* create_info);
int create( int create(
...@@ -458,7 +455,7 @@ class ha_innobase: public handler ...@@ -458,7 +455,7 @@ class ha_innobase: public handler
void reset_template(); void reset_template();
protected: protected:
void update_thd(THD* thd); inline void update_thd(THD* thd);
void update_thd(); void update_thd();
int general_fetch(uchar* buf, uint direction, uint match_mode); int general_fetch(uchar* buf, uint direction, uint match_mode);
......
...@@ -31,7 +31,6 @@ Created 4/24/1996 Heikki Tuuri ...@@ -31,7 +31,6 @@ Created 4/24/1996 Heikki Tuuri
#include "univ.i" #include "univ.i"
#include "dict0types.h" #include "dict0types.h"
#include "trx0types.h" #include "trx0types.h"
#include "trx0vtq.h"
#include "ut0byte.h" #include "ut0byte.h"
#include "mem0mem.h" #include "mem0mem.h"
#include "btr0types.h" #include "btr0types.h"
...@@ -39,6 +38,8 @@ Created 4/24/1996 Heikki Tuuri ...@@ -39,6 +38,8 @@ Created 4/24/1996 Heikki Tuuri
#include <deque> #include <deque>
struct vtq_record_t;
/** A stack of table names related through foreign key constraints */ /** A stack of table names related through foreign key constraints */
typedef std::deque<const char*, ut_allocator<const char*> > dict_names_t; typedef std::deque<const char*, ut_allocator<const char*> > dict_names_t;
...@@ -317,17 +318,19 @@ dict_process_sys_datafiles( ...@@ -317,17 +318,19 @@ dict_process_sys_datafiles(
const rec_t* rec, /*!< in: current SYS_DATAFILES rec */ const rec_t* rec, /*!< in: current SYS_DATAFILES rec */
ulint* space, /*!< out: pace id */ ulint* space, /*!< out: pace id */
const char** path); /*!< out: datafile path */ 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. 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 */ @return error message, or NULL on success */
UNIV_INTERN UNIV_INTERN
const char* const char*
dict_process_sys_vtq( dict_process_sys_vtq(
/*=======================*/ mem_heap_t* heap, /*!< in/out: heap memory */
mem_heap_t* heap, /*!< in/out: heap memory */ const rec_t* rec, /*!< in: current rec */
const rec_t* rec, /*!< in: current rec */ vtq_record_t& fields /*!< out: field values */
vtq_record_t& fields /*!< out: field values */
); );
/** Update the record for space_id in SYS_TABLESPACES to this filepath. /** 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. ...@@ -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] add_v new virtual columns added along with indexes
@param[in] eval_table mysql table used to evaluate virtual column @param[in] eval_table mysql table used to evaluate virtual column
value, see innobase_get_computed_value(). value, see innobase_get_computed_value().
@param[in] drop_historical whether to drop historical system rows
@return DB_SUCCESS or error code */ @return DB_SUCCESS or error code */
dberr_t dberr_t
row_merge_build_indexes( row_merge_build_indexes(
......
...@@ -235,18 +235,17 @@ row_lock_table_for_mysql( ...@@ -235,18 +235,17 @@ row_lock_table_for_mysql(
(ignored if table==NULL) */ (ignored if table==NULL) */
MY_ATTRIBUTE((nonnull(1))); MY_ATTRIBUTE((nonnull(1)));
/* System Versioning: row_insert_for_mysql() modes */ /** System Versioning: row_insert_for_mysql() modes */
enum ins_mode_t { enum ins_mode_t {
ROW_INS_NORMAL = 0, ROW_INS_NORMAL = 0, ///< plain row (without versioning)
// insert versioned row: sys_trx_start = TRX_ID, sys_trx_end = MAX ROW_INS_VERSIONED, ///< sys_trx_start = TRX_ID, sys_trx_end = MAX
ROW_INS_VERSIONED, ROW_INS_HISTORICAL ///< sys_trx_end = TRX_ID
// insert historical row: sys_trx_end = TRX_ID
ROW_INS_HISTORICAL
}; };
/** Does an insert for MySQL. /** Does an insert for MySQL.
@param[in] mysql_rec row in the MySQL format @param[in] mysql_rec row in the MySQL format
@param[in,out] prebuilt prebuilt struct in MySQL handle @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*/ @return error code or DB_SUCCESS*/
dberr_t dberr_t
row_insert_for_mysql( row_insert_for_mysql(
...@@ -274,6 +273,7 @@ row_get_prebuilt_update_vector( ...@@ -274,6 +273,7 @@ row_get_prebuilt_update_vector(
handle */ handle */
/** Does an update or delete of a row for MySQL. /** Does an update or delete of a row for MySQL.
@param[in,out] prebuilt prebuilt struct in MySQL handle @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 */ @return error code or DB_SUCCESS */
dberr_t dberr_t
row_update_for_mysql( row_update_for_mysql(
......
...@@ -573,8 +573,10 @@ struct upd_node_t{ ...@@ -573,8 +573,10 @@ struct upd_node_t{
compilation; speeds up execution: compilation; speeds up execution:
UPD_NODE_NO_ORD_CHANGE and UPD_NODE_NO_ORD_CHANGE and
UPD_NODE_NO_SIZE_CHANGE, ORed */ UPD_NODE_NO_SIZE_CHANGE, ORed */
bool versioned;/* update is versioned */ /** working with system versioned table */
bool vers_delete;/* versioned delete */ bool versioned;
/** set sys_trx_end = CUR_TRX_ID */
bool vers_delete;
/*----------------------*/ /*----------------------*/
/* Local storage for this graph node */ /* Local storage for this graph node */
ulint state; /*!< node execution state */ ulint state; /*!< node execution state */
......
...@@ -59,11 +59,7 @@ class MutexDebug { ...@@ -59,11 +59,7 @@ class MutexDebug {
@param[in] id ID of the latch to track */ @param[in] id ID of the latch to track */
Context(latch_id_t id) Context(latch_id_t id)
: :
latch_t(id), latch_t(id)
m_mutex(),
m_filename(),
m_line(),
m_thread_id(os_thread_id_t(ULINT_UNDEFINED))
{ {
ut_ad(id != LATCH_ID_NONE); ut_ad(id != LATCH_ID_NONE);
} }
......
...@@ -42,7 +42,6 @@ Created 3/26/1996 Heikki Tuuri ...@@ -42,7 +42,6 @@ Created 3/26/1996 Heikki Tuuri
#include "que0types.h" #include "que0types.h"
#include "mem0mem.h" #include "mem0mem.h"
#include "trx0xa.h" #include "trx0xa.h"
#include "trx0vtq.h"
#include "ut0vec.h" #include "ut0vec.h"
#include "fts0fts.h" #include "fts0fts.h"
#include "srv0srv.h" #include "srv0srv.h"
...@@ -884,6 +883,33 @@ struct TrxVersion { ...@@ -884,6 +883,33 @@ struct TrxVersion {
ulint m_version; 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; typedef std::list<TrxVersion, ut_allocator<TrxVersion> > hit_list_t;
struct trx_t { struct trx_t {
...@@ -1272,7 +1298,8 @@ struct trx_t { ...@@ -1272,7 +1298,8 @@ struct trx_t {
/* System Versioning */ /* System Versioning */
bool vtq_notify_on_commit; bool vtq_notify_on_commit;
/*!< Notify VTQ for System Versioned update */ /*!< 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; ulint magic_n;
/** @return whether any persistent undo log has been generated */ /** @return whether any persistent undo log has been generated */
......
#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( ...@@ -1594,17 +1594,21 @@ row_ins_get_sys_trx_end(
return(mach_read_from_8(field)); return(mach_read_from_8(field));
} }
/*********************************************************************//** /**
Performs search at clustered index and returns sys_trx_end if row was found. 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 */ @return DB_SUCCESS, DB_NO_REFERENCED_ROW */
static static
dberr_t dberr_t
row_ins_search_sys_trx_end( row_ins_search_sys_trx_end(
/*=======================*/ dict_index_t *index,
dict_index_t *index, /*!< in: index of record */ const rec_t *rec,
const rec_t *rec, /*!< in: record */ trx_id_t *end_trx_id)
trx_id_t *end_trx_id) /*!< out: end_trx_id */
{ {
ut_ad(!index->is_clust());
bool found = false; bool found = false;
mem_heap_t *heap = mem_heap_create(256); mem_heap_t *heap = mem_heap_create(256);
dict_index_t *clust_index = NULL; dict_index_t *clust_index = NULL;
...@@ -1629,7 +1633,8 @@ row_ins_search_sys_trx_end( ...@@ -1629,7 +1633,8 @@ row_ins_search_sys_trx_end(
mtr_commit(&mtr); mtr_commit(&mtr);
mem_heap_free(heap); mem_heap_free(heap);
if (!found) { 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"); ut_ad(false && "secondary index is out of sync");
return(DB_NO_REFERENCED_ROW); return(DB_NO_REFERENCED_ROW);
} }
...@@ -4014,7 +4019,7 @@ vers_row_ins_vtq_low(trx_t* trx, mem_heap_t* heap, dtuple_t* tuple) ...@@ -4014,7 +4019,7 @@ vers_row_ins_vtq_low(trx_t* trx, mem_heap_t* heap, dtuple_t* tuple)
break; break;
case DB_SUCCESS_LOCKED_REC: case DB_SUCCESS_LOCKED_REC:
/* The row had already been copied to the table. */ /* 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; return DB_SUCCESS;
default: default:
return err; return err;
...@@ -4068,7 +4073,8 @@ void vers_notify_vtq(trx_t* trx) ...@@ -4068,7 +4073,8 @@ void vers_notify_vtq(trx_t* trx)
err = vers_row_ins_vtq_low(trx, heap, tuple); err = vers_row_ins_vtq_low(trx, heap, tuple);
if (DB_SUCCESS != err) 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); mem_heap_free(heap);
} }
...@@ -4603,6 +4603,7 @@ this function and it will be passed to other functions for further accounting. ...@@ -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] add_v new virtual columns added along with indexes
@param[in] eval_table mysql table used to evaluate virtual column @param[in] eval_table mysql table used to evaluate virtual column
value, see innobase_get_computed_value(). value, see innobase_get_computed_value().
@param[in] drop_historical whether to drop historical system rows
@return DB_SUCCESS or error code */ @return DB_SUCCESS or error code */
dberr_t dberr_t
row_merge_build_indexes( row_merge_build_indexes(
......
...@@ -1863,6 +1863,7 @@ class ib_dec_counter { ...@@ -1863,6 +1863,7 @@ class ib_dec_counter {
/** Does an update or delete of a row for MySQL. /** Does an update or delete of a row for MySQL.
@param[in,out] prebuilt prebuilt struct in MySQL handle @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 */ @return error code or DB_SUCCESS */
dberr_t dberr_t
row_update_for_mysql( row_update_for_mysql(
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include "row0row.h" #include "row0row.h"
#include "trx0trx.h" #include "trx0trx.h"
#include "trx0types.h" #include "trx0types.h"
#include "trx0vtq.h"
/** Field or record selector. /** Field or record selector.
...@@ -145,7 +144,9 @@ vtq_query_trx_id(THD* thd, void *out, ulonglong _in_trx_id, vtq_field_t field) ...@@ -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); const char *err = trx->vtq_query.cache_result(heap, rec);
if (err) { 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"); ut_ad(false && "get VTQ field failed");
goto not_found; goto not_found;
} }
...@@ -378,7 +379,8 @@ vtq_query_commit_ts( ...@@ -378,7 +379,8 @@ vtq_query_commit_ts(
found: found:
clust_rec = row_get_clust_rec(BTR_SEARCH_LEAF, rec, index, &clust_index, &mtr); clust_rec = row_get_clust_rec(BTR_SEARCH_LEAF, rec, index, &clust_index, &mtr);
if (!clust_rec) { 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"); ut_ad(false && "secondary index is out of sync");
goto not_found; goto not_found;
} }
...@@ -391,7 +393,9 @@ vtq_query_commit_ts( ...@@ -391,7 +393,9 @@ vtq_query_commit_ts(
rec_ts, rec_ts,
backwards); backwards);
if (err) { 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"); ut_ad(false && "get VTQ field failed");
goto not_found; goto not_found;
} }
...@@ -438,10 +442,11 @@ vtq_trx_sees( ...@@ -438,10 +442,11 @@ vtq_trx_sees(
DBUG_RETURN(true); 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 (!commit_id1) {
if (!vtq_query_trx_id(thd, NULL, trx_id1, VTQ_ALL)) { 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); DBUG_RETURN(false);
} }
trx_t* trx = thd_to_trx(thd); trx_t* trx = thd_to_trx(thd);
...@@ -452,7 +457,9 @@ vtq_trx_sees( ...@@ -452,7 +457,9 @@ vtq_trx_sees(
if (!commit_id0) { if (!commit_id0) {
if (!vtq_query_trx_id(thd, &commit_id0, trx_id0, VTQ_COMMIT_ID)) { 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); DBUG_RETURN(false);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment