Commit f39237e2 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 2d96f74a
......@@ -2564,8 +2564,8 @@ btr_index_rec_validate(
offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, &heap);
for (i = 0; i < n; i++) {
dtype_t* type = dict_index_get_nth_type(index, i);
ulint fixed_size = dtype_get_fixed_size(type);
ulint fixed_size = dict_col_get_fixed_size(
dict_index_get_nth_col(index, i));
rec_get_nth_field(rec, offsets, i, &len);
......@@ -2584,8 +2584,7 @@ btr_index_rec_validate(
fprintf(stderr,
"InnoDB: field %lu len is %lu,"
" should be %lu\n",
(ulong) i, (ulong) len,
(ulong) dtype_get_fixed_size(type));
(ulong) i, (ulong) len, (ulong) fixed_size);
if (dump_on_error) {
buf_page_print(page);
......
......@@ -40,9 +40,6 @@ charset-collation code for them. */
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.
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,
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
prefix, in characters, multiplied by
dtype_get_mbmaxlen(dtype) */
......@@ -63,12 +64,12 @@ dtype_get_at_most_n_mbchars(
{
#ifndef UNIV_HOTBACKUP
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) {
ut_a(!(prefix_len % dtype->mbmaxlen));
return(innobase_get_at_most_n_mbchars
(dtype_get_charset_coll(dtype->prtype),
if (mbminlen != mbmaxlen) {
ut_a(!(prefix_len % mbmaxlen));
return(innobase_get_at_most_n_mbchars(
dtype_get_charset_coll(prtype),
prefix_len, data_len, str));
}
......@@ -291,36 +292,3 @@ dtype_print(
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
the built tuple is allocated */
{
dict_table_t* sys_columns;
dtuple_t* entry;
dict_col_t* column;
dfield_t* dfield;
byte* ptr;
dict_table_t* sys_columns;
dtuple_t* entry;
const dict_col_t* column;
dfield_t* dfield;
byte* ptr;
const char* col_name;
ut_ad(table && heap);
......@@ -162,21 +162,21 @@ dict_create_sys_columns_tuple(
dfield = dtuple_get_nth_field(entry, 3);
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);
/* 6: PRTYPE -------------------------*/
dfield = dtuple_get_nth_field(entry, 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);
/* 7: LEN ----------------------------*/
dfield = dtuple_get_nth_field(entry, 5);
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);
/* 8: PREC ---------------------------*/
......@@ -224,8 +224,7 @@ dict_build_table_def_step(
row_len = 0;
for (i = 0; i < table->n_def; i++) {
row_len += dtype_get_min_size(dict_col_get_type
(&table->cols[i]));
row_len += dict_col_get_min_size(&table->cols[i]);
}
if (row_len > BTR_PAGE_MAX_REC_SIZE) {
return(DB_TOO_BIG_RECORD);
......
This diff is collapsed.
......@@ -1295,7 +1295,8 @@ dict_load_foreigns(
following call does the comparison in the latin1_swedish_ci
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),
field, len)) {
......
......@@ -123,22 +123,28 @@ dict_mem_table_add_col(
ulint len) /* in: precision */
{
dict_col_t* col;
dtype_t* type;
ulint mbminlen;
ulint mbmaxlen;
ut_ad(table && name);
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
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->name = mem_heap_strdup(table->heap, name);
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(
mysql_prefix_len = templ->mysql_col_offset
+ 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();
if (templ->mysql_type == DATA_MYSQL_TRUE_VARCHAR) {
......@@ -3204,10 +3204,10 @@ build_template(
}
templ->charset = dtype_get_charset_coll_noninline(
index->table->cols[i].type.prtype);
templ->mbminlen = index->table->cols[i].type.mbminlen;
templ->mbmaxlen = index->table->cols[i].type.mbmaxlen;
templ->is_unsigned = index->table->cols[i].type.prtype
index->table->cols[i].prtype);
templ->mbminlen = index->table->cols[i].mbminlen;
templ->mbmaxlen = index->table->cols[i].mbmaxlen;
templ->is_unsigned = index->table->cols[i].prtype
& DATA_UNSIGNED;
if (templ->type == DATA_BLOB) {
prebuilt->templ_contains_blob = TRUE;
......@@ -3528,7 +3528,7 @@ calc_row_difference(
field_mysql_type = field->type();
col_type = prebuilt->table->cols[i].type.mtype;
col_type = prebuilt->table->cols[i].mtype;
switch (col_type) {
......@@ -3583,7 +3583,8 @@ calc_row_difference(
/* Let us use a dummy dfield to make the conversion
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) {
buf = row_mysql_store_col_in_innobase_format(
......
......@@ -1146,7 +1146,7 @@ ibuf_dummy_index_add_col(
dtype_get_mtype(type),
dtype_get_prtype(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);
}
/************************************************************************
......
......@@ -18,10 +18,6 @@ extern ulint data_mysql_default_charset_coll;
/* SQL data type struct */
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 */
#define DATA_VARCHAR 1 /* character varying of the
......@@ -172,7 +168,11 @@ dtype_get_at_most_n_mbchars(
/*========================*/
/* out: length of the prefix,
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
prefix, in characters, multiplied by
dtype_get_mbmaxlen(dtype) */
......@@ -228,7 +228,7 @@ void
dtype_copy(
/*=======*/
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. */
UNIV_INLINE
......@@ -244,6 +244,18 @@ dtype_get_prtype(
/*=============*/
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. */
ulint
......@@ -300,50 +312,52 @@ dtype_get_pad_char(
/*===============*/
/* out: padding character code, or
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. */
UNIV_INLINE
ulint
dtype_get_fixed_size(
/*=================*/
dtype_get_fixed_size_low(
/*=====================*/
/* 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. */
UNIV_INLINE
ulint
dtype_get_min_size(
/*===============*/
dtype_get_min_size_low(
/*===================*/
/* 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
incomplete and return incorrect information. */
UNIV_INLINE
ulint
dtype_get_max_size(
/*===============*/
/* out: maximum size (ULINT_MAX for
unbounded types) */
const dtype_t* type); /* in: type */
dtype_get_max_size_low(
/*===================*/
/* out: maximum size */
ulint mtype, /* in: main type */
ulint len); /* in: length */
/***************************************************************************
Returns a stored SQL NULL size for a type. For fixed length types it is
the fixed length of the type, otherwise 0. */
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
ulint
dtype_get_sql_null_size(
/*====================*/
/* out: SQL null storage size */
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 */
/* out: SQL null storage size
in ROW_FORMAT=REDUNDANT */
const dtype_t* type); /* in: type */
/**************************************************************************
Reads to a type the stored information which determines its alphabetical
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() */
struct dtype_struct{
ulint mtype:8; /* main data type */
ulint prtype:24; /* precise type; MySQL data type, charset code,
flags to indicate nullability, signedness,
whether this is a binary string, whether this
is a true VARCHAR where MySQL uses 2 bytes to
store the length */
unsigned mtype:8; /* main data type */
unsigned prtype:24; /* precise type; MySQL data
type, charset code, flags to
indicate nullability,
signedness, whether this is a
binary string, whether this is
a true VARCHAR where MySQL
uses 2 bytes to store the length */
/* the remaining fields do not affect alphabetical ordering: */
ulint mbminlen:2; /* minimum length of a character, in bytes */
ulint mbmaxlen:3; /* maximum length of a character, in bytes */
ulint len:16; /* length; for MySQL data this is
field->pack_length(), except that for a
>= 5.0.3 type true VARCHAR this is the
maximum byte length of the string data
(in addition to the string, MySQL uses 1 or
2 bytes to store the string length) */
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 */
};
#ifndef UNIV_NONINL
......
This diff is collapsed.
......@@ -79,17 +79,61 @@ dict_load_space_id_list(void);
/*************************************************************************
Gets the column data type. */
UNIV_INLINE
dtype_t*
dict_col_get_type(
/*==============*/
dict_col_t* col);
void
dict_col_copy_type(
/*===============*/
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. */
UNIV_INLINE
ulint
dict_col_get_no(
/*============*/
dict_col_t* col);
const dict_col_t* col);
/*************************************************************************
Gets the column position in the clustered index. */
UNIV_INLINE
......@@ -368,11 +412,12 @@ Returns a column's name. */
const char*
dict_table_get_col_name(
/*====================*/
/* out: column name. NOTE: not guaranteed to
stay valid if table is modified in any way
(columns added, etc.). */
dict_table_t* table, /* in: table */
ulint i); /* in: column number */
/* out: column name. NOTE: not
guaranteed to stay valid if
table is modified in any way
(columns added, etc.). */
const dict_table_t* table, /* in: table */
ulint i); /* in: column number */
/**************************************************************************
Prints a table definition. */
......@@ -488,30 +533,30 @@ dict_table_get_n_cols(
/************************************************************************
Gets the nth column of a table. */
UNIV_INLINE
dict_col_t*
const dict_col_t*
dict_table_get_nth_col(
/*===================*/
/* out: pointer to column object */
dict_table_t* table, /* in: table */
ulint pos); /* in: position of column */
/* out: pointer to column object */
const dict_table_t* table, /* in: table */
ulint pos); /* in: position of column */
/************************************************************************
Gets the nth column of a table. */
dict_col_t*
const dict_col_t*
dict_table_get_nth_col_noninline(
/*=============================*/
/* out: pointer to column object */
dict_table_t* table, /* in: table */
ulint pos); /* in: position of column */
/* out: pointer to column object */
const dict_table_t* table, /* in: table */
ulint pos); /* in: position of column */
/************************************************************************
Gets the given system column of a table. */
UNIV_INLINE
dict_col_t*
const dict_col_t*
dict_table_get_sys_col(
/*===================*/
/* out: pointer to column object */
dict_table_t* table, /* in: table */
ulint sys); /* in: DATA_ROW_ID, ... */
/* out: pointer to column object */
const dict_table_t* table, /* in: table */
ulint sys); /* in: DATA_ROW_ID, ... */
/************************************************************************
Gets the given system column number of a table. */
UNIV_INLINE
......@@ -633,23 +678,23 @@ dict_index_get_nth_field(
dict_index_t* index, /* in: index */
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
dtype_t*
dict_index_get_nth_type(
/*====================*/
/* out: data type */
dict_index_t* index, /* in: index */
ulint pos); /* in: position of the field */
const dict_col_t*
dict_index_get_nth_col(
/*===================*/
/* out: column */
const dict_index_t* index, /* in: index */
ulint pos); /* in: position of the field */
/************************************************************************
Gets the column number of the nth field in an index. */
UNIV_INLINE
ulint
dict_index_get_nth_col_no(
/*======================*/
/* out: column number */
dict_index_t* index, /* in: index */
ulint pos); /* in: position of the field */
/* out: column number */
const dict_index_t* index, /* in: index */
ulint pos); /* in: position of the field */
/************************************************************************
Looks for column n in an index. */
......@@ -728,10 +773,10 @@ dict_index_copy_types(
/*************************************************************************
Gets the field column. */
UNIV_INLINE
dict_col_t*
const dict_col_t*
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. */
......
......@@ -10,18 +10,73 @@ Created 1/8/1996 Heikki Tuuri
#include "trx0undo.h"
#include "trx0sys.h"
#include "rem0types.h"
#include "data0type.h"
/*************************************************************************
Gets the column data type. */
UNIV_INLINE
dtype_t*
dict_col_get_type(
/*==============*/
dict_col_t* col)
void
dict_col_copy_type(
/*===============*/
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
ulint
dict_col_get_no(
/*============*/
dict_col_t* col)
const dict_col_t* col)
{
ut_ad(col);
......@@ -145,12 +200,12 @@ dict_table_get_n_cols(
/************************************************************************
Gets the nth column of a table. */
UNIV_INLINE
dict_col_t*
const dict_col_t*
dict_table_get_nth_col(
/*===================*/
/* out: pointer to column object */
dict_table_t* table, /* in: table */
ulint pos) /* in: position of column */
/* out: pointer to column object */
const dict_table_t* table, /* in: table */
ulint pos) /* in: position of column */
{
ut_ad(table);
ut_ad(pos < table->n_def);
......@@ -162,14 +217,14 @@ dict_table_get_nth_col(
/************************************************************************
Gets the given system column of a table. */
UNIV_INLINE
dict_col_t*
const dict_col_t*
dict_table_get_sys_col(
/*===================*/
/* out: pointer to column object */
dict_table_t* table, /* in: table */
ulint sys) /* in: DATA_ROW_ID, ... */
/* out: pointer to column object */
const dict_table_t* table, /* in: table */
ulint sys) /* in: DATA_ROW_ID, ... */
{
dict_col_t* col;
const dict_col_t* col;
ut_ad(table);
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
- DATA_N_SYS_COLS + sys);
ut_ad(col->type.mtype == DATA_SYS);
ut_ad(col->type.prtype == (sys | DATA_NOT_NULL));
ut_ad(col->mtype == DATA_SYS);
ut_ad(col->prtype == (sys | DATA_NOT_NULL));
return(col);
}
......@@ -324,30 +379,28 @@ dict_index_get_sys_col_pos(
dict_index_t* index, /* in: index */
ulint type) /* in: DATA_ROW_ID, ... */
{
dict_col_t* col;
ut_ad(index);
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
ut_ad(!(index->type & DICT_UNIVERSAL));
col = dict_table_get_sys_col(index->table, type);
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
(index, dict_table_get_sys_col_no(index->table, type)));
return(dict_index_get_nth_col_pos(
index, dict_table_get_sys_col_no(index->table, type)));
}
/*************************************************************************
Gets the field column. */
UNIV_INLINE
dict_col_t*
const dict_col_t*
dict_field_get_col(
/*===============*/
dict_field_t* field)
const dict_field_t* 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
dtype_t*
dict_index_get_nth_type(
/*====================*/
/* out: data type */
dict_index_t* index, /* in: index */
ulint pos) /* in: position of the field */
const dict_col_t*
dict_index_get_nth_col(
/*===================*/
/* out: column */
const dict_index_t* index, /* in: index */
ulint pos) /* in: position of the field */
{
return(dict_col_get_type(dict_field_get_col
(dict_index_get_nth_field(index, pos))));
return(dict_field_get_col(dict_index_get_nth_field((dict_index_t*)
index, pos)));
}
/************************************************************************
......@@ -374,12 +427,11 @@ UNIV_INLINE
ulint
dict_index_get_nth_col_no(
/*======================*/
/* out: column number */
dict_index_t* index, /* in: index */
ulint pos) /* in: position of the field */
/* out: column number */
const dict_index_t* index, /* in: index */
ulint pos) /* in: position of the field */
{
return(dict_col_get_no(dict_field_get_col
(dict_index_get_nth_field(index, pos))));
return(dict_col_get_no(dict_index_get_nth_col(index, pos)));
}
/*************************************************************************
......
......@@ -121,12 +121,43 @@ dict_mem_foreign_create(void);
/* Data structure for a column in a table */
struct dict_col_struct{
ulint ind:10; /* table column position (they are numbered
starting from 0) */
ulint ord_part:1;/* nonzero if this column appears
in ordering fields of an index */
const char* name; /* name */
dtype_t type; /* data type */
/*----------------------*/
/* The following are copied from dtype_t,
so that all bit-fields can be packed tightly. */
unsigned mtype:8; /* main data type */
unsigned prtype:24; /* precise type; MySQL data
type, charset code, flags to
indicate nullability,
signedness, whether this is a
binary string, whether this is
a true VARCHAR where MySQL
uses 2 bytes to 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
......
......@@ -16,16 +16,17 @@ Created 7/1/1994 Heikki Tuuri
#include "rem0rec.h"
/*****************************************************************
Returns TRUE if two types are equal for comparison purposes. */
Returns TRUE if two columns are equal for comparison purposes. */
ibool
cmp_types_are_equal(
/*================*/
/* out: TRUE if the types are considered
equal in comparisons */
dtype_t* type1, /* in: type 1 */
dtype_t* type2, /* in: type 2 */
ibool check_charsets); /* in: whether to check charsets */
cmp_cols_are_equal(
/*===============*/
/* out: TRUE if the columns are
considered equal in comparisons */
const dict_col_t* col1, /* in: column 1 */
const dict_col_t* col2, /* in: column 2 */
ibool check_charsets);
/* in: whether to check charsets */
/*****************************************************************
This function is used to compare two data fields for which we know the
data type. */
......@@ -35,7 +36,8 @@ cmp_data_data(
/*==========*/
/* out: 1, 0, -1, if data1 is greater, equal,
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
buffer) */
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,
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
buffer) */
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,
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
buffer) */
ulint len1, /* in: data field length or UNIV_SQL_NULL */
......@@ -23,7 +24,7 @@ cmp_data_data(
buffer) */
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* dfield2)/* in: data field */
{
const dtype_t* type;
ut_ad(dfield_check_typed(dfield1));
return(cmp_data_data
(dfield_get_type(dfield1),
dfield_get_data(dfield1), dfield_get_len(dfield1),
dfield_get_data(dfield2), dfield_get_len(dfield2)));
type = dfield_get_type(dfield1);
return(cmp_data_data(type->mtype, type->prtype,
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));
}
dtype_copy(dfield_get_type(&(upd_field->new_val)),
dict_index_get_nth_type(index, field_no));
dict_col_copy_type(dict_index_get_nth_col(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));
log_ptr += 2;
for (i = 0; i < n; i++) {
dict_field_t* field;
dtype_t* type;
ulint len;
dict_field_t* field;
const dict_col_t* col;
ulint len;
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;
ut_ad(len < 0x7fff);
if (len == 0
&& (dtype_get_len(type) > 255
|| dtype_get_mtype(type) == DATA_BLOB)) {
&& (col->len > 255 || col->mtype == DATA_BLOB)) {
/* variable-length field
with maximum length > 255 */
len = 0x7fff;
}
if (dtype_get_prtype(type) & DATA_NOT_NULL) {
if (col->prtype & DATA_NOT_NULL) {
len |= 0x8000;
}
if (log_ptr + 2 > log_end) {
......@@ -548,7 +548,7 @@ mlog_parse_index(
len & 0x8000 ? DATA_NOT_NULL : 0,
len & 0x7fff);
dict_index_add_col(ind, table,
dict_index_add_col(ind, table, (dict_col_t*)
dict_table_get_nth_col(table, i),
0);
}
......
......@@ -489,9 +489,10 @@ pars_resolve_exp_columns(
n_cols = dict_table_get_n_cols(table);
for (i = 0; i < n_cols; i++) {
dict_col_t* col = dict_table_get_nth_col(table, i);
const char* col_name = dict_table_get_col_name(
table, i);
const dict_col_t* col
= dict_table_get_nth_col(table, i);
const char* col_name
= dict_table_get_col_name(table, i);
if ((sym_node->name_len == ut_strlen(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->prefetch_buf = NULL;
dfield_set_type(&(sym_node->common.val),
dict_col_get_type(col));
dict_col_copy_type(
col,
dfield_get_type(&sym_node
->common.val));
return;
}
......@@ -920,8 +923,9 @@ pars_process_assign_list(
clust_index, NULL);
upd_field->exp = assign_node->val;
if (!dtype_is_fixed_size(dict_index_get_nth_type
(clust_index, upd_field->field_no))) {
if (!dict_col_get_fixed_size(
dict_index_get_nth_col(clust_index,
upd_field->field_no))) {
changes_field_size = 0;
}
......
This diff is collapsed.
......@@ -202,8 +202,7 @@ rec_init_offsets(
}
field = dict_index_get_nth_field(index, i);
if (!(dtype_get_prtype(dict_col_get_type
(dict_field_get_col(field)))
if (!(dict_field_get_col(field)->prtype
& DATA_NOT_NULL)) {
/* nullable field => read the null flag */
......@@ -226,11 +225,11 @@ rec_init_offsets(
if (UNIV_UNLIKELY(!field->fixed_len)) {
/* Variable-length field: read the length */
dtype_t* type = dict_col_get_type
(dict_field_get_col(field));
const dict_col_t* col
= dict_field_get_col(field);
len = *lens--;
if (UNIV_UNLIKELY(dtype_get_len(type) > 255)
|| UNIV_UNLIKELY(dtype_get_mtype(type)
if (UNIV_UNLIKELY(col->len > 255)
|| UNIV_UNLIKELY(col->mtype
== DATA_BLOB)) {
if (len & 0x80) {
/* 1exxxxxxx xxxxxxxx */
......@@ -442,8 +441,6 @@ rec_get_converted_size_new(
{
ulint size = REC_N_NEW_EXTRA_BYTES
+ (index->n_nullable + 7) / 8;
dict_field_t* field;
dtype_t* type;
ulint i;
ulint n_fields;
ut_ad(index && dtuple);
......@@ -471,25 +468,27 @@ rec_get_converted_size_new(
/* read the lengths of fields 0..n */
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);
type = dict_col_get_type(dict_field_get_col(field));
ut_ad(len != UNIV_SQL_NULL
|| !(dtype_get_prtype(type) & DATA_NOT_NULL));
len = dtuple_get_nth_field(dtuple, i)->len;
col = dict_field_get_col(field);
ut_ad(len != UNIV_SQL_NULL || !(col->prtype & DATA_NOT_NULL));
if (len == UNIV_SQL_NULL) {
/* No length is stored for NULL fields. */
continue;
}
ut_ad(len <= dtype_get_len(type)
|| dtype_get_mtype(type) == DATA_BLOB);
ut_ad(len <= col->len || col->mtype == DATA_BLOB);
ut_ad(!field->fixed_len || len == field->fixed_len);
if (field->fixed_len) {
} else if (len < 128
|| (dtype_get_len(type) < 256
&& dtype_get_mtype(type) != DATA_BLOB)) {
|| (col->len < 256 && col->mtype != DATA_BLOB)) {
size++;
} else {
size += 2;
......@@ -588,8 +587,6 @@ rec_set_nth_field_extern_bit_new(
{
byte* nulls = rec - (REC_N_NEW_EXTRA_BYTES + 1);
byte* lens = nulls - (index->n_nullable + 7) / 8;
dict_field_t* field;
dtype_t* type;
ulint i;
ulint n_fields;
ulint null_mask = 1;
......@@ -603,9 +600,13 @@ rec_set_nth_field_extern_bit_new(
/* read the lengths of fields 0..n */
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);
type = dict_col_get_type(dict_field_get_col(field));
if (!(dtype_get_prtype(type) & DATA_NOT_NULL)) {
col = dict_field_get_col(field);
if (!(col->prtype & DATA_NOT_NULL)) {
if (UNIV_UNLIKELY(!(byte) null_mask)) {
nulls--;
null_mask = 1;
......@@ -629,8 +630,7 @@ rec_set_nth_field_extern_bit_new(
continue;
}
lens--;
if (dtype_get_len(type) > 255
|| dtype_get_mtype(type) == DATA_BLOB) {
if (col->len > 255 || col->mtype == DATA_BLOB) {
ulint len = lens[1];
if (len & 0x80) { /* 1exxxxxx: 2-byte length */
if (i == ith) {
......@@ -640,9 +640,10 @@ rec_set_nth_field_extern_bit_new(
/* toggle the extern bit */
len ^= 0x40;
if (mtr) {
mlog_write_ulint
(lens + 1, len,
MLOG_1BYTE, mtr);
mlog_write_ulint(lens + 1,
len,
MLOG_1BYTE,
mtr);
} else {
lens[1] = (byte) len;
}
......@@ -1137,8 +1138,6 @@ rec_copy_prefix_to_buf(
{
byte* nulls;
byte* lens;
dict_field_t* field;
dtype_t* type;
ulint i;
ulint prefix_len;
ulint null_mask;
......@@ -1180,9 +1179,13 @@ rec_copy_prefix_to_buf(
/* read the lengths of fields 0..n */
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);
type = dict_col_get_type(dict_field_get_col(field));
if (!(dtype_get_prtype(type) & DATA_NOT_NULL)) {
col = dict_field_get_col(field);
if (!(col->prtype & DATA_NOT_NULL)) {
/* nullable field => read the null flag */
if (UNIV_UNLIKELY(!(byte) null_mask)) {
nulls--;
......@@ -1201,8 +1204,7 @@ rec_copy_prefix_to_buf(
prefix_len += field->fixed_len;
} else {
ulint len = *lens--;
if (dtype_get_len(type) > 255
|| dtype_get_mtype(type) == DATA_BLOB) {
if (col->len > 255 || col->mtype == DATA_BLOB) {
if (len & 0x80) {
/* 1exxxxxx */
len &= 0x3f;
......
......@@ -135,12 +135,12 @@ row_ins_alloc_sys_fields(
/*=====================*/
ins_node_t* node) /* in: insert node */
{
dtuple_t* row;
dict_table_t* table;
mem_heap_t* heap;
dict_col_t* col;
dfield_t* dfield;
byte* ptr;
dtuple_t* row;
dict_table_t* table;
mem_heap_t* heap;
const dict_col_t* col;
dfield_t* dfield;
byte* ptr;
row = node->row;
table = node->table;
......@@ -445,7 +445,6 @@ row_ins_cascade_calc_update_vec(
upd_field_t* parent_ufield;
ulint n_fields_updated;
ulint parent_field_no;
dtype_t* type;
ulint i;
ulint j;
......@@ -479,7 +478,10 @@ row_ins_cascade_calc_update_vec(
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
updated. Let us make the update vector
......@@ -488,20 +490,17 @@ row_ins_cascade_calc_update_vec(
ufield = update->fields + n_fields_updated;
ufield->field_no
= dict_table_get_nth_col_pos
(table,
dict_index_get_nth_col_no(index, i));
= dict_table_get_nth_col_pos(
table, dict_col_get_no(col));
ufield->exp = NULL;
ufield->new_val = parent_ufield->new_val;
type = dict_index_get_nth_type(index, i);
/* Do not allow a NOT NULL column to be
updated as NULL */
if (ufield->new_val.len == UNIV_SQL_NULL
&& (type->prtype & DATA_NOT_NULL)) {
&& (col->prtype & DATA_NOT_NULL)) {
return(ULINT_UNDEFINED);
}
......@@ -510,9 +509,12 @@ row_ins_cascade_calc_update_vec(
column, do not allow the update */
if (ufield->new_val.len != UNIV_SQL_NULL
&& dtype_get_at_most_n_mbchars
(type, dtype_get_len(type),
ufield->new_val.len, ufield->new_val.data)
&& dtype_get_at_most_n_mbchars(
col->prtype,
col->mbminlen, col->mbmaxlen,
col->len,
ufield->new_val.len,
ufield->new_val.data)
< ufield->new_val.len) {
return(ULINT_UNDEFINED);
......@@ -523,7 +525,7 @@ row_ins_cascade_calc_update_vec(
need to pad with spaces the new value of the
child column */
min_size = dtype_get_min_size(type);
min_size = dict_col_get_min_size(col);
if (min_size
&& 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.len);
switch (UNIV_EXPECT(dtype_get_mbminlen
(type), 1)) {
switch (UNIV_EXPECT(col->mbminlen,1)) {
default:
ut_error;
case 1:
if (UNIV_UNLIKELY
(dtype_get_charset_coll
(dtype_get_prtype(type))
(dtype_get_charset_coll(
col->prtype)
== DATA_MYSQL_BINARY_CHARSET_COLL)) {
/* Do not pad BINARY
columns. */
......@@ -2211,7 +2212,6 @@ row_ins_index_entry_set_vals(
dfield_t* row_field;
ulint n_fields;
ulint i;
dtype_t* cur_type;
ut_ad(entry && row);
......@@ -2227,12 +2227,13 @@ row_ins_index_entry_set_vals(
if (ind_field->prefix_len > 0
&& dfield_get_len(row_field) != UNIV_SQL_NULL) {
cur_type = dict_col_get_type
(dict_field_get_col(ind_field));
const dict_col_t* col
= dict_field_get_col(ind_field);
field->len = dtype_get_at_most_n_mbchars
(cur_type, ind_field->prefix_len,
dfield_get_len(row_field), row_field->data);
field->len = dtype_get_at_most_n_mbchars(
col->prtype, col->mbminlen, col->mbmaxlen,
ind_field->prefix_len,
row_field->len, row_field->data);
} else {
field->len = row_field->len;
}
......
......@@ -1607,16 +1607,11 @@ row_table_got_default_clust_index(
/*==============================*/
dict_table_t* table)
{
dict_index_t* clust_index;
const dict_index_t* clust_index;
clust_index = dict_table_get_first_index(table);
if (dtype_get_mtype(dict_index_get_nth_type(clust_index, 0))
== DATA_SYS) {
return(TRUE);
}
return(FALSE);
return(dict_index_get_nth_col(clust_index, 0)->mtype == DATA_SYS);
}
/*************************************************************************
......
......@@ -114,10 +114,8 @@ row_build_index_entry(
dict_field_t* ind_field;
dfield_t* dfield;
dfield_t* dfield2;
dict_col_t* col;
ulint i;
ulint storage_len;
dtype_t* cur_type;
ut_ad(row && index && heap);
ut_ad(dtuple_check_typed(row));
......@@ -134,7 +132,7 @@ row_build_index_entry(
for (i = 0; i < entry_len; 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);
......@@ -146,14 +144,12 @@ row_build_index_entry(
if (ind_field->prefix_len) {
if (dfield_get_len(dfield2) != UNIV_SQL_NULL) {
cur_type = dict_col_get_type
(dict_field_get_col(ind_field));
storage_len = dtype_get_at_most_n_mbchars
(cur_type,
ind_field->prefix_len,
dfield_get_len(dfield2),
dfield2->data);
storage_len = dtype_get_at_most_n_mbchars(
col->prtype,
col->mbminlen, col->mbmaxlen,
ind_field->prefix_len,
dfield_get_len(dfield2),
dfield2->data);
dfield_set_len(dfield, storage_len);
}
......@@ -197,7 +193,6 @@ row_build(
dtuple_t* row;
dict_table_t* table;
dict_field_t* ind_field;
dict_col_t* col;
dfield_t* dfield;
ulint n_fields;
byte* field;
......@@ -244,7 +239,9 @@ row_build(
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,
dict_col_get_no(col));
field = rec_get_nth_field(rec, offsets, i, &len);
......@@ -427,11 +424,16 @@ row_build_row_ref(
if (clust_col_prefix_len > 0) {
if (len != UNIV_SQL_NULL) {
const dtype_t* dtype
= dfield_get_type(dfield);
dfield_set_len(dfield,
dtype_get_at_most_n_mbchars
(dfield_get_type(dfield),
clust_col_prefix_len, len,
(char*) field));
dtype_get_at_most_n_mbchars(
dtype->prtype,
dtype->mbminlen,
dtype->mbmaxlen,
clust_col_prefix_len,
len, (char*) field));
}
}
}
......@@ -524,11 +526,16 @@ row_build_row_ref_in_tuple(
if (clust_col_prefix_len > 0) {
if (len != UNIV_SQL_NULL) {
const dtype_t* dtype
= dfield_get_type(dfield);
dfield_set_len(dfield,
dtype_get_at_most_n_mbchars
(dfield_get_type(dfield),
clust_col_prefix_len, len,
(char*) field));
dtype_get_at_most_n_mbchars(
dtype->prtype,
dtype->mbminlen,
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 */
{
dict_index_t* clust_index;
dict_field_t* field;
dfield_t* dfield;
dfield_t* dfield2;
dict_col_t* col;
ulint ref_len;
ulint i;
dtype_t* cur_type;
ut_ad(ref && table && row);
......@@ -572,6 +574,11 @@ row_build_row_ref_from_row(
ut_ad(ref_len == dtuple_get_n_fields(ref));
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);
field = dict_index_get_nth_field(clust_index, i);
......@@ -585,12 +592,9 @@ row_build_row_ref_from_row(
if (field->prefix_len > 0
&& dfield->len != UNIV_SQL_NULL) {
cur_type = dict_col_get_type
(dict_field_get_col(field));
dfield->len = dtype_get_at_most_n_mbchars
(cur_type, field->prefix_len,
dfield->len, dfield->data);
dfield->len = dtype_get_at_most_n_mbchars(
col->prtype, col->mbminlen, col->mbmaxlen,
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 */
dict_index_t* clust_index) /* in: clustered index */
{
dict_field_t* ifield;
dict_col_t* col;
byte* sec_field;
ulint sec_len;
byte* clust_field;
ulint clust_len;
ulint n;
ulint i;
dtype_t* cur_type;
mem_heap_t* heap = NULL;
ulint clust_offsets_[REC_OFFS_NORMAL_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);
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);
col = dict_field_get_col(ifield);
clust_field = rec_get_nth_field
(clust_rec, clust_offs,
dict_col_get_clust_pos(col, clust_index),
&clust_len);
clust_field = rec_get_nth_field(
clust_rec, clust_offs,
dict_col_get_clust_pos(col, clust_index), &clust_len);
sec_field = rec_get_nth_field(sec_rec, sec_offs, i, &sec_len);
if (ifield->prefix_len > 0
&& clust_len != UNIV_SQL_NULL) {
cur_type = dict_col_get_type
(dict_field_get_col(ifield));
if (ifield->prefix_len > 0 && clust_len != UNIV_SQL_NULL) {
clust_len = dtype_get_at_most_n_mbchars
(cur_type, ifield->prefix_len,
clust_len, (char*) clust_field);
clust_len = dtype_get_at_most_n_mbchars(
col->prtype, col->mbminlen, col->mbmaxlen,
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,
sec_field, sec_len)) {
is_equal = FALSE;
......@@ -2247,8 +2243,7 @@ row_sel_convert_mysql_key_to_innobase(
while (key_ptr < key_end) {
ut_a(dict_col_get_type(field->col)->mtype
== dfield_get_type(dfield)->mtype);
ut_a(field->col->mtype == dfield_get_type(dfield)->mtype);
data_offset = 0;
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
manually immediately after we commit this to 4.1. */
new_len = dtype_get_sql_null_size
(dict_index_get_nth_type(index,
upd_field->field_no));
new_len = dict_col_get_sql_null_size(
dict_index_get_nth_col(index,
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 i;
ulint n_fields;
dtype_t* cur_type;
ut_ad(index);
......@@ -922,13 +921,17 @@ row_upd_index_replace_new_col_vals_index_pos(
if (field->prefix_len > 0
&& new_val->len != UNIV_SQL_NULL) {
cur_type = dict_col_get_type
(dict_field_get_col(field));
const dict_col_t* col
= dict_field_get_col(field);
dfield->len
= dtype_get_at_most_n_mbchars
(cur_type, field->prefix_len,
new_val->len, new_val->data);
= dtype_get_at_most_n_mbchars(
col->prtype,
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;
ulint j;
ulint i;
dtype_t* cur_type;
dict_index_t* clust_index;
ut_ad(index);
......@@ -995,13 +997,17 @@ row_upd_index_replace_new_col_vals(
if (field->prefix_len > 0
&& new_val->len != UNIV_SQL_NULL) {
cur_type = dict_col_get_type
(dict_field_get_col(field));
const dict_col_t* col
= dict_field_get_col(field);
dfield->len
= dtype_get_at_most_n_mbchars
(cur_type, field->prefix_len,
new_val->len, new_val->data);
= dtype_get_at_most_n_mbchars(
col->prtype,
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++) {
dict_field_t* ind_field
= dict_index_get_nth_field(index, i);
dict_col_t* col
= dict_field_get_col(ind_field);
ulint col_pos
= dict_col_get_clust_pos(col, clust_index);
ulint col_no
= dict_col_get_no(col);
const dict_field_t* ind_field;
const dict_col_t* col;
ulint col_pos;
ulint col_no;
ind_field = dict_index_get_nth_field(index, i);
col = dict_field_get_col(ind_field);
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++) {
......@@ -1137,12 +1144,13 @@ row_upd_changes_first_fields_binary(
for (i = 0; i < n; i++) {
dict_field_t* ind_field
= dict_index_get_nth_field(index, i);
dict_col_t* col
= dict_field_get_col(ind_field);
ulint col_pos
= dict_col_get_clust_pos(col, clust_index);
const dict_field_t* ind_field;
const dict_col_t* col;
ulint col_pos;
ind_field = dict_index_get_nth_field(index, i);
col = dict_field_get_col(ind_field);
col_pos = dict_col_get_clust_pos(col, clust_index);
ut_a(ind_field->prefix_len == 0);
......
......@@ -903,7 +903,7 @@ srv_init(void)
srv_sys->dummy_ind1 = dict_mem_index_create
("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);
srv_sys->dummy_ind1->table = table;
/* create dummy table and index for new-style infimum and supremum */
......@@ -913,7 +913,7 @@ srv_init(void)
DATA_ENGLISH | DATA_NOT_NULL, 8);
srv_sys->dummy_ind2 = dict_mem_index_create
("SYS_DUMMY2", "SYS_DUMMY2", DICT_HDR_SPACE, 0, 1);
dict_index_add_col(srv_sys->dummy_ind2, table,
dict_index_add_col(srv_sys->dummy_ind2, table, (dict_col_t*)
dict_table_get_nth_col(table, 0), 0);
srv_sys->dummy_ind2->table = table;
......
......@@ -413,7 +413,6 @@ trx_undo_page_report_modify(
{
dict_table_t* table;
upd_field_t* upd_field;
dict_col_t* col;
ulint first_free;
byte* ptr;
ulint len;
......@@ -627,7 +626,8 @@ trx_undo_page_report_modify(
for (col_no = 0; col_no < dict_table_get_n_cols(table);
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) {
......
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