Skip to content

Commit b21930f

Browse files
committed
MDEV-18749: Uninitialized value upon ADD FULLTEXT INDEX
row_merge_create_fts_sort_index(): Initialize dict_col_t. This fixes an access to uninitialized dict_col_t::ind when a debug assertion in MariaDB 10.4 invokes is_dropped() in rec_get_converted_size_comp_prefix_low(). Older MariaDB versions seem to be unaffected by the uninitialized values, but it should not hurt to initialize everything.
1 parent 91e4f00 commit b21930f

File tree

2 files changed

+12
-22
lines changed

2 files changed

+12
-22
lines changed

storage/innobase/row/row0ftsort.cc

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ row_merge_create_fts_sort_index(
9898
field = dict_index_get_nth_field(new_index, 0);
9999
field->name = NULL;
100100
field->prefix_len = 0;
101-
field->col = static_cast<dict_col_t*>(
102-
mem_heap_alloc(new_index->heap, sizeof(dict_col_t)));
101+
field->col = new(mem_heap_zalloc(new_index->heap, sizeof(dict_col_t)))
102+
dict_col_t();
103103
field->col->prtype = idx_field->col->prtype | DATA_NOT_NULL;
104104
field->col->mtype = charset == &my_charset_latin1
105105
? DATA_VARCHAR : DATA_VARMYSQL;
@@ -113,8 +113,8 @@ row_merge_create_fts_sort_index(
113113
field = dict_index_get_nth_field(new_index, 1);
114114
field->name = NULL;
115115
field->prefix_len = 0;
116-
field->col = static_cast<dict_col_t*>(
117-
mem_heap_alloc(new_index->heap, sizeof(dict_col_t)));
116+
field->col = new(mem_heap_zalloc(new_index->heap, sizeof(dict_col_t)))
117+
dict_col_t();
118118
field->col->mtype = DATA_INT;
119119
*opt_doc_id_size = FALSE;
120120

@@ -148,21 +148,16 @@ row_merge_create_fts_sort_index(
148148

149149
field->col->prtype = DATA_NOT_NULL | DATA_BINARY_TYPE;
150150

151-
field->col->mbminlen = 0;
152-
field->col->mbmaxlen = 0;
153-
154151
/* The third field is on the word's position in the original doc */
155152
field = dict_index_get_nth_field(new_index, 2);
156153
field->name = NULL;
157154
field->prefix_len = 0;
158-
field->col = static_cast<dict_col_t*>(
159-
mem_heap_alloc(new_index->heap, sizeof(dict_col_t)));
155+
field->col = new(mem_heap_zalloc(new_index->heap, sizeof(dict_col_t)))
156+
dict_col_t();
160157
field->col->mtype = DATA_INT;
161158
field->col->len = 4 ;
162159
field->fixed_len = 4;
163160
field->col->prtype = DATA_NOT_NULL;
164-
field->col->mbminlen = 0;
165-
field->col->mbmaxlen = 0;
166161

167162
return(new_index);
168163
}

storage/xtradb/row/row0ftsort.cc

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ row_merge_create_fts_sort_index(
101101
field = dict_index_get_nth_field(new_index, 0);
102102
field->name = NULL;
103103
field->prefix_len = 0;
104-
field->col = static_cast<dict_col_t*>(
105-
mem_heap_alloc(new_index->heap, sizeof(dict_col_t)));
104+
field->col = new(mem_heap_zalloc(new_index->heap, sizeof(dict_col_t)))
105+
dict_col_t();
106106
field->col->prtype = idx_field->col->prtype | DATA_NOT_NULL;
107107
field->col->mtype = charset == &my_charset_latin1
108108
? DATA_VARCHAR : DATA_VARMYSQL;
@@ -116,8 +116,8 @@ row_merge_create_fts_sort_index(
116116
field = dict_index_get_nth_field(new_index, 1);
117117
field->name = NULL;
118118
field->prefix_len = 0;
119-
field->col = static_cast<dict_col_t*>(
120-
mem_heap_alloc(new_index->heap, sizeof(dict_col_t)));
119+
field->col = new(mem_heap_zalloc(new_index->heap, sizeof(dict_col_t)))
120+
dict_col_t();
121121
field->col->mtype = DATA_INT;
122122
*opt_doc_id_size = FALSE;
123123

@@ -151,21 +151,16 @@ row_merge_create_fts_sort_index(
151151

152152
field->col->prtype = DATA_NOT_NULL | DATA_BINARY_TYPE;
153153

154-
field->col->mbminlen = 0;
155-
field->col->mbmaxlen = 0;
156-
157154
/* The third field is on the word's position in the original doc */
158155
field = dict_index_get_nth_field(new_index, 2);
159156
field->name = NULL;
160157
field->prefix_len = 0;
161-
field->col = static_cast<dict_col_t*>(
162-
mem_heap_alloc(new_index->heap, sizeof(dict_col_t)));
158+
field->col = new(mem_heap_zalloc(new_index->heap, sizeof(dict_col_t)))
159+
dict_col_t();
163160
field->col->mtype = DATA_INT;
164161
field->col->len = 4 ;
165162
field->fixed_len = 4;
166163
field->col->prtype = DATA_NOT_NULL;
167-
field->col->mbminlen = 0;
168-
field->col->mbmaxlen = 0;
169164

170165
return(new_index);
171166
}

0 commit comments

Comments
 (0)