diff options
author | unknown <marko@hundin.mysql.fi> | 2005-02-17 18:40:45 +0200 |
---|---|---|
committer | unknown <marko@hundin.mysql.fi> | 2005-02-17 18:40:45 +0200 |
commit | d0dbd41a3bf8ba665689f85891267daed1c25787 (patch) | |
tree | f1476a2bcaddc0404258056096a6d640d5afb132 /innobase | |
parent | 6075463f0342c0bf178c40dd7f9ecdeb7d5c8235 (diff) | |
download | mariadb-git-d0dbd41a3bf8ba665689f85891267daed1c25787.tar.gz |
After review fixes (Bug #5682)
innobase/include/data0type.ic:
dtype_get_fixed_size(), dtype_get_min_size(): Do not check
prtype, mbminlen and mbmaxlen for types other than DATA_MYSQL,
as that is the only type that can hold fixed-length strings of
variable-length objects (UTF-8 encoded characters).
innobase/row/row0sel.c:
row_sel_field_store_in_mysql_format(): Document which fields of
templ will be used. Add 0x20 padding only to DATA_MYSQL fields.
Change related debug assertions to real assertions for now, until
5.0 becomes generally available. Check with assertion that all
data types handled in the catch-all branch are appropriate.
Diffstat (limited to 'innobase')
-rw-r--r-- | innobase/include/data0type.ic | 3 | ||||
-rw-r--r-- | innobase/row/row0sel.c | 25 |
2 files changed, 22 insertions, 6 deletions
diff --git a/innobase/include/data0type.ic b/innobase/include/data0type.ic index 47f35bdce67..e63dde98974 100644 --- a/innobase/include/data0type.ic +++ b/innobase/include/data0type.ic @@ -354,6 +354,7 @@ dtype_get_fixed_size( case DATA_INT: case DATA_FLOAT: case DATA_DOUBLE: + return(dtype_get_len(type)); case DATA_MYSQL: if (type->prtype & DATA_BINARY_TYPE) { return(dtype_get_len(type)); @@ -438,6 +439,7 @@ dtype_get_min_size( case DATA_INT: case DATA_FLOAT: case DATA_DOUBLE: + return(type->len); case DATA_MYSQL: if ((type->prtype & DATA_BINARY_TYPE) || type->mbminlen == type->mbmaxlen) { @@ -446,6 +448,7 @@ dtype_get_min_size( /* this is a variable-length character set */ ut_a(type->mbminlen > 0); ut_a(type->mbmaxlen > type->mbminlen); + ut_a(type->len % type->mbmaxlen == 0); return(type->len * type->mbminlen / type->mbmaxlen); case DATA_VARCHAR: case DATA_BINARY: diff --git a/innobase/row/row0sel.c b/innobase/row/row0sel.c index 84a160cfc0d..22cece487a0 100644 --- a/innobase/row/row0sel.c +++ b/innobase/row/row0sel.c @@ -2233,7 +2233,9 @@ row_sel_field_store_in_mysql_format( are not in themselves stored here: the caller must allocate and copy the BLOB into buffer before, and pass the pointer to the BLOB in 'data' */ - const mysql_row_templ_t* templ, /* in: MySQL column template */ + const mysql_row_templ_t* templ, /* in: MySQL column template. + Its following fields are referenced: + type, is_unsigned, mysql_col_len, mbminlen, mbmaxlen */ byte* data, /* in: data to store */ ulint len) /* in: length of the data */ { @@ -2280,16 +2282,17 @@ row_sel_field_store_in_mysql_format( row_mysql_store_blob_ref(dest, templ->mysql_col_len, data, len); - } else { + } else if (templ->type == DATA_MYSQL) { memcpy(dest, data, len); - ut_ad(templ->mysql_col_len >= len); - ut_ad(templ->mbmaxlen >= templ->mbminlen); + ut_a(templ->mysql_col_len >= len); + ut_a(templ->mbmaxlen >= templ->mbminlen); - ut_ad(templ->mbmaxlen > templ->mbminlen + ut_a(templ->mbmaxlen > templ->mbminlen || templ->mysql_col_len == len); - ut_ad(!templ->mbmaxlen + ut_a(!templ->mbmaxlen || !(templ->mysql_col_len % templ->mbmaxlen)); + ut_a(len * templ->mbmaxlen >= templ->mysql_col_len); if (templ->mbminlen != templ->mbmaxlen) { /* Pad with spaces. This undoes the stripping @@ -2297,6 +2300,16 @@ row_sel_field_store_in_mysql_format( row_mysql_store_col_in_innobase_format(). */ memset(dest + len, 0x20, templ->mysql_col_len - len); } + } else { + ut_a(templ->type == DATA_CHAR + || templ->type == DATA_FIXBINARY + /*|| templ->type == DATA_SYS_CHILD + || templ->type == DATA_SYS*/ + || templ->type == DATA_FLOAT + || templ->type == DATA_DOUBLE + || templ->type == DATA_DECIMAL); + ut_ad(templ->mysql_col_len == len); + memcpy(dest, data, len); } } |