mirror of
https://github.com/MariaDB/server.git
synced 2025-01-25 00:04:33 +01:00
dict_col_t: Copy the fields of "dtype_t type" directly to this structure,
so that all integer fields can be packed into 64 bits. (Bug #20877) dtype_t: Change the type of all bit-fields to unsigned. dict_table_get_nth_col(), dict_table_get_sys_col_noninline(), dict_table_get_sys_col(), dict_field_get_col(): Return const dict_col_t*, so that changes to dict_col_t can be detected more easily. Add const to many dict_col_t* declarations. dict_index_get_nth_type(): Replace with dict_index_get_nth_col(). dict_col_get_type(): Replace with dict_col_copy_type(). dict_col_get_min_size(), dict_col_get_max_size(), dict_col_get_fixed_size(), dict_col_get_sql_null_size(): New functions. dtype_get_at_most_n_mbchars(): Replace the parameter dtype with the parameters prtype, mbminlen, mbmaxlen. dtype_get_pad_char(), cmp_data_data(), cmp_data_data_slow(), cmp_whole_field(): Replace the dtype_t* parameter with the ulint parameters mtype, prtype. dtype_copy(): Add a const qualifier to type2 (the one being copied from). dtype_set_mblen(): Replaced with dtype_get_mblen(). dtype_get_fixed_size_low(), dtype_get_min_size_low(), dtype_get_fixed_max_low(): Replace dtype_get_fixed_size(), dtype_get_min_size(), and dtype_get_max_size(). These are used by the dict_col_get_{fixed,min,max}_size() functions. cmp_types_are_equal(): Replace with cmp_cols_are_equal(). dict_table_get_col_name(): Add a const qualifier parameter to the parameter "table". dtype_binary, dtype_binary_val: Remove. dtype_is_fixed_size(): Remove.
This commit is contained in:
parent
2d96f74a05
commit
f39237e200
27 changed files with 833 additions and 638 deletions
|
@ -2564,8 +2564,8 @@ btr_index_rec_validate(
|
||||||
offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, &heap);
|
offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, &heap);
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
dtype_t* type = dict_index_get_nth_type(index, i);
|
ulint fixed_size = dict_col_get_fixed_size(
|
||||||
ulint fixed_size = dtype_get_fixed_size(type);
|
dict_index_get_nth_col(index, i));
|
||||||
|
|
||||||
rec_get_nth_field(rec, offsets, i, &len);
|
rec_get_nth_field(rec, offsets, i, &len);
|
||||||
|
|
||||||
|
@ -2584,8 +2584,7 @@ btr_index_rec_validate(
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"InnoDB: field %lu len is %lu,"
|
"InnoDB: field %lu len is %lu,"
|
||||||
" should be %lu\n",
|
" should be %lu\n",
|
||||||
(ulong) i, (ulong) len,
|
(ulong) i, (ulong) len, (ulong) fixed_size);
|
||||||
(ulong) dtype_get_fixed_size(type));
|
|
||||||
|
|
||||||
if (dump_on_error) {
|
if (dump_on_error) {
|
||||||
buf_page_print(page);
|
buf_page_print(page);
|
||||||
|
|
|
@ -40,9 +40,6 @@ charset-collation code for them. */
|
||||||
|
|
||||||
ulint data_mysql_default_charset_coll = 99999999;
|
ulint data_mysql_default_charset_coll = 99999999;
|
||||||
|
|
||||||
dtype_t dtype_binary_val = {DATA_BINARY, 0, 0, 0, 0};
|
|
||||||
dtype_t* dtype_binary = &dtype_binary_val;
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
Determine how many bytes the first n characters of the given string occupy.
|
Determine how many bytes the first n characters of the given string occupy.
|
||||||
If the string is shorter than n characters, returns the number of bytes
|
If the string is shorter than n characters, returns the number of bytes
|
||||||
|
@ -53,7 +50,11 @@ dtype_get_at_most_n_mbchars(
|
||||||
/*========================*/
|
/*========================*/
|
||||||
/* out: length of the prefix,
|
/* out: length of the prefix,
|
||||||
in bytes */
|
in bytes */
|
||||||
const dtype_t* dtype, /* in: data type */
|
ulint prtype, /* in: precise type */
|
||||||
|
ulint mbminlen, /* in: minimum length of a
|
||||||
|
multi-byte character */
|
||||||
|
ulint mbmaxlen, /* in: maximum length of a
|
||||||
|
multi-byte character */
|
||||||
ulint prefix_len, /* in: length of the requested
|
ulint prefix_len, /* in: length of the requested
|
||||||
prefix, in characters, multiplied by
|
prefix, in characters, multiplied by
|
||||||
dtype_get_mbmaxlen(dtype) */
|
dtype_get_mbmaxlen(dtype) */
|
||||||
|
@ -63,12 +64,12 @@ dtype_get_at_most_n_mbchars(
|
||||||
{
|
{
|
||||||
#ifndef UNIV_HOTBACKUP
|
#ifndef UNIV_HOTBACKUP
|
||||||
ut_a(data_len != UNIV_SQL_NULL);
|
ut_a(data_len != UNIV_SQL_NULL);
|
||||||
ut_ad(!dtype->mbmaxlen || !(prefix_len % dtype->mbmaxlen));
|
ut_ad(!mbmaxlen || !(prefix_len % mbmaxlen));
|
||||||
|
|
||||||
if (dtype->mbminlen != dtype->mbmaxlen) {
|
if (mbminlen != mbmaxlen) {
|
||||||
ut_a(!(prefix_len % dtype->mbmaxlen));
|
ut_a(!(prefix_len % mbmaxlen));
|
||||||
return(innobase_get_at_most_n_mbchars
|
return(innobase_get_at_most_n_mbchars(
|
||||||
(dtype_get_charset_coll(dtype->prtype),
|
dtype_get_charset_coll(prtype),
|
||||||
prefix_len, data_len, str));
|
prefix_len, data_len, str));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,36 +292,3 @@ dtype_print(
|
||||||
|
|
||||||
fprintf(stderr, " len %lu", (ulong) len);
|
fprintf(stderr, " len %lu", (ulong) len);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************************
|
|
||||||
Returns the maximum size of a data type. Note: types in system tables may be
|
|
||||||
incomplete and return incorrect information. */
|
|
||||||
|
|
||||||
ulint
|
|
||||||
dtype_get_max_size(
|
|
||||||
/*===============*/
|
|
||||||
/* out: maximum size (ULINT_MAX for
|
|
||||||
unbounded types) */
|
|
||||||
const dtype_t* type) /* in: type */
|
|
||||||
{
|
|
||||||
switch (type->mtype) {
|
|
||||||
case DATA_SYS:
|
|
||||||
case DATA_CHAR:
|
|
||||||
case DATA_FIXBINARY:
|
|
||||||
case DATA_INT:
|
|
||||||
case DATA_FLOAT:
|
|
||||||
case DATA_DOUBLE:
|
|
||||||
case DATA_MYSQL:
|
|
||||||
case DATA_VARCHAR:
|
|
||||||
case DATA_BINARY:
|
|
||||||
case DATA_DECIMAL:
|
|
||||||
case DATA_VARMYSQL:
|
|
||||||
return(type->len);
|
|
||||||
case DATA_BLOB:
|
|
||||||
return(ULINT_MAX);
|
|
||||||
default:
|
|
||||||
ut_error;
|
|
||||||
}
|
|
||||||
|
|
||||||
return(ULINT_MAX);
|
|
||||||
}
|
|
||||||
|
|
|
@ -124,11 +124,11 @@ dict_create_sys_columns_tuple(
|
||||||
mem_heap_t* heap) /* in: memory heap from which the memory for
|
mem_heap_t* heap) /* in: memory heap from which the memory for
|
||||||
the built tuple is allocated */
|
the built tuple is allocated */
|
||||||
{
|
{
|
||||||
dict_table_t* sys_columns;
|
dict_table_t* sys_columns;
|
||||||
dtuple_t* entry;
|
dtuple_t* entry;
|
||||||
dict_col_t* column;
|
const dict_col_t* column;
|
||||||
dfield_t* dfield;
|
dfield_t* dfield;
|
||||||
byte* ptr;
|
byte* ptr;
|
||||||
const char* col_name;
|
const char* col_name;
|
||||||
|
|
||||||
ut_ad(table && heap);
|
ut_ad(table && heap);
|
||||||
|
@ -162,21 +162,21 @@ dict_create_sys_columns_tuple(
|
||||||
dfield = dtuple_get_nth_field(entry, 3);
|
dfield = dtuple_get_nth_field(entry, 3);
|
||||||
|
|
||||||
ptr = mem_heap_alloc(heap, 4);
|
ptr = mem_heap_alloc(heap, 4);
|
||||||
mach_write_to_4(ptr, (column->type).mtype);
|
mach_write_to_4(ptr, column->mtype);
|
||||||
|
|
||||||
dfield_set_data(dfield, ptr, 4);
|
dfield_set_data(dfield, ptr, 4);
|
||||||
/* 6: PRTYPE -------------------------*/
|
/* 6: PRTYPE -------------------------*/
|
||||||
dfield = dtuple_get_nth_field(entry, 4);
|
dfield = dtuple_get_nth_field(entry, 4);
|
||||||
|
|
||||||
ptr = mem_heap_alloc(heap, 4);
|
ptr = mem_heap_alloc(heap, 4);
|
||||||
mach_write_to_4(ptr, (column->type).prtype);
|
mach_write_to_4(ptr, column->prtype);
|
||||||
|
|
||||||
dfield_set_data(dfield, ptr, 4);
|
dfield_set_data(dfield, ptr, 4);
|
||||||
/* 7: LEN ----------------------------*/
|
/* 7: LEN ----------------------------*/
|
||||||
dfield = dtuple_get_nth_field(entry, 5);
|
dfield = dtuple_get_nth_field(entry, 5);
|
||||||
|
|
||||||
ptr = mem_heap_alloc(heap, 4);
|
ptr = mem_heap_alloc(heap, 4);
|
||||||
mach_write_to_4(ptr, (column->type).len);
|
mach_write_to_4(ptr, column->len);
|
||||||
|
|
||||||
dfield_set_data(dfield, ptr, 4);
|
dfield_set_data(dfield, ptr, 4);
|
||||||
/* 8: PREC ---------------------------*/
|
/* 8: PREC ---------------------------*/
|
||||||
|
@ -224,8 +224,7 @@ dict_build_table_def_step(
|
||||||
|
|
||||||
row_len = 0;
|
row_len = 0;
|
||||||
for (i = 0; i < table->n_def; i++) {
|
for (i = 0; i < table->n_def; i++) {
|
||||||
row_len += dtype_get_min_size(dict_col_get_type
|
row_len += dict_col_get_min_size(&table->cols[i]);
|
||||||
(&table->cols[i]));
|
|
||||||
}
|
}
|
||||||
if (row_len > BTR_PAGE_MAX_REC_SIZE) {
|
if (row_len > BTR_PAGE_MAX_REC_SIZE) {
|
||||||
return(DB_TOO_BIG_RECORD);
|
return(DB_TOO_BIG_RECORD);
|
||||||
|
|
158
dict/dict0dict.c
158
dict/dict0dict.c
|
@ -192,8 +192,8 @@ static
|
||||||
void
|
void
|
||||||
dict_col_print_low(
|
dict_col_print_low(
|
||||||
/*===============*/
|
/*===============*/
|
||||||
dict_table_t* table, /* in: table */
|
const dict_table_t* table, /* in: table */
|
||||||
dict_col_t* col); /* in: column */
|
const dict_col_t* col); /* in: column */
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
Prints an index data. */
|
Prints an index data. */
|
||||||
static
|
static
|
||||||
|
@ -325,15 +325,27 @@ dict_table_decrement_handle_count(
|
||||||
mutex_exit(&(dict_sys->mutex));
|
mutex_exit(&(dict_sys->mutex));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Gets the column data type. */
|
||||||
|
|
||||||
|
void
|
||||||
|
dict_col_copy_type_noninline(
|
||||||
|
/*=========================*/
|
||||||
|
const dict_col_t* col, /* in: column */
|
||||||
|
dtype_t* type) /* out: data type */
|
||||||
|
{
|
||||||
|
return(dict_col_copy_type(col, type));
|
||||||
|
}
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
Gets the nth column of a table. */
|
Gets the nth column of a table. */
|
||||||
|
|
||||||
dict_col_t*
|
const dict_col_t*
|
||||||
dict_table_get_nth_col_noninline(
|
dict_table_get_nth_col_noninline(
|
||||||
/*=============================*/
|
/*=============================*/
|
||||||
/* out: pointer to column object */
|
/* out: pointer to column object */
|
||||||
dict_table_t* table, /* in: table */
|
const dict_table_t* table, /* in: table */
|
||||||
ulint pos) /* in: position of column */
|
ulint pos) /* in: position of column */
|
||||||
{
|
{
|
||||||
return(dict_table_get_nth_col(table, pos));
|
return(dict_table_get_nth_col(table, pos));
|
||||||
}
|
}
|
||||||
|
@ -381,11 +393,12 @@ Returns a column's name. */
|
||||||
const char*
|
const char*
|
||||||
dict_table_get_col_name(
|
dict_table_get_col_name(
|
||||||
/*====================*/
|
/*====================*/
|
||||||
/* out: column name. NOTE: not guaranteed to
|
/* out: column name. NOTE: not
|
||||||
stay valid if table is modified in any way
|
guaranteed to stay valid if
|
||||||
(columns added, etc.). */
|
table is modified in any way
|
||||||
dict_table_t* table, /* in: table */
|
(columns added, etc.). */
|
||||||
ulint i) /* in: column number */
|
const dict_table_t* table, /* in: table */
|
||||||
|
ulint i) /* in: column number */
|
||||||
{
|
{
|
||||||
ut_ad(table);
|
ut_ad(table);
|
||||||
ut_ad(i < table->n_def);
|
ut_ad(i < table->n_def);
|
||||||
|
@ -536,10 +549,10 @@ dict_index_get_nth_col_pos(
|
||||||
dict_index_t* index, /* in: index */
|
dict_index_t* index, /* in: index */
|
||||||
ulint n) /* in: column number */
|
ulint n) /* in: column number */
|
||||||
{
|
{
|
||||||
dict_field_t* field;
|
const dict_field_t* field;
|
||||||
dict_col_t* col;
|
const dict_col_t* col;
|
||||||
ulint pos;
|
ulint pos;
|
||||||
ulint n_fields;
|
ulint n_fields;
|
||||||
|
|
||||||
ut_ad(index);
|
ut_ad(index);
|
||||||
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
|
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
|
||||||
|
@ -576,10 +589,10 @@ dict_index_contains_col_or_prefix(
|
||||||
dict_index_t* index, /* in: index */
|
dict_index_t* index, /* in: index */
|
||||||
ulint n) /* in: column number */
|
ulint n) /* in: column number */
|
||||||
{
|
{
|
||||||
dict_field_t* field;
|
const dict_field_t* field;
|
||||||
dict_col_t* col;
|
const dict_col_t* col;
|
||||||
ulint pos;
|
ulint pos;
|
||||||
ulint n_fields;
|
ulint n_fields;
|
||||||
|
|
||||||
ut_ad(index);
|
ut_ad(index);
|
||||||
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
|
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
|
||||||
|
@ -723,11 +736,11 @@ dict_table_col_in_clustered_key(
|
||||||
dict_table_t* table, /* in: table */
|
dict_table_t* table, /* in: table */
|
||||||
ulint n) /* in: column number */
|
ulint n) /* in: column number */
|
||||||
{
|
{
|
||||||
dict_index_t* index;
|
dict_index_t* index;
|
||||||
dict_field_t* field;
|
const dict_field_t* field;
|
||||||
dict_col_t* col;
|
const dict_col_t* col;
|
||||||
ulint pos;
|
ulint pos;
|
||||||
ulint n_fields;
|
ulint n_fields;
|
||||||
|
|
||||||
ut_ad(table);
|
ut_ad(table);
|
||||||
|
|
||||||
|
@ -901,8 +914,8 @@ dict_table_add_to_cache(
|
||||||
|
|
||||||
row_len = 0;
|
row_len = 0;
|
||||||
for (i = 0; i < table->n_def; i++) {
|
for (i = 0; i < table->n_def; i++) {
|
||||||
ulint col_len = dtype_get_max_size
|
ulint col_len = dict_col_get_max_size(
|
||||||
(dict_col_get_type(dict_table_get_nth_col(table, i)));
|
dict_table_get_nth_col(table, i));
|
||||||
|
|
||||||
row_len += col_len;
|
row_len += col_len;
|
||||||
|
|
||||||
|
@ -1349,7 +1362,6 @@ dict_index_add_to_cache(
|
||||||
ulint page_no)/* in: root page number of the index */
|
ulint page_no)/* in: root page number of the index */
|
||||||
{
|
{
|
||||||
dict_index_t* new_index;
|
dict_index_t* new_index;
|
||||||
dict_field_t* field;
|
|
||||||
ulint n_ord;
|
ulint n_ord;
|
||||||
ulint i;
|
ulint i;
|
||||||
|
|
||||||
|
@ -1412,9 +1424,7 @@ dict_index_add_to_cache(
|
||||||
|
|
||||||
for (i = 0; i < n_ord; i++) {
|
for (i = 0; i < n_ord; i++) {
|
||||||
|
|
||||||
field = dict_index_get_nth_field(new_index, i);
|
dict_index_get_nth_field(new_index, i)->col->ord_part = 1;
|
||||||
|
|
||||||
dict_field_get_col(field)->ord_part = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
new_index->page = page_no;
|
new_index->page = page_no;
|
||||||
|
@ -1497,7 +1507,8 @@ dict_index_find_cols(
|
||||||
for (j = 0; j < table->n_cols; j++) {
|
for (j = 0; j < table->n_cols; j++) {
|
||||||
if (!strcmp(dict_table_get_col_name(table, j),
|
if (!strcmp(dict_table_get_col_name(table, j),
|
||||||
field->name)) {
|
field->name)) {
|
||||||
field->col = dict_table_get_nth_col(table, j);
|
field->col = (dict_col_t*)
|
||||||
|
dict_table_get_nth_col(table, j);
|
||||||
|
|
||||||
goto found;
|
goto found;
|
||||||
}
|
}
|
||||||
|
@ -1532,7 +1543,7 @@ dict_index_add_col(
|
||||||
field = dict_index_get_nth_field(index, index->n_def - 1);
|
field = dict_index_get_nth_field(index, index->n_def - 1);
|
||||||
|
|
||||||
field->col = col;
|
field->col = col;
|
||||||
field->fixed_len = dtype_get_fixed_size(&col->type);
|
field->fixed_len = dict_col_get_fixed_size(col);
|
||||||
|
|
||||||
if (prefix_len && field->fixed_len > prefix_len) {
|
if (prefix_len && field->fixed_len > prefix_len) {
|
||||||
field->fixed_len = prefix_len;
|
field->fixed_len = prefix_len;
|
||||||
|
@ -1546,7 +1557,7 @@ dict_index_add_col(
|
||||||
field->fixed_len = 0;
|
field->fixed_len = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(dtype_get_prtype(&col->type) & DATA_NOT_NULL)) {
|
if (!(col->prtype & DATA_NOT_NULL)) {
|
||||||
index->n_nullable++;
|
index->n_nullable++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1597,12 +1608,10 @@ dict_index_copy_types(
|
||||||
for (i = 0; i < n_fields; i++) {
|
for (i = 0; i < n_fields; i++) {
|
||||||
dict_field_t* ifield;
|
dict_field_t* ifield;
|
||||||
dtype_t* dfield_type;
|
dtype_t* dfield_type;
|
||||||
dtype_t* type;
|
|
||||||
|
|
||||||
ifield = dict_index_get_nth_field(index, i);
|
ifield = dict_index_get_nth_field(index, i);
|
||||||
dfield_type = dfield_get_type(dtuple_get_nth_field(tuple, i));
|
dfield_type = dfield_get_type(dtuple_get_nth_field(tuple, i));
|
||||||
type = dict_col_get_type(dict_field_get_col(ifield));
|
dict_col_copy_type(dict_field_get_col(ifield), dfield_type);
|
||||||
*dfield_type = *type;
|
|
||||||
if (UNIV_UNLIKELY(ifield->prefix_len)) {
|
if (UNIV_UNLIKELY(ifield->prefix_len)) {
|
||||||
dfield_type->len = ifield->prefix_len;
|
dfield_type->len = ifield->prefix_len;
|
||||||
}
|
}
|
||||||
|
@ -1619,15 +1628,13 @@ dict_table_copy_types(
|
||||||
dict_table_t* table) /* in: index */
|
dict_table_t* table) /* in: index */
|
||||||
{
|
{
|
||||||
dtype_t* dfield_type;
|
dtype_t* dfield_type;
|
||||||
dtype_t* type;
|
|
||||||
ulint i;
|
ulint i;
|
||||||
|
|
||||||
for (i = 0; i < dtuple_get_n_fields(tuple); i++) {
|
for (i = 0; i < dtuple_get_n_fields(tuple); i++) {
|
||||||
|
|
||||||
dfield_type = dfield_get_type(dtuple_get_nth_field(tuple, i));
|
dfield_type = dfield_get_type(dtuple_get_nth_field(tuple, i));
|
||||||
type = dict_col_get_type(dict_table_get_nth_col(table, i));
|
dict_col_copy_type(dict_table_get_nth_col(table, i),
|
||||||
|
dfield_type);
|
||||||
*dfield_type = *type;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1646,7 +1653,6 @@ dict_index_build_internal_clust(
|
||||||
{
|
{
|
||||||
dict_index_t* new_index;
|
dict_index_t* new_index;
|
||||||
dict_field_t* field;
|
dict_field_t* field;
|
||||||
dict_col_t* col;
|
|
||||||
ulint fixed_size;
|
ulint fixed_size;
|
||||||
ulint trx_id_pos;
|
ulint trx_id_pos;
|
||||||
ulint i;
|
ulint i;
|
||||||
|
@ -1708,26 +1714,26 @@ dict_index_build_internal_clust(
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!(index->type & DICT_UNIQUE)) {
|
if (!(index->type & DICT_UNIQUE)) {
|
||||||
dict_index_add_col(new_index, table,
|
dict_index_add_col(new_index, table, (dict_col_t*)
|
||||||
dict_table_get_sys_col(
|
dict_table_get_sys_col(
|
||||||
table, DATA_ROW_ID),
|
table, DATA_ROW_ID),
|
||||||
0);
|
0);
|
||||||
trx_id_pos++;
|
trx_id_pos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
dict_index_add_col(new_index, table,
|
dict_index_add_col(new_index, table, (dict_col_t*)
|
||||||
dict_table_get_sys_col(table, DATA_TRX_ID),
|
dict_table_get_sys_col(table, DATA_TRX_ID),
|
||||||
0);
|
0);
|
||||||
|
|
||||||
dict_index_add_col(new_index, table,
|
dict_index_add_col(new_index, table, (dict_col_t*)
|
||||||
dict_table_get_sys_col(table,
|
dict_table_get_sys_col(table,
|
||||||
DATA_ROLL_PTR),
|
DATA_ROLL_PTR),
|
||||||
0);
|
0);
|
||||||
|
|
||||||
for (i = 0; i < trx_id_pos; i++) {
|
for (i = 0; i < trx_id_pos; i++) {
|
||||||
|
|
||||||
fixed_size = dtype_get_fixed_size
|
fixed_size = dict_col_get_fixed_size(
|
||||||
(dict_index_get_nth_type(new_index, i));
|
dict_index_get_nth_col(new_index, i));
|
||||||
|
|
||||||
if (fixed_size == 0) {
|
if (fixed_size == 0) {
|
||||||
new_index->trx_id_offset = 0;
|
new_index->trx_id_offset = 0;
|
||||||
|
@ -1769,8 +1775,9 @@ dict_index_build_internal_clust(
|
||||||
there */
|
there */
|
||||||
for (i = 0; i + DATA_N_SYS_COLS < (ulint) table->n_cols; i++) {
|
for (i = 0; i + DATA_N_SYS_COLS < (ulint) table->n_cols; i++) {
|
||||||
|
|
||||||
col = dict_table_get_nth_col(table, i);
|
dict_col_t* col = (dict_col_t*)
|
||||||
ut_ad(col->type.mtype != DATA_SYS);
|
dict_table_get_nth_col(table, i);
|
||||||
|
ut_ad(col->mtype != DATA_SYS);
|
||||||
|
|
||||||
if (!indexed[col->ind]) {
|
if (!indexed[col->ind]) {
|
||||||
dict_index_add_col(new_index, table, col, 0);
|
dict_index_add_col(new_index, table, col, 0);
|
||||||
|
@ -2031,10 +2038,11 @@ dict_foreign_find_index(
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (types_idx && !cmp_types_are_equal
|
if (types_idx && !cmp_cols_are_equal(
|
||||||
(dict_index_get_nth_type(index, i),
|
dict_index_get_nth_col(index, i),
|
||||||
dict_index_get_nth_type(types_idx, i),
|
dict_index_get_nth_col(types_idx,
|
||||||
check_charsets)) {
|
i),
|
||||||
|
check_charsets)) {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2421,15 +2429,15 @@ static
|
||||||
const char*
|
const char*
|
||||||
dict_scan_col(
|
dict_scan_col(
|
||||||
/*==========*/
|
/*==========*/
|
||||||
/* out: scanned to */
|
/* out: scanned to */
|
||||||
struct charset_info_st* cs,/* in: the character set of ptr */
|
struct charset_info_st* cs, /* in: the character set of ptr */
|
||||||
const char* ptr, /* in: scanned to */
|
const char* ptr, /* in: scanned to */
|
||||||
ibool* success,/* out: TRUE if success */
|
ibool* success,/* out: TRUE if success */
|
||||||
dict_table_t* table, /* in: table in which the column is */
|
dict_table_t* table, /* in: table in which the column is */
|
||||||
dict_col_t** column, /* out: pointer to column if success */
|
const dict_col_t** column, /* out: pointer to column if success */
|
||||||
mem_heap_t* heap, /* in: heap where to allocate the name */
|
mem_heap_t* heap, /* in: heap where to allocate */
|
||||||
const char** name) /* out,own: the column name; NULL if no name
|
const char** name) /* out,own: the column name;
|
||||||
was scannable */
|
NULL if no name was scannable */
|
||||||
{
|
{
|
||||||
ulint i;
|
ulint i;
|
||||||
|
|
||||||
|
@ -2794,7 +2802,7 @@ dict_create_foreign_constraints_low(
|
||||||
ibool is_on_delete;
|
ibool is_on_delete;
|
||||||
ulint n_on_deletes;
|
ulint n_on_deletes;
|
||||||
ulint n_on_updates;
|
ulint n_on_updates;
|
||||||
dict_col_t* columns[500];
|
const dict_col_t*columns[500];
|
||||||
const char* column_names[500];
|
const char* column_names[500];
|
||||||
const char* referenced_table_name;
|
const char* referenced_table_name;
|
||||||
|
|
||||||
|
@ -3216,8 +3224,7 @@ scan_on_conditions:
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = 0; j < foreign->n_fields; j++) {
|
for (j = 0; j < foreign->n_fields; j++) {
|
||||||
if ((dict_index_get_nth_type
|
if ((dict_index_get_nth_col(foreign->foreign_index, j)->prtype)
|
||||||
(foreign->foreign_index, j)->prtype)
|
|
||||||
& DATA_NOT_NULL) {
|
& DATA_NOT_NULL) {
|
||||||
|
|
||||||
/* It is not sensible to define SET NULL
|
/* It is not sensible to define SET NULL
|
||||||
|
@ -3732,15 +3739,17 @@ dict_index_calc_min_rec_len(
|
||||||
ulint nullable = 0;
|
ulint nullable = 0;
|
||||||
sum = REC_N_NEW_EXTRA_BYTES;
|
sum = REC_N_NEW_EXTRA_BYTES;
|
||||||
for (i = 0; i < dict_index_get_n_fields(index); i++) {
|
for (i = 0; i < dict_index_get_n_fields(index); i++) {
|
||||||
dtype_t*t = dict_index_get_nth_type(index, i);
|
const dict_col_t* col
|
||||||
ulint size = dtype_get_fixed_size(t);
|
= dict_index_get_nth_col(index, i);
|
||||||
|
ulint size = dict_col_get_fixed_size(col);
|
||||||
sum += size;
|
sum += size;
|
||||||
if (!size) {
|
if (!size) {
|
||||||
size = dtype_get_len(t);
|
size = col->len;
|
||||||
sum += size < 128 ? 1 : 2;
|
sum += size < 128 ? 1 : 2;
|
||||||
}
|
}
|
||||||
if (!(dtype_get_prtype(t) & DATA_NOT_NULL))
|
if (!(col->prtype & DATA_NOT_NULL)) {
|
||||||
nullable++;
|
nullable++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* round the NULL flags up to full bytes */
|
/* round the NULL flags up to full bytes */
|
||||||
|
@ -3750,7 +3759,8 @@ dict_index_calc_min_rec_len(
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < dict_index_get_n_fields(index); i++) {
|
for (i = 0; i < dict_index_get_n_fields(index); i++) {
|
||||||
sum += dtype_get_fixed_size(dict_index_get_nth_type(index, i));
|
sum += dict_col_get_fixed_size(
|
||||||
|
dict_index_get_nth_col(index, i));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sum > 127) {
|
if (sum > 127) {
|
||||||
|
@ -4002,20 +4012,20 @@ static
|
||||||
void
|
void
|
||||||
dict_col_print_low(
|
dict_col_print_low(
|
||||||
/*===============*/
|
/*===============*/
|
||||||
dict_table_t* table, /* in: table */
|
const dict_table_t* table, /* in: table */
|
||||||
dict_col_t* col) /* in: column */
|
const dict_col_t* col) /* in: column */
|
||||||
{
|
{
|
||||||
dtype_t* type;
|
dtype_t type;
|
||||||
|
|
||||||
#ifdef UNIV_SYNC_DEBUG
|
#ifdef UNIV_SYNC_DEBUG
|
||||||
ut_ad(mutex_own(&(dict_sys->mutex)));
|
ut_ad(mutex_own(&(dict_sys->mutex)));
|
||||||
#endif /* UNIV_SYNC_DEBUG */
|
#endif /* UNIV_SYNC_DEBUG */
|
||||||
|
|
||||||
type = dict_col_get_type(col);
|
dict_col_copy_type(col, &type);
|
||||||
fprintf(stderr, "%s: ", dict_table_get_col_name(table,
|
fprintf(stderr, "%s: ", dict_table_get_col_name(table,
|
||||||
dict_col_get_no(col)));
|
dict_col_get_no(col)));
|
||||||
|
|
||||||
dtype_print(type);
|
dtype_print(&type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
|
|
|
@ -1295,7 +1295,8 @@ loop:
|
||||||
following call does the comparison in the latin1_swedish_ci
|
following call does the comparison in the latin1_swedish_ci
|
||||||
charset-collation, in a case-insensitive way. */
|
charset-collation, in a case-insensitive way. */
|
||||||
|
|
||||||
if (0 != cmp_data_data(dfield_get_type(dfield),
|
if (0 != cmp_data_data(dfield_get_type(dfield)->mtype,
|
||||||
|
dfield_get_type(dfield)->prtype,
|
||||||
dfield_get_data(dfield), dfield_get_len(dfield),
|
dfield_get_data(dfield), dfield_get_len(dfield),
|
||||||
field, len)) {
|
field, len)) {
|
||||||
|
|
||||||
|
|
|
@ -123,22 +123,28 @@ dict_mem_table_add_col(
|
||||||
ulint len) /* in: precision */
|
ulint len) /* in: precision */
|
||||||
{
|
{
|
||||||
dict_col_t* col;
|
dict_col_t* col;
|
||||||
dtype_t* type;
|
ulint mbminlen;
|
||||||
|
ulint mbmaxlen;
|
||||||
|
|
||||||
ut_ad(table && name);
|
ut_ad(table && name);
|
||||||
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
|
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
|
||||||
|
|
||||||
table->n_def++;
|
table->n_def++;
|
||||||
|
|
||||||
col = dict_table_get_nth_col(table, table->n_def - 1);
|
col = (dict_col_t*) dict_table_get_nth_col(table, table->n_def - 1);
|
||||||
|
|
||||||
col->ind = table->n_def - 1;
|
col->ind = table->n_def - 1;
|
||||||
col->name = mem_heap_strdup(table->heap, name);
|
col->name = mem_heap_strdup(table->heap, name);
|
||||||
col->ord_part = 0;
|
col->ord_part = 0;
|
||||||
|
|
||||||
type = dict_col_get_type(col);
|
col->mtype = mtype;
|
||||||
|
col->prtype = prtype;
|
||||||
|
col->len = len;
|
||||||
|
|
||||||
dtype_set(type, mtype, prtype, len);
|
dtype_get_mblen(mtype, prtype, &mbminlen, &mbmaxlen);
|
||||||
|
|
||||||
|
col->mbminlen = mbminlen;
|
||||||
|
col->mbmaxlen = mbmaxlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
|
|
|
@ -3195,7 +3195,7 @@ include_field:
|
||||||
mysql_prefix_len = templ->mysql_col_offset
|
mysql_prefix_len = templ->mysql_col_offset
|
||||||
+ templ->mysql_col_len;
|
+ templ->mysql_col_len;
|
||||||
}
|
}
|
||||||
templ->type = index->table->cols[i].type.mtype;
|
templ->type = index->table->cols[i].mtype;
|
||||||
templ->mysql_type = (ulint)field->type();
|
templ->mysql_type = (ulint)field->type();
|
||||||
|
|
||||||
if (templ->mysql_type == DATA_MYSQL_TRUE_VARCHAR) {
|
if (templ->mysql_type == DATA_MYSQL_TRUE_VARCHAR) {
|
||||||
|
@ -3204,10 +3204,10 @@ include_field:
|
||||||
}
|
}
|
||||||
|
|
||||||
templ->charset = dtype_get_charset_coll_noninline(
|
templ->charset = dtype_get_charset_coll_noninline(
|
||||||
index->table->cols[i].type.prtype);
|
index->table->cols[i].prtype);
|
||||||
templ->mbminlen = index->table->cols[i].type.mbminlen;
|
templ->mbminlen = index->table->cols[i].mbminlen;
|
||||||
templ->mbmaxlen = index->table->cols[i].type.mbmaxlen;
|
templ->mbmaxlen = index->table->cols[i].mbmaxlen;
|
||||||
templ->is_unsigned = index->table->cols[i].type.prtype
|
templ->is_unsigned = index->table->cols[i].prtype
|
||||||
& DATA_UNSIGNED;
|
& DATA_UNSIGNED;
|
||||||
if (templ->type == DATA_BLOB) {
|
if (templ->type == DATA_BLOB) {
|
||||||
prebuilt->templ_contains_blob = TRUE;
|
prebuilt->templ_contains_blob = TRUE;
|
||||||
|
@ -3528,7 +3528,7 @@ calc_row_difference(
|
||||||
|
|
||||||
field_mysql_type = field->type();
|
field_mysql_type = field->type();
|
||||||
|
|
||||||
col_type = prebuilt->table->cols[i].type.mtype;
|
col_type = prebuilt->table->cols[i].mtype;
|
||||||
|
|
||||||
switch (col_type) {
|
switch (col_type) {
|
||||||
|
|
||||||
|
@ -3583,7 +3583,8 @@ calc_row_difference(
|
||||||
/* Let us use a dummy dfield to make the conversion
|
/* Let us use a dummy dfield to make the conversion
|
||||||
from the MySQL column format to the InnoDB format */
|
from the MySQL column format to the InnoDB format */
|
||||||
|
|
||||||
dfield.type = (prebuilt->table->cols + i)->type;
|
dict_col_copy_type_noninline(prebuilt->table->cols + i,
|
||||||
|
&dfield.type);
|
||||||
|
|
||||||
if (n_len != UNIV_SQL_NULL) {
|
if (n_len != UNIV_SQL_NULL) {
|
||||||
buf = row_mysql_store_col_in_innobase_format(
|
buf = row_mysql_store_col_in_innobase_format(
|
||||||
|
|
|
@ -1146,7 +1146,7 @@ ibuf_dummy_index_add_col(
|
||||||
dtype_get_mtype(type),
|
dtype_get_mtype(type),
|
||||||
dtype_get_prtype(type),
|
dtype_get_prtype(type),
|
||||||
dtype_get_len(type));
|
dtype_get_len(type));
|
||||||
dict_index_add_col(index, index->table,
|
dict_index_add_col(index, index->table, (dict_col_t*)
|
||||||
dict_table_get_nth_col(index->table, i), len);
|
dict_table_get_nth_col(index->table, i), len);
|
||||||
}
|
}
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
|
|
|
@ -18,10 +18,6 @@ extern ulint data_mysql_default_charset_coll;
|
||||||
/* SQL data type struct */
|
/* SQL data type struct */
|
||||||
typedef struct dtype_struct dtype_t;
|
typedef struct dtype_struct dtype_t;
|
||||||
|
|
||||||
/* This variable is initialized as the standard binary variable length
|
|
||||||
data type */
|
|
||||||
extern dtype_t* dtype_binary;
|
|
||||||
|
|
||||||
/*-------------------------------------------*/
|
/*-------------------------------------------*/
|
||||||
/* The 'MAIN TYPE' of a column */
|
/* The 'MAIN TYPE' of a column */
|
||||||
#define DATA_VARCHAR 1 /* character varying of the
|
#define DATA_VARCHAR 1 /* character varying of the
|
||||||
|
@ -172,7 +168,11 @@ dtype_get_at_most_n_mbchars(
|
||||||
/*========================*/
|
/*========================*/
|
||||||
/* out: length of the prefix,
|
/* out: length of the prefix,
|
||||||
in bytes */
|
in bytes */
|
||||||
const dtype_t* dtype, /* in: data type */
|
ulint prtype, /* in: precise type */
|
||||||
|
ulint mbminlen, /* in: minimum length of a
|
||||||
|
multi-byte character */
|
||||||
|
ulint mbmaxlen, /* in: maximum length of a
|
||||||
|
multi-byte character */
|
||||||
ulint prefix_len, /* in: length of the requested
|
ulint prefix_len, /* in: length of the requested
|
||||||
prefix, in characters, multiplied by
|
prefix, in characters, multiplied by
|
||||||
dtype_get_mbmaxlen(dtype) */
|
dtype_get_mbmaxlen(dtype) */
|
||||||
|
@ -228,7 +228,7 @@ void
|
||||||
dtype_copy(
|
dtype_copy(
|
||||||
/*=======*/
|
/*=======*/
|
||||||
dtype_t* type1, /* in: type struct to copy to */
|
dtype_t* type1, /* in: type struct to copy to */
|
||||||
dtype_t* type2); /* in: type struct to copy from */
|
const dtype_t* type2); /* in: type struct to copy from */
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
Gets the SQL main data type. */
|
Gets the SQL main data type. */
|
||||||
UNIV_INLINE
|
UNIV_INLINE
|
||||||
|
@ -244,6 +244,18 @@ dtype_get_prtype(
|
||||||
/*=============*/
|
/*=============*/
|
||||||
dtype_t* type);
|
dtype_t* type);
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
Compute the mbminlen and mbmaxlen members of a data type structure. */
|
||||||
|
UNIV_INLINE
|
||||||
|
void
|
||||||
|
dtype_get_mblen(
|
||||||
|
/*============*/
|
||||||
|
ulint mtype, /* in: main type */
|
||||||
|
ulint prtype, /* in: precise type (and collation) */
|
||||||
|
ulint* mbminlen, /* out: minimum length of a
|
||||||
|
multi-byte character */
|
||||||
|
ulint* mbmaxlen); /* out: maximum length of a
|
||||||
|
multi-byte character */
|
||||||
|
/*************************************************************************
|
||||||
Gets the MySQL charset-collation code for MySQL string types. */
|
Gets the MySQL charset-collation code for MySQL string types. */
|
||||||
|
|
||||||
ulint
|
ulint
|
||||||
|
@ -300,50 +312,52 @@ dtype_get_pad_char(
|
||||||
/*===============*/
|
/*===============*/
|
||||||
/* out: padding character code, or
|
/* out: padding character code, or
|
||||||
ULINT_UNDEFINED if no padding specified */
|
ULINT_UNDEFINED if no padding specified */
|
||||||
const dtype_t* type); /* in: type */
|
ulint mtype, /* in: main type */
|
||||||
|
ulint prtype); /* in: precise type */
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
Returns the size of a fixed size data type, 0 if not a fixed size type. */
|
Returns the size of a fixed size data type, 0 if not a fixed size type. */
|
||||||
UNIV_INLINE
|
UNIV_INLINE
|
||||||
ulint
|
ulint
|
||||||
dtype_get_fixed_size(
|
dtype_get_fixed_size_low(
|
||||||
/*=================*/
|
/*=====================*/
|
||||||
/* out: fixed size, or 0 */
|
/* out: fixed size, or 0 */
|
||||||
dtype_t* type); /* in: type */
|
ulint mtype, /* in: main type */
|
||||||
|
ulint prtype, /* in: precise type */
|
||||||
|
ulint len, /* in: length */
|
||||||
|
ulint mbminlen, /* in: minimum length of a multibyte char */
|
||||||
|
ulint mbmaxlen); /* in: maximum length of a multibyte char */
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
Returns the minimum size of a data type. */
|
Returns the minimum size of a data type. */
|
||||||
UNIV_INLINE
|
UNIV_INLINE
|
||||||
ulint
|
ulint
|
||||||
dtype_get_min_size(
|
dtype_get_min_size_low(
|
||||||
/*===============*/
|
/*===================*/
|
||||||
/* out: minimum size */
|
/* out: minimum size */
|
||||||
const dtype_t* type); /* in: type */
|
ulint mtype, /* in: main type */
|
||||||
|
ulint prtype, /* in: precise type */
|
||||||
|
ulint len, /* in: length */
|
||||||
|
ulint mbminlen, /* in: minimum length of a multibyte char */
|
||||||
|
ulint mbmaxlen); /* in: maximum length of a multibyte char */
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
Returns the maximum size of a data type. Note: types in system tables may be
|
Returns the maximum size of a data type. Note: types in system tables may be
|
||||||
incomplete and return incorrect information. */
|
incomplete and return incorrect information. */
|
||||||
|
UNIV_INLINE
|
||||||
ulint
|
ulint
|
||||||
dtype_get_max_size(
|
dtype_get_max_size_low(
|
||||||
/*===============*/
|
/*===================*/
|
||||||
/* out: maximum size (ULINT_MAX for
|
/* out: maximum size */
|
||||||
unbounded types) */
|
ulint mtype, /* in: main type */
|
||||||
const dtype_t* type); /* in: type */
|
ulint len); /* in: length */
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
Returns a stored SQL NULL size for a type. For fixed length types it is
|
Returns the ROW_FORMAT=REDUNDANT stored SQL NULL size of a type.
|
||||||
the fixed length of the type, otherwise 0. */
|
For fixed length types it is the fixed length of the type, otherwise 0. */
|
||||||
UNIV_INLINE
|
UNIV_INLINE
|
||||||
ulint
|
ulint
|
||||||
dtype_get_sql_null_size(
|
dtype_get_sql_null_size(
|
||||||
/*====================*/
|
/*====================*/
|
||||||
/* out: SQL null storage size */
|
/* out: SQL null storage size
|
||||||
dtype_t* type); /* in: type */
|
in ROW_FORMAT=REDUNDANT */
|
||||||
/***************************************************************************
|
const dtype_t* type); /* in: type */
|
||||||
Returns TRUE if a type is of a fixed size. */
|
|
||||||
UNIV_INLINE
|
|
||||||
ibool
|
|
||||||
dtype_is_fixed_size(
|
|
||||||
/*================*/
|
|
||||||
/* out: TRUE if fixed size */
|
|
||||||
dtype_t* type); /* in: type */
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
Reads to a type the stored information which determines its alphabetical
|
Reads to a type the stored information which determines its alphabetical
|
||||||
ordering and the storage size of an SQL NULL value. */
|
ordering and the storage size of an SQL NULL value. */
|
||||||
|
@ -403,24 +417,30 @@ dtype_new_read_for_order_and_null_size()
|
||||||
sym_tab_add_null_lit() */
|
sym_tab_add_null_lit() */
|
||||||
|
|
||||||
struct dtype_struct{
|
struct dtype_struct{
|
||||||
ulint mtype:8; /* main data type */
|
unsigned mtype:8; /* main data type */
|
||||||
ulint prtype:24; /* precise type; MySQL data type, charset code,
|
unsigned prtype:24; /* precise type; MySQL data
|
||||||
flags to indicate nullability, signedness,
|
type, charset code, flags to
|
||||||
whether this is a binary string, whether this
|
indicate nullability,
|
||||||
is a true VARCHAR where MySQL uses 2 bytes to
|
signedness, whether this is a
|
||||||
store the length */
|
binary string, whether this is
|
||||||
|
a true VARCHAR where MySQL
|
||||||
|
uses 2 bytes to store the length */
|
||||||
|
|
||||||
/* the remaining fields do not affect alphabetical ordering: */
|
/* the remaining fields do not affect alphabetical ordering: */
|
||||||
|
|
||||||
ulint mbminlen:2; /* minimum length of a character, in bytes */
|
unsigned len:16; /* length; for MySQL data this
|
||||||
ulint mbmaxlen:3; /* maximum length of a character, in bytes */
|
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 len:16; /* length; for MySQL data this is
|
unsigned mbminlen:2; /* minimum length of a
|
||||||
field->pack_length(), except that for a
|
character, in bytes */
|
||||||
>= 5.0.3 type true VARCHAR this is the
|
unsigned mbmaxlen:3; /* maximum length of a
|
||||||
maximum byte length of the string data
|
character, in bytes */
|
||||||
(in addition to the string, MySQL uses 1 or
|
|
||||||
2 bytes to store the string length) */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef UNIV_NONINL
|
#ifndef UNIV_NONINL
|
||||||
|
|
|
@ -48,37 +48,50 @@ dtype_get_mysql_type(
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
Sets the mbminlen and mbmaxlen members of a data type structure. */
|
Compute the mbminlen and mbmaxlen members of a data type structure. */
|
||||||
|
UNIV_INLINE
|
||||||
|
void
|
||||||
|
dtype_get_mblen(
|
||||||
|
/*============*/
|
||||||
|
ulint mtype, /* in: main type */
|
||||||
|
ulint prtype, /* in: precise type (and collation) */
|
||||||
|
ulint* mbminlen, /* out: minimum length of a
|
||||||
|
multi-byte character */
|
||||||
|
ulint* mbmaxlen) /* out: maximum length of a
|
||||||
|
multi-byte character */
|
||||||
|
{
|
||||||
|
if (dtype_is_string_type(mtype)) {
|
||||||
|
#ifndef UNIV_HOTBACKUP
|
||||||
|
innobase_get_cset_width(dtype_get_charset_coll(prtype),
|
||||||
|
mbminlen, mbmaxlen);
|
||||||
|
ut_ad(*mbminlen <= *mbmaxlen);
|
||||||
|
ut_ad(*mbminlen <= 2); /* cf. the bit-field in dtype_t */
|
||||||
|
ut_ad(*mbmaxlen < 1 << 3); /* cf. the bit-field in dtype_t */
|
||||||
|
#else /* !UNIV_HOTBACKUP */
|
||||||
|
ut_a(mtype <= DATA_BINARY);
|
||||||
|
*mbminlen = *mbmaxlen = 1;
|
||||||
|
#endif /* !UNIV_HOTBACKUP */
|
||||||
|
} else {
|
||||||
|
*mbminlen = *mbmaxlen = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Compute the mbminlen and mbmaxlen members of a data type structure. */
|
||||||
UNIV_INLINE
|
UNIV_INLINE
|
||||||
void
|
void
|
||||||
dtype_set_mblen(
|
dtype_set_mblen(
|
||||||
/*============*/
|
/*============*/
|
||||||
dtype_t* type) /* in/out: type struct */
|
dtype_t* type) /* in/out: type */
|
||||||
{
|
{
|
||||||
ut_ad(type);
|
ulint mbminlen;
|
||||||
if (dtype_is_string_type(type->mtype)) {
|
ulint mbmaxlen;
|
||||||
#ifndef UNIV_HOTBACKUP
|
|
||||||
ulint mbminlen, mbmaxlen;
|
|
||||||
|
|
||||||
innobase_get_cset_width(dtype_get_charset_coll(type->prtype),
|
dtype_get_mblen(type->mtype, type->prtype, &mbminlen, &mbmaxlen);
|
||||||
&mbminlen, &mbmaxlen);
|
type->mbminlen = mbminlen;
|
||||||
ut_ad(mbminlen <= mbmaxlen);
|
type->mbmaxlen = mbmaxlen;
|
||||||
type->mbminlen = mbminlen;
|
|
||||||
type->mbmaxlen = mbmaxlen;
|
ut_ad(dtype_validate(type));
|
||||||
#else /* !UNIV_HOTBACKUP */
|
|
||||||
#ifdef notdefined
|
|
||||||
printf("ibbackup: DEBUG: type->mtype=%lu, type->prtype=%lu\n",
|
|
||||||
type->mtype, type->prtype);
|
|
||||||
#endif
|
|
||||||
ut_a(type->mtype <= DATA_BINARY);
|
|
||||||
#ifdef notdefined
|
|
||||||
ut_a(type->prtype == (DATA_BINARY | DATA_NOT_NULL));
|
|
||||||
#endif
|
|
||||||
type->mbminlen = type->mbmaxlen = 1;
|
|
||||||
#endif /* !UNIV_HOTBACKUP */
|
|
||||||
} else {
|
|
||||||
type->mbminlen = type->mbmaxlen = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
@ -100,7 +113,6 @@ dtype_set(
|
||||||
type->len = len;
|
type->len = len;
|
||||||
|
|
||||||
dtype_set_mblen(type);
|
dtype_set_mblen(type);
|
||||||
ut_ad(dtype_validate(type));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
@ -110,7 +122,7 @@ void
|
||||||
dtype_copy(
|
dtype_copy(
|
||||||
/*=======*/
|
/*=======*/
|
||||||
dtype_t* type1, /* in: type struct to copy to */
|
dtype_t* type1, /* in: type struct to copy to */
|
||||||
dtype_t* type2) /* in: type struct to copy from */
|
const dtype_t* type2) /* in: type struct to copy from */
|
||||||
{
|
{
|
||||||
*type1 = *type2;
|
*type1 = *type2;
|
||||||
|
|
||||||
|
@ -184,19 +196,20 @@ dtype_get_mbmaxlen(
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
Gets the padding character code for the type. */
|
Gets the padding character code for a type. */
|
||||||
UNIV_INLINE
|
UNIV_INLINE
|
||||||
ulint
|
ulint
|
||||||
dtype_get_pad_char(
|
dtype_get_pad_char(
|
||||||
/*===============*/
|
/*===============*/
|
||||||
/* out: padding character code, or
|
/* out: padding character code, or
|
||||||
ULINT_UNDEFINED if no padding specified */
|
ULINT_UNDEFINED if no padding specified */
|
||||||
const dtype_t* type) /* in: type */
|
ulint mtype, /* in: main type */
|
||||||
|
ulint prtype) /* in: precise type */
|
||||||
{
|
{
|
||||||
switch (type->mtype) {
|
switch (mtype) {
|
||||||
case DATA_FIXBINARY:
|
case DATA_FIXBINARY:
|
||||||
case DATA_BINARY:
|
case DATA_BINARY:
|
||||||
if (UNIV_UNLIKELY(dtype_get_charset_coll(type->prtype)
|
if (UNIV_UNLIKELY(dtype_get_charset_coll(prtype)
|
||||||
== DATA_MYSQL_BINARY_CHARSET_COLL)) {
|
== DATA_MYSQL_BINARY_CHARSET_COLL)) {
|
||||||
/* Starting from 5.0.18, do not pad
|
/* Starting from 5.0.18, do not pad
|
||||||
VARBINARY or BINARY columns. */
|
VARBINARY or BINARY columns. */
|
||||||
|
@ -212,7 +225,7 @@ dtype_get_pad_char(
|
||||||
|
|
||||||
return(0x20);
|
return(0x20);
|
||||||
case DATA_BLOB:
|
case DATA_BLOB:
|
||||||
if ((type->prtype & DATA_BINARY_TYPE) == 0) {
|
if (!(prtype & DATA_BINARY_TYPE)) {
|
||||||
return(0x20);
|
return(0x20);
|
||||||
}
|
}
|
||||||
/* Fall through */
|
/* Fall through */
|
||||||
|
@ -278,7 +291,9 @@ dtype_read_for_order_and_null_size(
|
||||||
dtype_t* type, /* in: type struct */
|
dtype_t* type, /* in: type struct */
|
||||||
byte* buf) /* in: buffer for stored type order info */
|
byte* buf) /* in: buffer for stored type order info */
|
||||||
{
|
{
|
||||||
ut_ad(4 == DATA_ORDER_NULL_TYPE_BUF_SIZE);
|
#if 4 != DATA_ORDER_NULL_TYPE_BUF_SIZE
|
||||||
|
# error "4 != DATA_ORDER_NULL_TYPE_BUF_SIZE"
|
||||||
|
#endif
|
||||||
|
|
||||||
type->mtype = buf[0] & 63;
|
type->mtype = buf[0] & 63;
|
||||||
type->prtype = buf[1];
|
type->prtype = buf[1];
|
||||||
|
@ -350,27 +365,27 @@ dtype_new_read_for_order_and_null_size(
|
||||||
Returns the size of a fixed size data type, 0 if not a fixed size type. */
|
Returns the size of a fixed size data type, 0 if not a fixed size type. */
|
||||||
UNIV_INLINE
|
UNIV_INLINE
|
||||||
ulint
|
ulint
|
||||||
dtype_get_fixed_size(
|
dtype_get_fixed_size_low(
|
||||||
/*=================*/
|
/*=====================*/
|
||||||
/* out: fixed size, or 0 */
|
/* out: fixed size, or 0 */
|
||||||
dtype_t* type) /* in: type */
|
ulint mtype, /* in: main type */
|
||||||
|
ulint prtype, /* in: precise type */
|
||||||
|
ulint len, /* in: length */
|
||||||
|
ulint mbminlen, /* in: minimum length of a multibyte char */
|
||||||
|
ulint mbmaxlen) /* in: maximum length of a multibyte char */
|
||||||
{
|
{
|
||||||
ulint mtype;
|
|
||||||
|
|
||||||
mtype = dtype_get_mtype(type);
|
|
||||||
|
|
||||||
switch (mtype) {
|
switch (mtype) {
|
||||||
case DATA_SYS:
|
case DATA_SYS:
|
||||||
#ifdef UNIV_DEBUG
|
#ifdef UNIV_DEBUG
|
||||||
switch (type->prtype & DATA_MYSQL_TYPE_MASK) {
|
switch (prtype & DATA_MYSQL_TYPE_MASK) {
|
||||||
case DATA_ROW_ID:
|
case DATA_ROW_ID:
|
||||||
ut_ad(type->len == DATA_ROW_ID_LEN);
|
ut_ad(len == DATA_ROW_ID_LEN);
|
||||||
break;
|
break;
|
||||||
case DATA_TRX_ID:
|
case DATA_TRX_ID:
|
||||||
ut_ad(type->len == DATA_TRX_ID_LEN);
|
ut_ad(len == DATA_TRX_ID_LEN);
|
||||||
break;
|
break;
|
||||||
case DATA_ROLL_PTR:
|
case DATA_ROLL_PTR:
|
||||||
ut_ad(type->len == DATA_ROLL_PTR_LEN);
|
ut_ad(len == DATA_ROLL_PTR_LEN);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ut_ad(0);
|
ut_ad(0);
|
||||||
|
@ -382,32 +397,32 @@ dtype_get_fixed_size(
|
||||||
case DATA_INT:
|
case DATA_INT:
|
||||||
case DATA_FLOAT:
|
case DATA_FLOAT:
|
||||||
case DATA_DOUBLE:
|
case DATA_DOUBLE:
|
||||||
return(dtype_get_len(type));
|
return(len);
|
||||||
case DATA_MYSQL:
|
case DATA_MYSQL:
|
||||||
if (type->prtype & DATA_BINARY_TYPE) {
|
if (prtype & DATA_BINARY_TYPE) {
|
||||||
return(dtype_get_len(type));
|
return(len);
|
||||||
} else {
|
} else {
|
||||||
#ifdef UNIV_HOTBACKUP
|
#ifdef UNIV_HOTBACKUP
|
||||||
if (type->mbminlen == type->mbmaxlen) {
|
if (mbminlen == mbmaxlen) {
|
||||||
return(dtype_get_len(type));
|
return(len);
|
||||||
}
|
}
|
||||||
#else /* UNIV_HOTBACKUP */
|
#else /* UNIV_HOTBACKUP */
|
||||||
/* We play it safe here and ask MySQL for
|
/* We play it safe here and ask MySQL for
|
||||||
mbminlen and mbmaxlen. Although
|
mbminlen and mbmaxlen. Although
|
||||||
type->mbminlen and type->mbmaxlen are
|
mbminlen and mbmaxlen are
|
||||||
initialized if and only if type->prtype
|
initialized if and only if prtype
|
||||||
is (in one of the 3 functions in this file),
|
is (in one of the 3 functions in this file),
|
||||||
it could be that none of these functions
|
it could be that none of these functions
|
||||||
has been called. */
|
has been called. */
|
||||||
|
|
||||||
ulint mbminlen, mbmaxlen;
|
ulint i_mbminlen, i_mbmaxlen;
|
||||||
|
|
||||||
innobase_get_cset_width
|
innobase_get_cset_width
|
||||||
(dtype_get_charset_coll(type->prtype),
|
(dtype_get_charset_coll(prtype),
|
||||||
&mbminlen, &mbmaxlen);
|
&i_mbminlen, &i_mbmaxlen);
|
||||||
|
|
||||||
if (UNIV_UNLIKELY(type->mbminlen != mbminlen)
|
if (UNIV_UNLIKELY(mbminlen != i_mbminlen)
|
||||||
|| UNIV_UNLIKELY(type->mbmaxlen != mbmaxlen)) {
|
|| UNIV_UNLIKELY(mbmaxlen != i_mbmaxlen)) {
|
||||||
|
|
||||||
ut_print_timestamp(stderr);
|
ut_print_timestamp(stderr);
|
||||||
fprintf(stderr, " InnoDB: "
|
fprintf(stderr, " InnoDB: "
|
||||||
|
@ -415,13 +430,13 @@ dtype_get_fixed_size(
|
||||||
"mbmaxlen=%lu, "
|
"mbmaxlen=%lu, "
|
||||||
"type->mbminlen=%lu, "
|
"type->mbminlen=%lu, "
|
||||||
"type->mbmaxlen=%lu\n",
|
"type->mbmaxlen=%lu\n",
|
||||||
|
(ulong) i_mbminlen,
|
||||||
|
(ulong) i_mbmaxlen,
|
||||||
(ulong) mbminlen,
|
(ulong) mbminlen,
|
||||||
(ulong) mbmaxlen,
|
(ulong) mbmaxlen);
|
||||||
(ulong) type->mbminlen,
|
|
||||||
(ulong) type->mbmaxlen);
|
|
||||||
}
|
}
|
||||||
if (mbminlen == mbmaxlen) {
|
if (mbminlen == mbmaxlen) {
|
||||||
return(dtype_get_len(type));
|
return(len);
|
||||||
}
|
}
|
||||||
#endif /* !UNIV_HOTBACKUP */
|
#endif /* !UNIV_HOTBACKUP */
|
||||||
}
|
}
|
||||||
|
@ -443,23 +458,27 @@ dtype_get_fixed_size(
|
||||||
Returns the minimum size of a data type. */
|
Returns the minimum size of a data type. */
|
||||||
UNIV_INLINE
|
UNIV_INLINE
|
||||||
ulint
|
ulint
|
||||||
dtype_get_min_size(
|
dtype_get_min_size_low(
|
||||||
/*===============*/
|
/*===================*/
|
||||||
/* out: minimum size */
|
/* out: minimum size */
|
||||||
const dtype_t* type) /* in: type */
|
ulint mtype, /* in: main type */
|
||||||
|
ulint prtype, /* in: precise type */
|
||||||
|
ulint len, /* in: length */
|
||||||
|
ulint mbminlen, /* in: minimum length of a multibyte char */
|
||||||
|
ulint mbmaxlen) /* in: maximum length of a multibyte char */
|
||||||
{
|
{
|
||||||
switch (type->mtype) {
|
switch (mtype) {
|
||||||
case DATA_SYS:
|
case DATA_SYS:
|
||||||
#ifdef UNIV_DEBUG
|
#ifdef UNIV_DEBUG
|
||||||
switch (type->prtype & DATA_MYSQL_TYPE_MASK) {
|
switch (prtype & DATA_MYSQL_TYPE_MASK) {
|
||||||
case DATA_ROW_ID:
|
case DATA_ROW_ID:
|
||||||
ut_ad(type->len == DATA_ROW_ID_LEN);
|
ut_ad(len == DATA_ROW_ID_LEN);
|
||||||
break;
|
break;
|
||||||
case DATA_TRX_ID:
|
case DATA_TRX_ID:
|
||||||
ut_ad(type->len == DATA_TRX_ID_LEN);
|
ut_ad(len == DATA_TRX_ID_LEN);
|
||||||
break;
|
break;
|
||||||
case DATA_ROLL_PTR:
|
case DATA_ROLL_PTR:
|
||||||
ut_ad(type->len == DATA_ROLL_PTR_LEN);
|
ut_ad(len == DATA_ROLL_PTR_LEN);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ut_ad(0);
|
ut_ad(0);
|
||||||
|
@ -471,58 +490,73 @@ dtype_get_min_size(
|
||||||
case DATA_INT:
|
case DATA_INT:
|
||||||
case DATA_FLOAT:
|
case DATA_FLOAT:
|
||||||
case DATA_DOUBLE:
|
case DATA_DOUBLE:
|
||||||
return(type->len);
|
return(len);
|
||||||
case DATA_MYSQL:
|
case DATA_MYSQL:
|
||||||
if ((type->prtype & DATA_BINARY_TYPE)
|
if ((prtype & DATA_BINARY_TYPE) || mbminlen == mbmaxlen) {
|
||||||
|| type->mbminlen == type->mbmaxlen) {
|
return(len);
|
||||||
return(type->len);
|
|
||||||
}
|
}
|
||||||
/* this is a variable-length character set */
|
/* this is a variable-length character set */
|
||||||
ut_a(type->mbminlen > 0);
|
ut_a(mbminlen > 0);
|
||||||
ut_a(type->mbmaxlen > type->mbminlen);
|
ut_a(mbmaxlen > mbminlen);
|
||||||
ut_a(type->len % type->mbmaxlen == 0);
|
ut_a(len % mbmaxlen == 0);
|
||||||
return(type->len * type->mbminlen / type->mbmaxlen);
|
return(len * mbminlen / mbmaxlen);
|
||||||
case DATA_VARCHAR:
|
case DATA_VARCHAR:
|
||||||
case DATA_BINARY:
|
case DATA_BINARY:
|
||||||
case DATA_DECIMAL:
|
case DATA_DECIMAL:
|
||||||
case DATA_VARMYSQL:
|
case DATA_VARMYSQL:
|
||||||
case DATA_BLOB:
|
case DATA_BLOB:
|
||||||
return(0);
|
return(0);
|
||||||
default: ut_error;
|
default:
|
||||||
|
ut_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
Returns a stored SQL NULL size for a type. For fixed length types it is
|
Returns the maximum size of a data type. Note: types in system tables may be
|
||||||
the fixed length of the type, otherwise 0. */
|
incomplete and return incorrect information. */
|
||||||
|
UNIV_INLINE
|
||||||
|
ulint
|
||||||
|
dtype_get_max_size_low(
|
||||||
|
/*===================*/
|
||||||
|
/* out: maximum size */
|
||||||
|
ulint mtype, /* in: main type */
|
||||||
|
ulint len) /* in: length */
|
||||||
|
{
|
||||||
|
switch (mtype) {
|
||||||
|
case DATA_SYS:
|
||||||
|
case DATA_CHAR:
|
||||||
|
case DATA_FIXBINARY:
|
||||||
|
case DATA_INT:
|
||||||
|
case DATA_FLOAT:
|
||||||
|
case DATA_DOUBLE:
|
||||||
|
case DATA_MYSQL:
|
||||||
|
case DATA_VARCHAR:
|
||||||
|
case DATA_BINARY:
|
||||||
|
case DATA_DECIMAL:
|
||||||
|
case DATA_VARMYSQL:
|
||||||
|
return(len);
|
||||||
|
case DATA_BLOB:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ut_error;
|
||||||
|
}
|
||||||
|
|
||||||
|
return(ULINT_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
Returns the ROW_FORMAT=REDUNDANT stored SQL NULL size of a type.
|
||||||
|
For fixed length types it is the fixed length of the type, otherwise 0. */
|
||||||
UNIV_INLINE
|
UNIV_INLINE
|
||||||
ulint
|
ulint
|
||||||
dtype_get_sql_null_size(
|
dtype_get_sql_null_size(
|
||||||
/*====================*/
|
/*====================*/
|
||||||
/* out: SQL null storage size */
|
/* out: SQL null storage size
|
||||||
dtype_t* type) /* in: type */
|
in ROW_FORMAT=REDUNDANT */
|
||||||
|
const dtype_t* type) /* in: type */
|
||||||
{
|
{
|
||||||
return(dtype_get_fixed_size(type));
|
return(dtype_get_fixed_size_low(type->mtype, type->prtype, type->len,
|
||||||
}
|
type->mbminlen, type->mbmaxlen) > 0);
|
||||||
|
|
||||||
/***************************************************************************
|
|
||||||
Returns TRUE if a type is of a fixed size. */
|
|
||||||
UNIV_INLINE
|
|
||||||
ibool
|
|
||||||
dtype_is_fixed_size(
|
|
||||||
/*================*/
|
|
||||||
/* out: TRUE if fixed size */
|
|
||||||
dtype_t* type) /* in: type */
|
|
||||||
{
|
|
||||||
ulint size;
|
|
||||||
|
|
||||||
size = dtype_get_fixed_size(type);
|
|
||||||
|
|
||||||
if (size) {
|
|
||||||
return(TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return(FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,17 +79,61 @@ dict_load_space_id_list(void);
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
Gets the column data type. */
|
Gets the column data type. */
|
||||||
UNIV_INLINE
|
UNIV_INLINE
|
||||||
dtype_t*
|
void
|
||||||
dict_col_get_type(
|
dict_col_copy_type(
|
||||||
/*==============*/
|
/*===============*/
|
||||||
dict_col_t* col);
|
const dict_col_t* col, /* in: column */
|
||||||
|
dtype_t* type); /* out: data type */
|
||||||
|
/*************************************************************************
|
||||||
|
Gets the column data type. */
|
||||||
|
|
||||||
|
void
|
||||||
|
dict_col_copy_type_noninline(
|
||||||
|
/*=========================*/
|
||||||
|
const dict_col_t* col, /* in: column */
|
||||||
|
dtype_t* type); /* out: data type */
|
||||||
|
/***************************************************************************
|
||||||
|
Returns the minimum size of the column. */
|
||||||
|
UNIV_INLINE
|
||||||
|
ulint
|
||||||
|
dict_col_get_min_size(
|
||||||
|
/*==================*/
|
||||||
|
/* out: minimum size */
|
||||||
|
const dict_col_t* col); /* in: column */
|
||||||
|
/***************************************************************************
|
||||||
|
Returns the maximum size of the column. */
|
||||||
|
UNIV_INLINE
|
||||||
|
ulint
|
||||||
|
dict_col_get_max_size(
|
||||||
|
/*==================*/
|
||||||
|
/* out: maximum size */
|
||||||
|
const dict_col_t* col); /* in: column */
|
||||||
|
/***************************************************************************
|
||||||
|
Returns the size of a fixed size column, 0 if not a fixed size column. */
|
||||||
|
UNIV_INLINE
|
||||||
|
ulint
|
||||||
|
dict_col_get_fixed_size(
|
||||||
|
/*====================*/
|
||||||
|
/* out: fixed size, or 0 */
|
||||||
|
const dict_col_t* col); /* in: column */
|
||||||
|
/***************************************************************************
|
||||||
|
Returns the ROW_FORMAT=REDUNDANT stored SQL NULL size of a column.
|
||||||
|
For fixed length types it is the fixed length of the type, otherwise 0. */
|
||||||
|
UNIV_INLINE
|
||||||
|
ulint
|
||||||
|
dict_col_get_sql_null_size(
|
||||||
|
/*=======================*/
|
||||||
|
/* out: SQL null storage size
|
||||||
|
in ROW_FORMAT=REDUNDANT */
|
||||||
|
const dict_col_t* col); /* in: column */
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
Gets the column number. */
|
Gets the column number. */
|
||||||
UNIV_INLINE
|
UNIV_INLINE
|
||||||
ulint
|
ulint
|
||||||
dict_col_get_no(
|
dict_col_get_no(
|
||||||
/*============*/
|
/*============*/
|
||||||
dict_col_t* col);
|
const dict_col_t* col);
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
Gets the column position in the clustered index. */
|
Gets the column position in the clustered index. */
|
||||||
UNIV_INLINE
|
UNIV_INLINE
|
||||||
|
@ -368,11 +412,12 @@ Returns a column's name. */
|
||||||
const char*
|
const char*
|
||||||
dict_table_get_col_name(
|
dict_table_get_col_name(
|
||||||
/*====================*/
|
/*====================*/
|
||||||
/* out: column name. NOTE: not guaranteed to
|
/* out: column name. NOTE: not
|
||||||
stay valid if table is modified in any way
|
guaranteed to stay valid if
|
||||||
(columns added, etc.). */
|
table is modified in any way
|
||||||
dict_table_t* table, /* in: table */
|
(columns added, etc.). */
|
||||||
ulint i); /* in: column number */
|
const dict_table_t* table, /* in: table */
|
||||||
|
ulint i); /* in: column number */
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
Prints a table definition. */
|
Prints a table definition. */
|
||||||
|
|
||||||
|
@ -488,30 +533,30 @@ dict_table_get_n_cols(
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
Gets the nth column of a table. */
|
Gets the nth column of a table. */
|
||||||
UNIV_INLINE
|
UNIV_INLINE
|
||||||
dict_col_t*
|
const dict_col_t*
|
||||||
dict_table_get_nth_col(
|
dict_table_get_nth_col(
|
||||||
/*===================*/
|
/*===================*/
|
||||||
/* out: pointer to column object */
|
/* out: pointer to column object */
|
||||||
dict_table_t* table, /* in: table */
|
const dict_table_t* table, /* in: table */
|
||||||
ulint pos); /* in: position of column */
|
ulint pos); /* in: position of column */
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
Gets the nth column of a table. */
|
Gets the nth column of a table. */
|
||||||
|
|
||||||
dict_col_t*
|
const dict_col_t*
|
||||||
dict_table_get_nth_col_noninline(
|
dict_table_get_nth_col_noninline(
|
||||||
/*=============================*/
|
/*=============================*/
|
||||||
/* out: pointer to column object */
|
/* out: pointer to column object */
|
||||||
dict_table_t* table, /* in: table */
|
const dict_table_t* table, /* in: table */
|
||||||
ulint pos); /* in: position of column */
|
ulint pos); /* in: position of column */
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
Gets the given system column of a table. */
|
Gets the given system column of a table. */
|
||||||
UNIV_INLINE
|
UNIV_INLINE
|
||||||
dict_col_t*
|
const dict_col_t*
|
||||||
dict_table_get_sys_col(
|
dict_table_get_sys_col(
|
||||||
/*===================*/
|
/*===================*/
|
||||||
/* out: pointer to column object */
|
/* out: pointer to column object */
|
||||||
dict_table_t* table, /* in: table */
|
const dict_table_t* table, /* in: table */
|
||||||
ulint sys); /* in: DATA_ROW_ID, ... */
|
ulint sys); /* in: DATA_ROW_ID, ... */
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
Gets the given system column number of a table. */
|
Gets the given system column number of a table. */
|
||||||
UNIV_INLINE
|
UNIV_INLINE
|
||||||
|
@ -633,23 +678,23 @@ dict_index_get_nth_field(
|
||||||
dict_index_t* index, /* in: index */
|
dict_index_t* index, /* in: index */
|
||||||
ulint pos); /* in: position of field */
|
ulint pos); /* in: position of field */
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
Gets pointer to the nth field data type in an index. */
|
Gets pointer to the nth column in an index. */
|
||||||
UNIV_INLINE
|
UNIV_INLINE
|
||||||
dtype_t*
|
const dict_col_t*
|
||||||
dict_index_get_nth_type(
|
dict_index_get_nth_col(
|
||||||
/*====================*/
|
/*===================*/
|
||||||
/* out: data type */
|
/* out: column */
|
||||||
dict_index_t* index, /* in: index */
|
const dict_index_t* index, /* in: index */
|
||||||
ulint pos); /* in: position of the field */
|
ulint pos); /* in: position of the field */
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
Gets the column number of the nth field in an index. */
|
Gets the column number of the nth field in an index. */
|
||||||
UNIV_INLINE
|
UNIV_INLINE
|
||||||
ulint
|
ulint
|
||||||
dict_index_get_nth_col_no(
|
dict_index_get_nth_col_no(
|
||||||
/*======================*/
|
/*======================*/
|
||||||
/* out: column number */
|
/* out: column number */
|
||||||
dict_index_t* index, /* in: index */
|
const dict_index_t* index, /* in: index */
|
||||||
ulint pos); /* in: position of the field */
|
ulint pos); /* in: position of the field */
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
Looks for column n in an index. */
|
Looks for column n in an index. */
|
||||||
|
|
||||||
|
@ -728,10 +773,10 @@ dict_index_copy_types(
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
Gets the field column. */
|
Gets the field column. */
|
||||||
UNIV_INLINE
|
UNIV_INLINE
|
||||||
dict_col_t*
|
const dict_col_t*
|
||||||
dict_field_get_col(
|
dict_field_get_col(
|
||||||
/*===============*/
|
/*===============*/
|
||||||
dict_field_t* field);
|
const dict_field_t* field);
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
In an index tree, finds the index corresponding to a record in the tree. */
|
In an index tree, finds the index corresponding to a record in the tree. */
|
||||||
|
|
||||||
|
|
|
@ -10,18 +10,73 @@ Created 1/8/1996 Heikki Tuuri
|
||||||
#include "trx0undo.h"
|
#include "trx0undo.h"
|
||||||
#include "trx0sys.h"
|
#include "trx0sys.h"
|
||||||
#include "rem0types.h"
|
#include "rem0types.h"
|
||||||
|
#include "data0type.h"
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
Gets the column data type. */
|
Gets the column data type. */
|
||||||
UNIV_INLINE
|
UNIV_INLINE
|
||||||
dtype_t*
|
void
|
||||||
dict_col_get_type(
|
dict_col_copy_type(
|
||||||
/*==============*/
|
/*===============*/
|
||||||
dict_col_t* col)
|
const dict_col_t* col, /* in: column */
|
||||||
|
dtype_t* type) /* out: data type */
|
||||||
{
|
{
|
||||||
ut_ad(col);
|
ut_ad(col && type);
|
||||||
|
|
||||||
return(&col->type);
|
type->mtype = col->mtype;
|
||||||
|
type->prtype = col->prtype;
|
||||||
|
type->len = col->len;
|
||||||
|
type->mbminlen = col->mbminlen;
|
||||||
|
type->mbmaxlen = col->mbmaxlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
Returns the minimum size of the column. */
|
||||||
|
UNIV_INLINE
|
||||||
|
ulint
|
||||||
|
dict_col_get_min_size(
|
||||||
|
/*==================*/
|
||||||
|
/* out: minimum size */
|
||||||
|
const dict_col_t* col) /* in: column */
|
||||||
|
{
|
||||||
|
return(dtype_get_min_size_low(col->mtype, col->prtype, col->len,
|
||||||
|
col->mbminlen, col->mbmaxlen));
|
||||||
|
}
|
||||||
|
/***************************************************************************
|
||||||
|
Returns the maximum size of the column. */
|
||||||
|
UNIV_INLINE
|
||||||
|
ulint
|
||||||
|
dict_col_get_max_size(
|
||||||
|
/*==================*/
|
||||||
|
/* out: maximum size */
|
||||||
|
const dict_col_t* col) /* in: column */
|
||||||
|
{
|
||||||
|
return(dtype_get_max_size_low(col->mtype, col->len));
|
||||||
|
}
|
||||||
|
/***************************************************************************
|
||||||
|
Returns the size of a fixed size column, 0 if not a fixed size column. */
|
||||||
|
UNIV_INLINE
|
||||||
|
ulint
|
||||||
|
dict_col_get_fixed_size(
|
||||||
|
/*====================*/
|
||||||
|
/* out: fixed size, or 0 */
|
||||||
|
const dict_col_t* col) /* in: column */
|
||||||
|
{
|
||||||
|
return(dtype_get_fixed_size_low(col->mtype, col->prtype, col->len,
|
||||||
|
col->mbminlen, col->mbmaxlen));
|
||||||
|
}
|
||||||
|
/***************************************************************************
|
||||||
|
Returns the ROW_FORMAT=REDUNDANT stored SQL NULL size of a column.
|
||||||
|
For fixed length types it is the fixed length of the type, otherwise 0. */
|
||||||
|
UNIV_INLINE
|
||||||
|
ulint
|
||||||
|
dict_col_get_sql_null_size(
|
||||||
|
/*=======================*/
|
||||||
|
/* out: SQL null storage size
|
||||||
|
in ROW_FORMAT=REDUNDANT */
|
||||||
|
const dict_col_t* col) /* in: column */
|
||||||
|
{
|
||||||
|
return(dict_col_get_fixed_size(col));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
@ -30,7 +85,7 @@ UNIV_INLINE
|
||||||
ulint
|
ulint
|
||||||
dict_col_get_no(
|
dict_col_get_no(
|
||||||
/*============*/
|
/*============*/
|
||||||
dict_col_t* col)
|
const dict_col_t* col)
|
||||||
{
|
{
|
||||||
ut_ad(col);
|
ut_ad(col);
|
||||||
|
|
||||||
|
@ -145,12 +200,12 @@ dict_table_get_n_cols(
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
Gets the nth column of a table. */
|
Gets the nth column of a table. */
|
||||||
UNIV_INLINE
|
UNIV_INLINE
|
||||||
dict_col_t*
|
const dict_col_t*
|
||||||
dict_table_get_nth_col(
|
dict_table_get_nth_col(
|
||||||
/*===================*/
|
/*===================*/
|
||||||
/* out: pointer to column object */
|
/* out: pointer to column object */
|
||||||
dict_table_t* table, /* in: table */
|
const dict_table_t* table, /* in: table */
|
||||||
ulint pos) /* in: position of column */
|
ulint pos) /* in: position of column */
|
||||||
{
|
{
|
||||||
ut_ad(table);
|
ut_ad(table);
|
||||||
ut_ad(pos < table->n_def);
|
ut_ad(pos < table->n_def);
|
||||||
|
@ -162,14 +217,14 @@ dict_table_get_nth_col(
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
Gets the given system column of a table. */
|
Gets the given system column of a table. */
|
||||||
UNIV_INLINE
|
UNIV_INLINE
|
||||||
dict_col_t*
|
const dict_col_t*
|
||||||
dict_table_get_sys_col(
|
dict_table_get_sys_col(
|
||||||
/*===================*/
|
/*===================*/
|
||||||
/* out: pointer to column object */
|
/* out: pointer to column object */
|
||||||
dict_table_t* table, /* in: table */
|
const dict_table_t* table, /* in: table */
|
||||||
ulint sys) /* in: DATA_ROW_ID, ... */
|
ulint sys) /* in: DATA_ROW_ID, ... */
|
||||||
{
|
{
|
||||||
dict_col_t* col;
|
const dict_col_t* col;
|
||||||
|
|
||||||
ut_ad(table);
|
ut_ad(table);
|
||||||
ut_ad(sys < DATA_N_SYS_COLS);
|
ut_ad(sys < DATA_N_SYS_COLS);
|
||||||
|
@ -177,8 +232,8 @@ dict_table_get_sys_col(
|
||||||
|
|
||||||
col = dict_table_get_nth_col(table, table->n_cols
|
col = dict_table_get_nth_col(table, table->n_cols
|
||||||
- DATA_N_SYS_COLS + sys);
|
- DATA_N_SYS_COLS + sys);
|
||||||
ut_ad(col->type.mtype == DATA_SYS);
|
ut_ad(col->mtype == DATA_SYS);
|
||||||
ut_ad(col->type.prtype == (sys | DATA_NOT_NULL));
|
ut_ad(col->prtype == (sys | DATA_NOT_NULL));
|
||||||
|
|
||||||
return(col);
|
return(col);
|
||||||
}
|
}
|
||||||
|
@ -324,30 +379,28 @@ dict_index_get_sys_col_pos(
|
||||||
dict_index_t* index, /* in: index */
|
dict_index_t* index, /* in: index */
|
||||||
ulint type) /* in: DATA_ROW_ID, ... */
|
ulint type) /* in: DATA_ROW_ID, ... */
|
||||||
{
|
{
|
||||||
dict_col_t* col;
|
|
||||||
|
|
||||||
ut_ad(index);
|
ut_ad(index);
|
||||||
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
|
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
|
||||||
ut_ad(!(index->type & DICT_UNIVERSAL));
|
ut_ad(!(index->type & DICT_UNIVERSAL));
|
||||||
|
|
||||||
col = dict_table_get_sys_col(index->table, type);
|
|
||||||
|
|
||||||
if (index->type & DICT_CLUSTERED) {
|
if (index->type & DICT_CLUSTERED) {
|
||||||
|
|
||||||
return(dict_col_get_clust_pos(col, index));
|
return(dict_col_get_clust_pos(
|
||||||
|
dict_table_get_sys_col(index->table, type),
|
||||||
|
index));
|
||||||
}
|
}
|
||||||
|
|
||||||
return(dict_index_get_nth_col_pos
|
return(dict_index_get_nth_col_pos(
|
||||||
(index, dict_table_get_sys_col_no(index->table, type)));
|
index, dict_table_get_sys_col_no(index->table, type)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
Gets the field column. */
|
Gets the field column. */
|
||||||
UNIV_INLINE
|
UNIV_INLINE
|
||||||
dict_col_t*
|
const dict_col_t*
|
||||||
dict_field_get_col(
|
dict_field_get_col(
|
||||||
/*===============*/
|
/*===============*/
|
||||||
dict_field_t* field)
|
const dict_field_t* field)
|
||||||
{
|
{
|
||||||
ut_ad(field);
|
ut_ad(field);
|
||||||
|
|
||||||
|
@ -355,17 +408,17 @@ dict_field_get_col(
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
Gets pointer to the nth field data type in an index. */
|
Gets pointer to the nth column in an index. */
|
||||||
UNIV_INLINE
|
UNIV_INLINE
|
||||||
dtype_t*
|
const dict_col_t*
|
||||||
dict_index_get_nth_type(
|
dict_index_get_nth_col(
|
||||||
/*====================*/
|
/*===================*/
|
||||||
/* out: data type */
|
/* out: column */
|
||||||
dict_index_t* index, /* in: index */
|
const dict_index_t* index, /* in: index */
|
||||||
ulint pos) /* in: position of the field */
|
ulint pos) /* in: position of the field */
|
||||||
{
|
{
|
||||||
return(dict_col_get_type(dict_field_get_col
|
return(dict_field_get_col(dict_index_get_nth_field((dict_index_t*)
|
||||||
(dict_index_get_nth_field(index, pos))));
|
index, pos)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
|
@ -374,12 +427,11 @@ UNIV_INLINE
|
||||||
ulint
|
ulint
|
||||||
dict_index_get_nth_col_no(
|
dict_index_get_nth_col_no(
|
||||||
/*======================*/
|
/*======================*/
|
||||||
/* out: column number */
|
/* out: column number */
|
||||||
dict_index_t* index, /* in: index */
|
const dict_index_t* index, /* in: index */
|
||||||
ulint pos) /* in: position of the field */
|
ulint pos) /* in: position of the field */
|
||||||
{
|
{
|
||||||
return(dict_col_get_no(dict_field_get_col
|
return(dict_col_get_no(dict_index_get_nth_col(index, pos)));
|
||||||
(dict_index_get_nth_field(index, pos))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
|
|
@ -121,12 +121,43 @@ dict_mem_foreign_create(void);
|
||||||
|
|
||||||
/* Data structure for a column in a table */
|
/* Data structure for a column in a table */
|
||||||
struct dict_col_struct{
|
struct dict_col_struct{
|
||||||
ulint ind:10; /* table column position (they are numbered
|
/*----------------------*/
|
||||||
starting from 0) */
|
/* The following are copied from dtype_t,
|
||||||
ulint ord_part:1;/* nonzero if this column appears
|
so that all bit-fields can be packed tightly. */
|
||||||
in ordering fields of an index */
|
unsigned mtype:8; /* main data type */
|
||||||
const char* name; /* name */
|
unsigned prtype:24; /* precise type; MySQL data
|
||||||
dtype_t type; /* data type */
|
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 store the length */
|
||||||
|
|
||||||
|
/* the remaining fields do not affect alphabetical ordering: */
|
||||||
|
|
||||||
|
unsigned 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) */
|
||||||
|
|
||||||
|
unsigned mbminlen:2; /* minimum length of a
|
||||||
|
character, in bytes */
|
||||||
|
unsigned mbmaxlen:3; /* maximum length of a
|
||||||
|
character, in bytes */
|
||||||
|
/*----------------------*/
|
||||||
|
/* End of definitions copied from dtype_t */
|
||||||
|
|
||||||
|
unsigned ind:10; /* table column position
|
||||||
|
(starting from 0) */
|
||||||
|
unsigned ord_part:1; /* nonzero if this column
|
||||||
|
appears in the ordering fields
|
||||||
|
of an index */
|
||||||
|
|
||||||
|
const char* name; /* name */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* DICT_MAX_INDEX_COL_LEN is measured in bytes and is the max index column
|
/* DICT_MAX_INDEX_COL_LEN is measured in bytes and is the max index column
|
||||||
|
|
|
@ -16,16 +16,17 @@ Created 7/1/1994 Heikki Tuuri
|
||||||
#include "rem0rec.h"
|
#include "rem0rec.h"
|
||||||
|
|
||||||
/*****************************************************************
|
/*****************************************************************
|
||||||
Returns TRUE if two types are equal for comparison purposes. */
|
Returns TRUE if two columns are equal for comparison purposes. */
|
||||||
|
|
||||||
ibool
|
ibool
|
||||||
cmp_types_are_equal(
|
cmp_cols_are_equal(
|
||||||
/*================*/
|
/*===============*/
|
||||||
/* out: TRUE if the types are considered
|
/* out: TRUE if the columns are
|
||||||
equal in comparisons */
|
considered equal in comparisons */
|
||||||
dtype_t* type1, /* in: type 1 */
|
const dict_col_t* col1, /* in: column 1 */
|
||||||
dtype_t* type2, /* in: type 2 */
|
const dict_col_t* col2, /* in: column 2 */
|
||||||
ibool check_charsets); /* in: whether to check charsets */
|
ibool check_charsets);
|
||||||
|
/* in: whether to check charsets */
|
||||||
/*****************************************************************
|
/*****************************************************************
|
||||||
This function is used to compare two data fields for which we know the
|
This function is used to compare two data fields for which we know the
|
||||||
data type. */
|
data type. */
|
||||||
|
@ -35,7 +36,8 @@ cmp_data_data(
|
||||||
/*==========*/
|
/*==========*/
|
||||||
/* out: 1, 0, -1, if data1 is greater, equal,
|
/* out: 1, 0, -1, if data1 is greater, equal,
|
||||||
less than data2, respectively */
|
less than data2, respectively */
|
||||||
dtype_t* cur_type,/* in: data type of the fields */
|
ulint mtype, /* in: main type */
|
||||||
|
ulint prtype, /* in: precise type */
|
||||||
byte* data1, /* in: data field (== a pointer to a memory
|
byte* data1, /* in: data field (== a pointer to a memory
|
||||||
buffer) */
|
buffer) */
|
||||||
ulint len1, /* in: data field length or UNIV_SQL_NULL */
|
ulint len1, /* in: data field length or UNIV_SQL_NULL */
|
||||||
|
@ -51,7 +53,8 @@ cmp_data_data_slow(
|
||||||
/*===============*/
|
/*===============*/
|
||||||
/* out: 1, 0, -1, if data1 is greater, equal,
|
/* out: 1, 0, -1, if data1 is greater, equal,
|
||||||
less than data2, respectively */
|
less than data2, respectively */
|
||||||
dtype_t* cur_type,/* in: data type of the fields */
|
ulint mtype, /* in: main type */
|
||||||
|
ulint prtype, /* in: precise type */
|
||||||
byte* data1, /* in: data field (== a pointer to a memory
|
byte* data1, /* in: data field (== a pointer to a memory
|
||||||
buffer) */
|
buffer) */
|
||||||
ulint len1, /* in: data field length or UNIV_SQL_NULL */
|
ulint len1, /* in: data field length or UNIV_SQL_NULL */
|
||||||
|
|
|
@ -15,7 +15,8 @@ cmp_data_data(
|
||||||
/*==========*/
|
/*==========*/
|
||||||
/* out: 1, 0, -1, if data1 is greater, equal,
|
/* out: 1, 0, -1, if data1 is greater, equal,
|
||||||
less than data2, respectively */
|
less than data2, respectively */
|
||||||
dtype_t* cur_type,/* in: data type of the fields */
|
ulint mtype, /* in: main type */
|
||||||
|
ulint prtype, /* in: precise type */
|
||||||
byte* data1, /* in: data field (== a pointer to a memory
|
byte* data1, /* in: data field (== a pointer to a memory
|
||||||
buffer) */
|
buffer) */
|
||||||
ulint len1, /* in: data field length or UNIV_SQL_NULL */
|
ulint len1, /* in: data field length or UNIV_SQL_NULL */
|
||||||
|
@ -23,7 +24,7 @@ cmp_data_data(
|
||||||
buffer) */
|
buffer) */
|
||||||
ulint len2) /* in: data field length or UNIV_SQL_NULL */
|
ulint len2) /* in: data field length or UNIV_SQL_NULL */
|
||||||
{
|
{
|
||||||
return(cmp_data_data_slow(cur_type, data1, len1, data2, len2));
|
return(cmp_data_data_slow(mtype, prtype, data1, len1, data2, len2));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************
|
/*****************************************************************
|
||||||
|
@ -38,12 +39,17 @@ cmp_dfield_dfield(
|
||||||
dfield_t* dfield1,/* in: data field; must have type field set */
|
dfield_t* dfield1,/* in: data field; must have type field set */
|
||||||
dfield_t* dfield2)/* in: data field */
|
dfield_t* dfield2)/* in: data field */
|
||||||
{
|
{
|
||||||
|
const dtype_t* type;
|
||||||
|
|
||||||
ut_ad(dfield_check_typed(dfield1));
|
ut_ad(dfield_check_typed(dfield1));
|
||||||
|
|
||||||
return(cmp_data_data
|
type = dfield_get_type(dfield1);
|
||||||
(dfield_get_type(dfield1),
|
|
||||||
dfield_get_data(dfield1), dfield_get_len(dfield1),
|
return(cmp_data_data(type->mtype, type->prtype,
|
||||||
dfield_get_data(dfield2), dfield_get_len(dfield2)));
|
dfield_get_data(dfield1),
|
||||||
|
dfield_get_len(dfield1),
|
||||||
|
dfield_get_data(dfield2),
|
||||||
|
dfield_get_len(dfield2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************
|
/*****************************************************************
|
||||||
|
|
|
@ -93,8 +93,8 @@ upd_field_set_field_no(
|
||||||
(ulong) dict_index_get_n_fields(index));
|
(ulong) dict_index_get_n_fields(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
dtype_copy(dfield_get_type(&(upd_field->new_val)),
|
dict_col_copy_type(dict_index_get_nth_col(index, field_no),
|
||||||
dict_index_get_nth_type(index, field_no));
|
dfield_get_type(&(upd_field->new_val)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
|
|
@ -445,21 +445,21 @@ mlog_open_and_write_index(
|
||||||
dict_index_get_n_unique_in_tree(index));
|
dict_index_get_n_unique_in_tree(index));
|
||||||
log_ptr += 2;
|
log_ptr += 2;
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
dict_field_t* field;
|
dict_field_t* field;
|
||||||
dtype_t* type;
|
const dict_col_t* col;
|
||||||
ulint len;
|
ulint len;
|
||||||
|
|
||||||
field = dict_index_get_nth_field(index, i);
|
field = dict_index_get_nth_field(index, i);
|
||||||
type = dict_col_get_type(dict_field_get_col(field));
|
col = dict_field_get_col(field);
|
||||||
len = field->fixed_len;
|
len = field->fixed_len;
|
||||||
ut_ad(len < 0x7fff);
|
ut_ad(len < 0x7fff);
|
||||||
if (len == 0
|
if (len == 0
|
||||||
&& (dtype_get_len(type) > 255
|
&& (col->len > 255 || col->mtype == DATA_BLOB)) {
|
||||||
|| dtype_get_mtype(type) == DATA_BLOB)) {
|
|
||||||
/* variable-length field
|
/* variable-length field
|
||||||
with maximum length > 255 */
|
with maximum length > 255 */
|
||||||
len = 0x7fff;
|
len = 0x7fff;
|
||||||
}
|
}
|
||||||
if (dtype_get_prtype(type) & DATA_NOT_NULL) {
|
if (col->prtype & DATA_NOT_NULL) {
|
||||||
len |= 0x8000;
|
len |= 0x8000;
|
||||||
}
|
}
|
||||||
if (log_ptr + 2 > log_end) {
|
if (log_ptr + 2 > log_end) {
|
||||||
|
@ -548,7 +548,7 @@ mlog_parse_index(
|
||||||
len & 0x8000 ? DATA_NOT_NULL : 0,
|
len & 0x8000 ? DATA_NOT_NULL : 0,
|
||||||
len & 0x7fff);
|
len & 0x7fff);
|
||||||
|
|
||||||
dict_index_add_col(ind, table,
|
dict_index_add_col(ind, table, (dict_col_t*)
|
||||||
dict_table_get_nth_col(table, i),
|
dict_table_get_nth_col(table, i),
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -489,9 +489,10 @@ pars_resolve_exp_columns(
|
||||||
n_cols = dict_table_get_n_cols(table);
|
n_cols = dict_table_get_n_cols(table);
|
||||||
|
|
||||||
for (i = 0; i < n_cols; i++) {
|
for (i = 0; i < n_cols; i++) {
|
||||||
dict_col_t* col = dict_table_get_nth_col(table, i);
|
const dict_col_t* col
|
||||||
const char* col_name = dict_table_get_col_name(
|
= dict_table_get_nth_col(table, i);
|
||||||
table, i);
|
const char* col_name
|
||||||
|
= dict_table_get_col_name(table, i);
|
||||||
|
|
||||||
if ((sym_node->name_len == ut_strlen(col_name))
|
if ((sym_node->name_len == ut_strlen(col_name))
|
||||||
&& (0 == ut_memcmp(sym_node->name, col_name,
|
&& (0 == ut_memcmp(sym_node->name, col_name,
|
||||||
|
@ -503,8 +504,10 @@ pars_resolve_exp_columns(
|
||||||
sym_node->col_no = i;
|
sym_node->col_no = i;
|
||||||
sym_node->prefetch_buf = NULL;
|
sym_node->prefetch_buf = NULL;
|
||||||
|
|
||||||
dfield_set_type(&(sym_node->common.val),
|
dict_col_copy_type(
|
||||||
dict_col_get_type(col));
|
col,
|
||||||
|
dfield_get_type(&sym_node
|
||||||
|
->common.val));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -920,8 +923,9 @@ pars_process_assign_list(
|
||||||
clust_index, NULL);
|
clust_index, NULL);
|
||||||
upd_field->exp = assign_node->val;
|
upd_field->exp = assign_node->val;
|
||||||
|
|
||||||
if (!dtype_is_fixed_size(dict_index_get_nth_type
|
if (!dict_col_get_fixed_size(
|
||||||
(clust_index, upd_field->field_no))) {
|
dict_index_get_nth_col(clust_index,
|
||||||
|
upd_field->field_no))) {
|
||||||
changes_field_size = 0;
|
changes_field_size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
181
rem/rem0cmp.c
181
rem/rem0cmp.c
|
@ -92,47 +92,48 @@ cmp_collate(
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************
|
/*****************************************************************
|
||||||
Returns TRUE if two types are equal for comparison purposes. */
|
Returns TRUE if two columns are equal for comparison purposes. */
|
||||||
|
|
||||||
ibool
|
ibool
|
||||||
cmp_types_are_equal(
|
cmp_cols_are_equal(
|
||||||
/*================*/
|
/*===============*/
|
||||||
/* out: TRUE if the types are considered
|
/* out: TRUE if the columns are
|
||||||
equal in comparisons */
|
considered equal in comparisons */
|
||||||
dtype_t* type1, /* in: type 1 */
|
const dict_col_t* col1, /* in: column 1 */
|
||||||
dtype_t* type2, /* in: type 2 */
|
const dict_col_t* col2, /* in: column 2 */
|
||||||
ibool check_charsets) /* in: whether to check charsets */
|
ibool check_charsets)
|
||||||
|
/* in: whether to check charsets */
|
||||||
{
|
{
|
||||||
if (dtype_is_non_binary_string_type(type1->mtype, type1->prtype)
|
if (dtype_is_non_binary_string_type(col1->mtype, col1->prtype)
|
||||||
&& dtype_is_non_binary_string_type(type2->mtype, type2->prtype)) {
|
&& dtype_is_non_binary_string_type(col2->mtype, col2->prtype)) {
|
||||||
|
|
||||||
/* Both are non-binary string types: they can be compared if
|
/* Both are non-binary string types: they can be compared if
|
||||||
and only if the charset-collation is the same */
|
and only if the charset-collation is the same */
|
||||||
|
|
||||||
if (check_charsets) {
|
if (check_charsets) {
|
||||||
return(dtype_get_charset_coll(type1->prtype)
|
return(dtype_get_charset_coll(col1->prtype)
|
||||||
== dtype_get_charset_coll(type2->prtype));
|
== dtype_get_charset_coll(col2->prtype));
|
||||||
} else {
|
} else {
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dtype_is_binary_string_type(type1->mtype, type1->prtype)
|
if (dtype_is_binary_string_type(col1->mtype, col1->prtype)
|
||||||
&& dtype_is_binary_string_type(type2->mtype, type2->prtype)) {
|
&& dtype_is_binary_string_type(col2->mtype, col2->prtype)) {
|
||||||
|
|
||||||
/* Both are binary string types: they can be compared */
|
/* Both are binary string types: they can be compared */
|
||||||
|
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type1->mtype != type2->mtype) {
|
if (col1->mtype != col2->mtype) {
|
||||||
|
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type1->mtype == DATA_INT
|
if (col1->mtype == DATA_INT
|
||||||
&& (type1->prtype & DATA_UNSIGNED)
|
&& (col1->prtype & DATA_UNSIGNED)
|
||||||
!= (type2->prtype & DATA_UNSIGNED)) {
|
!= (col2->prtype & DATA_UNSIGNED)) {
|
||||||
|
|
||||||
/* The storage format of an unsigned integer is different
|
/* The storage format of an unsigned integer is different
|
||||||
from a signed integer: in a signed integer we OR
|
from a signed integer: in a signed integer we OR
|
||||||
|
@ -141,12 +142,7 @@ cmp_types_are_equal(
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type1->mtype == DATA_INT && type1->len != type2->len) {
|
return(col1->mtype != DATA_INT || col1->len == col2->len);
|
||||||
|
|
||||||
return(FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return(TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef UNIV_HOTBACKUP
|
#ifndef UNIV_HOTBACKUP
|
||||||
|
@ -159,7 +155,8 @@ cmp_whole_field(
|
||||||
/*============*/
|
/*============*/
|
||||||
/* out: 1, 0, -1, if a is greater,
|
/* out: 1, 0, -1, if a is greater,
|
||||||
equal, less than b, respectively */
|
equal, less than b, respectively */
|
||||||
dtype_t* type, /* in: data type */
|
ulint mtype, /* in: main type */
|
||||||
|
ulint prtype, /* in: precise type */
|
||||||
unsigned char* a, /* in: data field */
|
unsigned char* a, /* in: data field */
|
||||||
unsigned int a_length, /* in: data field length,
|
unsigned int a_length, /* in: data field length,
|
||||||
not UNIV_SQL_NULL */
|
not UNIV_SQL_NULL */
|
||||||
|
@ -172,11 +169,8 @@ cmp_whole_field(
|
||||||
double d_1;
|
double d_1;
|
||||||
double d_2;
|
double d_2;
|
||||||
int swap_flag = 1;
|
int swap_flag = 1;
|
||||||
ulint data_type;
|
|
||||||
|
|
||||||
data_type = type->mtype;
|
switch (mtype) {
|
||||||
|
|
||||||
switch (data_type) {
|
|
||||||
|
|
||||||
case DATA_DECIMAL:
|
case DATA_DECIMAL:
|
||||||
/* Remove preceding spaces */
|
/* Remove preceding spaces */
|
||||||
|
@ -253,11 +247,8 @@ cmp_whole_field(
|
||||||
}
|
}
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
case DATA_VARMYSQL:
|
|
||||||
case DATA_MYSQL:
|
|
||||||
case DATA_BLOB:
|
case DATA_BLOB:
|
||||||
if (data_type == DATA_BLOB
|
if (prtype & DATA_BINARY_TYPE) {
|
||||||
&& 0 != (type->prtype & DATA_BINARY_TYPE)) {
|
|
||||||
|
|
||||||
ut_print_timestamp(stderr);
|
ut_print_timestamp(stderr);
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
|
@ -265,15 +256,17 @@ cmp_whole_field(
|
||||||
" with a character set sensitive\n"
|
" with a character set sensitive\n"
|
||||||
"InnoDB: comparison!\n");
|
"InnoDB: comparison!\n");
|
||||||
}
|
}
|
||||||
|
/* fall through */
|
||||||
|
case DATA_VARMYSQL:
|
||||||
|
case DATA_MYSQL:
|
||||||
return(innobase_mysql_cmp
|
return(innobase_mysql_cmp
|
||||||
((int)(type->prtype & DATA_MYSQL_TYPE_MASK),
|
((int)(prtype & DATA_MYSQL_TYPE_MASK),
|
||||||
(uint)dtype_get_charset_coll(type->prtype),
|
(uint)dtype_get_charset_coll(prtype),
|
||||||
a, a_length, b, b_length));
|
a, a_length, b, b_length));
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"InnoDB: unknown type number %lu\n",
|
"InnoDB: unknown type number %lu\n",
|
||||||
(ulong) data_type);
|
(ulong) mtype);
|
||||||
ut_error;
|
ut_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,7 +283,8 @@ cmp_data_data_slow(
|
||||||
/*===============*/
|
/*===============*/
|
||||||
/* out: 1, 0, -1, if data1 is greater, equal,
|
/* out: 1, 0, -1, if data1 is greater, equal,
|
||||||
less than data2, respectively */
|
less than data2, respectively */
|
||||||
dtype_t* cur_type,/* in: data type of the fields */
|
ulint mtype, /* in: main type */
|
||||||
|
ulint prtype, /* in: precise type */
|
||||||
byte* data1, /* in: data field (== a pointer to a memory
|
byte* data1, /* in: data field (== a pointer to a memory
|
||||||
buffer) */
|
buffer) */
|
||||||
ulint len1, /* in: data field length or UNIV_SQL_NULL */
|
ulint len1, /* in: data field length or UNIV_SQL_NULL */
|
||||||
|
@ -303,8 +297,6 @@ cmp_data_data_slow(
|
||||||
ulint data2_byte;
|
ulint data2_byte;
|
||||||
ulint cur_bytes;
|
ulint cur_bytes;
|
||||||
|
|
||||||
ut_ad(dtype_validate(cur_type));
|
|
||||||
|
|
||||||
if (len1 == UNIV_SQL_NULL || len2 == UNIV_SQL_NULL) {
|
if (len1 == UNIV_SQL_NULL || len2 == UNIV_SQL_NULL) {
|
||||||
|
|
||||||
if (len1 == len2) {
|
if (len1 == len2) {
|
||||||
|
@ -322,13 +314,13 @@ cmp_data_data_slow(
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cur_type->mtype >= DATA_FLOAT
|
if (mtype >= DATA_FLOAT
|
||||||
|| (cur_type->mtype == DATA_BLOB
|
|| (mtype == DATA_BLOB
|
||||||
&& 0 == (cur_type->prtype & DATA_BINARY_TYPE)
|
&& 0 == (prtype & DATA_BINARY_TYPE)
|
||||||
&& dtype_get_charset_coll(cur_type->prtype)
|
&& dtype_get_charset_coll(prtype)
|
||||||
!= DATA_MYSQL_LATIN1_SWEDISH_CHARSET_COLL)) {
|
!= DATA_MYSQL_LATIN1_SWEDISH_CHARSET_COLL)) {
|
||||||
|
|
||||||
return(cmp_whole_field(cur_type,
|
return(cmp_whole_field(mtype, prtype,
|
||||||
data1, (unsigned) len1,
|
data1, (unsigned) len1,
|
||||||
data2, (unsigned) len2));
|
data2, (unsigned) len2));
|
||||||
}
|
}
|
||||||
|
@ -344,7 +336,7 @@ cmp_data_data_slow(
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
data1_byte = dtype_get_pad_char(cur_type);
|
data1_byte = dtype_get_pad_char(mtype, prtype);
|
||||||
|
|
||||||
if (data1_byte == ULINT_UNDEFINED) {
|
if (data1_byte == ULINT_UNDEFINED) {
|
||||||
|
|
||||||
|
@ -355,7 +347,7 @@ cmp_data_data_slow(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len2 <= cur_bytes) {
|
if (len2 <= cur_bytes) {
|
||||||
data2_byte = dtype_get_pad_char(cur_type);
|
data2_byte = dtype_get_pad_char(mtype, prtype);
|
||||||
|
|
||||||
if (data2_byte == ULINT_UNDEFINED) {
|
if (data2_byte == ULINT_UNDEFINED) {
|
||||||
|
|
||||||
|
@ -372,9 +364,9 @@ cmp_data_data_slow(
|
||||||
goto next_byte;
|
goto next_byte;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cur_type->mtype <= DATA_CHAR
|
if (mtype <= DATA_CHAR
|
||||||
|| (cur_type->mtype == DATA_BLOB
|
|| (mtype == DATA_BLOB
|
||||||
&& 0 == (cur_type->prtype & DATA_BINARY_TYPE))) {
|
&& 0 == (prtype & DATA_BINARY_TYPE))) {
|
||||||
|
|
||||||
data1_byte = cmp_collate(data1_byte);
|
data1_byte = cmp_collate(data1_byte);
|
||||||
data2_byte = cmp_collate(data2_byte);
|
data2_byte = cmp_collate(data2_byte);
|
||||||
|
@ -435,8 +427,6 @@ cmp_dtuple_rec_with_match(
|
||||||
value for current comparison */
|
value for current comparison */
|
||||||
{
|
{
|
||||||
#ifndef UNIV_HOTBACKUP
|
#ifndef UNIV_HOTBACKUP
|
||||||
dtype_t* cur_type; /* pointer to type of the current
|
|
||||||
field in dtuple */
|
|
||||||
dfield_t* dtuple_field; /* current field in logical record */
|
dfield_t* dtuple_field; /* current field in logical record */
|
||||||
ulint dtuple_f_len; /* the length of the current field
|
ulint dtuple_f_len; /* the length of the current field
|
||||||
in the logical record */
|
in the logical record */
|
||||||
|
@ -483,8 +473,17 @@ cmp_dtuple_rec_with_match(
|
||||||
|
|
||||||
while (cur_field < dtuple_get_n_fields_cmp(dtuple)) {
|
while (cur_field < dtuple_get_n_fields_cmp(dtuple)) {
|
||||||
|
|
||||||
|
ulint mtype;
|
||||||
|
ulint prtype;
|
||||||
|
|
||||||
dtuple_field = dtuple_get_nth_field(dtuple, cur_field);
|
dtuple_field = dtuple_get_nth_field(dtuple, cur_field);
|
||||||
cur_type = dfield_get_type(dtuple_field);
|
{
|
||||||
|
const dtype_t* type
|
||||||
|
= dfield_get_type(dtuple_field);
|
||||||
|
|
||||||
|
mtype = type->mtype;
|
||||||
|
prtype = type->prtype;
|
||||||
|
}
|
||||||
|
|
||||||
dtuple_f_len = dfield_get_len(dtuple_field);
|
dtuple_f_len = dfield_get_len(dtuple_field);
|
||||||
|
|
||||||
|
@ -524,13 +523,13 @@ cmp_dtuple_rec_with_match(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cur_type->mtype >= DATA_FLOAT
|
if (mtype >= DATA_FLOAT
|
||||||
|| (cur_type->mtype == DATA_BLOB
|
|| (mtype == DATA_BLOB
|
||||||
&& 0 == (cur_type->prtype & DATA_BINARY_TYPE)
|
&& 0 == (prtype & DATA_BINARY_TYPE)
|
||||||
&& dtype_get_charset_coll(cur_type->prtype)
|
&& dtype_get_charset_coll(prtype)
|
||||||
!= DATA_MYSQL_LATIN1_SWEDISH_CHARSET_COLL)) {
|
!= DATA_MYSQL_LATIN1_SWEDISH_CHARSET_COLL)) {
|
||||||
|
|
||||||
ret = cmp_whole_field(cur_type,
|
ret = cmp_whole_field(mtype, prtype,
|
||||||
dfield_get_data(dtuple_field),
|
dfield_get_data(dtuple_field),
|
||||||
(unsigned) dtuple_f_len,
|
(unsigned) dtuple_f_len,
|
||||||
rec_b_ptr, (unsigned) rec_f_len);
|
rec_b_ptr, (unsigned) rec_f_len);
|
||||||
|
@ -558,7 +557,7 @@ cmp_dtuple_rec_with_match(
|
||||||
goto next_field;
|
goto next_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
rec_byte = dtype_get_pad_char(cur_type);
|
rec_byte = dtype_get_pad_char(mtype, prtype);
|
||||||
|
|
||||||
if (rec_byte == ULINT_UNDEFINED) {
|
if (rec_byte == ULINT_UNDEFINED) {
|
||||||
ret = 1;
|
ret = 1;
|
||||||
|
@ -570,7 +569,8 @@ cmp_dtuple_rec_with_match(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UNIV_UNLIKELY(dtuple_f_len <= cur_bytes)) {
|
if (UNIV_UNLIKELY(dtuple_f_len <= cur_bytes)) {
|
||||||
dtuple_byte = dtype_get_pad_char(cur_type);
|
dtuple_byte = dtype_get_pad_char(mtype,
|
||||||
|
prtype);
|
||||||
|
|
||||||
if (dtuple_byte == ULINT_UNDEFINED) {
|
if (dtuple_byte == ULINT_UNDEFINED) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
@ -589,9 +589,9 @@ cmp_dtuple_rec_with_match(
|
||||||
goto next_byte;
|
goto next_byte;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cur_type->mtype <= DATA_CHAR
|
if (mtype <= DATA_CHAR
|
||||||
|| (cur_type->mtype == DATA_BLOB
|
|| (mtype == DATA_BLOB
|
||||||
&& !(cur_type->prtype & DATA_BINARY_TYPE))) {
|
&& !(prtype & DATA_BINARY_TYPE))) {
|
||||||
|
|
||||||
rec_byte = cmp_collate(rec_byte);
|
rec_byte = cmp_collate(rec_byte);
|
||||||
dtuple_byte = cmp_collate(dtuple_byte);
|
dtuple_byte = cmp_collate(dtuple_byte);
|
||||||
|
@ -730,8 +730,6 @@ cmp_rec_rec_with_match(
|
||||||
the value for the current comparison */
|
the value for the current comparison */
|
||||||
{
|
{
|
||||||
#ifndef UNIV_HOTBACKUP
|
#ifndef UNIV_HOTBACKUP
|
||||||
dtype_t* cur_type; /* pointer to type struct of the
|
|
||||||
current field in index */
|
|
||||||
ulint rec1_n_fields; /* the number of fields in rec */
|
ulint rec1_n_fields; /* the number of fields in rec */
|
||||||
ulint rec1_f_len; /* length of current field in rec */
|
ulint rec1_f_len; /* length of current field in rec */
|
||||||
byte* rec1_b_ptr; /* pointer to the current byte in rec field */
|
byte* rec1_b_ptr; /* pointer to the current byte in rec field */
|
||||||
|
@ -764,12 +762,19 @@ cmp_rec_rec_with_match(
|
||||||
|
|
||||||
while ((cur_field < rec1_n_fields) && (cur_field < rec2_n_fields)) {
|
while ((cur_field < rec1_n_fields) && (cur_field < rec2_n_fields)) {
|
||||||
|
|
||||||
if (index->type & DICT_UNIVERSAL) {
|
ulint mtype;
|
||||||
cur_type = dtype_binary;
|
ulint prtype;
|
||||||
|
|
||||||
|
if (UNIV_UNLIKELY(index->type & DICT_UNIVERSAL)) {
|
||||||
|
/* This is for the insert buffer B-tree. */
|
||||||
|
mtype = DATA_BINARY;
|
||||||
|
prtype = 0;
|
||||||
} else {
|
} else {
|
||||||
cur_type = dict_col_get_type
|
const dict_col_t* col
|
||||||
(dict_field_get_col(dict_index_get_nth_field
|
= dict_index_get_nth_col(index, cur_field);
|
||||||
(index, cur_field)));
|
|
||||||
|
mtype = col->mtype;
|
||||||
|
prtype = col->prtype;
|
||||||
}
|
}
|
||||||
|
|
||||||
rec1_b_ptr = rec_get_nth_field(rec1, offsets1,
|
rec1_b_ptr = rec_get_nth_field(rec1, offsets1,
|
||||||
|
@ -834,13 +839,13 @@ cmp_rec_rec_with_match(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cur_type->mtype >= DATA_FLOAT
|
if (mtype >= DATA_FLOAT
|
||||||
|| (cur_type->mtype == DATA_BLOB
|
|| (mtype == DATA_BLOB
|
||||||
&& 0 == (cur_type->prtype & DATA_BINARY_TYPE)
|
&& 0 == (prtype & DATA_BINARY_TYPE)
|
||||||
&& dtype_get_charset_coll(cur_type->prtype)
|
&& dtype_get_charset_coll(prtype)
|
||||||
!= DATA_MYSQL_LATIN1_SWEDISH_CHARSET_COLL)) {
|
!= DATA_MYSQL_LATIN1_SWEDISH_CHARSET_COLL)) {
|
||||||
|
|
||||||
ret = cmp_whole_field(cur_type,
|
ret = cmp_whole_field(mtype, prtype,
|
||||||
rec1_b_ptr,
|
rec1_b_ptr,
|
||||||
(unsigned) rec1_f_len,
|
(unsigned) rec1_f_len,
|
||||||
rec2_b_ptr,
|
rec2_b_ptr,
|
||||||
|
@ -867,7 +872,7 @@ cmp_rec_rec_with_match(
|
||||||
goto next_field;
|
goto next_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
rec2_byte = dtype_get_pad_char(cur_type);
|
rec2_byte = dtype_get_pad_char(mtype, prtype);
|
||||||
|
|
||||||
if (rec2_byte == ULINT_UNDEFINED) {
|
if (rec2_byte == ULINT_UNDEFINED) {
|
||||||
ret = 1;
|
ret = 1;
|
||||||
|
@ -879,7 +884,7 @@ cmp_rec_rec_with_match(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rec1_f_len <= cur_bytes) {
|
if (rec1_f_len <= cur_bytes) {
|
||||||
rec1_byte = dtype_get_pad_char(cur_type);
|
rec1_byte = dtype_get_pad_char(mtype, prtype);
|
||||||
|
|
||||||
if (rec1_byte == ULINT_UNDEFINED) {
|
if (rec1_byte == ULINT_UNDEFINED) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
@ -898,9 +903,9 @@ cmp_rec_rec_with_match(
|
||||||
goto next_byte;
|
goto next_byte;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cur_type->mtype <= DATA_CHAR
|
if (mtype <= DATA_CHAR
|
||||||
|| (cur_type->mtype == DATA_BLOB
|
|| (mtype == DATA_BLOB
|
||||||
&& !(cur_type->prtype & DATA_BINARY_TYPE))) {
|
&& !(prtype & DATA_BINARY_TYPE))) {
|
||||||
|
|
||||||
rec1_byte = cmp_collate(rec1_byte);
|
rec1_byte = cmp_collate(rec1_byte);
|
||||||
rec2_byte = cmp_collate(rec2_byte);
|
rec2_byte = cmp_collate(rec2_byte);
|
||||||
|
@ -972,8 +977,6 @@ cmp_debug_dtuple_rec_with_match(
|
||||||
returns, contains the value for current
|
returns, contains the value for current
|
||||||
comparison */
|
comparison */
|
||||||
{
|
{
|
||||||
dtype_t* cur_type; /* pointer to type of the current
|
|
||||||
field in dtuple */
|
|
||||||
dfield_t* dtuple_field; /* current field in logical record */
|
dfield_t* dtuple_field; /* current field in logical record */
|
||||||
ulint dtuple_f_len; /* the length of the current field
|
ulint dtuple_f_len; /* the length of the current field
|
||||||
in the logical record */
|
in the logical record */
|
||||||
|
@ -1014,9 +1017,17 @@ cmp_debug_dtuple_rec_with_match(
|
||||||
|
|
||||||
while (cur_field < dtuple_get_n_fields_cmp(dtuple)) {
|
while (cur_field < dtuple_get_n_fields_cmp(dtuple)) {
|
||||||
|
|
||||||
dtuple_field = dtuple_get_nth_field(dtuple, cur_field);
|
ulint mtype;
|
||||||
|
ulint prtype;
|
||||||
|
|
||||||
cur_type = dfield_get_type(dtuple_field);
|
dtuple_field = dtuple_get_nth_field(dtuple, cur_field);
|
||||||
|
{
|
||||||
|
const dtype_t* type
|
||||||
|
= dfield_get_type(dtuple_field);
|
||||||
|
|
||||||
|
mtype = type->mtype;
|
||||||
|
prtype = type->prtype;
|
||||||
|
}
|
||||||
|
|
||||||
dtuple_f_data = dfield_get_data(dtuple_field);
|
dtuple_f_data = dfield_get_data(dtuple_field);
|
||||||
dtuple_f_len = dfield_get_len(dtuple_field);
|
dtuple_f_len = dfield_get_len(dtuple_field);
|
||||||
|
@ -1032,7 +1043,7 @@ cmp_debug_dtuple_rec_with_match(
|
||||||
goto order_resolved;
|
goto order_resolved;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = cmp_data_data(cur_type, dtuple_f_data, dtuple_f_len,
|
ret = cmp_data_data(mtype, prtype, dtuple_f_data, dtuple_f_len,
|
||||||
rec_f_data, rec_f_len);
|
rec_f_data, rec_f_len);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
goto order_resolved;
|
goto order_resolved;
|
||||||
|
|
|
@ -202,8 +202,7 @@ rec_init_offsets(
|
||||||
}
|
}
|
||||||
|
|
||||||
field = dict_index_get_nth_field(index, i);
|
field = dict_index_get_nth_field(index, i);
|
||||||
if (!(dtype_get_prtype(dict_col_get_type
|
if (!(dict_field_get_col(field)->prtype
|
||||||
(dict_field_get_col(field)))
|
|
||||||
& DATA_NOT_NULL)) {
|
& DATA_NOT_NULL)) {
|
||||||
/* nullable field => read the null flag */
|
/* nullable field => read the null flag */
|
||||||
|
|
||||||
|
@ -226,11 +225,11 @@ rec_init_offsets(
|
||||||
|
|
||||||
if (UNIV_UNLIKELY(!field->fixed_len)) {
|
if (UNIV_UNLIKELY(!field->fixed_len)) {
|
||||||
/* Variable-length field: read the length */
|
/* Variable-length field: read the length */
|
||||||
dtype_t* type = dict_col_get_type
|
const dict_col_t* col
|
||||||
(dict_field_get_col(field));
|
= dict_field_get_col(field);
|
||||||
len = *lens--;
|
len = *lens--;
|
||||||
if (UNIV_UNLIKELY(dtype_get_len(type) > 255)
|
if (UNIV_UNLIKELY(col->len > 255)
|
||||||
|| UNIV_UNLIKELY(dtype_get_mtype(type)
|
|| UNIV_UNLIKELY(col->mtype
|
||||||
== DATA_BLOB)) {
|
== DATA_BLOB)) {
|
||||||
if (len & 0x80) {
|
if (len & 0x80) {
|
||||||
/* 1exxxxxxx xxxxxxxx */
|
/* 1exxxxxxx xxxxxxxx */
|
||||||
|
@ -442,8 +441,6 @@ rec_get_converted_size_new(
|
||||||
{
|
{
|
||||||
ulint size = REC_N_NEW_EXTRA_BYTES
|
ulint size = REC_N_NEW_EXTRA_BYTES
|
||||||
+ (index->n_nullable + 7) / 8;
|
+ (index->n_nullable + 7) / 8;
|
||||||
dict_field_t* field;
|
|
||||||
dtype_t* type;
|
|
||||||
ulint i;
|
ulint i;
|
||||||
ulint n_fields;
|
ulint n_fields;
|
||||||
ut_ad(index && dtuple);
|
ut_ad(index && dtuple);
|
||||||
|
@ -471,25 +468,27 @@ rec_get_converted_size_new(
|
||||||
|
|
||||||
/* read the lengths of fields 0..n */
|
/* read the lengths of fields 0..n */
|
||||||
for (i = 0; i < n_fields; i++) {
|
for (i = 0; i < n_fields; i++) {
|
||||||
ulint len = dtuple_get_nth_field(dtuple, i)->len;
|
dict_field_t* field;
|
||||||
|
ulint len;
|
||||||
|
const dict_col_t* col;
|
||||||
|
|
||||||
field = dict_index_get_nth_field(index, i);
|
field = dict_index_get_nth_field(index, i);
|
||||||
type = dict_col_get_type(dict_field_get_col(field));
|
len = dtuple_get_nth_field(dtuple, i)->len;
|
||||||
ut_ad(len != UNIV_SQL_NULL
|
col = dict_field_get_col(field);
|
||||||
|| !(dtype_get_prtype(type) & DATA_NOT_NULL));
|
|
||||||
|
ut_ad(len != UNIV_SQL_NULL || !(col->prtype & DATA_NOT_NULL));
|
||||||
|
|
||||||
if (len == UNIV_SQL_NULL) {
|
if (len == UNIV_SQL_NULL) {
|
||||||
/* No length is stored for NULL fields. */
|
/* No length is stored for NULL fields. */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ut_ad(len <= dtype_get_len(type)
|
ut_ad(len <= col->len || col->mtype == DATA_BLOB);
|
||||||
|| dtype_get_mtype(type) == DATA_BLOB);
|
|
||||||
ut_ad(!field->fixed_len || len == field->fixed_len);
|
ut_ad(!field->fixed_len || len == field->fixed_len);
|
||||||
|
|
||||||
if (field->fixed_len) {
|
if (field->fixed_len) {
|
||||||
} else if (len < 128
|
} else if (len < 128
|
||||||
|| (dtype_get_len(type) < 256
|
|| (col->len < 256 && col->mtype != DATA_BLOB)) {
|
||||||
&& dtype_get_mtype(type) != DATA_BLOB)) {
|
|
||||||
size++;
|
size++;
|
||||||
} else {
|
} else {
|
||||||
size += 2;
|
size += 2;
|
||||||
|
@ -588,8 +587,6 @@ rec_set_nth_field_extern_bit_new(
|
||||||
{
|
{
|
||||||
byte* nulls = rec - (REC_N_NEW_EXTRA_BYTES + 1);
|
byte* nulls = rec - (REC_N_NEW_EXTRA_BYTES + 1);
|
||||||
byte* lens = nulls - (index->n_nullable + 7) / 8;
|
byte* lens = nulls - (index->n_nullable + 7) / 8;
|
||||||
dict_field_t* field;
|
|
||||||
dtype_t* type;
|
|
||||||
ulint i;
|
ulint i;
|
||||||
ulint n_fields;
|
ulint n_fields;
|
||||||
ulint null_mask = 1;
|
ulint null_mask = 1;
|
||||||
|
@ -603,9 +600,13 @@ rec_set_nth_field_extern_bit_new(
|
||||||
|
|
||||||
/* read the lengths of fields 0..n */
|
/* read the lengths of fields 0..n */
|
||||||
for (i = 0; i < n_fields; i++) {
|
for (i = 0; i < n_fields; i++) {
|
||||||
|
const dict_field_t* field;
|
||||||
|
const dict_col_t* col;
|
||||||
|
|
||||||
field = dict_index_get_nth_field(index, i);
|
field = dict_index_get_nth_field(index, i);
|
||||||
type = dict_col_get_type(dict_field_get_col(field));
|
col = dict_field_get_col(field);
|
||||||
if (!(dtype_get_prtype(type) & DATA_NOT_NULL)) {
|
|
||||||
|
if (!(col->prtype & DATA_NOT_NULL)) {
|
||||||
if (UNIV_UNLIKELY(!(byte) null_mask)) {
|
if (UNIV_UNLIKELY(!(byte) null_mask)) {
|
||||||
nulls--;
|
nulls--;
|
||||||
null_mask = 1;
|
null_mask = 1;
|
||||||
|
@ -629,8 +630,7 @@ rec_set_nth_field_extern_bit_new(
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
lens--;
|
lens--;
|
||||||
if (dtype_get_len(type) > 255
|
if (col->len > 255 || col->mtype == DATA_BLOB) {
|
||||||
|| dtype_get_mtype(type) == DATA_BLOB) {
|
|
||||||
ulint len = lens[1];
|
ulint len = lens[1];
|
||||||
if (len & 0x80) { /* 1exxxxxx: 2-byte length */
|
if (len & 0x80) { /* 1exxxxxx: 2-byte length */
|
||||||
if (i == ith) {
|
if (i == ith) {
|
||||||
|
@ -640,9 +640,10 @@ rec_set_nth_field_extern_bit_new(
|
||||||
/* toggle the extern bit */
|
/* toggle the extern bit */
|
||||||
len ^= 0x40;
|
len ^= 0x40;
|
||||||
if (mtr) {
|
if (mtr) {
|
||||||
mlog_write_ulint
|
mlog_write_ulint(lens + 1,
|
||||||
(lens + 1, len,
|
len,
|
||||||
MLOG_1BYTE, mtr);
|
MLOG_1BYTE,
|
||||||
|
mtr);
|
||||||
} else {
|
} else {
|
||||||
lens[1] = (byte) len;
|
lens[1] = (byte) len;
|
||||||
}
|
}
|
||||||
|
@ -1137,8 +1138,6 @@ rec_copy_prefix_to_buf(
|
||||||
{
|
{
|
||||||
byte* nulls;
|
byte* nulls;
|
||||||
byte* lens;
|
byte* lens;
|
||||||
dict_field_t* field;
|
|
||||||
dtype_t* type;
|
|
||||||
ulint i;
|
ulint i;
|
||||||
ulint prefix_len;
|
ulint prefix_len;
|
||||||
ulint null_mask;
|
ulint null_mask;
|
||||||
|
@ -1180,9 +1179,13 @@ rec_copy_prefix_to_buf(
|
||||||
|
|
||||||
/* read the lengths of fields 0..n */
|
/* read the lengths of fields 0..n */
|
||||||
for (i = 0; i < n_fields; i++) {
|
for (i = 0; i < n_fields; i++) {
|
||||||
|
const dict_field_t* field;
|
||||||
|
const dict_col_t* col;
|
||||||
|
|
||||||
field = dict_index_get_nth_field(index, i);
|
field = dict_index_get_nth_field(index, i);
|
||||||
type = dict_col_get_type(dict_field_get_col(field));
|
col = dict_field_get_col(field);
|
||||||
if (!(dtype_get_prtype(type) & DATA_NOT_NULL)) {
|
|
||||||
|
if (!(col->prtype & DATA_NOT_NULL)) {
|
||||||
/* nullable field => read the null flag */
|
/* nullable field => read the null flag */
|
||||||
if (UNIV_UNLIKELY(!(byte) null_mask)) {
|
if (UNIV_UNLIKELY(!(byte) null_mask)) {
|
||||||
nulls--;
|
nulls--;
|
||||||
|
@ -1201,8 +1204,7 @@ rec_copy_prefix_to_buf(
|
||||||
prefix_len += field->fixed_len;
|
prefix_len += field->fixed_len;
|
||||||
} else {
|
} else {
|
||||||
ulint len = *lens--;
|
ulint len = *lens--;
|
||||||
if (dtype_get_len(type) > 255
|
if (col->len > 255 || col->mtype == DATA_BLOB) {
|
||||||
|| dtype_get_mtype(type) == DATA_BLOB) {
|
|
||||||
if (len & 0x80) {
|
if (len & 0x80) {
|
||||||
/* 1exxxxxx */
|
/* 1exxxxxx */
|
||||||
len &= 0x3f;
|
len &= 0x3f;
|
||||||
|
|
|
@ -135,12 +135,12 @@ row_ins_alloc_sys_fields(
|
||||||
/*=====================*/
|
/*=====================*/
|
||||||
ins_node_t* node) /* in: insert node */
|
ins_node_t* node) /* in: insert node */
|
||||||
{
|
{
|
||||||
dtuple_t* row;
|
dtuple_t* row;
|
||||||
dict_table_t* table;
|
dict_table_t* table;
|
||||||
mem_heap_t* heap;
|
mem_heap_t* heap;
|
||||||
dict_col_t* col;
|
const dict_col_t* col;
|
||||||
dfield_t* dfield;
|
dfield_t* dfield;
|
||||||
byte* ptr;
|
byte* ptr;
|
||||||
|
|
||||||
row = node->row;
|
row = node->row;
|
||||||
table = node->table;
|
table = node->table;
|
||||||
|
@ -445,7 +445,6 @@ row_ins_cascade_calc_update_vec(
|
||||||
upd_field_t* parent_ufield;
|
upd_field_t* parent_ufield;
|
||||||
ulint n_fields_updated;
|
ulint n_fields_updated;
|
||||||
ulint parent_field_no;
|
ulint parent_field_no;
|
||||||
dtype_t* type;
|
|
||||||
ulint i;
|
ulint i;
|
||||||
ulint j;
|
ulint j;
|
||||||
|
|
||||||
|
@ -479,7 +478,10 @@ row_ins_cascade_calc_update_vec(
|
||||||
|
|
||||||
if (parent_ufield->field_no == parent_field_no) {
|
if (parent_ufield->field_no == parent_field_no) {
|
||||||
|
|
||||||
ulint min_size;
|
ulint min_size;
|
||||||
|
const dict_col_t* col;
|
||||||
|
|
||||||
|
col = dict_index_get_nth_col(index, i);
|
||||||
|
|
||||||
/* A field in the parent index record is
|
/* A field in the parent index record is
|
||||||
updated. Let us make the update vector
|
updated. Let us make the update vector
|
||||||
|
@ -488,20 +490,17 @@ row_ins_cascade_calc_update_vec(
|
||||||
ufield = update->fields + n_fields_updated;
|
ufield = update->fields + n_fields_updated;
|
||||||
|
|
||||||
ufield->field_no
|
ufield->field_no
|
||||||
= dict_table_get_nth_col_pos
|
= dict_table_get_nth_col_pos(
|
||||||
(table,
|
table, dict_col_get_no(col));
|
||||||
dict_index_get_nth_col_no(index, i));
|
|
||||||
ufield->exp = NULL;
|
ufield->exp = NULL;
|
||||||
|
|
||||||
ufield->new_val = parent_ufield->new_val;
|
ufield->new_val = parent_ufield->new_val;
|
||||||
|
|
||||||
type = dict_index_get_nth_type(index, i);
|
|
||||||
|
|
||||||
/* Do not allow a NOT NULL column to be
|
/* Do not allow a NOT NULL column to be
|
||||||
updated as NULL */
|
updated as NULL */
|
||||||
|
|
||||||
if (ufield->new_val.len == UNIV_SQL_NULL
|
if (ufield->new_val.len == UNIV_SQL_NULL
|
||||||
&& (type->prtype & DATA_NOT_NULL)) {
|
&& (col->prtype & DATA_NOT_NULL)) {
|
||||||
|
|
||||||
return(ULINT_UNDEFINED);
|
return(ULINT_UNDEFINED);
|
||||||
}
|
}
|
||||||
|
@ -510,9 +509,12 @@ row_ins_cascade_calc_update_vec(
|
||||||
column, do not allow the update */
|
column, do not allow the update */
|
||||||
|
|
||||||
if (ufield->new_val.len != UNIV_SQL_NULL
|
if (ufield->new_val.len != UNIV_SQL_NULL
|
||||||
&& dtype_get_at_most_n_mbchars
|
&& dtype_get_at_most_n_mbchars(
|
||||||
(type, dtype_get_len(type),
|
col->prtype,
|
||||||
ufield->new_val.len, ufield->new_val.data)
|
col->mbminlen, col->mbmaxlen,
|
||||||
|
col->len,
|
||||||
|
ufield->new_val.len,
|
||||||
|
ufield->new_val.data)
|
||||||
< ufield->new_val.len) {
|
< ufield->new_val.len) {
|
||||||
|
|
||||||
return(ULINT_UNDEFINED);
|
return(ULINT_UNDEFINED);
|
||||||
|
@ -523,7 +525,7 @@ row_ins_cascade_calc_update_vec(
|
||||||
need to pad with spaces the new value of the
|
need to pad with spaces the new value of the
|
||||||
child column */
|
child column */
|
||||||
|
|
||||||
min_size = dtype_get_min_size(type);
|
min_size = dict_col_get_min_size(col);
|
||||||
|
|
||||||
if (min_size
|
if (min_size
|
||||||
&& ufield->new_val.len != UNIV_SQL_NULL
|
&& ufield->new_val.len != UNIV_SQL_NULL
|
||||||
|
@ -544,14 +546,13 @@ row_ins_cascade_calc_update_vec(
|
||||||
parent_ufield->new_val.data,
|
parent_ufield->new_val.data,
|
||||||
parent_ufield->new_val.len);
|
parent_ufield->new_val.len);
|
||||||
|
|
||||||
switch (UNIV_EXPECT(dtype_get_mbminlen
|
switch (UNIV_EXPECT(col->mbminlen,1)) {
|
||||||
(type), 1)) {
|
|
||||||
default:
|
default:
|
||||||
ut_error;
|
ut_error;
|
||||||
case 1:
|
case 1:
|
||||||
if (UNIV_UNLIKELY
|
if (UNIV_UNLIKELY
|
||||||
(dtype_get_charset_coll
|
(dtype_get_charset_coll(
|
||||||
(dtype_get_prtype(type))
|
col->prtype)
|
||||||
== DATA_MYSQL_BINARY_CHARSET_COLL)) {
|
== DATA_MYSQL_BINARY_CHARSET_COLL)) {
|
||||||
/* Do not pad BINARY
|
/* Do not pad BINARY
|
||||||
columns. */
|
columns. */
|
||||||
|
@ -2211,7 +2212,6 @@ row_ins_index_entry_set_vals(
|
||||||
dfield_t* row_field;
|
dfield_t* row_field;
|
||||||
ulint n_fields;
|
ulint n_fields;
|
||||||
ulint i;
|
ulint i;
|
||||||
dtype_t* cur_type;
|
|
||||||
|
|
||||||
ut_ad(entry && row);
|
ut_ad(entry && row);
|
||||||
|
|
||||||
|
@ -2227,12 +2227,13 @@ row_ins_index_entry_set_vals(
|
||||||
if (ind_field->prefix_len > 0
|
if (ind_field->prefix_len > 0
|
||||||
&& dfield_get_len(row_field) != UNIV_SQL_NULL) {
|
&& dfield_get_len(row_field) != UNIV_SQL_NULL) {
|
||||||
|
|
||||||
cur_type = dict_col_get_type
|
const dict_col_t* col
|
||||||
(dict_field_get_col(ind_field));
|
= dict_field_get_col(ind_field);
|
||||||
|
|
||||||
field->len = dtype_get_at_most_n_mbchars
|
field->len = dtype_get_at_most_n_mbchars(
|
||||||
(cur_type, ind_field->prefix_len,
|
col->prtype, col->mbminlen, col->mbmaxlen,
|
||||||
dfield_get_len(row_field), row_field->data);
|
ind_field->prefix_len,
|
||||||
|
row_field->len, row_field->data);
|
||||||
} else {
|
} else {
|
||||||
field->len = row_field->len;
|
field->len = row_field->len;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1607,16 +1607,11 @@ row_table_got_default_clust_index(
|
||||||
/*==============================*/
|
/*==============================*/
|
||||||
dict_table_t* table)
|
dict_table_t* table)
|
||||||
{
|
{
|
||||||
dict_index_t* clust_index;
|
const dict_index_t* clust_index;
|
||||||
|
|
||||||
clust_index = dict_table_get_first_index(table);
|
clust_index = dict_table_get_first_index(table);
|
||||||
|
|
||||||
if (dtype_get_mtype(dict_index_get_nth_type(clust_index, 0))
|
return(dict_index_get_nth_col(clust_index, 0)->mtype == DATA_SYS);
|
||||||
== DATA_SYS) {
|
|
||||||
return(TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return(FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
|
|
@ -114,10 +114,8 @@ row_build_index_entry(
|
||||||
dict_field_t* ind_field;
|
dict_field_t* ind_field;
|
||||||
dfield_t* dfield;
|
dfield_t* dfield;
|
||||||
dfield_t* dfield2;
|
dfield_t* dfield2;
|
||||||
dict_col_t* col;
|
|
||||||
ulint i;
|
ulint i;
|
||||||
ulint storage_len;
|
ulint storage_len;
|
||||||
dtype_t* cur_type;
|
|
||||||
|
|
||||||
ut_ad(row && index && heap);
|
ut_ad(row && index && heap);
|
||||||
ut_ad(dtuple_check_typed(row));
|
ut_ad(dtuple_check_typed(row));
|
||||||
|
@ -134,7 +132,7 @@ row_build_index_entry(
|
||||||
|
|
||||||
for (i = 0; i < entry_len; i++) {
|
for (i = 0; i < entry_len; i++) {
|
||||||
ind_field = dict_index_get_nth_field(index, i);
|
ind_field = dict_index_get_nth_field(index, i);
|
||||||
col = ind_field->col;
|
const dict_col_t* col = ind_field->col;
|
||||||
|
|
||||||
dfield = dtuple_get_nth_field(entry, i);
|
dfield = dtuple_get_nth_field(entry, i);
|
||||||
|
|
||||||
|
@ -146,14 +144,12 @@ row_build_index_entry(
|
||||||
if (ind_field->prefix_len) {
|
if (ind_field->prefix_len) {
|
||||||
if (dfield_get_len(dfield2) != UNIV_SQL_NULL) {
|
if (dfield_get_len(dfield2) != UNIV_SQL_NULL) {
|
||||||
|
|
||||||
cur_type = dict_col_get_type
|
storage_len = dtype_get_at_most_n_mbchars(
|
||||||
(dict_field_get_col(ind_field));
|
col->prtype,
|
||||||
|
col->mbminlen, col->mbmaxlen,
|
||||||
storage_len = dtype_get_at_most_n_mbchars
|
ind_field->prefix_len,
|
||||||
(cur_type,
|
dfield_get_len(dfield2),
|
||||||
ind_field->prefix_len,
|
dfield2->data);
|
||||||
dfield_get_len(dfield2),
|
|
||||||
dfield2->data);
|
|
||||||
|
|
||||||
dfield_set_len(dfield, storage_len);
|
dfield_set_len(dfield, storage_len);
|
||||||
}
|
}
|
||||||
|
@ -197,7 +193,6 @@ row_build(
|
||||||
dtuple_t* row;
|
dtuple_t* row;
|
||||||
dict_table_t* table;
|
dict_table_t* table;
|
||||||
dict_field_t* ind_field;
|
dict_field_t* ind_field;
|
||||||
dict_col_t* col;
|
|
||||||
dfield_t* dfield;
|
dfield_t* dfield;
|
||||||
ulint n_fields;
|
ulint n_fields;
|
||||||
byte* field;
|
byte* field;
|
||||||
|
@ -244,7 +239,9 @@ row_build(
|
||||||
|
|
||||||
if (ind_field->prefix_len == 0) {
|
if (ind_field->prefix_len == 0) {
|
||||||
|
|
||||||
col = dict_field_get_col(ind_field);
|
const dict_col_t* col
|
||||||
|
= dict_field_get_col(ind_field);
|
||||||
|
|
||||||
dfield = dtuple_get_nth_field(row,
|
dfield = dtuple_get_nth_field(row,
|
||||||
dict_col_get_no(col));
|
dict_col_get_no(col));
|
||||||
field = rec_get_nth_field(rec, offsets, i, &len);
|
field = rec_get_nth_field(rec, offsets, i, &len);
|
||||||
|
@ -427,11 +424,16 @@ row_build_row_ref(
|
||||||
if (clust_col_prefix_len > 0) {
|
if (clust_col_prefix_len > 0) {
|
||||||
if (len != UNIV_SQL_NULL) {
|
if (len != UNIV_SQL_NULL) {
|
||||||
|
|
||||||
|
const dtype_t* dtype
|
||||||
|
= dfield_get_type(dfield);
|
||||||
|
|
||||||
dfield_set_len(dfield,
|
dfield_set_len(dfield,
|
||||||
dtype_get_at_most_n_mbchars
|
dtype_get_at_most_n_mbchars(
|
||||||
(dfield_get_type(dfield),
|
dtype->prtype,
|
||||||
clust_col_prefix_len, len,
|
dtype->mbminlen,
|
||||||
(char*) field));
|
dtype->mbmaxlen,
|
||||||
|
clust_col_prefix_len,
|
||||||
|
len, (char*) field));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -524,11 +526,16 @@ notfound:
|
||||||
if (clust_col_prefix_len > 0) {
|
if (clust_col_prefix_len > 0) {
|
||||||
if (len != UNIV_SQL_NULL) {
|
if (len != UNIV_SQL_NULL) {
|
||||||
|
|
||||||
|
const dtype_t* dtype
|
||||||
|
= dfield_get_type(dfield);
|
||||||
|
|
||||||
dfield_set_len(dfield,
|
dfield_set_len(dfield,
|
||||||
dtype_get_at_most_n_mbchars
|
dtype_get_at_most_n_mbchars(
|
||||||
(dfield_get_type(dfield),
|
dtype->prtype,
|
||||||
clust_col_prefix_len, len,
|
dtype->mbminlen,
|
||||||
(char*) field));
|
dtype->mbmaxlen,
|
||||||
|
clust_col_prefix_len,
|
||||||
|
len, (char*) field));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -555,13 +562,8 @@ row_build_row_ref_from_row(
|
||||||
directly into data of this row */
|
directly into data of this row */
|
||||||
{
|
{
|
||||||
dict_index_t* clust_index;
|
dict_index_t* clust_index;
|
||||||
dict_field_t* field;
|
|
||||||
dfield_t* dfield;
|
|
||||||
dfield_t* dfield2;
|
|
||||||
dict_col_t* col;
|
|
||||||
ulint ref_len;
|
ulint ref_len;
|
||||||
ulint i;
|
ulint i;
|
||||||
dtype_t* cur_type;
|
|
||||||
|
|
||||||
ut_ad(ref && table && row);
|
ut_ad(ref && table && row);
|
||||||
|
|
||||||
|
@ -572,6 +574,11 @@ row_build_row_ref_from_row(
|
||||||
ut_ad(ref_len == dtuple_get_n_fields(ref));
|
ut_ad(ref_len == dtuple_get_n_fields(ref));
|
||||||
|
|
||||||
for (i = 0; i < ref_len; i++) {
|
for (i = 0; i < ref_len; i++) {
|
||||||
|
const dict_col_t* col;
|
||||||
|
dict_field_t* field;
|
||||||
|
dfield_t* dfield;
|
||||||
|
dfield_t* dfield2;
|
||||||
|
|
||||||
dfield = dtuple_get_nth_field(ref, i);
|
dfield = dtuple_get_nth_field(ref, i);
|
||||||
|
|
||||||
field = dict_index_get_nth_field(clust_index, i);
|
field = dict_index_get_nth_field(clust_index, i);
|
||||||
|
@ -585,12 +592,9 @@ row_build_row_ref_from_row(
|
||||||
if (field->prefix_len > 0
|
if (field->prefix_len > 0
|
||||||
&& dfield->len != UNIV_SQL_NULL) {
|
&& dfield->len != UNIV_SQL_NULL) {
|
||||||
|
|
||||||
cur_type = dict_col_get_type
|
dfield->len = dtype_get_at_most_n_mbchars(
|
||||||
(dict_field_get_col(field));
|
col->prtype, col->mbminlen, col->mbmaxlen,
|
||||||
|
field->prefix_len, dfield->len, dfield->data);
|
||||||
dfield->len = dtype_get_at_most_n_mbchars
|
|
||||||
(cur_type, field->prefix_len,
|
|
||||||
dfield->len, dfield->data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,15 +69,12 @@ row_sel_sec_rec_is_for_clust_rec(
|
||||||
rec_t* clust_rec, /* in: clustered index record */
|
rec_t* clust_rec, /* in: clustered index record */
|
||||||
dict_index_t* clust_index) /* in: clustered index */
|
dict_index_t* clust_index) /* in: clustered index */
|
||||||
{
|
{
|
||||||
dict_field_t* ifield;
|
|
||||||
dict_col_t* col;
|
|
||||||
byte* sec_field;
|
byte* sec_field;
|
||||||
ulint sec_len;
|
ulint sec_len;
|
||||||
byte* clust_field;
|
byte* clust_field;
|
||||||
ulint clust_len;
|
ulint clust_len;
|
||||||
ulint n;
|
ulint n;
|
||||||
ulint i;
|
ulint i;
|
||||||
dtype_t* cur_type;
|
|
||||||
mem_heap_t* heap = NULL;
|
mem_heap_t* heap = NULL;
|
||||||
ulint clust_offsets_[REC_OFFS_NORMAL_SIZE];
|
ulint clust_offsets_[REC_OFFS_NORMAL_SIZE];
|
||||||
ulint sec_offsets_[REC_OFFS_SMALL_SIZE];
|
ulint sec_offsets_[REC_OFFS_SMALL_SIZE];
|
||||||
|
@ -96,27 +93,26 @@ row_sel_sec_rec_is_for_clust_rec(
|
||||||
n = dict_index_get_n_ordering_defined_by_user(sec_index);
|
n = dict_index_get_n_ordering_defined_by_user(sec_index);
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
|
const dict_field_t* ifield;
|
||||||
|
const dict_col_t* col;
|
||||||
|
|
||||||
ifield = dict_index_get_nth_field(sec_index, i);
|
ifield = dict_index_get_nth_field(sec_index, i);
|
||||||
col = dict_field_get_col(ifield);
|
col = dict_field_get_col(ifield);
|
||||||
|
|
||||||
clust_field = rec_get_nth_field
|
clust_field = rec_get_nth_field(
|
||||||
(clust_rec, clust_offs,
|
clust_rec, clust_offs,
|
||||||
dict_col_get_clust_pos(col, clust_index),
|
dict_col_get_clust_pos(col, clust_index), &clust_len);
|
||||||
&clust_len);
|
|
||||||
sec_field = rec_get_nth_field(sec_rec, sec_offs, i, &sec_len);
|
sec_field = rec_get_nth_field(sec_rec, sec_offs, i, &sec_len);
|
||||||
|
|
||||||
if (ifield->prefix_len > 0
|
if (ifield->prefix_len > 0 && clust_len != UNIV_SQL_NULL) {
|
||||||
&& clust_len != UNIV_SQL_NULL) {
|
|
||||||
|
|
||||||
cur_type = dict_col_get_type
|
clust_len = dtype_get_at_most_n_mbchars(
|
||||||
(dict_field_get_col(ifield));
|
col->prtype, col->mbminlen, col->mbmaxlen,
|
||||||
|
ifield->prefix_len,
|
||||||
clust_len = dtype_get_at_most_n_mbchars
|
clust_len, (char*) clust_field);
|
||||||
(cur_type, ifield->prefix_len,
|
|
||||||
clust_len, (char*) clust_field);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 != cmp_data_data(dict_col_get_type(col),
|
if (0 != cmp_data_data(col->mtype, col->prtype,
|
||||||
clust_field, clust_len,
|
clust_field, clust_len,
|
||||||
sec_field, sec_len)) {
|
sec_field, sec_len)) {
|
||||||
is_equal = FALSE;
|
is_equal = FALSE;
|
||||||
|
@ -2247,8 +2243,7 @@ row_sel_convert_mysql_key_to_innobase(
|
||||||
|
|
||||||
while (key_ptr < key_end) {
|
while (key_ptr < key_end) {
|
||||||
|
|
||||||
ut_a(dict_col_get_type(field->col)->mtype
|
ut_a(field->col->mtype == dfield_get_type(dfield)->mtype);
|
||||||
== dfield_get_type(dfield)->mtype);
|
|
||||||
|
|
||||||
data_offset = 0;
|
data_offset = 0;
|
||||||
is_null = FALSE;
|
is_null = FALSE;
|
||||||
|
|
|
@ -388,9 +388,9 @@ row_upd_changes_field_size_or_external(
|
||||||
this fix also to 4.0. The merge to 5.0 will be made
|
this fix also to 4.0. The merge to 5.0 will be made
|
||||||
manually immediately after we commit this to 4.1. */
|
manually immediately after we commit this to 4.1. */
|
||||||
|
|
||||||
new_len = dtype_get_sql_null_size
|
new_len = dict_col_get_sql_null_size(
|
||||||
(dict_index_get_nth_type(index,
|
dict_index_get_nth_col(index,
|
||||||
upd_field->field_no));
|
upd_field->field_no));
|
||||||
}
|
}
|
||||||
|
|
||||||
old_len = rec_offs_nth_size(offsets, upd_field->field_no);
|
old_len = rec_offs_nth_size(offsets, upd_field->field_no);
|
||||||
|
@ -884,7 +884,6 @@ row_upd_index_replace_new_col_vals_index_pos(
|
||||||
ulint j;
|
ulint j;
|
||||||
ulint i;
|
ulint i;
|
||||||
ulint n_fields;
|
ulint n_fields;
|
||||||
dtype_t* cur_type;
|
|
||||||
|
|
||||||
ut_ad(index);
|
ut_ad(index);
|
||||||
|
|
||||||
|
@ -922,13 +921,17 @@ row_upd_index_replace_new_col_vals_index_pos(
|
||||||
if (field->prefix_len > 0
|
if (field->prefix_len > 0
|
||||||
&& new_val->len != UNIV_SQL_NULL) {
|
&& new_val->len != UNIV_SQL_NULL) {
|
||||||
|
|
||||||
cur_type = dict_col_get_type
|
const dict_col_t* col
|
||||||
(dict_field_get_col(field));
|
= dict_field_get_col(field);
|
||||||
|
|
||||||
dfield->len
|
dfield->len
|
||||||
= dtype_get_at_most_n_mbchars
|
= dtype_get_at_most_n_mbchars(
|
||||||
(cur_type, field->prefix_len,
|
col->prtype,
|
||||||
new_val->len, new_val->data);
|
col->mbminlen,
|
||||||
|
col->mbmaxlen,
|
||||||
|
field->prefix_len,
|
||||||
|
new_val->len,
|
||||||
|
new_val->data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -957,7 +960,6 @@ row_upd_index_replace_new_col_vals(
|
||||||
dfield_t* new_val;
|
dfield_t* new_val;
|
||||||
ulint j;
|
ulint j;
|
||||||
ulint i;
|
ulint i;
|
||||||
dtype_t* cur_type;
|
|
||||||
dict_index_t* clust_index;
|
dict_index_t* clust_index;
|
||||||
|
|
||||||
ut_ad(index);
|
ut_ad(index);
|
||||||
|
@ -995,13 +997,17 @@ row_upd_index_replace_new_col_vals(
|
||||||
if (field->prefix_len > 0
|
if (field->prefix_len > 0
|
||||||
&& new_val->len != UNIV_SQL_NULL) {
|
&& new_val->len != UNIV_SQL_NULL) {
|
||||||
|
|
||||||
cur_type = dict_col_get_type
|
const dict_col_t* col
|
||||||
(dict_field_get_col(field));
|
= dict_field_get_col(field);
|
||||||
|
|
||||||
dfield->len
|
dfield->len
|
||||||
= dtype_get_at_most_n_mbchars
|
= dtype_get_at_most_n_mbchars(
|
||||||
(cur_type, field->prefix_len,
|
col->prtype,
|
||||||
new_val->len, new_val->data);
|
col->mbminlen,
|
||||||
|
col->mbmaxlen,
|
||||||
|
field->prefix_len,
|
||||||
|
new_val->len,
|
||||||
|
new_val->data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1044,14 +1050,15 @@ row_upd_changes_ord_field_binary(
|
||||||
|
|
||||||
for (i = 0; i < n_unique; i++) {
|
for (i = 0; i < n_unique; i++) {
|
||||||
|
|
||||||
dict_field_t* ind_field
|
const dict_field_t* ind_field;
|
||||||
= dict_index_get_nth_field(index, i);
|
const dict_col_t* col;
|
||||||
dict_col_t* col
|
ulint col_pos;
|
||||||
= dict_field_get_col(ind_field);
|
ulint col_no;
|
||||||
ulint col_pos
|
|
||||||
= dict_col_get_clust_pos(col, clust_index);
|
ind_field = dict_index_get_nth_field(index, i);
|
||||||
ulint col_no
|
col = dict_field_get_col(ind_field);
|
||||||
= dict_col_get_no(col);
|
col_pos = dict_col_get_clust_pos(col, clust_index);
|
||||||
|
col_no = dict_col_get_no(col);
|
||||||
|
|
||||||
for (j = 0; j < n_upd_fields; j++) {
|
for (j = 0; j < n_upd_fields; j++) {
|
||||||
|
|
||||||
|
@ -1137,12 +1144,13 @@ row_upd_changes_first_fields_binary(
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
|
|
||||||
dict_field_t* ind_field
|
const dict_field_t* ind_field;
|
||||||
= dict_index_get_nth_field(index, i);
|
const dict_col_t* col;
|
||||||
dict_col_t* col
|
ulint col_pos;
|
||||||
= dict_field_get_col(ind_field);
|
|
||||||
ulint col_pos
|
ind_field = dict_index_get_nth_field(index, i);
|
||||||
= dict_col_get_clust_pos(col, clust_index);
|
col = dict_field_get_col(ind_field);
|
||||||
|
col_pos = dict_col_get_clust_pos(col, clust_index);
|
||||||
|
|
||||||
ut_a(ind_field->prefix_len == 0);
|
ut_a(ind_field->prefix_len == 0);
|
||||||
|
|
||||||
|
|
|
@ -903,7 +903,7 @@ srv_init(void)
|
||||||
|
|
||||||
srv_sys->dummy_ind1 = dict_mem_index_create
|
srv_sys->dummy_ind1 = dict_mem_index_create
|
||||||
("SYS_DUMMY1", "SYS_DUMMY1", DICT_HDR_SPACE, 0, 1);
|
("SYS_DUMMY1", "SYS_DUMMY1", DICT_HDR_SPACE, 0, 1);
|
||||||
dict_index_add_col(srv_sys->dummy_ind1, table,
|
dict_index_add_col(srv_sys->dummy_ind1, table, (dict_col_t*)
|
||||||
dict_table_get_nth_col(table, 0), 0);
|
dict_table_get_nth_col(table, 0), 0);
|
||||||
srv_sys->dummy_ind1->table = table;
|
srv_sys->dummy_ind1->table = table;
|
||||||
/* create dummy table and index for new-style infimum and supremum */
|
/* create dummy table and index for new-style infimum and supremum */
|
||||||
|
@ -913,7 +913,7 @@ srv_init(void)
|
||||||
DATA_ENGLISH | DATA_NOT_NULL, 8);
|
DATA_ENGLISH | DATA_NOT_NULL, 8);
|
||||||
srv_sys->dummy_ind2 = dict_mem_index_create
|
srv_sys->dummy_ind2 = dict_mem_index_create
|
||||||
("SYS_DUMMY2", "SYS_DUMMY2", DICT_HDR_SPACE, 0, 1);
|
("SYS_DUMMY2", "SYS_DUMMY2", DICT_HDR_SPACE, 0, 1);
|
||||||
dict_index_add_col(srv_sys->dummy_ind2, table,
|
dict_index_add_col(srv_sys->dummy_ind2, table, (dict_col_t*)
|
||||||
dict_table_get_nth_col(table, 0), 0);
|
dict_table_get_nth_col(table, 0), 0);
|
||||||
srv_sys->dummy_ind2->table = table;
|
srv_sys->dummy_ind2->table = table;
|
||||||
|
|
||||||
|
|
|
@ -413,7 +413,6 @@ trx_undo_page_report_modify(
|
||||||
{
|
{
|
||||||
dict_table_t* table;
|
dict_table_t* table;
|
||||||
upd_field_t* upd_field;
|
upd_field_t* upd_field;
|
||||||
dict_col_t* col;
|
|
||||||
ulint first_free;
|
ulint first_free;
|
||||||
byte* ptr;
|
byte* ptr;
|
||||||
ulint len;
|
ulint len;
|
||||||
|
@ -627,7 +626,8 @@ trx_undo_page_report_modify(
|
||||||
for (col_no = 0; col_no < dict_table_get_n_cols(table);
|
for (col_no = 0; col_no < dict_table_get_n_cols(table);
|
||||||
col_no++) {
|
col_no++) {
|
||||||
|
|
||||||
col = dict_table_get_nth_col(table, col_no);
|
const dict_col_t* col
|
||||||
|
= dict_table_get_nth_col(table, col_no);
|
||||||
|
|
||||||
if (col->ord_part > 0) {
|
if (col->ord_part > 0) {
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue