Commit d3a7ef99 authored by Marko Mäkelä's avatar Marko Mäkelä

Bug#55626: MIN and MAX reading a delete-marked record from secondary index

Remove a bogus debug assertion that triggered the bug.
Add assertions precisely where records must not be delete-marked.
And a comment to clarify when the record is allowed to be delete-marked.
parent ae55711e
...@@ -2690,7 +2690,6 @@ row_sel_store_mysql_rec( ...@@ -2690,7 +2690,6 @@ row_sel_store_mysql_rec(
ut_ad(prebuilt->mysql_template); ut_ad(prebuilt->mysql_template);
ut_ad(prebuilt->default_rec); ut_ad(prebuilt->default_rec);
ut_ad(rec_offs_validate(rec, NULL, offsets)); ut_ad(rec_offs_validate(rec, NULL, offsets));
ut_ad(!rec_get_deleted_flag(rec, rec_offs_comp(offsets)));
if (UNIV_LIKELY_NULL(prebuilt->blob_heap)) { if (UNIV_LIKELY_NULL(prebuilt->blob_heap)) {
mem_heap_free(prebuilt->blob_heap); mem_heap_free(prebuilt->blob_heap);
...@@ -3611,6 +3610,7 @@ row_search_for_mysql( ...@@ -3611,6 +3610,7 @@ row_search_for_mysql(
row_sel_try_search_shortcut_for_mysql(). row_sel_try_search_shortcut_for_mysql().
The latch will not be released until The latch will not be released until
mtr_commit(&mtr). */ mtr_commit(&mtr). */
ut_ad(!rec_get_deleted_flag(rec, comp));
if (!row_sel_store_mysql_rec(buf, prebuilt, if (!row_sel_store_mysql_rec(buf, prebuilt,
rec, offsets)) { rec, offsets)) {
...@@ -4238,7 +4238,7 @@ row_search_for_mysql( ...@@ -4238,7 +4238,7 @@ row_search_for_mysql(
rec = old_vers; rec = old_vers;
} }
} else if (!lock_sec_rec_cons_read_sees(rec, trx->read_view)) { } else {
/* We are looking into a non-clustered index, /* We are looking into a non-clustered index,
and to get the right version of the record we and to get the right version of the record we
have to look also into the clustered index: this have to look also into the clustered index: this
...@@ -4246,10 +4246,14 @@ row_search_for_mysql( ...@@ -4246,10 +4246,14 @@ row_search_for_mysql(
information via the clustered index record. */ information via the clustered index record. */
ut_ad(index != clust_index); ut_ad(index != clust_index);
ut_ad(!dict_index_is_clust(index));
if (!lock_sec_rec_cons_read_sees(
rec, trx->read_view)) {
goto requires_clust_rec; goto requires_clust_rec;
} }
} }
}
/* NOTE that at this point rec can be an old version of a clustered /* NOTE that at this point rec can be an old version of a clustered
index record built for a consistent read. We cannot assume after this index record built for a consistent read. We cannot assume after this
...@@ -4370,8 +4374,13 @@ row_search_for_mysql( ...@@ -4370,8 +4374,13 @@ row_search_for_mysql(
ULINT_UNDEFINED, &heap); ULINT_UNDEFINED, &heap);
result_rec = rec; result_rec = rec;
} }
/* result_rec can legitimately be delete-marked
now that it has been established that it points to a
clustered index record that exists in the read view. */
} else { } else {
result_rec = rec; result_rec = rec;
ut_ad(!rec_get_deleted_flag(rec, comp));
} }
/* We found a qualifying record 'result_rec'. At this point, /* We found a qualifying record 'result_rec'. At this point,
......
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