Commit 1c1026ec authored by marko's avatar marko

Reduce the size of the data dictionary cache. (Bug #20877)

dtype_t: Remove unused field "prec", which was supposed to be used for
the precision of decimal columns in stand-alone InnoDB.

dtype_get_prec(): Remove.

dtype_set(), dict_mem_table_add_col(): Remove parameter "prec".

dtype_t: Turn all fields (mtype, prtype, len, mbminlen, mbmaxlen, len)
into bit-fields.

dict_table_t, dict_index_t, dict_tree_t: Omit magic_n from non-debug builds.

dict_col_t: Turn ind, clust_pos, and ord_part into bit-fields.

Replace the default clust_pos value ULINT_UNDEFINED with
REC_MAX_N_FIELDS and replace all references to clust_pos with calls to
the accessor function dict_col_get_clust_pos().

dict_field_t: Turn prefix_len and fixed_len into bit-fields.

dict_tree_t: Remove pad[64].

dict_table_t: Turn the fields ibd_file_missing, tablespace_discarded,
cached, flags, stat_initialized, and autoinc_inited into bit-fields.
Remove does_not_fit_in_memory from non-debug builds.

dict_index_t: Turn the fields trx_id_offset, n_user_defined_cols,
n_uniq, n_def, n_fields, n_nullable, and cached into bit-fields.

dict_foreign_struct: Turn n_fields and type into bit-fields.

rw_lock_t: Turn cline, last_s_line, and last_x_line into bit-fields.
Omit level unless #defined UNIV_SYNC_DEBUG.

Move REC_MAX_N_FIELDS (and REC_MAX_HEAP_NO and REC_MAX_N_OWNED)
from rem0rec.c to rem0types.h, as they are needed in dict0dict.ic.
dict_col_get_clust_pos(): Map REC_MAX_N_FIELDS to ULINT_UNDEFINED.
parent 85f5b73e
......@@ -322,7 +322,8 @@ btr_search_update_block_hash_info(
the block is recommended */
btr_search_t* info, /* in: search info */
buf_block_t* block, /* in: buffer block */
btr_cur_t* cursor) /* in: cursor */
btr_cur_t* cursor __attribute__((unused)))
/* in: cursor */
{
#ifdef UNIV_SYNC_DEBUG
ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED));
......@@ -362,9 +363,11 @@ btr_search_update_block_hash_info(
block->side = info->side;
}
#ifdef UNIV_DEBUG
if (cursor->index->table->does_not_fit_in_memory) {
block->n_hash_helps = 0;
}
#endif /* UNIV_DEBUG */
if ((block->n_hash_helps > page_get_n_recs(block->frame)
/ BTR_SEARCH_PAGE_BUILD_LIMIT)
......
......@@ -40,7 +40,7 @@ charset-collation code for them. */
ulint data_mysql_default_charset_coll = 99999999;
dtype_t dtype_binary_val = {DATA_BINARY, 0, 0, 0, 0, 0};
dtype_t dtype_binary_val = {DATA_BINARY, 0, 0, 0, 0};
dtype_t* dtype_binary = &dtype_binary_val;
/*************************************************************************
......@@ -291,7 +291,7 @@ dtype_print(
}
}
fprintf(stderr, " len %lu prec %lu", (ulong) len, (ulong) type->prec);
fprintf(stderr, " len %lu", (ulong) len);
}
/***************************************************************************
......
......@@ -247,14 +247,14 @@ dict_boot(void)
/*-------------------------*/
table = dict_mem_table_create("SYS_TABLES", DICT_HDR_SPACE, 8, 0);
dict_mem_table_add_col(table, "NAME", DATA_BINARY, 0, 0, 0);
dict_mem_table_add_col(table, "ID", DATA_BINARY, 0, 0, 0);
dict_mem_table_add_col(table, "N_COLS", DATA_INT, 0, 4, 0);
dict_mem_table_add_col(table, "TYPE", DATA_INT, 0, 4, 0);
dict_mem_table_add_col(table, "MIX_ID", DATA_BINARY, 0, 0, 0);
dict_mem_table_add_col(table, "MIX_LEN", DATA_INT, 0, 4, 0);
dict_mem_table_add_col(table, "CLUSTER_NAME", DATA_BINARY, 0, 0, 0);
dict_mem_table_add_col(table, "SPACE", DATA_INT, 0, 4, 0);
dict_mem_table_add_col(table, "NAME", DATA_BINARY, 0, 0);
dict_mem_table_add_col(table, "ID", DATA_BINARY, 0, 0);
dict_mem_table_add_col(table, "N_COLS", DATA_INT, 0, 4);
dict_mem_table_add_col(table, "TYPE", DATA_INT, 0, 4);
dict_mem_table_add_col(table, "MIX_ID", DATA_BINARY, 0, 0);
dict_mem_table_add_col(table, "MIX_LEN", DATA_INT, 0, 4);
dict_mem_table_add_col(table, "CLUSTER_NAME", DATA_BINARY, 0, 0);
dict_mem_table_add_col(table, "SPACE", DATA_INT, 0, 4);
table->id = DICT_TABLES_ID;
......@@ -287,13 +287,13 @@ dict_boot(void)
/*-------------------------*/
table = dict_mem_table_create("SYS_COLUMNS", DICT_HDR_SPACE, 7, 0);
dict_mem_table_add_col(table, "TABLE_ID", DATA_BINARY,0,0,0);
dict_mem_table_add_col(table, "POS", DATA_INT, 0, 4, 0);
dict_mem_table_add_col(table, "NAME", DATA_BINARY, 0, 0, 0);
dict_mem_table_add_col(table, "MTYPE", DATA_INT, 0, 4, 0);
dict_mem_table_add_col(table, "PRTYPE", DATA_INT, 0, 4, 0);
dict_mem_table_add_col(table, "LEN", DATA_INT, 0, 4, 0);
dict_mem_table_add_col(table, "PREC", DATA_INT, 0, 4, 0);
dict_mem_table_add_col(table, "TABLE_ID", DATA_BINARY, 0, 0);
dict_mem_table_add_col(table, "POS", DATA_INT, 0, 4);
dict_mem_table_add_col(table, "NAME", DATA_BINARY, 0, 0);
dict_mem_table_add_col(table, "MTYPE", DATA_INT, 0, 4);
dict_mem_table_add_col(table, "PRTYPE", DATA_INT, 0, 4);
dict_mem_table_add_col(table, "LEN", DATA_INT, 0, 4);
dict_mem_table_add_col(table, "PREC", DATA_INT, 0, 4);
table->id = DICT_COLUMNS_ID;
......@@ -315,13 +315,13 @@ dict_boot(void)
/*-------------------------*/
table = dict_mem_table_create("SYS_INDEXES", DICT_HDR_SPACE, 7, 0);
dict_mem_table_add_col(table, "TABLE_ID", DATA_BINARY, 0,0,0);
dict_mem_table_add_col(table, "ID", DATA_BINARY, 0, 0, 0);
dict_mem_table_add_col(table, "NAME", DATA_BINARY, 0, 0, 0);
dict_mem_table_add_col(table, "N_FIELDS", DATA_INT, 0, 4, 0);
dict_mem_table_add_col(table, "TYPE", DATA_INT, 0, 4, 0);
dict_mem_table_add_col(table, "SPACE", DATA_INT, 0, 4, 0);
dict_mem_table_add_col(table, "PAGE_NO", DATA_INT, 0, 4, 0);
dict_mem_table_add_col(table, "TABLE_ID", DATA_BINARY, 0, 0);
dict_mem_table_add_col(table, "ID", DATA_BINARY, 0, 0);
dict_mem_table_add_col(table, "NAME", DATA_BINARY, 0, 0);
dict_mem_table_add_col(table, "N_FIELDS", DATA_INT, 0, 4);
dict_mem_table_add_col(table, "TYPE", DATA_INT, 0, 4);
dict_mem_table_add_col(table, "SPACE", DATA_INT, 0, 4);
dict_mem_table_add_col(table, "PAGE_NO", DATA_INT, 0, 4);
/* The '+ 2' below comes from the 2 system fields */
#if DICT_SYS_INDEXES_PAGE_NO_FIELD != 6 + 2
......@@ -353,9 +353,9 @@ dict_boot(void)
/*-------------------------*/
table = dict_mem_table_create("SYS_FIELDS", DICT_HDR_SPACE, 3, 0);
dict_mem_table_add_col(table, "INDEX_ID", DATA_BINARY, 0,0,0);
dict_mem_table_add_col(table, "POS", DATA_INT, 0, 4, 0);
dict_mem_table_add_col(table, "COL_NAME", DATA_BINARY, 0,0,0);
dict_mem_table_add_col(table, "INDEX_ID", DATA_BINARY, 0, 0);
dict_mem_table_add_col(table, "POS", DATA_INT, 0, 4);
dict_mem_table_add_col(table, "COL_NAME", DATA_BINARY, 0, 0);
table->id = DICT_FIELDS_ID;
dict_table_add_to_cache(table);
......
......@@ -181,7 +181,7 @@ dict_create_sys_columns_tuple(
dfield = dtuple_get_nth_field(entry, 6);
ptr = mem_heap_alloc(heap, 4);
mach_write_to_4(ptr, (column->type).prec);
mach_write_to_4(ptr, 0/* unused */);
dfield_set_data(dfield, ptr, 4);
/*---------------------------------*/
......
......@@ -556,7 +556,7 @@ dict_index_get_nth_col_pos(
if (index->type & DICT_CLUSTERED) {
return(col->clust_pos);
return(dict_col_get_clust_pos(col));
}
n_fields = dict_index_get_n_fields(index);
......@@ -884,25 +884,25 @@ dict_table_add_to_cache(
dict_mem_table_add_col(table, "DB_ROW_ID", DATA_SYS,
DATA_ROW_ID | DATA_NOT_NULL,
DATA_ROW_ID_LEN, 0);
DATA_ROW_ID_LEN);
#if DATA_ROW_ID != 0
#error "DATA_ROW_ID != 0"
#endif
dict_mem_table_add_col(table, "DB_TRX_ID", DATA_SYS,
DATA_TRX_ID | DATA_NOT_NULL,
DATA_TRX_ID_LEN, 0);
DATA_TRX_ID_LEN);
#if DATA_TRX_ID != 1
#error "DATA_TRX_ID != 1"
#endif
dict_mem_table_add_col(table, "DB_ROLL_PTR", DATA_SYS,
DATA_ROLL_PTR | DATA_NOT_NULL,
DATA_ROLL_PTR_LEN, 0);
DATA_ROLL_PTR_LEN);
#if DATA_ROLL_PTR != 2
#error "DATA_ROLL_PTR != 2"
#endif
dict_mem_table_add_col(table, "DB_MIX_ID", DATA_SYS,
DATA_MIX_ID | DATA_NOT_NULL,
DATA_MIX_ID_LEN, 0);
DATA_MIX_ID_LEN);
#if DATA_MIX_ID != 3
#error "DATA_MIX_ID != 3"
#endif
......@@ -1815,7 +1815,7 @@ dict_index_build_internal_clust(
if (UNIV_UNLIKELY(index->type & DICT_UNIVERSAL)) {
/* No fixed number of fields determines an entry uniquely */
new_index->n_uniq = ULINT_MAX;
new_index->n_uniq = REC_MAX_N_FIELDS;
} else if (index->type & DICT_UNIQUE) {
/* Only the fields defined so far are needed to identify
......@@ -1902,7 +1902,7 @@ dict_index_build_internal_clust(
/* Add to new_index non-system columns of table not yet included
there */
for (i = 0; i < table->n_cols - DATA_N_SYS_COLS; i++) {
for (i = 0; i + DATA_N_SYS_COLS < (ulint) table->n_cols; i++) {
col = dict_table_get_nth_col(table, i);
ut_ad(col->type.mtype != DATA_SYS);
......@@ -3741,7 +3741,9 @@ dict_tree_create(
tree->tree_index = NULL;
#ifdef UNIV_DEBUG
tree->magic_n = DICT_TREE_MAGIC_N;
#endif /* UNIV_DEBUG */
rw_lock_create(&tree->lock, SYNC_INDEX_TREE);
......@@ -3843,7 +3845,7 @@ dict_tree_build_node_ptr(
field = dtuple_get_nth_field(tuple, n_unique);
dfield_set_data(field, buf, 4);
dtype_set(dfield_get_type(field), DATA_SYS_CHILD, DATA_NOT_NULL, 4, 0);
dtype_set(dfield_get_type(field), DATA_SYS_CHILD, DATA_NOT_NULL, 4);
rec_copy_prefix_to_dtuple(tuple, rec, ind, n_unique, heap);
dtuple_set_info_bits(tuple, dtuple_get_info_bits(tuple)
......@@ -4167,7 +4169,7 @@ dict_table_print_low(
(ulong) UT_LIST_GET_LEN(table->indexes),
(ulong) table->stat_n_rows);
for (i = 0; i < table->n_cols - 1; i++) {
for (i = 0; i + 1 < (ulint) table->n_cols; i++) {
dict_col_print_low(dict_table_get_nth_col(table, i));
fputs("; ", stderr);
}
......
......@@ -331,7 +331,6 @@ dict_load_columns(
ulint mtype;
ulint prtype;
ulint col_len;
ulint prec;
ulint i;
mtr_t mtr;
......@@ -356,7 +355,7 @@ dict_load_columns(
btr_pcur_open_on_user_rec(sys_index, tuple, PAGE_CUR_GE,
BTR_SEARCH_LEAF, &pcur, &mtr);
for (i = 0; i < table->n_cols - DATA_N_SYS_COLS; i++) {
for (i = 0; i + DATA_N_SYS_COLS < (ulint) table->n_cols; i++) {
rec = btr_pcur_get_rec(&pcur);
......@@ -411,11 +410,7 @@ dict_load_columns(
ut_a(!strcmp("PREC", dict_field_get_col
(dict_index_get_nth_field(sys_index, 8))->name));
field = rec_get_nth_field_old(rec, 8, &len);
prec = mach_read_from_4(field);
dict_mem_table_add_col(table, name, mtype, prtype, col_len,
prec);
dict_mem_table_add_col(table, name, mtype, prtype, col_len);
btr_pcur_move_to_next_user_rec(&pcur, &mtr);
}
......
......@@ -76,7 +76,9 @@ dict_mem_table_create(
UT_LIST_INIT(table->foreign_list);
UT_LIST_INIT(table->referenced_list);
#ifdef UNIV_DEBUG
table->does_not_fit_in_memory = FALSE;
#endif /* UNIV_DEBUG */
table->stat_initialized = FALSE;
......@@ -87,9 +89,9 @@ dict_mem_table_create(
mutex_create(&table->autoinc_mutex, SYNC_DICT_AUTOINC_MUTEX);
table->autoinc_inited = FALSE;
#ifdef UNIV_DEBUG
table->magic_n = DICT_TABLE_MAGIC_N;
#endif /* UNIV_DEBUG */
return(table);
}
......@@ -118,8 +120,7 @@ dict_mem_table_add_col(
const char* name, /* in: column name */
ulint mtype, /* in: main datatype */
ulint prtype, /* in: precise type */
ulint len, /* in: length */
ulint prec) /* in: precision */
ulint len) /* in: precision */
{
dict_col_t* col;
dtype_t* type;
......@@ -136,11 +137,11 @@ dict_mem_table_add_col(
col->table = table;
col->ord_part = 0;
col->clust_pos = ULINT_UNDEFINED;
col->clust_pos = REC_MAX_N_FIELDS;
type = dict_col_get_type(col);
dtype_set(type, mtype, prtype, len, prec);
dtype_set(type, mtype, prtype, len);
}
/**************************************************************************
......@@ -183,8 +184,9 @@ dict_mem_index_create(
index->stat_n_diff_key_vals = NULL;
index->cached = FALSE;
#ifdef UNIV_DEBUG
index->magic_n = DICT_INDEX_MAGIC_N;
#endif /* UNIV_DEBUG */
return(index);
}
......
......@@ -3164,8 +3164,8 @@ ha_innobase::build_template(
templ->col_no = i;
if (index == clust_index) {
templ->rec_field_no = (index->table->cols + i)
->clust_pos;
templ->rec_field_no = dict_col_get_clust_pos
(&index->table->cols[i]);
} else {
templ->rec_field_no = dict_index_get_nth_col_pos(
index, i);
......@@ -3224,8 +3224,8 @@ ha_innobase::build_template(
for (i = 0; i < n_requested_fields; i++) {
templ = prebuilt->mysql_template + i;
templ->rec_field_no =
(index->table->cols + templ->col_no)->clust_pos;
templ->rec_field_no = dict_col_get_clust_pos
(&index->table->cols[templ->col_no]);
}
}
}
......@@ -3598,7 +3598,8 @@ calc_row_difference(
}
ufield->exp = NULL;
ufield->field_no = prebuilt->table->cols[i].clust_pos;
ufield->field_no = dict_col_get_clust_pos
(&prebuilt->table->cols[i]);
n_changed++;
}
}
......@@ -4578,8 +4579,7 @@ create_table_def(
| nulls_allowed | unsigned_type
| binary_type | long_true_varchar,
charset_no),
col_len,
0);
col_len);
}
error = row_create_table_for_mysql(table, trx);
......
......@@ -524,8 +524,8 @@ ibuf_data_init_for_space(
/* use old-style record format for the insert buffer */
table = dict_mem_table_create(buf, space, 2, 0);
dict_mem_table_add_col(table, "PAGE_NO", DATA_BINARY, 0, 0, 0);
dict_mem_table_add_col(table, "TYPES", DATA_BINARY, 0, 0, 0);
dict_mem_table_add_col(table, "PAGE_NO", DATA_BINARY, 0, 0);
dict_mem_table_add_col(table, "TYPES", DATA_BINARY, 0, 0);
table->id = ut_dulint_add(DICT_IBUF_ID_MIN, space);
......@@ -1145,8 +1145,7 @@ ibuf_dummy_index_add_col(
dict_mem_table_add_col(index->table, "DUMMY",
dtype_get_mtype(type),
dtype_get_prtype(type),
dtype_get_len(type),
dtype_get_prec(type));
dtype_get_len(type));
dict_index_add_col(index,
dict_table_get_nth_col(index->table, i), len);
}
......
......@@ -334,7 +334,7 @@ dtuple_set_types_binary(
for (i = 0; i < n; i++) {
dfield_type = dfield_get_type(dtuple_get_nth_field(tuple, i));
dtype_set(dfield_type, DATA_BINARY, 0, 0, 0);
dtype_set(dfield_type, DATA_BINARY, 0, 0);
}
}
......
......@@ -224,8 +224,7 @@ dtype_set(
dtype_t* type, /* in: type struct to init */
ulint mtype, /* in: main data type */
ulint prtype, /* in: precise type */
ulint len, /* in: length of type */
ulint prec); /* in: precision of type */
ulint len); /* in: precision of type */
/*************************************************************************
Copies a data type structure. */
UNIV_INLINE
......@@ -280,13 +279,6 @@ dtype_get_len(
/*==========*/
dtype_t* type);
/*************************************************************************
Gets the type precision. */
UNIV_INLINE
ulint
dtype_get_prec(
/*===========*/
dtype_t* type);
/*************************************************************************
Gets the minimum length of a character, in bytes. */
UNIV_INLINE
ulint
......@@ -415,8 +407,8 @@ dtype_new_read_for_order_and_null_size()
sym_tab_add_null_lit() */
struct dtype_struct{
ulint mtype; /* main data type */
ulint prtype; /* precise type; MySQL data type, charset code,
ulint mtype:8; /* main data type */
ulint prtype:24; /* precise type; MySQL data type, charset code,
flags to indicate nullability, signedness,
whether this is a binary string, whether this
is a true VARCHAR where MySQL uses 2 bytes to
......@@ -424,16 +416,15 @@ struct dtype_struct{
/* the remaining fields do not affect alphabetical ordering: */
ulint len; /* length; for MySQL data this is
ulint mbminlen:3; /* minimum length of a character, in bytes */
ulint mbmaxlen:3; /* maximum length of a character, in bytes */
ulint len:16; /* length; for MySQL data this is
field->pack_length(), except that for a
>= 5.0.3 type true VARCHAR this is the
maximum byte length of the string data
(in addition to the string, MySQL uses 1 or
2 bytes to store the string length) */
ulint prec; /* precision */
ulint mbminlen; /* minimum length of a character, in bytes */
ulint mbmaxlen; /* maximum length of a character, in bytes */
};
#ifndef UNIV_NONINL
......
......@@ -58,9 +58,13 @@ dtype_set_mblen(
ut_ad(type);
if (dtype_is_string_type(type->mtype)) {
#ifndef UNIV_HOTBACKUP
ulint mbminlen, mbmaxlen;
innobase_get_cset_width(dtype_get_charset_coll(type->prtype),
&type->mbminlen, &type->mbmaxlen);
ut_ad(type->mbminlen <= type->mbmaxlen);
&mbminlen, &mbmaxlen);
ut_ad(mbminlen <= mbmaxlen);
type->mbminlen = mbminlen;
type->mbmaxlen = mbmaxlen;
#else /* !UNIV_HOTBACKUP */
#ifdef notdefined
printf("ibbackup: DEBUG: type->mtype=%lu, type->prtype=%lu\n",
......@@ -86,8 +90,7 @@ dtype_set(
dtype_t* type, /* in: type struct to init */
ulint mtype, /* in: main data type */
ulint prtype, /* in: precise type */
ulint len, /* in: length of type */
ulint prec) /* in: precision of type */
ulint len) /* in: precision of type */
{
ut_ad(type);
ut_ad(mtype <= DATA_MTYPE_MAX);
......@@ -95,7 +98,6 @@ dtype_set(
type->mtype = mtype;
type->prtype = prtype;
type->len = len;
type->prec = prec;
dtype_set_mblen(type);
ut_ad(dtype_validate(type));
......@@ -154,19 +156,6 @@ dtype_get_len(
return(type->len);
}
/*************************************************************************
Gets the type precision. */
UNIV_INLINE
ulint
dtype_get_prec(
/*===========*/
dtype_t* type)
{
ut_ad(type);
return(type->prec);
}
/*************************************************************************
Gets the minimum length of a character, in bytes. */
UNIV_INLINE
......
......@@ -9,6 +9,7 @@ Created 1/8/1996 Heikki Tuuri
#include "dict0load.h"
#include "trx0undo.h"
#include "trx0sys.h"
#include "rem0types.h"
/*************************************************************************
Gets the column data type. */
......@@ -46,7 +47,9 @@ dict_col_get_clust_pos(
{
ut_ad(col);
return(col->clust_pos);
return(col->clust_pos == REC_MAX_N_FIELDS
? ULINT_UNDEFINED
: col->clust_pos);
}
/************************************************************************
......@@ -321,7 +324,7 @@ dict_index_get_sys_col_pos(
if (index->type & DICT_CLUSTERED) {
return(col->clust_pos);
return(dict_col_get_clust_pos(col));
}
return(dict_index_get_nth_col_pos
......
......@@ -75,8 +75,7 @@ dict_mem_table_add_col(
const char* name, /* in: column name */
ulint mtype, /* in: main datatype */
ulint prtype, /* in: precise type */
ulint len, /* in: length */
ulint prec); /* in: precision */
ulint len); /* in: precision */
/**************************************************************************
Creates an index memory object. */
......@@ -123,11 +122,11 @@ dict_mem_foreign_create(void);
/* Data structure for a column in a table */
struct dict_col_struct{
hash_node_t hash; /* hash chain node */
ulint ind; /* table column position (they are numbered
ulint ind:10; /* table column position (they are numbered
starting from 0) */
ulint clust_pos;/* position of the column in the
ulint clust_pos:10;/* position of the column in the
clustered index */
ulint ord_part;/* count of how many times this column
ulint ord_part:12;/* count of how many times this column
appears in ordering fields of an index */
const char* name; /* name */
dtype_t type; /* data type */
......@@ -145,14 +144,14 @@ UTF-8 charset. In that charset, a character may take at most 3 bytes. */
struct dict_field_struct{
dict_col_t* col; /* pointer to the table column */
const char* name; /* name of the column */
ulint prefix_len; /* 0 or the length of the column
ulint prefix_len:10; /* 0 or the length of the column
prefix in bytes in a MySQL index of
type, e.g., INDEX (textcol(25));
must be smaller than
DICT_MAX_INDEX_COL_LEN; NOTE that
in the UTF-8 charset, MySQL sets this
to 3 * the prefix len in UTF-8 chars */
ulint fixed_len; /* 0 or the fixed length of the
ulint fixed_len:10; /* 0 or the fixed length of the
column if smaller than
DICT_MAX_INDEX_COL_LEN */
};
......@@ -163,17 +162,16 @@ struct dict_tree_struct{
dulint id; /* id of the index stored in the tree */
ulint space; /* space of index tree */
ulint page; /* index tree root page number */
byte pad[64];/* Padding to prevent other memory hotspots on
the same memory cache line */
rw_lock_t lock; /* read-write lock protecting the upper levels
of the index tree */
dict_index_t* tree_index; /* the index stored in the
index tree */
#ifdef UNIV_DEBUG
ulint magic_n;/* magic number */
# define DICT_TREE_MAGIC_N 7545676
#endif /* UNIV_DEBUG */
};
#define DICT_TREE_MAGIC_N 7545676
/* Data structure for an index */
struct dict_index_struct{
dulint id; /* id of the index */
......@@ -183,29 +181,29 @@ struct dict_index_struct{
const char* table_name; /* table name */
dict_table_t* table; /* back pointer to table */
ulint space; /* space where the index tree is placed */
ulint trx_id_offset;/* position of the the trx id column
ulint trx_id_offset:10;/* position of the the trx id column
in a clustered index record, if the fields
before it are known to be of a fixed size,
0 otherwise */
ulint n_user_defined_cols;
ulint n_user_defined_cols:10;
/* number of columns the user defined to
be in the index: in the internal
representation we add more columns */
ulint n_uniq; /* number of fields from the beginning
ulint n_uniq:10;/* number of fields from the beginning
which are enough to determine an index
entry uniquely */
ulint n_def; /* number of fields defined so far */
ulint n_fields;/* number of fields in the index */
ulint n_def:10;/* number of fields defined so far */
ulint n_fields:10;/* number of fields in the index */
ulint n_nullable:10;/* number of nullable fields */
ibool cached:1;/* TRUE if the index object is in the
dictionary cache */
dict_field_t* fields; /* array of field descriptions */
ulint n_nullable;/* number of nullable fields */
UT_LIST_NODE_T(dict_index_t)
indexes;/* list of indexes of the table */
dict_tree_t* tree; /* index tree struct */
UT_LIST_NODE_T(dict_index_t)
tree_indexes; /* list of indexes of the same index
tree */
ibool cached; /* TRUE if the index object is in the
dictionary cache */
btr_search_t* search_info; /* info used in optimistic searches */
/*----------------------*/
ib_longlong* stat_n_diff_key_vals;
......@@ -218,7 +216,10 @@ struct dict_index_struct{
ulint stat_n_leaf_pages;
/* approximate number of leaf pages in the
index tree */
#ifdef UNIV_DEBUG
ulint magic_n;/* magic number */
# define DICT_INDEX_MAGIC_N 76789786
#endif
};
/* Data structure for a foreign key constraint; an example:
......@@ -229,7 +230,13 @@ struct dict_foreign_struct{
this memory heap */
char* id; /* id of the constraint as a
null-terminated string */
ulint type; /* 0 or DICT_FOREIGN_ON_DELETE_CASCADE
ulint n_fields:10; /* number of indexes' first fields
for which the the foreign key
constraint is defined: we allow the
indexes to contain more fields than
mentioned in the constraint, as long
as the first fields are as mentioned */
ulint type:6; /* 0 or DICT_FOREIGN_ON_DELETE_CASCADE
or DICT_FOREIGN_ON_DELETE_SET_NULL */
char* foreign_table_name;/* foreign table name */
dict_table_t* foreign_table; /* table where the foreign key is */
......@@ -240,12 +247,6 @@ struct dict_foreign_struct{
is */
const char** referenced_col_names;/* names of the referenced
columns in the referenced table */
ulint n_fields; /* number of indexes' first fields
for which the the foreign key
constraint is defined: we allow the
indexes to contain more fields than
mentioned in the constraint, as long
as the first fields are as mentioned */
dict_index_t* foreign_index; /* foreign index; we require that
both tables contain explicitly defined
indexes for the constraint: InnoDB
......@@ -270,12 +271,9 @@ a foreign key constraint is enforced, therefore RESTRICT just means no flag */
#define DICT_FOREIGN_ON_UPDATE_NO_ACTION 32
#define DICT_INDEX_MAGIC_N 76789786
/* Data structure for a database table */
struct dict_table_struct{
dulint id; /* id of the table */
ulint flags; /* DICT_TF_COMPACT, ... */
mem_heap_t* heap; /* memory heap */
const char* name; /* table name */
const char* dir_path_of_temp_table;/* NULL or the directory path
......@@ -286,17 +284,20 @@ struct dict_table_struct{
\temp\... */
ulint space; /* space where the clustered index of the
table is placed */
ibool ibd_file_missing;/* TRUE if this is in a single-table
ibool ibd_file_missing:1;/* TRUE if this is in a single-table
tablespace and the .ibd file is missing; then
we must return in ha_innodb.cc an error if the
user tries to query such an orphaned table */
ibool tablespace_discarded;/* this flag is set TRUE when the
ibool tablespace_discarded:1;/* this flag is set TRUE when the
user calls DISCARD TABLESPACE on this table,
and reset to FALSE in IMPORT TABLESPACE */
ibool cached:1;/* TRUE if the table object has been added
to the dictionary cache */
ulint flags:8;/* DICT_TF_COMPACT, ... */
hash_node_t name_hash; /* hash chain node */
hash_node_t id_hash; /* hash chain node */
ulint n_def; /* number of columns defined so far */
ulint n_cols; /* number of columns */
ulint n_def:10;/* number of columns defined so far */
ulint n_cols:10;/* number of columns */
dict_col_t* cols; /* array of column descriptions */
UT_LIST_BASE_NODE_T(dict_index_t)
indexes; /* list of indexes of the table */
......@@ -321,8 +322,6 @@ struct dict_table_struct{
on the table: we cannot drop the table while
there are foreign key checks running on
it! */
ibool cached; /* TRUE if the table object has been added
to the dictionary cache */
lock_t* auto_inc_lock;/* a buffer for an auto-inc lock
for this table: we allocate the memory here
so that individual transactions can get it
......@@ -345,6 +344,7 @@ struct dict_table_struct{
accurate. it's ULINT_MAX if there are
unbounded variable-width fields. initialized
in dict_table_add_to_cache. */
#ifdef UNIV_DEBUG
/*----------------------*/
ibool does_not_fit_in_memory;
/* this field is used to specify in simulations
......@@ -355,6 +355,7 @@ struct dict_table_struct{
dictionary on disk, and the database will
forget about value TRUE if it has to reload
the table definition from disk */
#endif /* UNIV_DEBUG */
/*----------------------*/
ib_longlong stat_n_rows;
/* approximate number of rows in the table;
......@@ -364,7 +365,7 @@ struct dict_table_struct{
database pages */
ulint stat_sum_of_other_index_sizes;
/* other indexes in database pages */
ibool stat_initialized; /* TRUE if statistics have
ibool stat_initialized:1; /* TRUE if statistics have
been calculated the first time
after database startup or table creation */
ulint stat_modified_counter;
......@@ -383,15 +384,17 @@ struct dict_table_struct{
mutex_t autoinc_mutex;
/* mutex protecting the autoincrement
counter */
ibool autoinc_inited;
ibool autoinc_inited:1;
/* TRUE if the autoinc counter has been
inited; MySQL gets the init value by executing
SELECT MAX(auto inc column) */
ib_longlong autoinc;/* autoinc counter value to give to the
next inserted row */
#ifdef UNIV_DEBUG
ulint magic_n;/* magic number */
# define DICT_TABLE_MAGIC_N 76333786
#endif /* UNIV_DEBUG */
};
#define DICT_TABLE_MAGIC_N 76333786
#ifndef UNIV_NONINL
#include "dict0mem.ic"
......
......@@ -14,11 +14,6 @@ Created 5/30/1994 Heikki Tuuri
#include "rem0types.h"
#include "mtr0types.h"
/* Maximum values for various fields (for non-blob tuples) */
#define REC_MAX_N_FIELDS (1024 - 1)
#define REC_MAX_HEAP_NO (2 * 8192 - 1)
#define REC_MAX_N_OWNED (16 - 1)
/* 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
......
......@@ -12,5 +12,9 @@ Created 5/30/1994 Heikki Tuuri
/* We define the physical record simply as an array of bytes */
typedef byte rec_t;
/* Maximum values for various fields (for non-blob tuples) */
#define REC_MAX_N_FIELDS (1024 - 1)
#define REC_MAX_HEAP_NO (2 * 8192 - 1)
#define REC_MAX_N_OWNED (16 - 1)
#endif
......@@ -440,15 +440,14 @@ struct rw_lock_struct {
UT_LIST_BASE_NODE_T(rw_lock_debug_t) debug_list;
/* In the debug version: pointer to the debug
info list of the lock */
#endif /* UNIV_SYNC_DEBUG */
ulint level; /* Level in the global latching order. */
#endif /* UNIV_SYNC_DEBUG */
const char* cfile_name;/* File name where lock created */
ulint cline; /* Line where created */
ulint cline:14; /* Line where created */
const char* last_s_file_name;/* File name where last s-locked */
const char* last_x_file_name;/* File name where last x-locked */
ulint last_s_line; /* Line number where last time s-locked */
ulint last_x_line; /* Line number where last time x-locked */
ulint last_s_line:14; /* Line number where last time s-locked */
ulint last_x_line:14; /* Line number where last time x-locked */
ulint magic_n;
};
......
......@@ -546,7 +546,7 @@ mlog_parse_index(
((len + 1) & 0x7fff) <= 1
? DATA_BINARY : DATA_FIXBINARY,
len & 0x8000 ? DATA_NOT_NULL : 0,
len & 0x7fff, 0);
len & 0x7fff);
dict_index_add_col
(ind, dict_table_get_nth_col(table, i), 0);
}
......
......@@ -381,7 +381,7 @@ page_create(
dfield_set_data(field, "infimum", 8);
dtype_set(dfield_get_type(field),
DATA_VARCHAR, DATA_ENGLISH | DATA_NOT_NULL, 8, 0);
DATA_VARCHAR, DATA_ENGLISH | DATA_NOT_NULL, 8);
/* Set the corresponding physical record to its place in the page
record heap */
......@@ -407,7 +407,7 @@ page_create(
dfield_set_data(field, "supremum", comp ? 8 : 9);
dtype_set(dfield_get_type(field),
DATA_VARCHAR, DATA_ENGLISH | DATA_NOT_NULL, comp ? 8 : 9, 0);
DATA_VARCHAR, DATA_ENGLISH | DATA_NOT_NULL, comp ? 8 : 9);
supremum_rec = rec_convert_dtuple_to_rec(heap_top, index, tuple);
......
......@@ -254,43 +254,43 @@ pars_resolve_func_data_type(
== DATA_INT);
} else if (func == PARS_COUNT_TOKEN) {
ut_a(arg);
dtype_set(que_node_get_data_type(node), DATA_INT, 0, 4, 0);
dtype_set(que_node_get_data_type(node), DATA_INT, 0, 4);
} else if (func == PARS_TO_CHAR_TOKEN) {
ut_a(dtype_get_mtype(que_node_get_data_type(arg)) == DATA_INT);
dtype_set(que_node_get_data_type(node), DATA_VARCHAR,
DATA_ENGLISH, 0, 0);
DATA_ENGLISH, 0);
} else if (func == PARS_TO_BINARY_TOKEN) {
if (dtype_get_mtype(que_node_get_data_type(arg)) == DATA_INT) {
dtype_set(que_node_get_data_type(node), DATA_VARCHAR,
DATA_ENGLISH, 0, 0);
DATA_ENGLISH, 0);
} else {
dtype_set(que_node_get_data_type(node), DATA_BINARY,
0, 0, 0);
0, 0);
}
} else if (func == PARS_TO_NUMBER_TOKEN) {
ut_a(dtype_get_mtype(que_node_get_data_type(arg))
== DATA_VARCHAR);
dtype_set(que_node_get_data_type(node), DATA_INT, 0, 4, 0);
dtype_set(que_node_get_data_type(node), DATA_INT, 0, 4);
} else if (func == PARS_BINARY_TO_NUMBER_TOKEN) {
ut_a(dtype_get_mtype(que_node_get_data_type(arg))
== DATA_VARCHAR);
dtype_set(que_node_get_data_type(node), DATA_INT, 0, 4, 0);
dtype_set(que_node_get_data_type(node), DATA_INT, 0, 4);
} else if (func == PARS_LENGTH_TOKEN) {
ut_a(dtype_get_mtype(que_node_get_data_type(arg))
== DATA_VARCHAR);
dtype_set(que_node_get_data_type(node), DATA_INT, 0, 4, 0);
dtype_set(que_node_get_data_type(node), DATA_INT, 0, 4);
} else if (func == PARS_INSTR_TOKEN) {
ut_a(dtype_get_mtype(que_node_get_data_type(arg))
== DATA_VARCHAR);
dtype_set(que_node_get_data_type(node), DATA_INT, 0, 4, 0);
dtype_set(que_node_get_data_type(node), DATA_INT, 0, 4);
} else if (func == PARS_SYSDATE_TOKEN) {
ut_a(arg == NULL);
dtype_set(que_node_get_data_type(node), DATA_INT, 0, 4, 0);
dtype_set(que_node_get_data_type(node), DATA_INT, 0, 4);
} else if ((func == PARS_SUBSTR_TOKEN)
|| (func == PARS_CONCAT_TOKEN)) {
......@@ -298,7 +298,7 @@ pars_resolve_func_data_type(
ut_a(dtype_get_mtype(que_node_get_data_type(arg))
== DATA_VARCHAR);
dtype_set(que_node_get_data_type(node), DATA_VARCHAR,
DATA_ENGLISH, 0, 0);
DATA_ENGLISH, 0);
} else if ((func == '>') || (func == '<') || (func == '=')
|| (func == PARS_GE_TOKEN)
......@@ -310,18 +310,18 @@ pars_resolve_func_data_type(
|| (func == PARS_NOTFOUND_TOKEN)) {
/* We currently have no iboolean type: use integer type */
dtype_set(que_node_get_data_type(node), DATA_INT, 0, 4, 0);
dtype_set(que_node_get_data_type(node), DATA_INT, 0, 4);
} else if (func == PARS_RND_TOKEN) {
ut_a(dtype_get_mtype(que_node_get_data_type(arg)) == DATA_INT);
dtype_set(que_node_get_data_type(node), DATA_INT, 0, 4, 0);
dtype_set(que_node_get_data_type(node), DATA_INT, 0, 4);
} else if (func == PARS_RND_STR_TOKEN) {
ut_a(dtype_get_mtype(que_node_get_data_type(arg)) == DATA_INT);
dtype_set(que_node_get_data_type(node), DATA_VARCHAR,
DATA_ENGLISH, 0, 0);
DATA_ENGLISH, 0);
} else {
ut_error;
}
......@@ -1126,23 +1126,23 @@ pars_set_dfield_type(
if (type == &pars_int_token) {
ut_a(len == 0);
dtype_set(dfield_get_type(dfield), DATA_INT, flags, 4, 0);
dtype_set(dfield_get_type(dfield), DATA_INT, flags, 4);
} else if (type == &pars_char_token) {
ut_a(len == 0);
dtype_set(dfield_get_type(dfield), DATA_VARCHAR,
DATA_ENGLISH | flags, 0, 0);
DATA_ENGLISH | flags, 0);
} else if (type == &pars_binary_token) {
ut_a(len != 0);
dtype_set(dfield_get_type(dfield), DATA_FIXBINARY,
DATA_BINARY_TYPE | flags, len, 0);
DATA_BINARY_TYPE | flags, len);
} else if (type == &pars_blob_token) {
ut_a(len == 0);
dtype_set(dfield_get_type(dfield), DATA_BLOB,
DATA_BINARY_TYPE | flags, 0, 0);
DATA_BINARY_TYPE | flags, 0);
} else {
ut_error;
}
......@@ -1599,7 +1599,8 @@ pars_create_table(
sym_node_t* table_sym, /* in: table name node in the symbol
table */
sym_node_t* column_defs, /* in: list of column names */
void* not_fit_in_memory)/* in: a non-NULL pointer means that
void* not_fit_in_memory __attribute__((unused)))
/* in: a non-NULL pointer means that
this is a table which in simulations
should be simulated as not fitting
in memory; thread is put to sleep
......@@ -1623,18 +1624,18 @@ pars_create_table(
create tables in the old (not compact) record format. */
table = dict_mem_table_create(table_sym->name, 0, n_cols, 0);
#ifdef UNIV_DEBUG
if (not_fit_in_memory != NULL) {
table->does_not_fit_in_memory = TRUE;
}
#endif /* UNIV_DEBUG */
column = column_defs;
while (column) {
dtype = dfield_get_type(que_node_get_val(column));
dict_mem_table_add_col(table, column->name, dtype->mtype,
dtype->prtype, dtype->len,
dtype->prec);
dtype->prtype, dtype->len);
column->resolved = TRUE;
column->token_type = SYM_COLUMN;
......
......@@ -102,7 +102,7 @@ sym_tab_add_int_lit(
node->indirection = NULL;
dtype_set(&(node->common.val.type), DATA_INT, 0, 4, 0);
dtype_set(&(node->common.val.type), DATA_INT, 0, 4);
data = mem_heap_alloc(sym_tab->heap, 4);
mach_write_to_4(data, val);
......@@ -144,7 +144,7 @@ sym_tab_add_str_lit(
node->indirection = NULL;
dtype_set(&(node->common.val.type), DATA_VARCHAR, DATA_ENGLISH, 0, 0);
dtype_set(&(node->common.val.type), DATA_VARCHAR, DATA_ENGLISH, 0);
if (len) {
data = mem_heap_alloc(sym_tab->heap, len);
......@@ -226,7 +226,7 @@ sym_tab_add_bound_lit(
ut_error;
}
dtype_set(&(node->common.val.type), blit->type, blit->prtype, len, 0);
dtype_set(&(node->common.val.type), blit->type, blit->prtype, len);
dfield_set_data(&(node->common.val), blit->address, blit->length);
......
......@@ -972,7 +972,8 @@ row_upd_index_replace_new_col_vals(
upd_field = upd_get_nth_field(update, i);
if (upd_field->field_no == field->col->clust_pos) {
if (upd_field->field_no
== dict_col_get_clust_pos(field->col)) {
dfield = dtuple_get_nth_field(entry, j);
......
......@@ -899,7 +899,7 @@ srv_init(void)
table = dict_mem_table_create("SYS_DUMMY1",
DICT_HDR_SPACE, 1, 0);
dict_mem_table_add_col(table, "DUMMY", DATA_CHAR,
DATA_ENGLISH | DATA_NOT_NULL, 8, 0);
DATA_ENGLISH | DATA_NOT_NULL, 8);
srv_sys->dummy_ind1 = dict_mem_index_create
("SYS_DUMMY1", "SYS_DUMMY1", DICT_HDR_SPACE, 0, 1);
......@@ -910,7 +910,7 @@ srv_init(void)
table = dict_mem_table_create("SYS_DUMMY2",
DICT_HDR_SPACE, 1, DICT_TF_COMPACT);
dict_mem_table_add_col(table, "DUMMY", DATA_CHAR,
DATA_ENGLISH | DATA_NOT_NULL, 8, 0);
DATA_ENGLISH | DATA_NOT_NULL, 8);
srv_sys->dummy_ind2 = dict_mem_index_create
("SYS_DUMMY2", "SYS_DUMMY2", DICT_HDR_SPACE, 0, 1);
dict_index_add_col(srv_sys->dummy_ind2,
......
......@@ -89,7 +89,8 @@ void
rw_lock_create_func(
/*================*/
rw_lock_t* lock, /* in: pointer to memory */
ulint level, /* in: level */
ulint level __attribute__((unused)),
/* in: level */
const char* cfile_name, /* in: file name where created */
ulint cline, /* in: file line where created */
const char* cmutex_name) /* in: mutex name */
......@@ -116,9 +117,9 @@ rw_lock_create_func(
#ifdef UNIV_SYNC_DEBUG
UT_LIST_INIT(lock->debug_list);
#endif /* UNIV_SYNC_DEBUG */
lock->level = level;
#endif /* UNIV_SYNC_DEBUG */
lock->magic_n = RW_LOCK_MAGIC_N;
......
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