Commit 996edd8a authored by marko's avatar marko

branches/zip: Do not access the fields of dfield_t directly.

dfield_dup(): New function for duplicating the data pointed to by dfield_t.

dfield_set_len(), dfield_set_data(): Add Valgrind instrumentation.
parent 1033dbfb
...@@ -40,7 +40,7 @@ dfield_data_is_binary_equal( ...@@ -40,7 +40,7 @@ dfield_data_is_binary_equal(
ulint len, /* in: data length or UNIV_SQL_NULL */ ulint len, /* in: data length or UNIV_SQL_NULL */
const byte* data) /* in: data */ const byte* data) /* in: data */
{ {
if (len != field->len) { if (len != dfield_get_len(field)) {
return(FALSE); return(FALSE);
} }
...@@ -50,7 +50,7 @@ dfield_data_is_binary_equal( ...@@ -50,7 +50,7 @@ dfield_data_is_binary_equal(
return(TRUE); return(TRUE);
} }
if (0 != ut_memcmp(field->data, data, len)) { if (0 != memcmp(dfield_get_data(field), data, len)) {
return(FALSE); return(FALSE);
} }
...@@ -251,7 +251,7 @@ dtuple_validate( ...@@ -251,7 +251,7 @@ dtuple_validate(
if (!dfield_is_null(field)) { if (!dfield_is_null(field)) {
data = field->data; data = dfield_get_data(field);
UNIV_MEM_ASSERT_RW(data, len); UNIV_MEM_ASSERT_RW(data, len);
for (j = 0; j < len; j++) { for (j = 0; j < len; j++) {
...@@ -493,10 +493,10 @@ dfield_print_raw( ...@@ -493,10 +493,10 @@ dfield_print_raw(
FILE* f, /* in: output stream */ FILE* f, /* in: output stream */
const dfield_t* dfield) /* in: dfield */ const dfield_t* dfield) /* in: dfield */
{ {
ulint len = dfield->len; ulint len = dfield_get_len(dfield);
if (!dfield_is_null(dfield)) { if (!dfield_is_null(dfield)) {
ulint print_len = ut_min(len, 1000); ulint print_len = ut_min(len, 1000);
ut_print_buf(f, dfield->data, print_len); ut_print_buf(f, dfield_get_data(dfield), print_len);
if (len != print_len) { if (len != print_len) {
fprintf(f, "(total %lu bytes%s)", fprintf(f, "(total %lu bytes%s)",
(ulong) len, (ulong) len,
...@@ -614,11 +614,13 @@ dtuple_convert_big_rec( ...@@ -614,11 +614,13 @@ dtuple_convert_big_rec(
if (ifield->fixed_len if (ifield->fixed_len
|| dfield_is_null(dfield) || dfield_is_null(dfield)
|| dfield_is_ext(dfield) || dfield_is_ext(dfield)
|| dfield->len <= BTR_EXTERN_FIELD_REF_SIZE * 2) { || dfield_get_len(dfield)
<= BTR_EXTERN_FIELD_REF_SIZE * 2) {
goto skip_field; goto skip_field;
} }
savings = dfield->len - BTR_EXTERN_FIELD_REF_SIZE; savings = dfield_get_len(dfield)
- BTR_EXTERN_FIELD_REF_SIZE;
/* Check that there would be savings */ /* Check that there would be savings */
if (longest >= savings) { if (longest >= savings) {
...@@ -650,9 +652,9 @@ skip_field: ...@@ -650,9 +652,9 @@ skip_field:
ifield = dict_index_get_nth_field(index, longest_i); ifield = dict_index_get_nth_field(index, longest_i);
vector->fields[n_fields].field_no = longest_i; vector->fields[n_fields].field_no = longest_i;
vector->fields[n_fields].len = dfield->len; vector->fields[n_fields].len = dfield_get_len(dfield);
vector->fields[n_fields].data = dfield->data; vector->fields[n_fields].data = dfield_get_data(dfield);
/* Set the extern field reference in dfield to zero */ /* Set the extern field reference in dfield to zero */
dfield_set_data(dfield, dfield_set_data(dfield,
......
...@@ -3729,7 +3729,7 @@ calc_row_difference( ...@@ -3729,7 +3729,7 @@ calc_row_difference(
from the MySQL column format to the InnoDB format */ from the MySQL column format to the InnoDB format */
dict_col_copy_type(prebuilt->table->cols + i, dict_col_copy_type(prebuilt->table->cols + i,
&dfield.type); dfield_get_type(&dfield));
if (n_len != UNIV_SQL_NULL) { if (n_len != UNIV_SQL_NULL) {
buf = row_mysql_store_col_in_innobase_format( buf = row_mysql_store_col_in_innobase_format(
......
...@@ -1525,12 +1525,13 @@ ibuf_entry_build( ...@@ -1525,12 +1525,13 @@ ibuf_entry_build(
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
if (fixed_len) { if (fixed_len) {
/* dict_index_add_col() should guarantee these */ /* dict_index_add_col() should guarantee these */
ut_ad(fixed_len <= (ulint) entry_field->type.len); ut_ad(fixed_len <= (ulint)
dfield_get_type(entry_field)->len);
if (ifield->prefix_len) { if (ifield->prefix_len) {
ut_ad(ifield->prefix_len == fixed_len); ut_ad(ifield->prefix_len == fixed_len);
} else { } else {
ut_ad(fixed_len ut_ad(fixed_len == (ulint)
== (ulint) entry_field->type.len); dfield_get_type(entry_field)->len);
} }
} }
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
......
...@@ -128,6 +128,14 @@ dfield_copy( ...@@ -128,6 +128,14 @@ dfield_copy(
dfield_t* field1, /* out: field to copy to */ dfield_t* field1, /* out: field to copy to */
const dfield_t* field2);/* in: field to copy from */ const dfield_t* field2);/* in: field to copy from */
/************************************************************************* /*************************************************************************
Copies the data pointed to by a data field. */
UNIV_INLINE
void
dfield_dup(
/*=======*/
dfield_t* field, /* in/out: data field */
mem_heap_t* heap); /* in: memory heap where allocated */
/*************************************************************************
Tests if data length and content is equal for two dfields. */ Tests if data length and content is equal for two dfields. */
UNIV_INLINE UNIV_INLINE
ibool ibool
......
...@@ -86,6 +86,9 @@ dfield_set_len( ...@@ -86,6 +86,9 @@ dfield_set_len(
ulint len) /* in: length or UNIV_SQL_NULL */ ulint len) /* in: length or UNIV_SQL_NULL */
{ {
ut_ad(field); ut_ad(field);
#ifdef UNIV_VALGRIND_DEBUG
if (len != UNIV_SQL_NULL) UNIV_MEM_ASSERT_RW(field->data, len);
#endif /* UNIV_VALGRIND_DEBUG */
field->ext = 0; field->ext = 0;
field->len = len; field->len = len;
...@@ -144,6 +147,9 @@ dfield_set_data( ...@@ -144,6 +147,9 @@ dfield_set_data(
{ {
ut_ad(field); ut_ad(field);
#ifdef UNIV_VALGRIND_DEBUG
if (len != UNIV_SQL_NULL) UNIV_MEM_ASSERT_RW(data, len);
#endif /* UNIV_VALGRIND_DEBUG */
field->data = (void*) data; field->data = (void*) data;
field->ext = 0; field->ext = 0;
field->len = len; field->len = len;
...@@ -188,6 +194,21 @@ dfield_copy( ...@@ -188,6 +194,21 @@ dfield_copy(
*field1 = *field2; *field1 = *field2;
} }
/*************************************************************************
Copies the data pointed to by a data field. */
UNIV_INLINE
void
dfield_dup(
/*=======*/
dfield_t* field, /* in/out: data field */
mem_heap_t* heap) /* in: memory heap where allocated */
{
if (!dfield_is_null(field)) {
UNIV_MEM_ASSERT_RW(field->data, field->len);
field->data = mem_heap_dup(heap, field->data, field->len);
}
}
/************************************************************************* /*************************************************************************
Tests if data length and content is equal for two dfields. */ Tests if data length and content is equal for two dfields. */
UNIV_INLINE UNIV_INLINE
...@@ -202,15 +223,9 @@ dfield_datas_are_binary_equal( ...@@ -202,15 +223,9 @@ dfield_datas_are_binary_equal(
len = field1->len; len = field1->len;
if ((len != field2->len) return(len == field2->len
|| ((len != UNIV_SQL_NULL) && (len == UNIV_SQL_NULL
&& (0 != ut_memcmp(field1->data, field2->data, || !memcmp(field1->data, field2->data, len)));
len)))) {
return(FALSE);
}
return(TRUE);
} }
/************************************************************************* /*************************************************************************
......
...@@ -126,7 +126,7 @@ que_node_get_data_type( ...@@ -126,7 +126,7 @@ que_node_get_data_type(
{ {
ut_ad(node); ut_ad(node);
return(&(((que_common_t*)node)->val.type)); return(dfield_get_type(&((que_common_t*) node)->val));
} }
/************************************************************************* /*************************************************************************
......
...@@ -102,7 +102,7 @@ sym_tab_add_int_lit( ...@@ -102,7 +102,7 @@ sym_tab_add_int_lit(
node->indirection = NULL; node->indirection = NULL;
dtype_set(&(node->common.val.type), DATA_INT, 0, 4); dtype_set(dfield_get_type(&node->common.val), DATA_INT, 0, 4);
data = mem_heap_alloc(sym_tab->heap, 4); data = mem_heap_alloc(sym_tab->heap, 4);
mach_write_to_4(data, val); mach_write_to_4(data, val);
...@@ -144,7 +144,8 @@ sym_tab_add_str_lit( ...@@ -144,7 +144,8 @@ sym_tab_add_str_lit(
node->indirection = NULL; node->indirection = NULL;
dtype_set(&(node->common.val.type), DATA_VARCHAR, DATA_ENGLISH, 0); dtype_set(dfield_get_type(&node->common.val),
DATA_VARCHAR, DATA_ENGLISH, 0);
if (len) { if (len) {
data = mem_heap_alloc(sym_tab->heap, len); data = mem_heap_alloc(sym_tab->heap, len);
...@@ -226,7 +227,8 @@ sym_tab_add_bound_lit( ...@@ -226,7 +227,8 @@ sym_tab_add_bound_lit(
ut_error; ut_error;
} }
dtype_set(&(node->common.val.type), blit->type, blit->prtype, len); dtype_set(dfield_get_type(&node->common.val),
blit->type, blit->prtype, len);
dfield_set_data(&(node->common.val), blit->address, blit->length); dfield_set_data(&(node->common.val), blit->address, blit->length);
...@@ -261,7 +263,7 @@ sym_tab_add_null_lit( ...@@ -261,7 +263,7 @@ sym_tab_add_null_lit(
node->indirection = NULL; node->indirection = NULL;
node->common.val.type.mtype = DATA_ERROR; dfield_get_type(&node->common.val)->mtype = DATA_ERROR;
dfield_set_null(&node->common.val); dfield_set_null(&node->common.val);
......
...@@ -757,7 +757,7 @@ rec_get_converted_size_comp( ...@@ -757,7 +757,7 @@ rec_get_converted_size_comp(
case REC_STATUS_NODE_PTR: case REC_STATUS_NODE_PTR:
n_fields--; n_fields--;
ut_ad(n_fields == dict_index_get_n_unique_in_tree(index)); ut_ad(n_fields == dict_index_get_n_unique_in_tree(index));
ut_ad(fields[n_fields].len == 4); ut_ad(dfield_get_len(&fields[n_fields]) == 4);
data_size = 4; /* child page number */ data_size = 4; /* child page number */
break; break;
case REC_STATUS_INFIMUM: case REC_STATUS_INFIMUM:
......
...@@ -475,6 +475,7 @@ row_ins_cascade_calc_update_vec( ...@@ -475,6 +475,7 @@ row_ins_cascade_calc_update_vec(
ulint min_size; ulint min_size;
const dict_col_t* col; const dict_col_t* col;
ulint ufield_len;
col = dict_index_get_nth_col(index, i); col = dict_index_get_nth_col(index, i);
...@@ -490,7 +491,10 @@ row_ins_cascade_calc_update_vec( ...@@ -490,7 +491,10 @@ row_ins_cascade_calc_update_vec(
ufield->exp = NULL; ufield->exp = NULL;
ufield->new_val = parent_ufield->new_val; ufield->new_val = parent_ufield->new_val;
ufield->new_val.ext = 0; ufield_len = dfield_get_len(&ufield->new_val);
/* Clear the "external storage" flag */
dfield_set_len(&ufield->new_val, ufield_len);
/* Do not allow a NOT NULL column to be /* Do not allow a NOT NULL column to be
updated as NULL */ updated as NULL */
...@@ -509,9 +513,9 @@ row_ins_cascade_calc_update_vec( ...@@ -509,9 +513,9 @@ row_ins_cascade_calc_update_vec(
col->prtype, col->prtype,
col->mbminlen, col->mbmaxlen, col->mbminlen, col->mbmaxlen,
col->len, col->len,
ufield->new_val.len, ufield_len,
ufield->new_val.data) dfield_get_data(&ufield->new_val))
< ufield->new_val.len) { < ufield_len) {
return(ULINT_UNDEFINED); return(ULINT_UNDEFINED);
} }
...@@ -523,28 +527,31 @@ row_ins_cascade_calc_update_vec( ...@@ -523,28 +527,31 @@ row_ins_cascade_calc_update_vec(
min_size = dict_col_get_min_size(col); min_size = dict_col_get_min_size(col);
if (min_size /* Because UNIV_SQL_NULL (the marker
&& !dfield_is_null(&ufield->new_val) of SQL NULL values) exceeds all possible
&& ufield->new_val.len < min_size) { values of min_size, the test below will
not hold for SQL NULL columns. */
if (min_size > ufield_len) {
char* pad_start; char* pad_start;
const char* pad_end; const char* pad_end;
ufield->new_val.data = mem_heap_alloc( char* padded_data
= mem_heap_alloc(
heap, min_size); heap, min_size);
pad_start = ((char*) ufield pad_start = padded_data + ufield_len;
->new_val.data) pad_end = padded_data + min_size;
+ ufield->new_val.len;
pad_end = ((char*) ufield memcpy(padded_data,
->new_val.data) dfield_get_data(&ufield
+ min_size; ->new_val),
ufield->new_val.len = min_size; dfield_get_len(&ufield
ut_memcpy(ufield->new_val.data, ->new_val));
parent_ufield->new_val.data,
parent_ufield->new_val.len);
switch (UNIV_EXPECT(col->mbminlen,1)) { switch (UNIV_EXPECT(col->mbminlen,1)) {
default: default:
ut_error; ut_error;
return(ULINT_UNDEFINED);
case 1: case 1:
if (UNIV_UNLIKELY if (UNIV_UNLIKELY
(dtype_get_charset_coll( (dtype_get_charset_coll(
...@@ -561,8 +568,7 @@ row_ins_cascade_calc_update_vec( ...@@ -561,8 +568,7 @@ row_ins_cascade_calc_update_vec(
break; break;
case 2: case 2:
/* space=0x0020 */ /* space=0x0020 */
ut_a(!(ufield->new_val.len ut_a(!(ufield_len % 2));
% 2));
ut_a(!(min_size % 2)); ut_a(!(min_size % 2));
do { do {
*pad_start++ = 0x00; *pad_start++ = 0x00;
...@@ -570,6 +576,9 @@ row_ins_cascade_calc_update_vec( ...@@ -570,6 +576,9 @@ row_ins_cascade_calc_update_vec(
} while (pad_start < pad_end); } while (pad_start < pad_end);
break; break;
} }
dfield_set_data(&ufield->new_val,
padded_data, min_size);
} }
n_fields_updated++; n_fields_updated++;
...@@ -2234,10 +2243,12 @@ row_ins_index_entry_set_vals( ...@@ -2234,10 +2243,12 @@ row_ins_index_entry_set_vals(
len = dtype_get_at_most_n_mbchars( len = dtype_get_at_most_n_mbchars(
col->prtype, col->mbminlen, col->mbmaxlen, col->prtype, col->mbminlen, col->mbmaxlen,
ind_field->prefix_len, ind_field->prefix_len,
len, row_field->data); len, dfield_get_data(row_field));
ut_ad(!dfield_is_ext(row_field));
} }
dfield_set_data(field, row_field->data, len); dfield_set_data(field, dfield_get_data(row_field), len);
if (dfield_is_ext(row_field)) { if (dfield_is_ext(row_field)) {
ut_ad(dict_index_is_clust(index)); ut_ad(dict_index_is_clust(index));
dfield_set_ext(field); dfield_set_ext(field);
......
...@@ -113,16 +113,16 @@ row_merge_tuple_print( ...@@ -113,16 +113,16 @@ row_merge_tuple_print(
if (dfield_is_null(field)) { if (dfield_is_null(field)) {
fputs("\n NULL;", f); fputs("\n NULL;", f);
} else { } else {
ulint len = ut_min(field->len, 20); ulint field_len = dfield_get_len(field);
ulint len = ut_min(field_len, 20);
if (dfield_is_ext(field)) { if (dfield_is_ext(field)) {
fputs("\nE", f); fputs("\nE", f);
} else { } else {
fputs("\n ", f); fputs("\n ", f);
} }
ut_print_buf(f, field->data, len); ut_print_buf(f, dfield_get_data(field), len);
if (len != field->len) { if (len != field_len) {
fprintf(f, " (total %lu bytes)", fprintf(f, " (total %lu bytes)", field_len);
(ulong) field->len);
} }
} }
} }
...@@ -261,34 +261,36 @@ row_merge_buf_add( ...@@ -261,34 +261,36 @@ row_merge_buf_add(
ulint col_no; ulint col_no;
const dfield_t* row_field; const dfield_t* row_field;
ulint len; ulint len;
const void* field_data;
ifield = dict_index_get_nth_field(index, i); ifield = dict_index_get_nth_field(index, i);
col = ifield->col; col = ifield->col;
col_no = dict_col_get_no(col); col_no = dict_col_get_no(col);
row_field = dtuple_get_nth_field(row, col_no); row_field = dtuple_get_nth_field(row, col_no);
dfield_copy(field, row_field); dfield_copy(field, row_field);
len = field->len; len = dfield_get_len(field);
field_data = dfield_get_data(field);
if (dfield_is_null(field)) { if (dfield_is_null(field)) {
ut_ad(!(col->prtype & DATA_NOT_NULL)); ut_ad(!(col->prtype & DATA_NOT_NULL));
field->data = NULL; ut_ad(field_data == NULL);
continue; continue;
} else if (UNIV_LIKELY(!ext)) { } else if (UNIV_LIKELY(!ext)) {
} else if (dict_index_is_clust(index)) { } else if (dict_index_is_clust(index)) {
/* Flag externally stored fields. */ /* Flag externally stored fields. */
byte* buf = row_ext_lookup(ext, col_no, byte* buf = row_ext_lookup(ext, col_no,
field->data, len, &len); field_data, len, &len);
if (UNIV_LIKELY_NULL(buf)) { if (UNIV_LIKELY_NULL(buf)) {
if (i < dict_index_get_n_unique(index)) { if (i < dict_index_get_n_unique(index)) {
dfield_set_data(field, buf, len); dfield_set_data(field, buf, len);
} else { } else {
dfield_set_ext(field); dfield_set_ext(field);
len = field->len; len = dfield_get_len(field);
} }
} }
} else { } else {
byte* buf = row_ext_lookup(ext, col_no, byte* buf = row_ext_lookup(ext, col_no,
field->data, len, &len); field_data, len, &len);
if (UNIV_LIKELY_NULL(buf)) { if (UNIV_LIKELY_NULL(buf)) {
dfield_set_data(field, buf, len); dfield_set_data(field, buf, len);
} }
...@@ -297,11 +299,12 @@ row_merge_buf_add( ...@@ -297,11 +299,12 @@ row_merge_buf_add(
/* If a column prefix index, take only the prefix */ /* If a column prefix index, take only the prefix */
if (ifield->prefix_len) { if (ifield->prefix_len) {
field->len = len = dtype_get_at_most_n_mbchars( len = dtype_get_at_most_n_mbchars(
col->prtype, col->prtype,
col->mbminlen, col->mbmaxlen, col->mbminlen, col->mbmaxlen,
ifield->prefix_len, ifield->prefix_len,
len, field->data); len, dfield_get_data(field));
dfield_set_len(field, len);
} }
ut_ad(len <= col->len || col->mtype == DATA_BLOB); ut_ad(len <= col->len || col->mtype == DATA_BLOB);
...@@ -365,12 +368,7 @@ row_merge_buf_add( ...@@ -365,12 +368,7 @@ row_merge_buf_add(
/* Copy the data fields. */ /* Copy the data fields. */
do { do {
if (!dfield_is_null(field)) { dfield_dup(field++, buf->heap);
field->data = mem_heap_dup(buf->heap,
field->data, field->len);
}
field++;
} while (--n_fields); } while (--n_fields);
return(TRUE); return(TRUE);
...@@ -1163,8 +1161,10 @@ row_merge_read_clustered_index( ...@@ -1163,8 +1161,10 @@ row_merge_read_clustered_index(
for (i = 0; i < n_nonnull; i++) { for (i = 0; i < n_nonnull; i++) {
dfield_t* field dfield_t* field
= &row->fields[nonnull[i]]; = &row->fields[nonnull[i]];
dtype_t* field_type
= dfield_get_type(field);
ut_a(!(field->type.prtype ut_a(!(field_type->prtype
& DATA_NOT_NULL)); & DATA_NOT_NULL));
if (dfield_is_null(field)) { if (dfield_is_null(field)) {
...@@ -1173,7 +1173,7 @@ row_merge_read_clustered_index( ...@@ -1173,7 +1173,7 @@ row_merge_read_clustered_index(
goto err_exit; goto err_exit;
} }
field->type.prtype |= DATA_NOT_NULL; field_type->prtype |= DATA_NOT_NULL;
} }
} }
} }
......
...@@ -414,7 +414,9 @@ skip_secondaries: ...@@ -414,7 +414,9 @@ skip_secondaries:
can calculate from node->roll_ptr the file can calculate from node->roll_ptr the file
address of the new_val data */ address of the new_val data */
internal_offset = ((const byte*)ufield->new_val.data) internal_offset
= ((const byte*)
dfield_get_data(&ufield->new_val))
- node->undo_rec; - node->undo_rec;
ut_a(internal_offset < UNIV_PAGE_SIZE); ut_a(internal_offset < UNIV_PAGE_SIZE);
...@@ -452,9 +454,11 @@ skip_secondaries: ...@@ -452,9 +454,11 @@ skip_secondaries:
data_field = buf_block_get_frame(block) data_field = buf_block_get_frame(block)
+ offset + internal_offset; + offset + internal_offset;
ut_a(ufield->new_val.len >= BTR_EXTERN_FIELD_REF_SIZE); ut_a(dfield_get_len(&ufield->new_val)
>= BTR_EXTERN_FIELD_REF_SIZE);
btr_free_externally_stored_field( btr_free_externally_stored_field(
index, data_field + ufield->new_val.len index,
data_field + dfield_get_len(&ufield->new_val)
- BTR_EXTERN_FIELD_REF_SIZE, - BTR_EXTERN_FIELD_REF_SIZE,
NULL, NULL, NULL, 0, FALSE, &mtr); NULL, NULL, NULL, 0, FALSE, &mtr);
mtr_commit(&mtr); mtr_commit(&mtr);
......
...@@ -75,9 +75,6 @@ row_build_index_entry( ...@@ -75,9 +75,6 @@ row_build_index_entry(
{ {
dtuple_t* entry; dtuple_t* entry;
ulint entry_len; ulint entry_len;
dict_field_t* ind_field;
dfield_t* dfield;
const dfield_t* dfield2;
ulint i; ulint i;
ut_ad(row && index && heap); ut_ad(row && index && heap);
...@@ -101,24 +98,26 @@ row_build_index_entry( ...@@ -101,24 +98,26 @@ row_build_index_entry(
} }
for (i = 0; i < entry_len; i++) { for (i = 0; i < entry_len; i++) {
const dict_col_t* col; const dict_field_t* ind_field
ulint col_no; = dict_index_get_nth_field(index, i);
ind_field = dict_index_get_nth_field(index, i); const dict_col_t* col
col = ind_field->col; = ind_field->col;
col_no = dict_col_get_no(col); ulint col_no
= dict_col_get_no(col);
dfield = dtuple_get_nth_field(entry, i); dfield_t* dfield
= dtuple_get_nth_field(entry, i);
dfield2 = dtuple_get_nth_field(row, col_no); const dfield_t* dfield2
= dtuple_get_nth_field(row, col_no);
ulint len
= dfield_get_len(dfield);
dfield_copy(dfield, dfield2); dfield_copy(dfield, dfield2);
if (UNIV_LIKELY_NULL(ext) && !dfield_is_null(dfield)) { if (UNIV_LIKELY_NULL(ext) && !dfield_is_null(dfield)) {
/* See if the column is stored externally. */ /* See if the column is stored externally. */
ulint len = dfield_get_len(dfield);
byte* buf = row_ext_lookup(ext, col_no, byte* buf = row_ext_lookup(ext, col_no,
dfield->data, dfield_get_data(dfield),
dfield->len, &len); len, &len);
if (UNIV_LIKELY_NULL(buf)) { if (UNIV_LIKELY_NULL(buf)) {
dfield_set_data(dfield, buf, len); dfield_set_data(dfield, buf, len);
} }
...@@ -126,10 +125,11 @@ row_build_index_entry( ...@@ -126,10 +125,11 @@ row_build_index_entry(
/* If a column prefix index, take only the prefix */ /* If a column prefix index, take only the prefix */
if (ind_field->prefix_len > 0 && !dfield_is_null(dfield)) { if (ind_field->prefix_len > 0 && !dfield_is_null(dfield)) {
dfield->len = dtype_get_at_most_n_mbchars( len = dtype_get_at_most_n_mbchars(
col->prtype, col->mbminlen, col->mbmaxlen, col->prtype, col->mbminlen, col->mbmaxlen,
ind_field->prefix_len, ind_field->prefix_len,
dfield->len, dfield->data); len, dfield_get_data(dfield));
dfield_set_len(dfield, len);
} }
} }
...@@ -639,9 +639,14 @@ row_build_row_ref_from_row( ...@@ -639,9 +639,14 @@ row_build_row_ref_from_row(
if (field->prefix_len > 0 && !dfield_is_null(dfield)) { if (field->prefix_len > 0 && !dfield_is_null(dfield)) {
dfield->len = dtype_get_at_most_n_mbchars( ulint len = dfield_get_len(dfield);
len = dtype_get_at_most_n_mbchars(
col->prtype, col->mbminlen, col->mbmaxlen, col->prtype, col->mbminlen, col->mbmaxlen,
field->prefix_len, dfield->len, dfield->data); field->prefix_len,
len, dfield_get_data(dfield));
dfield_set_len(dfield, len);
} }
} }
......
...@@ -2432,7 +2432,9 @@ row_sel_convert_mysql_key_to_innobase( ...@@ -2432,7 +2432,9 @@ row_sel_convert_mysql_key_to_innobase(
fprintf(stderr, "\n"); fprintf(stderr, "\n");
if (!is_null) { if (!is_null) {
dfield->len -= (ulint)(key_ptr - key_end); ulint len = dfield_get_len(dfield);
dfield_set_len(dfield, len
- (ulint) (key_ptr - key_end));
} }
} }
......
...@@ -583,20 +583,22 @@ row_upd_index_write_log( ...@@ -583,20 +583,22 @@ row_upd_index_write_log(
new_val = &(upd_field->new_val); new_val = &(upd_field->new_val);
len = new_val->len; len = dfield_get_len(new_val);
log_ptr += mach_write_compressed(log_ptr, upd_field->field_no); log_ptr += mach_write_compressed(log_ptr, upd_field->field_no);
log_ptr += mach_write_compressed(log_ptr, len); log_ptr += mach_write_compressed(log_ptr, len);
if (len != UNIV_SQL_NULL) { if (len != UNIV_SQL_NULL) {
if (log_ptr + len < buf_end) { if (log_ptr + len < buf_end) {
ut_memcpy(log_ptr, new_val->data, len); memcpy(log_ptr, dfield_get_data(new_val), len);
log_ptr += len; log_ptr += len;
} else { } else {
mlog_close(mtr, log_ptr); mlog_close(mtr, log_ptr);
mlog_catenate_string(mtr, new_val->data, len); mlog_catenate_string(mtr,
dfield_get_data(new_val),
len);
log_ptr = mlog_open(mtr, MLOG_BUF_MARGIN); log_ptr = mlog_open(mtr, MLOG_BUF_MARGIN);
buf_end = log_ptr + MLOG_BUF_MARGIN; buf_end = log_ptr + MLOG_BUF_MARGIN;
...@@ -887,24 +889,25 @@ row_upd_index_replace_new_col_vals_index_pos( ...@@ -887,24 +889,25 @@ row_upd_index_replace_new_col_vals_index_pos(
} }
if (heap) { if (heap) {
dfield->data = mem_heap_dup( dfield_dup(dfield, heap);
heap,
dfield->data, dfield->len);
} }
if (field->prefix_len > 0) { if (field->prefix_len > 0) {
const dict_col_t* col const dict_col_t* col
= dict_field_get_col(field); = dict_field_get_col(field);
ulint len
= dfield_get_len(dfield);
dfield->len len = dtype_get_at_most_n_mbchars(
= dtype_get_at_most_n_mbchars(
col->prtype, col->prtype,
col->mbminlen, col->mbminlen,
col->mbmaxlen, col->mbmaxlen,
field->prefix_len, field->prefix_len,
dfield->len, len,
dfield->data); dfield_get_data(dfield));
dfield_set_len(dfield, len);
} }
} }
} }
...@@ -962,24 +965,25 @@ row_upd_index_replace_new_col_vals( ...@@ -962,24 +965,25 @@ row_upd_index_replace_new_col_vals(
} }
if (heap) { if (heap) {
dfield->data = mem_heap_dup( dfield_dup(dfield, heap);
heap,
dfield->data, dfield->len);
} }
if (field->prefix_len > 0) { if (field->prefix_len > 0) {
const dict_col_t* col const dict_col_t* col
= dict_field_get_col(field); = dict_field_get_col(field);
ulint len
= dfield_get_len(dfield);
dfield->len len = dtype_get_at_most_n_mbchars(
= dtype_get_at_most_n_mbchars(
col->prtype, col->prtype,
col->mbminlen, col->mbminlen,
col->mbmaxlen, col->mbmaxlen,
field->prefix_len, field->prefix_len,
dfield->len, len,
dfield->data); dfield_get_data(dfield));
dfield_set_len(dfield, len);
} }
} }
} }
......
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