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

Remove dict_col_def_t

Store dict_col_t::def_val inline, using an anonymous struct.

dict_mem_table_fake_nth_col_default(),
dict_col_set_added_column_default(): Remove.

dict_mem_fill_column_struct(): Initialize def_val.
parent bfb3d327
......@@ -260,40 +260,6 @@ dict_add_col_name(
return(res);
}
/****************************************************************//**
Fake column default values for recovery*/
UNIV_INTERN
void
dict_mem_table_fake_nth_col_default(
/*==============*/
dict_table_t* table, /*!< in/out: table, set the default values
for the nth columns */
ulint pos, /*!< in: the position of column in table */
mem_heap_t* heap /*!< in: mem_heap for default value */
)
{
ulint fixed_size = 0;
ulint def_val_len = 0;
dict_col_t* col = NULL;
ut_ad(table->is_instant());
col = dict_table_get_nth_col(table, pos);
fixed_size = dict_col_get_fixed_size(col, dict_table_is_comp(table));
/* For non-fixed size columns, we fake one byte default value */
def_val_len = fixed_size ? fixed_size : 1;
col->def_val = (dict_col_def_t*)mem_heap_alloc(heap, sizeof(*col->def_val));
col->def_val->col = col;
col->def_val->def_val_len = def_val_len;
col->def_val->def_val = (unsigned char*)mem_heap_zalloc(heap, def_val_len + 1);
/* For string, we use space */
if(dtype_is_string_type(col->mtype))
memset(col->def_val->def_val, ' ', def_val_len);
}
/**********************************************************************//**
Adds a column definition to a table. */
void
......@@ -656,6 +622,8 @@ dict_mem_fill_column_struct(
column->mtype = (unsigned int) mtype;
column->prtype = (unsigned int) prtype;
column->len = (unsigned int) col_len;
column->def_val.data = NULL;
column->def_val.len = UNIV_SQL_DEFAULT;
dtype_get_mblen(mtype, prtype, &mbminlen, &mbmaxlen);
dict_col_set_mbminmaxlen(column, mbminlen, mbmaxlen);
......
......@@ -194,18 +194,6 @@ dict_col_set_mbminmaxlen(
character size, in bytes */
MY_ATTRIBUTE((nonnull));
/*********************************************************************//**
Sets default value of added columns */
UNIV_INLINE
void
dict_col_set_added_column_default(
/*===============*/
dict_col_t* col, /*!< in/out: column */
const byte* def_val, /*!< in: pointer of default value */
ulint def_val_len, /*!< in: length of default value */
mem_heap_t* heap ); /*!< in: mem_heap_t for default value in col */
/*********************************************************************//**
Gets the column data type. */
UNIV_INLINE
......
......@@ -73,28 +73,6 @@ dict_col_set_mbminmaxlen(
col->mbminmaxlen = DATA_MBMINMAXLEN(mbminlen, mbmaxlen);
}
/*********************************************************************//**
Sets default value of added columns */
UNIV_INLINE
void
dict_col_set_added_column_default(
dict_col_t* col, /*!< in: column */
const byte* def_val, /*!< in: default value */
ulint def_val_len, /*!< in: the length of default value */
mem_heap_t* heap ) /*!< in: memory heap for dict object */
{
ut_a(col);
col->def_val = (dict_col_def_t*)mem_heap_alloc(heap, sizeof(*col->def_val));
col->def_val->col = col;
col->def_val->def_val_len = def_val_len;
if (def_val) {
col->def_val->def_val = (byte*)mem_heap_strdupl(heap, (char*)def_val, def_val_len);
} else {
col->def_val->def_val = NULL;
}
}
/*********************************************************************//**
Gets the column data type. */
UNIV_INLINE
......@@ -1314,9 +1292,9 @@ dict_index_get_nth_field_def(const dict_index_t* index, uint pos, ulint* len)
ut_ad(dict_index_is_clust(index));
const dict_col_t* col = dict_index_get_nth_col(index, pos);
ut_ad(col->def_val);
*len = col->def_val->def_val_len;
return(col->def_val->def_val);
ut_ad(col->def_val.len != UNIV_SQL_DEFAULT);
*len = col->def_val.len;
return(col->def_val.data);
}
/********************************************************************//**
......
......@@ -336,16 +336,6 @@ void
dict_mem_table_free(
/*================*/
dict_table_t* table); /*!< in: table */
/**********************************************************************//**
Fake column default values for recovery */
void
dict_mem_table_fake_nth_col_default(
/*================*/
dict_table_t* table, /*!< in/out: table, set the default values
for the nth columns */
ulint pos, /*!< in: the position of column in table */
mem_heap_t* heap /*!< in: mem_heap for default value */
);
/****************************************************************//**
Adds a column definition to a table. */
void
......@@ -585,13 +575,6 @@ struct table_name_t
char* m_name;
};
/** Data structure for a column added default value */
struct dict_col_def_t {
dict_col_t* col;
byte* def_val;
unsigned def_val_len;
};
/** Data structure for a column in a table */
struct dict_col_t{
/*----------------------*/
......@@ -637,7 +620,13 @@ struct dict_col_t{
3072 (REC_VERSION_56_MAX_INDEX_COL_LEN)
bytes. */
dict_col_def_t* def_val;/*!< default value of added columns */
/** Data for instantly added columns */
struct {
/** original default value of instantly added column */
const byte* data;
/** len of data, or UNIV_SQL_DEFAULT if unavailable */
unsigned len;
} def_val;
/** Retrieve the column name.
@param[in] table table name */
......
......@@ -505,7 +505,7 @@ computers! */
#define UNIV_SQL_NULL ULINT32_UNDEFINED
/** Flag for default value of instant added column */
/** Special length indicating a missing instantly added column */
#define UNIV_SQL_DEFAULT (UNIV_SQL_NULL - 1)
/** Check the record whether store in the row */
......
......@@ -609,13 +609,6 @@ mlog_parse_index(
len & 0x8000 ? DATA_NOT_NULL : 0,
len & 0x7fff);
if (n_core_fields > 0 && n_core_fields <= i) {
/* For recovery, it does not need the true default values.
We fake it!*/
dict_mem_table_fake_nth_col_default(table, i, table->heap);
}
dict_index_add_col(ind, table,
dict_table_get_nth_col(table, i),
0);
......
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