Commit 3fb6b0f3 authored by Marko Mäkelä's avatar Marko Mäkelä

Minor cleanup of dict_col_t

dict_col_t::is_added(): The new name for is_instant().
parent 1725d3b9
......@@ -561,7 +561,7 @@ btr_cur_instant_init_add_column(
ulint len;
const byte* data = rec_get_nth_field(rec, offsets, i, &len);
dict_col_t* col = index->fields[i].col;
ut_ad(!col->is_instant_add());
ut_ad(!col->is_added());
ut_ad(!col->def_val.data);
col->def_val.len = len;
switch (len) {
......
......@@ -65,7 +65,7 @@ void dtuple_t::trim(const dict_index_t& index)
continue;
}
ut_ad(col->is_instant_add());
ut_ad(col->is_added());
ulint len = dfield_get_len(dfield);
if (len != col->def_val.len) {
break;
......
......@@ -713,9 +713,9 @@ dict_mem_fill_column_struct(
dtype_get_mblen(mtype, prtype, &mbminlen, &mbmaxlen);
column->mbminlen = mbminlen;
column->mbmaxlen = mbmaxlen;
column->dropped = false;
column->def_val.data = NULL;
column->def_val.len = UNIV_SQL_DEFAULT;
column->dropped = false;
}
/**********************************************************************//**
......@@ -1229,7 +1229,8 @@ void dict_index_t::reconstruct_fields()
fields = temp_fields;
}
/** Remove the instant fields from the index. */
/** Remove instant ALTER TABLE metadata.
Protected by index root page x-latch or table X-lock. */
void dict_index_t::remove_instant()
{
DBUG_ASSERT(is_primary());
......@@ -1275,7 +1276,7 @@ void dict_index_t::remove_instant()
table, dict_col_get_no(field.col));
temp_field.col = &table->cols[field.col->ind];
if (temp_field.col->is_instant_add()) {
if (temp_field.col->is_added()) {
temp_field.col->remove_instant();
}
......@@ -1516,7 +1517,6 @@ void dict_table_t::construct_dropped_columns(const byte* data)
field_data += INSTANT_FIELD_LEN;
}
dropped_cols = static_cast<dict_col_t*>(mem_heap_zalloc(
heap, n_dropped_cols * sizeof(dict_col_t)));
......@@ -1524,7 +1524,7 @@ void dict_table_t::construct_dropped_columns(const byte* data)
for (ulint i = 0; i < n_dropped_cols; i++) {
dict_col_t& drop_col = dropped_cols[i];
bool is_fixed = false;
drop_col.set_dropped();
drop_col.dropped = true;
while (j < num_non_pk_fields) {
if (non_pk_col_map[j] == 0) {
......@@ -1574,7 +1574,7 @@ void dict_table_t::fill_dropped_column(
dict_col_t& drop_col = temp_drop_cols[j++];
dict_col_t col = cols[i];
drop_col.set_dropped();
drop_col.dropped = true;
drop_col.ind = dict_col_get_clust_pos(
&cols[i], dict_table_get_first_index(this));
......@@ -1653,7 +1653,7 @@ void dict_table_t::instant_op_column(
/* Copy the new default values to this->heap. */
for (unsigned i = n_cols; i < table.n_cols; i++) {
dict_col_t& c = cols[i - DATA_N_SYS_COLS];
DBUG_ASSERT(c.is_instant_add());
DBUG_ASSERT(c.is_added());
if (c.def_val.len == 0) {
c.def_val.data = field_ref_zero;
} else if (const void*& d = c.def_val.data) {
......
......@@ -4481,7 +4481,7 @@ innobase_op_instant_try(
dfield_t* d = dtuple_get_nth_field(row, i);
if (col->is_instant_add()) {
if (col->is_added()) {
dfield_set_data(d, col->def_val.data,
col->def_val.len);
} else if ((*af)->real_maybe_null()) {
......@@ -5601,7 +5601,7 @@ prepare_inplace_alter_table_dict(
DBUG_ASSERT(!strcmp((*af)->field_name.str,
dict_table_get_col_name(ctx->new_table,
i)));
DBUG_ASSERT(!col->is_instant_add());
DBUG_ASSERT(!col->is_added());
if (new_field->field) {
#if 0
......
......@@ -490,7 +490,8 @@ dict_table_get_nth_v_col(
ut_ad(table);
ut_ad(pos < table->n_v_def);
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
ut_ad(!table->v_cols[pos].m_col.is_instant_add());
ut_ad(!table->v_cols[pos].m_col.is_added());
ut_ad(!table->v_cols[pos].m_col.is_dropped());
return &table->v_cols[pos];
}
......
......@@ -588,8 +588,8 @@ struct dict_col_t{
3072 (REC_VERSION_56_MAX_INDEX_COL_LEN)
bytes. */
/** Whether the column is deleted. */
bool dropped;
/** Whether the column has been instantly dropped. */
unsigned dropped:1;
/** Detach the column from an index.
@param[in] index index to be detached from */
......@@ -644,18 +644,21 @@ struct dict_col_t{
}
/** @return whether this is an instantly-added column */
bool is_instant_add() const
bool is_added() const
{
DBUG_ASSERT(def_val.len != UNIV_SQL_DEFAULT || !def_val.data);
return def_val.len != UNIV_SQL_DEFAULT;
}
/** @return whether the column was instantly dropped */
bool is_dropped() const { return dropped; }
/** Get the default value of an instantly-added column.
@param[out] len value length (in bytes), or UNIV_SQL_NULL
@return default value
@retval NULL if the default value is SQL NULL (len=UNIV_SQL_NULL) */
const byte* instant_value(ulint* len) const
{
DBUG_ASSERT(is_instant_add());
DBUG_ASSERT(is_added());
*len = def_val.len;
return static_cast<const byte*>(def_val.data);
}
......@@ -663,22 +666,10 @@ struct dict_col_t{
/** Remove the 'instant ADD' status of the column */
void remove_instant()
{
DBUG_ASSERT(is_instant_add());
DBUG_ASSERT(is_added());
def_val.len = UNIV_SQL_DEFAULT;
def_val.data = NULL;
}
/** @return whether the column is dropped */
bool is_dropped() const
{
return dropped;
}
/** Set the dropped flag. */
void set_dropped()
{
dropped = true;
}
};
/** Index information put in a list of virtual column structure. Index
......@@ -1129,8 +1120,7 @@ struct dict_index_t {
for (ulint i = n_core_fields; i < n_prefix; i++) {
const dict_col_t* col = fields[i].col;
if (col->is_dropped()
|| col->is_instant_add()) {
if (col->is_dropped() || col->is_added()) {
n++;
continue;
}
......@@ -1204,7 +1194,7 @@ struct dict_index_t {
@param[in] clustered index definition after instant ADD COLUMN */
void instant_add_field(const dict_index_t& instant);
/** Remove instant fields from the clustered index.
/** Remove instant ALTER TABLE metadata.
Protected by index root page x-latch or table X-lock. */
void remove_instant();
......
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