diff options
author | unknown <marko@hundin.mysql.fi> | 2005-02-17 17:15:29 +0200 |
---|---|---|
committer | unknown <marko@hundin.mysql.fi> | 2005-02-17 17:15:29 +0200 |
commit | 6075463f0342c0bf178c40dd7f9ecdeb7d5c8235 (patch) | |
tree | c7f0fcd17c220dc071ec22c5ba7c04fc4544d346 /innobase/row | |
parent | ca021698d1f41d63bacfb3baf5a73dc40790547c (diff) | |
download | mariadb-git-6075463f0342c0bf178c40dd7f9ecdeb7d5c8235.tar.gz |
InnoDB: Make CREATE TABLE return error when the minimum row length
exceeds the maximum record size. (Bug #5682)
innobase/data/data0type.c:
Remove function dtype_str_needs_mysql_cmp().
Document dtype_get_at_most_n_mbchars().
dtype_get_at_most_n_mbchars(): Use mbminlen and mbmaxlen.
innobase/dict/dict0crea.c:
dict_build_table_def_step(): Reject if minimum row size is too big.
innobase/include/data0type.h:
Remove dtype_str_needs_mysql_cmp().
Document dtype_get_at_most_n_mbchars().
Add dtype_get_min_size().
innobase/include/data0type.ic:
Add dtype_get_min_size().
innobase/include/row0mysql.h:
row_mysql_store_col_in_innobase_format(): Add parameter comp,
as we will only truncate UTF-8 CHAR(n) columns in row_format=compact.
innobase/include/row0mysql.ic:
row_mysql_store_col_in_innobase_format(): Add parameter comp,
as we will only truncate UTF-8 CHAR(n) columns in row_format=compact.
innobase/row/row0mysql.c:
Pass parameter comp to row_mysql_store_col_in_innobase_format().
innobase/row/row0sel.c:
Pass parameter comp to row_mysql_store_col_in_innobase_format().
row_sel_field_store_in_mysql_format(): Undo the stripping of
UTF-8 CHAR(n) columns by padding with spaces.
Diffstat (limited to 'innobase/row')
-rw-r--r-- | innobase/row/row0mysql.c | 3 | ||||
-rw-r--r-- | innobase/row/row0sel.c | 58 |
2 files changed, 39 insertions, 22 deletions
diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c index 0ec261e798f..39c4b76f814 100644 --- a/innobase/row/row0mysql.c +++ b/innobase/row/row0mysql.c @@ -238,7 +238,8 @@ row_mysql_convert_row_to_innobase( + templ->mysql_col_offset, mysql_rec + templ->mysql_col_offset, templ->mysql_col_len, - templ->type, templ->is_unsigned); + templ->type, prebuilt->table->comp, + templ->is_unsigned); next_column: ; } diff --git a/innobase/row/row0sel.c b/innobase/row/row0sel.c index c0141f896ce..84a160cfc0d 100644 --- a/innobase/row/row0sel.c +++ b/innobase/row/row0sel.c @@ -2137,6 +2137,7 @@ row_sel_convert_mysql_key_to_innobase( row_mysql_store_col_in_innobase_format( dfield, buf, key_ptr + data_offset, data_len, type, + index->table->comp, dfield_get_type(dfield)->prtype & DATA_UNSIGNED); buf += data_len; @@ -2232,17 +2233,15 @@ 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' */ - ulint col_len,/* in: MySQL column length */ + const mysql_row_templ_t* templ, /* in: MySQL column template */ byte* data, /* in: data to store */ - ulint len, /* in: length of the data */ - ulint type, /* in: data type */ - ulint is_unsigned)/* in: != 0 if an unsigned integer type */ + ulint len) /* in: length of the data */ { byte* ptr; ut_ad(len != UNIV_SQL_NULL); - if (type == DATA_INT) { + if (templ->type == DATA_INT) { /* Convert integer data from Innobase to a little-endian format, sign bit restored to normal */ @@ -2257,31 +2256,47 @@ row_sel_field_store_in_mysql_format( data++; } - if (!is_unsigned) { + if (!templ->is_unsigned) { dest[len - 1] = (byte) (dest[len - 1] ^ 128); } - ut_ad(col_len == len); - } else if (type == DATA_VARCHAR || type == DATA_VARMYSQL - || type == DATA_BINARY) { + ut_ad(templ->mysql_col_len == len); + } else if (templ->type == DATA_VARCHAR || templ->type == DATA_VARMYSQL + || templ->type == DATA_BINARY) { /* Store the length of the data to the first two bytes of dest; does not do anything yet because MySQL has no real vars! */ dest = row_mysql_store_var_len(dest, len); ut_memcpy(dest, data, len); - - /* ut_ad(col_len >= len + 2); No real var implemented in - MySQL yet! */ +#if 0 + /* No real var implemented in MySQL yet! */ + ut_ad(templ->mysql_col_len >= len + 2); +#endif - } else if (type == DATA_BLOB) { + } else if (templ->type == DATA_BLOB) { /* Store a pointer to the BLOB buffer to dest: the BLOB was already copied to the buffer in row_sel_store_mysql_rec */ - row_mysql_store_blob_ref(dest, col_len, data, len); + row_mysql_store_blob_ref(dest, templ->mysql_col_len, + data, len); } else { - ut_memcpy(dest, data, len); - ut_ad(col_len == len); + memcpy(dest, data, len); + + ut_ad(templ->mysql_col_len >= len); + ut_ad(templ->mbmaxlen >= templ->mbminlen); + + ut_ad(templ->mbmaxlen > templ->mbminlen + || templ->mysql_col_len == len); + ut_ad(!templ->mbmaxlen + || !(templ->mysql_col_len % templ->mbmaxlen)); + + if (templ->mbminlen != templ->mbmaxlen) { + /* Pad with spaces. This undoes the stripping + done in row0mysql.ic, function + row_mysql_store_col_in_innobase_format(). */ + memset(dest + len, 0x20, templ->mysql_col_len - len); + } } } @@ -2401,8 +2416,7 @@ row_sel_store_mysql_rec( row_sel_field_store_in_mysql_format( mysql_rec + templ->mysql_col_offset, - templ->mysql_col_len, data, len, - templ->type, templ->is_unsigned); + templ, data, len); if (templ->type == DATA_VARCHAR || templ->type == DATA_VARMYSQL @@ -2487,7 +2501,7 @@ row_sel_store_mysql_rec( len -= 2; } } else { - ut_ad(templ->mbminlen == 1); + ut_ad(!pad_char || templ->mbminlen == 1); memset(mysql_rec + templ->mysql_col_offset, pad_char, templ->mysql_col_len); } @@ -2855,9 +2869,11 @@ row_sel_push_cache_row_for_mysql( ut_ad(prebuilt->fetch_cache_first == 0); - ut_a(row_sel_store_mysql_rec( + if (!row_sel_store_mysql_rec( prebuilt->fetch_cache[prebuilt->n_fetch_cached], - prebuilt, rec, offsets)); + prebuilt, rec, offsets)) { + ut_error; + } prebuilt->n_fetch_cached++; } |