From c029d4562322d8c792f96717e0fb7f18d2379b2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 4 Sep 2020 12:07:46 +0300 Subject: [PATCH] MDEV-23600 follow-up: uninitialized rec_field_is_prefix build_template_field(): Initialize templ->rec_field_is_prefix also for indexes on virtual columns. This was caught on 10.5 by MemorySanitizer as use-of-uninitialized-value in row_search_with_covering_prefix() when running the test main.fast_prefix_index_fetch_innodb. --- storage/innobase/handler/ha_innodb.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index e171b6a99b3..2493a11b554 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -7455,6 +7455,8 @@ build_template_field( #ifdef HAVE_valgrind_or_MSAN MEM_UNDEFINED(templ, sizeof *templ); #endif /* HAVE_valgrind_or_MSAN */ + templ->rec_field_is_prefix = FALSE; + templ->rec_prefix_field_no = ULINT_UNDEFINED; templ->is_virtual = !field->stored_in_db(); if (!templ->is_virtual) { @@ -7516,8 +7518,6 @@ build_template_field( << " query " << innobase_get_stmt_unsafe(current_thd, &size); } - templ->rec_field_is_prefix = FALSE; - templ->rec_prefix_field_no = ULINT_UNDEFINED; if (dict_index_is_clust(index)) { templ->rec_field_no = templ->clust_rec_field_no; @@ -7535,7 +7535,6 @@ build_template_field( DBUG_ASSERT(!ha_innobase::omits_virtual_cols(*table->s)); col = &dict_table_get_nth_v_col(index->table, v_no)->m_col; templ->clust_rec_field_no = v_no; - templ->rec_prefix_field_no = ULINT_UNDEFINED; if (dict_index_is_clust(index)) { templ->rec_field_no = templ->clust_rec_field_no;