Commit 79644bdb authored by marko's avatar marko

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.
parent 0b25b850
...@@ -2564,8 +2564,8 @@ btr_index_rec_validate( ...@@ -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( ...@@ -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. */ ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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);
......
This diff is collapsed.
...@@ -1295,7 +1295,8 @@ dict_load_foreigns( ...@@ -1295,7 +1295,8 @@ dict_load_foreigns(
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( ...@@ -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 @@ build_template( ...@@ -3195,7 +3195,7 @@ build_template(
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 @@ build_template( ...@@ -3204,10 +3204,10 @@ build_template(
} }
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( ...@@ -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( ...@@ -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( ...@@ -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; ...@@ -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( ...@@ -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 ...@@ -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( ...@@ -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( ...@@ -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() ...@@ -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
ulint len:16; /* length; for MySQL data this is type true VARCHAR this is the
field->pack_length(), except that for a maximum byte length of the
>= 5.0.3 type true VARCHAR this is the string data (in addition to
maximum byte length of the string data the string, MySQL uses 1 or 2
(in addition to the string, MySQL uses 1 or bytes to store the string length) */
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 */
}; };
#ifndef UNIV_NONINL #ifndef UNIV_NONINL
......
This diff is collapsed.
...@@ -79,17 +79,61 @@ dict_load_space_id_list(void); ...@@ -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. */ ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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 ...@@ -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);
type->mtype = col->mtype;
type->prtype = col->prtype;
type->len = col->len;
type->mbminlen = col->mbminlen;
type->mbmaxlen = col->mbmaxlen;
}
return(&col->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 */
{
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 ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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 ...@@ -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); ...@@ -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 ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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;
} }
......
This diff is collapsed.
...@@ -202,8 +202,7 @@ rec_init_offsets( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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 @@ row_build_row_ref_in_tuple( ...@@ -524,11 +526,16 @@ row_build_row_ref_in_tuple(
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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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
(dict_field_get_col(ifield));
clust_len = dtype_get_at_most_n_mbchars clust_len = dtype_get_at_most_n_mbchars(
(cur_type, ifield->prefix_len, col->prtype, col->mbminlen, col->mbmaxlen,
clust_len, (char*) clust_field); 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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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) ...@@ -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) ...@@ -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( ...@@ -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( ...@@ -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) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment