Commit f92d223f authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-17750: Remove dict_index_get_sys_col_pos()

dict_index_t::db_trx_id(): Return the position of DB_TRX_ID.
Only valid for the clustered index.

dict_index_t::db_roll_ptr(): Return the position of DB_ROLL_PTR.
Only valid for the clustered index.

dict_index_get_sys_col_pos(): Remove. This was performing unnecessarily
complex computations, which only made sense for DB_ROW_ID, which would
exist either as the first field in the clustered index or as the last
field in a secondary index (only when a DB_ROW_ID column is materialised).

row_sel_store_row_id_to_prebuilt(): Remove, and replace with simpler code.

row_upd_index_entry_sys_field(): Remove.

btr_cur_log_sys(): Replaces row_upd_write_sys_vals_to_log().

btr_cur_write_sys(): Write DB_TRX_ID,DB_ROLL_PTR to a data tuple.
parent eea0c3c3
......@@ -3229,8 +3229,11 @@ btr_cur_ins_lock_and_undo(
roll_ptr = roll_ptr_t(1) << ROLL_PTR_INSERT_FLAG_POS;
if (!(flags & BTR_KEEP_SYS_FLAG)) {
upd_sys:
row_upd_index_entry_sys_field(entry, index,
DATA_ROLL_PTR, roll_ptr);
dfield_t* r = dtuple_get_nth_field(
entry, index->db_roll_ptr());
ut_ad(r->len == DATA_ROLL_PTR_LEN);
trx_write_roll_ptr(static_cast<byte*>(r->data),
roll_ptr);
}
} else {
err = trx_undo_report_row_operation(thr, index, entry,
......@@ -3819,6 +3822,50 @@ btr_cur_upd_lock_and_undo(
cmpl_info, rec, offsets, roll_ptr));
}
/** Copy DB_TRX_ID,DB_ROLL_PTR to the redo log.
@param[in] index clustered index
@param[in] trx_id_t DB_TRX_ID
@param[in] roll_ptr DB_ROLL_PTR
@param[in,out] log_ptr redo log buffer
@return current end of the redo log buffer */
static byte*
btr_cur_log_sys(
const dict_index_t* index,
trx_id_t trx_id,
roll_ptr_t roll_ptr,
byte* log_ptr)
{
log_ptr += mach_write_compressed(log_ptr, index->db_trx_id());
/* Yes, we are writing DB_ROLL_PTR,DB_TRX_ID in reverse order,
after emitting the position of DB_TRX_ID in the index.
This is how row_upd_write_sys_vals_to_log()
originally worked, and it is part of the redo log format. */
trx_write_roll_ptr(log_ptr, roll_ptr);
log_ptr += DATA_ROLL_PTR_LEN;
log_ptr += mach_u64_write_compressed(log_ptr, trx_id);
return log_ptr;
}
/** Write DB_TRX_ID,DB_ROLL_PTR to a clustered index entry.
@param[in,out] entry clustered index entry
@param[in] index clustered index
@param[in] trx_id DB_TRX_ID
@param[in] roll_ptr DB_ROLL_PTR */
static void btr_cur_write_sys(
dtuple_t* entry,
const dict_index_t* index,
trx_id_t trx_id,
roll_ptr_t roll_ptr)
{
dfield_t* t = dtuple_get_nth_field(entry, index->db_trx_id());
ut_ad(t->len == DATA_TRX_ID_LEN);
trx_write_trx_id(static_cast<byte*>(t->data), trx_id);
dfield_t* r = dtuple_get_nth_field(entry, index->db_roll_ptr());
ut_ad(r->len == DATA_ROLL_PTR_LEN);
trx_write_roll_ptr(static_cast<byte*>(r->data), roll_ptr);
}
/***********************************************************//**
Writes a redo log record of updating a record in-place. */
void
......@@ -3858,8 +3905,7 @@ btr_cur_update_in_place_log(
log_ptr++;
if (dict_index_is_clust(index)) {
log_ptr = row_upd_write_sys_vals_to_log(
index, trx_id, roll_ptr, log_ptr, mtr);
log_ptr = btr_cur_log_sys(index, trx_id, roll_ptr, log_ptr);
} else {
/* Dummy system fields for a secondary index */
/* TRX_ID Position */
......@@ -4532,10 +4578,7 @@ btr_cur_optimistic_update(
page_cur_move_to_prev(page_cursor);
if (!(flags & BTR_KEEP_SYS_FLAG)) {
row_upd_index_entry_sys_field(new_entry, index, DATA_ROLL_PTR,
roll_ptr);
row_upd_index_entry_sys_field(new_entry, index, DATA_TRX_ID,
trx_id);
btr_cur_write_sys(new_entry, index, trx_id, roll_ptr);
}
/* There are no externally stored columns in new_entry */
......@@ -4850,10 +4893,7 @@ btr_cur_pessimistic_update(
}
if (!(flags & BTR_KEEP_SYS_FLAG)) {
row_upd_index_entry_sys_field(new_entry, index, DATA_ROLL_PTR,
roll_ptr);
row_upd_index_entry_sys_field(new_entry, index, DATA_TRX_ID,
trx_id);
btr_cur_write_sys(new_entry, index, trx_id, roll_ptr);
}
if (!page_zip) {
......@@ -5125,8 +5165,7 @@ btr_cur_del_mark_set_clust_rec_log(
*log_ptr++ = 0;
*log_ptr++ = 1;
log_ptr = row_upd_write_sys_vals_to_log(
index, trx_id, roll_ptr, log_ptr, mtr);
log_ptr = btr_cur_log_sys(index, trx_id, roll_ptr, log_ptr);
mach_write_to_2(log_ptr, page_offset(rec));
log_ptr += 2;
......
......@@ -1207,16 +1207,6 @@ dict_table_get_nth_col_pos(
ulint n, /*!< in: column number */
ulint* prefix_col_pos) /*!< out: col num if prefix */
MY_ATTRIBUTE((nonnull(1), warn_unused_result));
/********************************************************************//**
Returns the position of a system column in an index.
@return position, ULINT_UNDEFINED if not contained */
UNIV_INLINE
ulint
dict_index_get_sys_col_pos(
/*=======================*/
const dict_index_t* index, /*!< in: index */
ulint type) /*!< in: DATA_ROW_ID, ... */
MY_ATTRIBUTE((nonnull, warn_unused_result));
/*******************************************************************//**
Adds a column to index. */
void
......
......@@ -925,31 +925,6 @@ dict_index_get_nth_field(
}
#endif /* UNIV_DEBUG */
/********************************************************************//**
Returns the position of a system column in an index.
@return position, ULINT_UNDEFINED if not contained */
UNIV_INLINE
ulint
dict_index_get_sys_col_pos(
/*=======================*/
const dict_index_t* index, /*!< in: index */
ulint type) /*!< in: DATA_ROW_ID, ... */
{
ut_ad(index);
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
ut_ad(!dict_index_is_ibuf(index));
if (dict_index_is_clust(index)) {
return(dict_col_get_clust_pos(
dict_table_get_sys_col(index->table, type),
index));
}
return(dict_index_get_nth_col_pos(
index, dict_table_get_sys_col_no(index->table, type), NULL));
}
/*********************************************************************//**
Gets the field column.
@return field->col, pointer to the table column */
......
......@@ -28,7 +28,6 @@ Created 1/8/1996 Heikki Tuuri
#ifndef dict0mem_h
#define dict0mem_h
#include "univ.i"
#include "dict0types.h"
#include "data0type.h"
#include "mem0mem.h"
......@@ -50,6 +49,7 @@ Created 1/8/1996 Heikki Tuuri
#include "ut0new.h"
#include "fil0fil.h"
#include "fil0crypt.h"
#include <sql_const.h>
#include <set>
#include <algorithm>
#include <iterator>
......@@ -1103,12 +1103,19 @@ struct dict_index_t {
/** @return whether the index includes virtual columns */
bool has_virtual() const { return type & DICT_VIRTUAL; }
/** @return the position of DB_TRX_ID */
unsigned db_trx_id() const {
DBUG_ASSERT(is_primary());
DBUG_ASSERT(n_uniq);
DBUG_ASSERT(n_uniq <= MAX_REF_PARTS);
return n_uniq;
}
/** @return the position of DB_ROLL_PTR */
unsigned db_roll_ptr() const { return db_trx_id() + 1; }
/** @return the offset of the metadata BLOB field,
or the first user field after the PRIMARY KEY,DB_TRX_ID,DB_ROLL_PTR */
unsigned first_user_field() const {
ut_ad(is_primary());
return n_uniq + 2;
}
unsigned first_user_field() const { return db_trx_id() + 2; }
/** @return whether the index is corrupted */
inline bool is_corrupted() const;
......
/*****************************************************************************
Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, MariaDB Corporation.
Copyright (c) 2017, 2018, 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
......@@ -39,16 +39,12 @@ row_get_trx_id_offset(
const dict_index_t* index, /*!< in: clustered index */
const ulint* offsets)/*!< in: record offsets */
{
ulint pos;
ulint offset;
ulint len;
ut_ad(dict_index_is_clust(index));
ut_ad(rec_offs_validate(NULL, index, offsets));
pos = dict_index_get_sys_col_pos(index, DATA_TRX_ID);
offset = rec_get_nth_field_offs(offsets, pos, &len);
offset = rec_get_nth_field_offs(offsets, index->db_trx_id(), &len);
ut_ad(len == DATA_TRX_ID_LEN);
......
......@@ -101,19 +101,6 @@ upd_get_field_by_field_no(
bool is_virtual) /*!< in: if it is a virtual column */
MY_ATTRIBUTE((warn_unused_result));
/*********************************************************************//**
Writes into the redo log the values of trx id and roll ptr and enough info
to determine their positions within a clustered index record.
@return new pointer to mlog */
byte*
row_upd_write_sys_vals_to_log(
/*==========================*/
dict_index_t* index, /*!< in: clustered index */
trx_id_t trx_id, /*!< in: transaction id */
roll_ptr_t roll_ptr,/*!< in: roll ptr of the undo log record */
byte* log_ptr,/*!< pointer to a buffer of size > 20 opened
in mlog */
mtr_t* mtr); /*!< in: mtr */
/*********************************************************************//**
Updates the trx id and roll ptr field in a clustered index record when
a row is updated or marked deleted. */
UNIV_INLINE
......@@ -128,18 +115,6 @@ row_upd_rec_sys_fields(
const trx_t* trx, /*!< in: transaction */
roll_ptr_t roll_ptr);/*!< in: DB_ROLL_PTR to the undo log */
/*********************************************************************//**
Sets the trx id or roll ptr field of a clustered index entry. */
void
row_upd_index_entry_sys_field(
/*==========================*/
dtuple_t* entry, /*!< in/out: index entry, where the memory
buffers for sys fields are already allocated:
the function just copies the new values to
them */
dict_index_t* index, /*!< in: clustered index */
ulint type, /*!< in: DATA_TRX_ID or DATA_ROLL_PTR */
ib_uint64_t val); /*!< in: value to write */
/*********************************************************************//**
Creates an update node for a query graph.
@return own: update node */
upd_node_t*
......
......@@ -167,13 +167,13 @@ row_upd_rec_sys_fields(
const trx_t* trx, /*!< in: transaction */
roll_ptr_t roll_ptr)/*!< in: DB_ROLL_PTR to the undo log */
{
ut_ad(dict_index_is_clust(index));
ut_ad(index->is_primary());
ut_ad(rec_offs_validate(rec, index, offsets));
if (page_zip) {
ulint pos = dict_index_get_sys_col_pos(index, DATA_TRX_ID);
if (UNIV_LIKELY_NULL(page_zip)) {
page_zip_write_trx_id_and_roll_ptr(page_zip, rec, offsets,
pos, trx->id, roll_ptr);
index->db_trx_id(),
trx->id, roll_ptr);
} else {
ulint offset = index->trx_id_offset;
......
......@@ -79,27 +79,22 @@ trx_undo_trx_id_is_insert(
/*======================*/
const byte* trx_id) /*!< in: DB_TRX_ID, followed by DB_ROLL_PTR */
MY_ATTRIBUTE((warn_unused_result));
/*****************************************************************//**
Writes a roll ptr to an index page. In case that the size changes in
some future version, this function should be used instead of
mach_write_... */
UNIV_INLINE
void
trx_write_roll_ptr(
/*===============*/
byte* ptr, /*!< in: pointer to memory where
written */
roll_ptr_t roll_ptr); /*!< in: roll ptr */
/*****************************************************************//**
Reads a roll ptr from an index page. In case that the roll ptr size
changes in some future version, this function should be used instead of
mach_read_...
/** Write DB_ROLL_PTR.
@param[out] ptr buffer
@param[in] roll_ptr DB_ROLL_PTR value */
inline void trx_write_roll_ptr(byte* ptr, roll_ptr_t roll_ptr)
{
compile_time_assert(DATA_ROLL_PTR_LEN == 7);
mach_write_to_7(ptr, roll_ptr);
}
/** Read DB_ROLL_PTR.
@param[in] ptr buffer
@return roll ptr */
UNIV_INLINE
roll_ptr_t
trx_read_roll_ptr(
/*==============*/
const byte* ptr); /*!< in: pointer to memory from where to read */
inline roll_ptr_t trx_read_roll_ptr(const byte* ptr)
{
compile_time_assert(DATA_ROLL_PTR_LEN == 7);
return mach_read_from_7(ptr);
}
/** Gets an undo log page and x-latches it.
@param[in] page_id page id
......
......@@ -103,37 +103,6 @@ trx_undo_trx_id_is_insert(
return bool(trx_id[DATA_TRX_ID_LEN] >> 7);
}
/*****************************************************************//**
Writes a roll ptr to an index page. In case that the size changes in
some future version, this function should be used instead of
mach_write_... */
UNIV_INLINE
void
trx_write_roll_ptr(
/*===============*/
byte* ptr, /*!< in: pointer to memory where
written */
roll_ptr_t roll_ptr) /*!< in: roll ptr */
{
compile_time_assert(DATA_ROLL_PTR_LEN == 7);
mach_write_to_7(ptr, roll_ptr);
}
/*****************************************************************//**
Reads a roll ptr from an index page. In case that the roll ptr size
changes in some future version, this function should be used instead of
mach_read_...
@return roll ptr */
UNIV_INLINE
roll_ptr_t
trx_read_roll_ptr(
/*==============*/
const byte* ptr) /*!< in: pointer to memory from where to read */
{
compile_time_assert(DATA_ROLL_PTR_LEN == 7);
return(mach_read_from_7(ptr));
}
/** Gets an undo log page and x-latches it.
@param[in] page_id page id
@param[in,out] mtr mini-transaction
......
......@@ -1787,17 +1787,11 @@ page_cur_insert_rec_zip(
columns of free_rec, in case it will not be
overwritten by insert_rec. */
ulint trx_id_col;
ulint trx_id_offs;
ulint len;
trx_id_col = dict_index_get_sys_col_pos(index,
DATA_TRX_ID);
ut_ad(trx_id_col > 0);
ut_ad(trx_id_col != ULINT_UNDEFINED);
trx_id_offs = rec_get_nth_field_offs(foffsets,
trx_id_col, &len);
trx_id_offs = rec_get_nth_field_offs(
foffsets, index->db_trx_id(), &len);
ut_ad(len == DATA_TRX_ID_LEN);
if (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN + trx_id_offs
......@@ -1813,7 +1807,7 @@ page_cur_insert_rec_zip(
ut_ad(free_rec + trx_id_offs + DATA_TRX_ID_LEN
== rec_get_nth_field(free_rec, foffsets,
trx_id_col + 1, &len));
index->db_roll_ptr(), &len));
ut_ad(len == DATA_ROLL_PTR_LEN);
}
......
......@@ -1411,10 +1411,7 @@ page_zip_compress(
/* Dense page directory and uncompressed columns, if any */
if (page_is_leaf(page)) {
if (dict_index_is_clust(index)) {
trx_id_col = dict_index_get_sys_col_pos(
index, DATA_TRX_ID);
ut_ad(trx_id_col > 0);
ut_ad(trx_id_col != ULINT_UNDEFINED);
trx_id_col = index->db_trx_id();
slot_size = PAGE_ZIP_DIR_SLOT_SIZE
+ DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN;
......@@ -1422,8 +1419,6 @@ page_zip_compress(
} else {
/* Signal the absence of trx_id
in page_zip_fields_encode() */
ut_ad(dict_index_get_sys_col_pos(
index, DATA_TRX_ID) == ULINT_UNDEFINED);
trx_id_col = 0;
slot_size = PAGE_ZIP_DIR_SLOT_SIZE;
}
......@@ -3730,29 +3725,25 @@ page_zip_write_rec(
ulint len;
if (dict_index_is_clust(index)) {
ulint trx_id_col;
trx_id_col = dict_index_get_sys_col_pos(index,
DATA_TRX_ID);
ut_ad(trx_id_col != ULINT_UNDEFINED);
/* Store separately trx_id, roll_ptr and
the BTR_EXTERN_FIELD_REF of each BLOB column. */
if (rec_offs_any_extern(offsets)) {
data = page_zip_write_rec_ext(
page_zip, page,
rec, index, offsets, create,
trx_id_col, heap_no, storage, data);
index->db_trx_id(), heap_no,
storage, data);
} else {
/* Locate trx_id and roll_ptr. */
const byte* src
= rec_get_nth_field(rec, offsets,
trx_id_col, &len);
index->db_trx_id(),
&len);
ut_ad(len == DATA_TRX_ID_LEN);
ut_ad(src + DATA_TRX_ID_LEN
== rec_get_nth_field(
rec, offsets,
trx_id_col + 1, &len));
index->db_roll_ptr(), &len));
ut_ad(len == DATA_ROLL_PTR_LEN);
/* Log the preceding fields. */
......@@ -3780,8 +3771,6 @@ page_zip_write_rec(
} else {
/* Leaf page of a secondary index:
no externally stored columns */
ut_ad(dict_index_get_sys_col_pos(index, DATA_TRX_ID)
== ULINT_UNDEFINED);
ut_ad(!rec_offs_any_extern(offsets));
/* Log the entire record. */
......
......@@ -2641,8 +2641,6 @@ rec_get_trx_id(
const rec_t* rec,
const dict_index_t* index)
{
ulint trx_id_col
= dict_index_get_sys_col_pos(index, DATA_TRX_ID);
const byte* trx_id;
ulint len;
mem_heap_t* heap = NULL;
......@@ -2650,15 +2648,10 @@ rec_get_trx_id(
rec_offs_init(offsets_);
ulint* offsets = offsets_;
ut_ad(trx_id_col <= MAX_REF_PARTS);
ut_ad(dict_index_is_clust(index));
ut_ad(trx_id_col > 0);
ut_ad(trx_id_col != ULINT_UNDEFINED);
offsets = rec_get_offsets(rec, index, offsets, true,
trx_id_col + 1, &heap);
index->db_trx_id() + 1, &heap);
trx_id = rec_get_nth_field(rec, offsets, trx_id_col, &len);
trx_id = rec_get_nth_field(rec, offsets, index->db_trx_id(), &len);
ut_ad(len == DATA_TRX_ID_LEN);
......
......@@ -1244,19 +1244,16 @@ row_log_table_get_pk(
ulint trx_id_offs = index->trx_id_offset;
if (!trx_id_offs) {
ulint pos = dict_index_get_sys_col_pos(
index, DATA_TRX_ID);
ulint len;
ut_ad(pos > 0);
if (!offsets) {
offsets = rec_get_offsets(
rec, index, NULL, true,
pos + 1, heap);
index->db_trx_id() + 1, heap);
}
trx_id_offs = rec_get_nth_field_offs(
offsets, pos, &len);
offsets, index->db_trx_id(), &len);
ut_ad(len == DATA_TRX_ID_LEN);
}
......
......@@ -34,7 +34,6 @@ Created 9/17/2000 Heikki Tuuri
#include "btr0sea.h"
#include "dict0boot.h"
#include "dict0crea.h"
#include <sql_const.h>
#include "dict0dict.h"
#include "dict0load.h"
#include "dict0priv.h"
......
......@@ -2694,44 +2694,6 @@ row_sel_convert_mysql_key_to_innobase(
dtuple_set_n_fields(tuple, n_fields);
}
/**************************************************************//**
Stores the row id to the prebuilt struct. */
static
void
row_sel_store_row_id_to_prebuilt(
/*=============================*/
row_prebuilt_t* prebuilt, /*!< in/out: prebuilt */
const rec_t* index_rec, /*!< in: record */
const dict_index_t* index, /*!< in: index of the record */
const ulint* offsets) /*!< in: rec_get_offsets
(index_rec, index) */
{
const byte* data;
ulint len;
ut_ad(rec_offs_validate(index_rec, index, offsets));
data = rec_get_nth_field(
index_rec, offsets,
dict_index_get_sys_col_pos(index, DATA_ROW_ID), &len);
if (UNIV_UNLIKELY(len != DATA_ROW_ID_LEN)) {
ib::error() << "Row id field is wrong length " << len << " in"
" index " << index->name
<< " of table " << index->table->name
<< ", Field number "
<< dict_index_get_sys_col_pos(index, DATA_ROW_ID)
<< ", record:";
rec_print_new(stderr, index_rec, offsets);
putc('\n', stderr);
ut_error;
}
ut_memcpy(prebuilt->row_id, data, len);
}
/**************************************************************//**
Stores a non-SQL-NULL field in the MySQL format. The counterpart of this
function is row_mysql_store_col_in_innobase_format() in row0mysql.cc. */
......@@ -5494,11 +5456,19 @@ row_search_mvcc(
}
}
if (prebuilt->clust_index_was_generated) {
row_sel_store_row_id_to_prebuilt(
prebuilt, result_rec,
result_rec == rec ? index : clust_index,
offsets);
if (!prebuilt->clust_index_was_generated) {
} else if (result_rec != rec || index->is_primary()) {
memcpy(prebuilt->row_id, result_rec, DATA_ROW_ID_LEN);
} else {
ulint len;
const byte* data = rec_get_nth_field(
result_rec, offsets, index->n_fields - 1,
&len);
ut_ad(dict_index_get_nth_col(index,
index->n_fields - 1)
->prtype == (DATA_ROW_ID | DATA_NOT_NULL));
ut_ad(len == DATA_ROW_ID_LEN);
memcpy(prebuilt->row_id, data, DATA_ROW_ID_LEN);
}
}
......
......@@ -497,39 +497,6 @@ row_upd_rec_sys_fields_in_recovery(
}
}
/*********************************************************************//**
Sets the trx id or roll ptr field of a clustered index entry. */
void
row_upd_index_entry_sys_field(
/*==========================*/
dtuple_t* entry, /*!< in/out: index entry, where the memory
buffers for sys fields are already allocated:
the function just copies the new values to
them */
dict_index_t* index, /*!< in: clustered index */
ulint type, /*!< in: DATA_TRX_ID or DATA_ROLL_PTR */
ib_uint64_t val) /*!< in: value to write */
{
dfield_t* dfield;
byte* field;
ulint pos;
ut_ad(dict_index_is_clust(index));
pos = dict_index_get_sys_col_pos(index, type);
dfield = dtuple_get_nth_field(entry, pos);
field = static_cast<byte*>(dfield_get_data(dfield));
if (type == DATA_TRX_ID) {
ut_ad(val > 0);
trx_write_trx_id(field, val);
} else {
ut_ad(type == DATA_ROLL_PTR);
trx_write_roll_ptr(field, val);
}
}
/***********************************************************//**
Returns TRUE if row update changes size of some field in index or if some
field to be updated is stored externally in rec or update.
......@@ -732,35 +699,6 @@ row_upd_rec_in_place(
}
}
/*********************************************************************//**
Writes into the redo log the values of trx id and roll ptr and enough info
to determine their positions within a clustered index record.
@return new pointer to mlog */
byte*
row_upd_write_sys_vals_to_log(
/*==========================*/
dict_index_t* index, /*!< in: clustered index */
trx_id_t trx_id, /*!< in: transaction id */
roll_ptr_t roll_ptr,/*!< in: roll ptr of the undo log record */
byte* log_ptr,/*!< pointer to a buffer of size > 20 opened
in mlog */
mtr_t* mtr MY_ATTRIBUTE((unused))) /*!< in: mtr */
{
ut_ad(dict_index_is_clust(index));
ut_ad(mtr);
log_ptr += mach_write_compressed(log_ptr,
dict_index_get_sys_col_pos(
index, DATA_TRX_ID));
trx_write_roll_ptr(log_ptr, roll_ptr);
log_ptr += DATA_ROLL_PTR_LEN;
log_ptr += mach_u64_write_compressed(log_ptr, trx_id);
return(log_ptr);
}
/*********************************************************************//**
Parses the log data of system field values.
@return log data end or NULL */
......@@ -1055,7 +993,6 @@ row_upd_build_difference_binary(
ulint len;
upd_t* update;
ulint n_diff;
ulint trx_id_pos;
ulint i;
ulint offsets_[REC_OFFS_NORMAL_SIZE];
ulint n_fld = dtuple_get_n_fields(entry);
......@@ -1070,10 +1007,6 @@ row_upd_build_difference_binary(
n_diff = 0;
trx_id_pos = dict_index_get_sys_col_pos(index, DATA_TRX_ID);
ut_ad(dict_index_get_sys_col_pos(index, DATA_ROLL_PTR)
== trx_id_pos + 1);
if (!offsets) {
offsets = rec_get_offsets(rec, index, offsets_, true,
ULINT_UNDEFINED, &heap);
......@@ -1088,17 +1021,10 @@ row_upd_build_difference_binary(
/* NOTE: we compare the fields as binary strings!
(No collation) */
if (no_sys) {
/* TRX_ID */
if (i == trx_id_pos) {
continue;
}
/* DB_ROLL_PTR */
if (i == trx_id_pos + 1) {
if (no_sys && (i == index->db_trx_id()
|| i == index->db_roll_ptr())) {
continue;
}
}
if (!dfield_is_ext(dfield)
!= !rec_offs_nth_extern(offsets, i)
......@@ -2761,7 +2687,11 @@ row_upd_clust_rec_by_insert(
if (index->is_instant()) entry->trim(*index);
ut_ad(dtuple_get_info_bits(entry) == 0);
row_upd_index_entry_sys_field(entry, index, DATA_TRX_ID, trx->id);
{
dfield_t* t = dtuple_get_nth_field(entry, index->db_trx_id());
ut_ad(t->len == DATA_TRX_ID_LEN);
trx_write_trx_id(static_cast<byte*>(t->data), trx->id);
}
switch (node->state) {
default:
......
......@@ -954,9 +954,7 @@ trx_undo_page_report_modify(
*ptr++ = (byte) rec_get_info_bits(rec, dict_table_is_comp(table));
/* Store the values of the system columns */
field = rec_get_nth_field(rec, offsets,
dict_index_get_sys_col_pos(
index, DATA_TRX_ID), &flen);
field = rec_get_nth_field(rec, offsets, index->db_trx_id(), &flen);
ut_ad(flen == DATA_TRX_ID_LEN);
trx_id = trx_read_trx_id(field);
......@@ -970,9 +968,7 @@ trx_undo_page_report_modify(
}
ptr += mach_u64_write_compressed(ptr, trx_id);
field = rec_get_nth_field(rec, offsets,
dict_index_get_sys_col_pos(
index, DATA_ROLL_PTR), &flen);
field = rec_get_nth_field(rec, offsets, index->db_roll_ptr(), &flen);
ut_ad(flen == DATA_ROLL_PTR_LEN);
ut_ad(memcmp(field, field_ref_zero, DATA_ROLL_PTR_LEN));
......@@ -1578,9 +1574,7 @@ trx_undo_update_rec_get_update(
mach_write_to_6(buf, trx_id);
upd_field_set_field_no(upd_field,
dict_index_get_sys_col_pos(index, DATA_TRX_ID),
index);
upd_field_set_field_no(upd_field, index->db_trx_id(), index);
dfield_set_data(&(upd_field->new_val), buf, DATA_TRX_ID_LEN);
upd_field = upd_get_nth_field(update, n_fields + 1);
......@@ -1589,9 +1583,7 @@ trx_undo_update_rec_get_update(
trx_write_roll_ptr(buf, roll_ptr);
upd_field_set_field_no(
upd_field, dict_index_get_sys_col_pos(index, DATA_ROLL_PTR),
index);
upd_field_set_field_no(upd_field, index->db_roll_ptr(), index);
dfield_set_data(&(upd_field->new_val), buf, DATA_ROLL_PTR_LEN);
/* Store then the updated ordinary columns to the update vector */
......
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