From 5f60c7c3c23c5f20fd9a8074aa72df00e13a1c5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= <marko.makela@mariadb.com> Date: Fri, 18 Jan 2019 10:39:52 +0200 Subject: [PATCH] MDEV-17823 Assertion failed when accessing indexed instantly added column This assertion would fail when a secondary index record for an instantly added column was accessed. It is unclear to me why this code path is executed so rarely. I was unable to cover it even when using FORCE INDEX. row_sel_sec_rec_is_for_clust_rec(): Remove the assertion, and use the proper function rec_get_nth_cfield(). row_sel_store_mysql_field_func(): Simply use rec_get_nth_cfield() instead of duplicating its logic. --- storage/innobase/row/row0sel.cc | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/storage/innobase/row/row0sel.cc b/storage/innobase/row/row0sel.cc index 58b063a3b05..8ca33d33d80 100644 --- a/storage/innobase/row/row0sel.cc +++ b/storage/innobase/row/row0sel.cc @@ -254,9 +254,9 @@ row_sel_sec_rec_is_for_clust_rec( clust_field = static_cast<byte*>(vfield->data); } else { clust_pos = dict_col_get_clust_pos(col, clust_index); - ut_ad(!rec_offs_nth_default(clust_offs, clust_pos)); - clust_field = rec_get_nth_field( - clust_rec, clust_offs, clust_pos, &clust_len); + clust_field = rec_get_nth_cfield( + clust_rec, clust_index, clust_offs, + clust_pos, &clust_len); } sec_field = rec_get_nth_field(sec_rec, sec_offs, i, &sec_len); @@ -3010,17 +3010,7 @@ row_sel_store_mysql_field_func( } else { /* The field is stored in the index record, or in the metadata for instant ADD COLUMN. */ - - if (rec_offs_nth_default(offsets, field_no)) { - ut_ad(dict_index_is_clust(index)); - ut_ad(index->is_instant()); - const dict_index_t* clust_index - = dict_table_get_first_index(prebuilt->table); - ut_ad(index == clust_index); - data = clust_index->instant_field_value(field_no,&len); - } else { - data = rec_get_nth_field(rec, offsets, field_no, &len); - } + data = rec_get_nth_cfield(rec, index, offsets, field_no, &len); if (len == UNIV_SQL_NULL) { /* MySQL assumes that the field for an SQL -- 2.30.9