Commit 058579bb authored by Marko Mäkelä's avatar Marko Mäkelä

Rename REC_INFO_DEFAULT_ROW and add accessors

REC_INFO_DEFAULT_ROW_ADD: Renamed from REC_INFO_DEFAULT_ROW.
This is for instant ADD COLUMN only.

REC_INFO_DEFAULT_ROW_ALTER: The more generic 'default row' record,
with additional information other than instant ADD COLUMN.

dtuple_t::is_default_row(), upd_t::is_default_row(): Check if info_bits
is for the 'default row'.
parent 61f7b909
......@@ -2432,11 +2432,10 @@ btr_cur_search_to_nth_level_func(
ut_ad(index->is_instant());
/* This may be a search tuple for
btr_pcur_restore_position(). */
ut_ad(tuple->info_bits == REC_INFO_DEFAULT_ROW
|| tuple->info_bits == REC_INFO_DEFAULT_ROW_DROP
|| tuple->info_bits == REC_INFO_MIN_REC_FLAG
|| tuple->info_bits == (REC_INFO_MIN_REC_FLAG
| REC_INFO_DELETED_FLAG));
ut_ad(tuple->is_default_row()
|| (tuple->is_default_row(
tuple->info_bits
^ REC_STATUS_INSTANT)));
} else if (rec_is_default_row(btr_cur_get_rec(cursor),
index)) {
/* Only user records belong in the adaptive
......@@ -3578,8 +3577,7 @@ btr_cur_optimistic_insert(
} else if (index->disable_ahi) {
# endif
} else if (entry->info_bits & REC_INFO_MIN_REC_FLAG) {
ut_ad(entry->info_bits == REC_INFO_DEFAULT_ROW
|| entry->info_bits == REC_INFO_DEFAULT_ROW_DROP);
ut_ad(entry->is_default_row());
ut_ad(index->is_instant());
ut_ad(flags == BTR_NO_LOCKING_FLAG);
} else {
......@@ -3787,8 +3785,7 @@ btr_cur_pessimistic_insert(
if (index->disable_ahi); else
# endif
if (entry->info_bits & REC_INFO_MIN_REC_FLAG) {
ut_ad(entry->info_bits == REC_INFO_DEFAULT_ROW
|| entry->info_bits == REC_INFO_DEFAULT_ROW_DROP);
ut_ad(entry->is_default_row());
ut_ad(index->is_instant());
ut_ad((flags & ulint(~BTR_KEEP_IBUF_BITMAP))
== BTR_NO_LOCKING_FLAG);
......@@ -4287,8 +4284,7 @@ btr_cur_trim(
const que_thr_t* thr)
{
if (!index->is_instant()) {
} else if (UNIV_UNLIKELY(update->info_bits == REC_INFO_DEFAULT_ROW
|| update->info_bits == REC_INFO_DEFAULT_ROW_DROP)) {
} else if (UNIV_UNLIKELY(update->is_default_row())) {
/* We are either updating a 'default row'
(instantly adding columns to a table where instant ADD was
already executed) or rolling back such an operation. */
......@@ -4394,12 +4390,7 @@ btr_cur_optimistic_update(
|| trx_is_recv(thr_get_trx(thr)));
#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
const bool is_default_row = update->info_bits == REC_INFO_DEFAULT_ROW;
const bool is_new_default_row = update->info_bits ==
(REC_INFO_DEFAULT_ROW | REC_INFO_DELETED_FLAG);
if (UNIV_LIKELY(!is_default_row)
&& UNIV_LIKELY(!is_new_default_row)
if (UNIV_LIKELY(!update->is_default_row())
&& !row_upd_changes_field_size_or_external(index, *offsets,
update)) {
......@@ -4564,9 +4555,8 @@ btr_cur_optimistic_update(
lock_rec_store_on_page_infimum(block, rec);
}
if (UNIV_UNLIKELY(is_default_row || is_new_default_row)) {
ut_ad(new_entry->info_bits == REC_INFO_DEFAULT_ROW
|| new_entry->info_bits == REC_INFO_DEFAULT_ROW_DROP);
if (UNIV_UNLIKELY(update->is_default_row())) {
ut_ad(new_entry->is_default_row());
ut_ad(index->is_instant());
/* This can be innobase_add_instant_try() performing a
subsequent instant ADD COLUMN, or its rollback by
......@@ -4592,7 +4582,7 @@ btr_cur_optimistic_update(
cursor, new_entry, offsets, heap, 0/*n_ext*/, mtr);
ut_a(rec); /* <- We calculated above the insert would fit */
if (UNIV_UNLIKELY(is_default_row)) {
if (UNIV_UNLIKELY(update->is_default_row())) {
/* We must empty the PAGE_FREE list, because if this
was a rollback, the shortened 'default row' record
would have too many fields, and we would be unable to
......@@ -4895,8 +4885,7 @@ btr_cur_pessimistic_update(
}
if (UNIV_UNLIKELY(is_default_row)) {
ut_ad(new_entry->info_bits == REC_INFO_DEFAULT_ROW
|| new_entry->info_bits == REC_INFO_DEFAULT_ROW_DROP);
ut_ad(new_entry->is_default_row());
ut_ad(index->is_instant());
/* This can be innobase_add_instant_try() performing a
subsequent instant ADD COLUMN, or its rollback by
......
......@@ -80,13 +80,6 @@ void dtuple_t::trim(const dict_index_t& index)
n_fields = i;
}
/** Whether the dtuple represnets default row with drop column info.
@return true if it is default row with drop column or false. */
bool dtuple_t::is_new_default_row() const
{
return info_bits == REC_INFO_DEFAULT_ROW_DROP;
}
/** Compare two data tuples.
@param[in] tuple1 first data tuple
@param[in] tuple2 second data tuple
......
......@@ -4539,10 +4539,10 @@ innobase_op_instant_try(
if (index->is_drop_field_exist()) {
entry = row_build_clust_default_entry(row, index, ctx->heap);
entry->info_bits = REC_INFO_DEFAULT_ROW_DROP;
entry->info_bits = REC_INFO_DEFAULT_ROW_ALTER;
} else {
entry = row_build_index_entry(row, NULL, index, ctx->heap);
entry->info_bits = REC_INFO_DEFAULT_ROW;
entry->info_bits = REC_INFO_DEFAULT_ROW_ADD;
}
mtr_t mtr;
......@@ -4582,14 +4582,13 @@ innobase_op_instant_try(
/* Reserve room for DB_TRX_ID,DB_ROLL_PTR and any
non-updated off-page columns in case they are moved off
page as a result of the update. */
const unsigned f = index->n_dropped_fields
|| ctx->n_instant_drop_cols;
upd_t* update = upd_create(index->n_fields, ctx->heap);
update->n_fields = n;
if (index->n_dropped_fields > 0 || ctx->n_instant_drop_cols > 0) {
update->info_bits = (REC_INFO_DEFAULT_ROW
| REC_INFO_DELETED_FLAG);
} else {
update->info_bits = REC_INFO_DEFAULT_ROW;
}
update->info_bits == f
? REC_INFO_DEFAULT_ROW_ALTER
: REC_INFO_DEFAULT_ROW_ADD;
/* Add the default values for instantly added columns */
unsigned j = 0;
......@@ -4597,36 +4596,27 @@ innobase_op_instant_try(
for (unsigned i = 0; i < user_table->n_cols; i++) {
if (ctx->col_map[i] == ULINT_UNDEFINED) {
ulint field_no = user_table->dropped_cols[
drop_cols_offset++].ind;
unsigned field_no = user_table->dropped_cols[
drop_cols_offset++].ind;
upd_field_t* uf = upd_get_nth_field(
update, j++);
update, j++);
uf->field_no = field_no;
if (update->info_bits == REC_INFO_DEFAULT_ROW) {
uf->new_val = entry->fields[field_no];
} else {
uf->new_val = entry->fields[field_no + 1];
}
uf->new_val = entry->fields[field_no + f];
}
ut_ad(j <= n);
}
unsigned k = n_old_fields;
while (k < index->n_fields) {
for (unsigned k = n_old_fields; k < index->n_fields; k++) {
upd_field_t* uf = upd_get_nth_field(update, j++);
uf->field_no = k;
uf->new_val = entry->fields[k + f];
if (update->info_bits == REC_INFO_DEFAULT_ROW) {
uf->new_val = entry->fields[k];
} else {
uf->new_val = entry->fields[k + 1];
}
k++;
ut_ad(j <= n);
}
ut_ad(j == n);
ulint* offsets = NULL;
mem_heap_t* offsets_heap = NULL;
big_rec_t* big_rec;
......
/*****************************************************************************
Copyright (c) 1994, 2016, 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
......@@ -654,8 +654,26 @@ struct dtuple_t {
@param[in] index index possibly with instantly added columns */
void trim(const dict_index_t& index);
/** Default row data tuple with drop column information.*/
bool is_new_default_row() const;
/** @return whether this is a hidden 'default row' record
for instant ALTER TABLE (not only ADD COLUMN) */
bool is_new_default_row() const
{
return UNIV_UNLIKELY(info_bits == REC_INFO_DEFAULT_ROW_ALTER);
}
/**
@param info_bits the info_bits of a data tuple
@return whether this is a hidden 'default row' record
for instant ADD COLUMN or ALTER TABLE */
static bool is_default_row(ulint info_bits)
{
return UNIV_UNLIKELY((info_bits & ~REC_INFO_DELETED_FLAG)
== REC_INFO_DEFAULT_ROW_ADD);
}
/** @return whether this is a hidden 'default row' record
for instant ADD COLUMN or ALTER TABLE */
bool is_default_row() const { return is_default_row(info_bits); }
};
/** A slot for a field in a big rec vector */
......
......@@ -559,6 +559,40 @@ struct dtype_t{
/** The DB_TRX_ID,DB_ROLL_PTR values for "no history is available" */
extern const byte reset_trx_id[DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN];
/** Info bit denoting the predefined minimum record: this bit is set
if and only if the record is the first user record on a non-leaf
B-tree page that is the leftmost page on its level
(PAGE_LEVEL is nonzero and FIL_PAGE_PREV is FIL_NULL). */
#define REC_INFO_MIN_REC_FLAG 0x10UL
/** The delete-mark flag in info bits */
#define REC_INFO_DELETED_FLAG 0x20UL
/** Record status values for ROW_FORMAT=COMPACT,DYNAMIC,COMPRESSED */
enum rec_comp_status_t {
/** User record (PAGE_LEVEL=0, heap>=PAGE_HEAP_NO_USER_LOW) */
REC_STATUS_ORDINARY = 0,
/** Node pointer record (PAGE_LEVEL>=0, heap>=PAGE_HEAP_NO_USER_LOW) */
REC_STATUS_NODE_PTR = 1,
/** The page infimum pseudo-record (heap=PAGE_HEAP_NO_INFIMUM) */
REC_STATUS_INFIMUM = 2,
/** The page supremum pseudo-record (heap=PAGE_HEAP_NO_SUPREMUM) */
REC_STATUS_SUPREMUM = 3,
/** Clustered index record that has been inserted or updated
after instant ADD COLUMN (more than dict_index_t::n_core_fields) */
REC_STATUS_INSTANT = 4
};
/** The dtuple_t::info_bits of the hidden 'default row' of instant ADD COLUMN.
@see rec_is_default_row()
@see rec_is_new_default_row() */
static const byte REC_INFO_DEFAULT_ROW_ADD
= REC_INFO_MIN_REC_FLAG | REC_STATUS_INSTANT;
/** The dtuple_t::info_bits of the hidden 'default row' of instant ALTER TABLE.
@see rec_is_default_row() */
static const byte REC_INFO_DEFAULT_ROW_ALTER
= REC_INFO_DEFAULT_ROW_ADD | REC_INFO_DELETED_FLAG;
#include "data0type.ic"
#endif
......@@ -39,15 +39,6 @@ Created 5/30/1994 Heikki Tuuri
#include <ostream>
#include <sstream>
/* Info bit denoting the predefined minimum record: this bit is set
if and only if the record is the first user record on a non-leaf
B-tree page that is the leftmost page on its level
(PAGE_LEVEL is nonzero and FIL_PAGE_PREV is FIL_NULL). */
#define REC_INFO_MIN_REC_FLAG 0x10UL
/* The deleted flag in info bits */
#define REC_INFO_DELETED_FLAG 0x20UL /* when bit is set to 1, it means the
record has been delete marked */
/* Number of extra bytes in an old-style record,
in addition to the data and the offsets */
#define REC_N_OLD_EXTRA_BYTES 6
......@@ -55,32 +46,6 @@ in addition to the data and the offsets */
in addition to the data and the offsets */
#define REC_N_NEW_EXTRA_BYTES 5
/** Record status values for ROW_FORMAT=COMPACT,DYNAMIC,COMPRESSED */
enum rec_comp_status_t {
/** User record (PAGE_LEVEL=0, heap>=PAGE_HEAP_NO_USER_LOW) */
REC_STATUS_ORDINARY = 0,
/** Node pointer record (PAGE_LEVEL>=0, heap>=PAGE_HEAP_NO_USER_LOW) */
REC_STATUS_NODE_PTR = 1,
/** The page infimum pseudo-record (heap=PAGE_HEAP_NO_INFIMUM) */
REC_STATUS_INFIMUM = 2,
/** The page supremum pseudo-record (heap=PAGE_HEAP_NO_SUPREMUM) */
REC_STATUS_SUPREMUM = 3,
/** Clustered index record that has been inserted or updated
after instant ADD COLUMN (more than dict_index_t::n_core_fields) */
REC_STATUS_INSTANT = 4
};
/** The dtuple_t::info_bits of the 'default row' record.
@see rec_is_default_row() */
static const byte REC_INFO_DEFAULT_ROW
= REC_INFO_MIN_REC_FLAG | REC_STATUS_INSTANT;
/** The dtuple_t::info_bits of the 'default row' record with dropped
column information. */
static const byte REC_INFO_DEFAULT_ROW_DROP
= REC_INFO_MIN_REC_FLAG | REC_INFO_DELETED_FLAG
| REC_STATUS_INSTANT;
#define REC_NEW_STATUS 3 /* This is single byte bit-field */
#define REC_NEW_STATUS_MASK 0x7UL
#define REC_NEW_STATUS_SHIFT 0
......@@ -822,9 +787,7 @@ in the clustered index.
@param[in] rec leaf page record
@param[in] index index of the record
@return whether the record is the 'default row' pseudo-record */
inline
bool
rec_is_default_row(const rec_t* rec, const dict_index_t* index)
inline bool rec_is_default_row(const rec_t* rec, const dict_index_t* index)
{
bool is = rec_get_info_bits(rec, dict_table_is_comp(index->table))
& REC_INFO_MIN_REC_FLAG;
......
......@@ -1442,14 +1442,13 @@ rec_get_converted_size(
} else {
ut_ad(dtuple->n_fields >= index->n_core_fields);
ut_ad(dtuple->n_fields <= index->n_fields
|| dtuple->info_bits == REC_INFO_DEFAULT_ROW_DROP);
|| dtuple->is_new_default_row());
}
#endif
if (dict_table_is_comp(index->table)) {
if (UNIV_UNLIKELY(dtuple_get_info_bits(dtuple)
== REC_INFO_DEFAULT_ROW_DROP)) {
if (UNIV_UNLIKELY(dtuple->is_new_default_row())) {
return (rec_get_default_rec_converted_size(
index, dtuple, NULL));
}
......
......@@ -490,6 +490,12 @@ struct upd_t{
return false;
}
/** @return whether this is for a hidden 'default row' record
for instant ADD COLUMN or ALTER TABLE */
bool is_default_row() const {
return dtuple_t::is_default_row(info_bits);
}
#ifdef UNIV_DEBUG
bool validate() const
{
......@@ -503,7 +509,6 @@ struct upd_t{
return(true);
}
#endif // UNIV_DEBUG
};
/** Kinds of update operation */
......
......@@ -2652,8 +2652,7 @@ row_ins_clust_index_entry_low(
#endif /* UNIV_DEBUG */
if (UNIV_UNLIKELY(entry->info_bits != 0)) {
ut_ad(entry->info_bits == REC_INFO_DEFAULT_ROW
|| entry->info_bits == REC_INFO_DEFAULT_ROW_DROP);
ut_ad(entry->is_default_row());
ut_ad(flags == BTR_NO_LOCKING_FLAG);
ut_ad(index->is_instant());
ut_ad(!dict_index_is_online_ddl(index));
......
......@@ -1256,8 +1256,7 @@ row_search_on_row_ref(
index = dict_table_get_first_index(table);
if (UNIV_UNLIKELY(ref->info_bits != 0)) {
ut_ad(ref->info_bits == REC_INFO_DEFAULT_ROW
|| ref->info_bits == REC_INFO_DEFAULT_ROW_DROP);
ut_ad(ref->is_default_row());
ut_ad(ref->n_fields <= index->n_uniq);
btr_pcur_open_at_index_side(true, index, mode, pcur, true, 0,
mtr);
......
......@@ -1218,9 +1218,10 @@ row_undo_mod_parse_undo_rec(
ut_ad(!"wrong info_bits in undo log record");
goto close_table;
}
node->update->info_bits = REC_INFO_DEFAULT_ROW;
// FIXME: Could be REC_INFO_DEFAULT_ROW_ALTER as well?
node->update->info_bits = REC_INFO_DEFAULT_ROW_ADD;
const_cast<dtuple_t*>(node->ref)->info_bits
= REC_INFO_DEFAULT_ROW;
= REC_INFO_DEFAULT_ROW_ADD;
}
if (!row_undo_search_clust_to_pcur(node)) {
......@@ -1297,7 +1298,7 @@ row_undo_mod(
ut_ad(dict_index_is_clust(node->index));
if (node->ref->info_bits) {
ut_ad(node->ref->info_bits == REC_INFO_DEFAULT_ROW);
ut_ad(node->ref->is_default_row());
goto rollback_clust;
}
......
......@@ -1383,7 +1383,7 @@ row_upd_index_replace_new_col_vals_index_pos(
dtuple_set_info_bits(entry, update->info_bits);
if (UNIV_UNLIKELY(entry->info_bits == REC_INFO_DEFAULT_ROW_DROP)) {
if (UNIV_UNLIKELY(entry->is_new_default_row())) {
row_upd_index_replace_default_rec_pos(entry, index, update, heap);
return;
}
......
......@@ -40,9 +40,12 @@ Created 3/26/1996 Heikki Tuuri
#include "fsp0sysspace.h"
#include "row0mysql.h"
/** The search tuple corresponding to TRX_UNDO_INSERT_DEFAULT */
/** The search tuple corresponding to TRX_UNDO_INSERT_DEFAULT. */
const dtuple_t trx_undo_default_rec = {
REC_INFO_DEFAULT_ROW, 0, 0,
/* This also works for REC_INFO_DEFAULT_ROW_ALTER, because the
delete-mark (REC_INFO_DELETED_FLAG) is ignored when searching. */
REC_INFO_DEFAULT_ROW_ADD,
0, 0,
NULL, 0, NULL,
UT_LIST_NODE_T(dtuple_t)()
#ifdef UNIV_DEBUG
......@@ -506,8 +509,7 @@ trx_undo_page_report_insert(
/* Store then the fields required to uniquely determine the record
to be inserted in the clustered index */
if (UNIV_UNLIKELY(clust_entry->info_bits != 0)) {
ut_ad(clust_entry->info_bits == REC_INFO_DEFAULT_ROW
|| clust_entry->info_bits == REC_INFO_DEFAULT_ROW_DROP);
ut_ad(clust_entry->is_default_row());
ut_ad(index->is_instant());
ut_ad(undo_block->frame[first_free + 2]
== TRX_UNDO_INSERT_REC);
......
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