Commit 0444f59f authored by unknown's avatar unknown

InnoDB: Small improvements to earlier patch (fix Bug #7350 better),

suggested in review by Heikki.


innobase/include/data0type.h:
  Improve comment of dtype_struct.
innobase/include/data0type.ic:
  Rename innobase_get_mb_cset() to innobase_get_cset_width().
  dtype_get_fixed_size(): Add an extra integrity check for
  type->prtype, type->mbminlen and type->mbmaxlen.
sql/ha_innodb.cc:
  Rename innobase_get_mb_cset() to innobase_get_cset_width()
parent edf5f0ec
......@@ -370,7 +370,13 @@ dtype_print(
/*========*/
dtype_t* type); /* in: type */
/* Structure for an SQL data type */
/* Structure for an SQL data type.
If you add fields to this structure, be sure to initialize them everywhere.
This structure is initialized in the following functions:
dtype_set()
dtype_read_for_order_and_null_size()
dtype_new_read_for_order_and_null_size()
sym_tab_add_null_lit() */
struct dtype_struct{
ulint mtype; /* main data type */
......
......@@ -15,8 +15,8 @@ NOTE: the prototype of this function is copied from ha_innodb.cc! If you change
this function, you MUST change also the prototype here! */
extern
void
innobase_get_mb_cset(
/*=================*/
innobase_get_cset_width(
/*====================*/
ulint cset, /* in: MySQL charset-collation code */
ulint* mbminlen, /* out: minimum length of a char (in bytes) */
ulint* mbmaxlen); /* out: maximum length of a char (in bytes) */
......@@ -42,7 +42,7 @@ dtype_set_mblen(
{
ut_ad(type);
if (dtype_is_string_type(type->mtype)) {
innobase_get_mb_cset(dtype_get_charset_coll(type->prtype),
innobase_get_cset_width(dtype_get_charset_coll(type->prtype),
&type->mbminlen, &type->mbmaxlen);
ut_ad(type->mbminlen <= type->mbmaxlen);
} else {
......@@ -355,9 +355,40 @@ dtype_get_fixed_size(
case DATA_FLOAT:
case DATA_DOUBLE:
case DATA_MYSQL:
if ((type->prtype & DATA_BINARY_TYPE)
|| type->mbminlen == type->mbmaxlen) {
if (type->prtype & DATA_BINARY_TYPE) {
return(dtype_get_len(type));
} else {
/* We play it safe here and ask MySQL for
mbminlen and mbmaxlen. Although
type->mbminlen and type->mbmaxlen are
initialized if and only if type->prtype
is (in one of the 3 functions in this file),
it could be that none of these functions
has been called. */
ulint mbminlen, mbmaxlen;
innobase_get_cset_width(
dtype_get_charset_coll(type->prtype),
&mbminlen, &mbmaxlen);
if (type->mbminlen != mbminlen
|| type->mbmaxlen != mbmaxlen) {
ut_print_timestamp(stderr);
fprintf(stderr, " InnoDB: "
"mbminlen=%lu, "
"mbmaxlen=%lu, "
"type->mbminlen=%lu, "
"type->mbmaxlen=%lu\n",
(ulong) mbminlen,
(ulong) mbmaxlen,
(ulong) type->mbminlen,
(ulong) type->mbmaxlen);
}
if (mbminlen == mbmaxlen) {
return(dtype_get_len(type));
}
}
/* fall through for variable-length charsets */
case DATA_VARCHAR:
......
......@@ -541,8 +541,8 @@ NOTE that the exact prototype of this function has to be in
/innobase/data/data0type.ic! */
extern "C"
void
innobase_get_mb_cset(
/*=================*/
innobase_get_cset_width(
/*====================*/
ulint cset, /* in: MySQL charset-collation code */
ulint* mbminlen, /* out: minimum length of a char (in bytes) */
ulint* mbmaxlen) /* out: maximum length of a char (in bytes) */
......
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