Commit dc3f45dd authored by marko's avatar marko

branches/zip: btr_cur_optimistic_insert(): Correct an error that was made

in r2631.  Include the node pointer field in the size calculation.

rec_get_converted_size_comp_prefix(): New function, to compute the storage
size of the prefix of an ordinary record in COMPACT format.

rec_get_converted_size_comp(): Use rec_get_converted_size_comp_prefix().
parent 8239c09a
......@@ -1071,7 +1071,6 @@ btr_cur_optimistic_insert(
modification log. */
ulint free_space_zip = page_zip_empty_size(
cursor->index->n_fields, zip_size) - 1;
ulint extra;
ulint n_uniq = dict_index_get_n_unique_in_tree(index);
ut_ad(dict_table_is_comp(index->table));
......@@ -1081,10 +1080,10 @@ btr_cur_optimistic_insert(
infinite page splits. */
if (UNIV_LIKELY(entry->n_fields >= n_uniq)
&& UNIV_UNLIKELY(rec_get_converted_size_comp(
index, REC_STATUS_NODE_PTR,
entry->fields, n_uniq,
&extra)
&& UNIV_UNLIKELY(REC_NODE_PTR_SIZE
+ rec_get_converted_size_comp_prefix(
index, entry->fields, n_uniq,
NULL)
/* On a compressed page, there is
a two-byte entry in the dense
page directory for every record.
......
......@@ -693,6 +693,20 @@ rec_get_converted_extra_size(
ulint n_ext) /* in: number of externally stored columns */
__attribute__((const));
/**************************************************************
Determines the size of a data tuple prefix in ROW_FORMAT=COMPACT. */
UNIV_INTERN
ulint
rec_get_converted_size_comp_prefix(
/*===============================*/
/* out: total size */
const dict_index_t* index, /* in: record descriptor;
dict_table_is_comp() is
assumed to hold, even if
it does not */
const dfield_t* fields, /* in: array of data fields */
ulint n_fields,/* in: number of data fields */
ulint* extra); /* out: extra size */
/**************************************************************
Determines the size of a data tuple in ROW_FORMAT=COMPACT. */
UNIV_INTERN
ulint
......
......@@ -727,52 +727,31 @@ rec_get_nth_field_offs_old(
}
/**************************************************************
Determines the size of a data tuple in ROW_FORMAT=COMPACT. */
Determines the size of a data tuple prefix in ROW_FORMAT=COMPACT. */
UNIV_INTERN
ulint
rec_get_converted_size_comp(
/*========================*/
rec_get_converted_size_comp_prefix(
/*===============================*/
/* out: total size */
const dict_index_t* index, /* in: record descriptor;
dict_table_is_comp() is
assumed to hold, even if
it does not */
ulint status, /* in: status bits of the record */
const dfield_t* fields, /* in: array of data fields */
ulint n_fields,/* in: number of data fields */
ulint* extra) /* out: extra size */
{
ulint extra_size;
ulint data_size;
ulint i;
ulint extra_size;
ulint data_size;
ulint i;
ut_ad(index);
ut_ad(fields);
ut_ad(n_fields > 0);
switch (UNIV_EXPECT(status, REC_STATUS_ORDINARY)) {
case REC_STATUS_ORDINARY:
ut_ad(n_fields == dict_index_get_n_fields(index));
data_size = 0;
break;
case REC_STATUS_NODE_PTR:
n_fields--;
ut_ad(n_fields == dict_index_get_n_unique_in_tree(index));
ut_ad(dfield_get_len(&fields[n_fields]) == 4);
data_size = 4; /* child page number */
break;
case REC_STATUS_INFIMUM:
case REC_STATUS_SUPREMUM:
/* infimum or supremum record, 8 data bytes */
extra_size = REC_N_NEW_EXTRA_BYTES;
data_size = 8;
goto func_exit;
default:
ut_error;
return(ULINT_UNDEFINED);
}
ut_ad(n_fields <= dict_index_get_n_fields(index));
extra_size = REC_N_NEW_EXTRA_BYTES
+ UT_BITS_IN_BYTES(index->n_nullable);
data_size = 0;
/* read the lengths of fields 0..n */
for (i = 0; i < n_fields; i++) {
......@@ -815,7 +794,6 @@ rec_get_converted_size_comp(
data_size += len;
}
func_exit:
if (UNIV_LIKELY_NULL(extra)) {
*extra = extra_size;
}
......@@ -823,6 +801,54 @@ func_exit:
return(extra_size + data_size);
}
/**************************************************************
Determines the size of a data tuple in ROW_FORMAT=COMPACT. */
UNIV_INTERN
ulint
rec_get_converted_size_comp(
/*========================*/
/* out: total size */
const dict_index_t* index, /* in: record descriptor;
dict_table_is_comp() is
assumed to hold, even if
it does not */
ulint status, /* in: status bits of the record */
const dfield_t* fields, /* in: array of data fields */
ulint n_fields,/* in: number of data fields */
ulint* extra) /* out: extra size */
{
ulint size;
ut_ad(index);
ut_ad(fields);
ut_ad(n_fields > 0);
switch (UNIV_EXPECT(status, REC_STATUS_ORDINARY)) {
case REC_STATUS_ORDINARY:
ut_ad(n_fields == dict_index_get_n_fields(index));
size = 0;
break;
case REC_STATUS_NODE_PTR:
n_fields--;
ut_ad(n_fields == dict_index_get_n_unique_in_tree(index));
ut_ad(dfield_get_len(&fields[n_fields]) == REC_NODE_PTR_SIZE);
size = REC_NODE_PTR_SIZE; /* child page number */
break;
case REC_STATUS_INFIMUM:
case REC_STATUS_SUPREMUM:
/* infimum or supremum record, 8 data bytes */
if (UNIV_LIKELY_NULL(extra)) {
*extra = REC_N_NEW_EXTRA_BYTES;
}
return(REC_N_NEW_EXTRA_BYTES + 8);
default:
ut_error;
return(ULINT_UNDEFINED);
}
return(size + rec_get_converted_size_comp_prefix(index, fields,
n_fields, extra));
}
/***************************************************************
Sets the value of the ith field SQL null bit of an old-style record. */
UNIV_INTERN
......
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