Index: dict/dict0dict.c =================================================================== --- dict/dict0dict.c (revision 1522) +++ dict/dict0dict.c (working copy) @@ -1587,9 +1587,6 @@ dict_index_copy_types( ifield = dict_index_get_nth_field(index, i); dfield_type = dfield_get_type(dtuple_get_nth_field(tuple, i)); dict_col_copy_type(dict_field_get_col(ifield), dfield_type); - if (UNIV_UNLIKELY(ifield->prefix_len)) { - dfield_type->len = ifield->prefix_len; - } } } Index: include/data0type.h =================================================================== --- include/data0type.h (revision 1522) +++ include/data0type.h (working copy) @@ -378,9 +378,7 @@ dtype_new_store_for_order_and_null_size( byte* buf, /* in: buffer for DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE bytes where we store the info */ - dtype_t* type, /* in: type struct */ - ulint prefix_len);/* in: prefix length to - replace type->len, or 0 */ + dtype_t* type); /* in: type struct */ /************************************************************************** Reads to a type the stored information which determines its alphabetical ordering and the storage size of an SQL NULL value. This is the 4.1.x storage Index: include/data0type.ic =================================================================== --- include/data0type.ic (revision 1522) +++ include/data0type.ic (working copy) @@ -246,14 +246,11 @@ dtype_new_store_for_order_and_null_size( byte* buf, /* in: buffer for DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE bytes where we store the info */ - dtype_t* type, /* in: type struct */ - ulint prefix_len)/* in: prefix length to - replace type->len, or 0 */ + dtype_t* type) /* in: type struct */ { #if 6 != DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE #error "6 != DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE" #endif - ulint len; buf[0] = (byte)(type->mtype & 0xFFUL); @@ -268,9 +265,7 @@ dtype_new_store_for_order_and_null_size( buf[1] = (byte)(type->prtype & 0xFFUL); - len = prefix_len ? prefix_len : type->len; - - mach_write_to_2(buf + 2, len & 0xFFFFUL); + mach_write_to_2(buf + 2, type->len & 0xFFFFUL); ut_ad(dtype_get_charset_coll(type->prtype) < 256); mach_write_to_2(buf + 4, dtype_get_charset_coll(type->prtype)); Index: ibuf/ibuf0ibuf.c =================================================================== --- ibuf/ibuf0ibuf.c (revision 1522) +++ ibuf/ibuf0ibuf.c (working copy) @@ -1365,8 +1365,8 @@ ibuf_entry_build( index tree; NOTE that the original entry must be kept because we copy pointers to its fields */ - dict_index_t* index, /* in: non-clustered index */ dtuple_t* entry, /* in: entry for a non-clustered index */ + ibool comp, /* in: flag: TRUE=compact record format */ ulint space, /* in: space id */ ulint page_no,/* in: index page number where entry should be inserted */ @@ -1430,12 +1430,13 @@ ibuf_entry_build( dfield_set_data(field, buf, 4); + ut_ad(comp == 0 || comp == 1); /* Store the type info in buf2, and add the fields from entry to tuple */ buf2 = mem_heap_alloc(heap, n_fields * DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE - + dict_table_is_comp(index->table)); - if (dict_table_is_comp(index->table)) { + + comp); + if (comp) { *buf2++ = 0; /* write the compact format indicator */ } for (i = 0; i < n_fields; i++) { @@ -1448,21 +1449,20 @@ ibuf_entry_build( dtype_new_store_for_order_and_null_size( buf2 + i * DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE, - dfield_get_type(entry_field), - dict_index_get_nth_field(index, i)->prefix_len); + dfield_get_type(entry_field)); } /* Store the type info in buf2 to field 3 of tuple */ field = dtuple_get_nth_field(tuple, 3); - if (dict_table_is_comp(index->table)) { + if (comp) { buf2--; } dfield_set_data(field, buf2, n_fields * DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE - + dict_table_is_comp(index->table)); + + comp); /* Set all the types in the new tuple binary */ dtuple_set_types_binary(tuple, n_fields + 4); @@ -2596,7 +2596,8 @@ ibuf_insert_low( the first fields and the type information for other fields, and which will be inserted to the insert buffer. */ - ibuf_entry = ibuf_entry_build(index, entry, space, page_no, heap); + ibuf_entry = ibuf_entry_build(entry, dict_table_is_comp(index->table), + space, page_no, heap); /* Open a cursor to the insert buffer tree to calculate if we can add the new entry to it without exceeding the free space limit for the Index: row/row0row.c =================================================================== --- row/row0row.c (revision 1522) +++ row/row0row.c (working copy) @@ -142,20 +142,16 @@ row_build_index_entry( dfield_copy(dfield, dfield2); /* If a column prefix index, take only the prefix */ - if (ind_field->prefix_len) { - if (dfield_get_len(dfield2) != UNIV_SQL_NULL) { + if (ind_field->prefix_len > 0 + && dfield_get_len(dfield2) != UNIV_SQL_NULL) { - 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); - } - - dfield_get_type(dfield)->len = ind_field->prefix_len; + 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); } }