Commit 0009bb26 authored by Marko Mäkelä's avatar Marko Mäkelä

Clean up the update code

row_upd_changes_field_size_or_external(): Revert some unnecessary
changes, and assert that the update vector does not contain the
magic value UNIV_SQL_DEFAULT.

row_upd_rec_in_place(): Remove a redundant assertion.
rec_set_nth_field() already asserts the same.

row_upd_build_sec_rec_difference_binary(): Assert that there are
no default values in a secondary index tuple.
parent acae212a
......@@ -328,6 +328,7 @@ dfield_data_is_binary_equal(
ulint len, /*!< in: data length or UNIV_SQL_NULL */
const byte* data) /*!< in: data */
{
ut_ad(len != UNIV_SQL_DEFAULT);
return(len == dfield_get_len(field)
&& (len == UNIV_SQL_NULL
|| !memcmp(dfield_get_data(field), data, len)));
......
......@@ -1224,6 +1224,7 @@ rec_set_nth_field(
ut_ad(rec);
ut_ad(rec_offs_validate(rec, NULL, offsets));
ut_ad(!rec_offs_nth_default(offsets, n));
if (len == UNIV_SQL_NULL) {
if (!rec_offs_nth_sql_null(offsets, n)) {
......@@ -1234,7 +1235,6 @@ rec_set_nth_field(
return;
}
ut_ad(!rec_offs_nth_default(offsets, n));
data2 = (byte*)rec_get_nth_field(rec, offsets, n, &len2);
if (len2 == UNIV_SQL_NULL) {
ut_ad(!rec_offs_comp(offsets));
......
......@@ -563,9 +563,9 @@ row_upd_index_entry_sys_field(
/***********************************************************//**
Returns TRUE if row update changes size of some field in index or if some
field to be updated is stored externally in rec or added columns or update.
field to be updated is stored externally in rec or update.
@return TRUE if the update changes the size of some field in index or
the field is external in rec or added columns or update */
the field is external in rec or update */
ibool
row_upd_changes_field_size_or_external(
/*===================================*/
......@@ -595,6 +595,7 @@ row_upd_changes_field_size_or_external(
new_val = &(upd_field->new_val);
new_len = dfield_get_len(new_val);
ut_ad(new_len != UNIV_SQL_DEFAULT);
if (dfield_is_null(new_val) && !rec_offs_comp(offsets)) {
/* A bug fixed on Dec 31st, 2004: we looked at the
......@@ -610,8 +611,8 @@ row_upd_changes_field_size_or_external(
old_len = rec_offs_nth_size(offsets, upd_field->field_no);
if (rec_offs_comp(offsets)){
if(rec_offs_nth_sql_null(offsets,
if (rec_offs_comp(offsets)
&& rec_offs_nth_sql_null(offsets,
upd_field->field_no)) {
/* Note that in the compact table format, for a
variable length field, an SQL NULL will use zero
......@@ -620,15 +621,12 @@ row_upd_changes_field_size_or_external(
use one byte! Thus, we cannot use update-in-place
if we update an SQL NULL varchar to an empty string! */
old_len = UNIV_SQL_NULL;
} else if (rec_offs_nth_default(offsets, upd_field->field_no)) {
/* If update the added columns, use pessimistic update */
old_len = UNIV_SQL_DEFAULT;
}
old_len = UNIV_SQL_NULL;
}
if (dfield_is_ext(new_val) || old_len != new_len
|| rec_offs_nth_extern(offsets, upd_field->field_no)) {
|| rec_offs_nth_extern(offsets, upd_field->field_no)) {
return(TRUE);
}
}
......@@ -734,10 +732,6 @@ row_upd_rec_in_place(
ut_ad(!dfield_is_ext(new_val) ==
!rec_offs_nth_extern(offsets, upd_field->field_no));
/* If the added columns is been updated, it always use
pessimistic update. So we assert here. Detailed in
row_upd_changes_field_size_or_external() */
ut_ad(!rec_offs_nth_default(offsets, upd_field->field_no));
rec_set_nth_field(rec, offsets, upd_field->field_no,
dfield_get_data(new_val),
dfield_get_len(new_val));
......@@ -999,6 +993,7 @@ row_upd_build_sec_rec_difference_binary(
ut_ad(rec_offs_validate(rec, index, offsets));
ut_ad(rec_offs_n_fields(offsets) == dtuple_get_n_fields(entry));
ut_ad(!rec_offs_any_extern(offsets));
ut_ad(!rec_offs_any_default(offsets));
update = upd_create(dtuple_get_n_fields(entry), heap);
......@@ -1006,9 +1001,6 @@ row_upd_build_sec_rec_difference_binary(
for (i = 0; i < dtuple_get_n_fields(entry); i++) {
/* There is no default value added column
in secondary index */
ut_ad(!rec_offs_nth_default(offsets, i));
data = rec_get_nth_field(rec, offsets, i, &len);
dfield = dtuple_get_nth_field(entry, i);
......
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