Skip to content

Commit ce19598

Browse files
committed
MDEV-19385: Inconsistent definition of dtuple_get_nth_v_field()
The accessor dtuple_get_nth_v_field() was defined differently between debug and release builds in MySQL 5.7.8 in mysql/mysql-server@c47e175 and a debug assertion to document or enforce the questionable assumption tuple->v_fields == &tuple->fields[tuple->n_fields] was missing. This was apparently no problem until MDEV-11369 introduced instant ADD COLUMN to MariaDB Server 10.3. With that work present, in one test case, trx_undo_report_insert_virtual() could in release builds fetch the wrong value for a virtual column. We replace many of the dtuple_t accessors with const-preserving inline functions, and fix missing or misleadingly applied const qualifiers accordingly.
1 parent 3db94d2 commit ce19598

21 files changed

+168
-358
lines changed

storage/innobase/data/data0data.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Created 5/30/1994 Heikki Tuuri
3737
/** Dummy variable to catch access to uninitialized fields. In the
3838
debug version, dtuple_create() will make all fields of dtuple_t point
3939
to data_error. */
40-
byte data_error;
40+
ut_d(byte data_error);
4141
#endif /* UNIV_DEBUG */
4242

4343
/** Compare two data tuples.
@@ -416,7 +416,7 @@ dfield_print_also_hex(
416416
break;
417417
}
418418

419-
data = static_cast<byte*>(dfield_get_data(dfield));
419+
data = static_cast<const byte*>(dfield_get_data(dfield));
420420
/* fall through */
421421

422422
case DATA_BINARY:

storage/innobase/fts/fts0fts.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3366,12 +3366,11 @@ fts_fetch_doc_from_tuple(
33663366
const dict_field_t* ifield;
33673367
const dict_col_t* col;
33683368
ulint pos;
3369-
dfield_t* field;
33703369

33713370
ifield = dict_index_get_nth_field(index, i);
33723371
col = dict_field_get_col(ifield);
33733372
pos = dict_col_get_no(col);
3374-
field = dtuple_get_nth_field(tuple, pos);
3373+
const dfield_t* field = dtuple_get_nth_field(tuple, pos);
33753374

33763375
if (!get_doc->index_cache->charset) {
33773376
get_doc->index_cache->charset = fts_get_charset(

storage/innobase/gis/gis0geo.cc

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 2013, 2015, Oracle and/or its affiliates. All Rights Reserved.
4+
Copyright (c) 2019, MariaDB Corporation.
45
56
This program is free software; you can redistribute it and/or modify it under
67
the terms of the GNU General Public License as published by the Free Software
@@ -68,9 +69,9 @@ static
6869
int
6970
rtree_add_point_to_mbr(
7071
/*===================*/
71-
uchar** wkb, /*!< in: pointer to wkb,
72+
const uchar** wkb, /*!< in: pointer to wkb,
7273
where point is stored */
73-
uchar* end, /*!< in: end of wkb. */
74+
const uchar* end, /*!< in: end of wkb. */
7475
uint n_dims, /*!< in: dimensions. */
7576
uchar byte_order, /*!< in: byte order. */
7677
double* mbr) /*!< in/out: mbr, which
@@ -108,9 +109,9 @@ static
108109
int
109110
rtree_get_point_mbr(
110111
/*================*/
111-
uchar** wkb, /*!< in: pointer to wkb,
112+
const uchar** wkb, /*!< in: pointer to wkb,
112113
where point is stored. */
113-
uchar* end, /*!< in: end of wkb. */
114+
const uchar* end, /*!< in: end of wkb. */
114115
uint n_dims, /*!< in: dimensions. */
115116
uchar byte_order, /*!< in: byte order. */
116117
double* mbr) /*!< in/out: mbr,
@@ -127,9 +128,9 @@ static
127128
int
128129
rtree_get_linestring_mbr(
129130
/*=====================*/
130-
uchar** wkb, /*!< in: pointer to wkb,
131+
const uchar** wkb, /*!< in: pointer to wkb,
131132
where point is stored. */
132-
uchar* end, /*!< in: end of wkb. */
133+
const uchar* end, /*!< in: end of wkb. */
133134
uint n_dims, /*!< in: dimensions. */
134135
uchar byte_order, /*!< in: byte order. */
135136
double* mbr) /*!< in/out: mbr,
@@ -158,9 +159,9 @@ static
158159
int
159160
rtree_get_polygon_mbr(
160161
/*==================*/
161-
uchar** wkb, /*!< in: pointer to wkb,
162+
const uchar** wkb, /*!< in: pointer to wkb,
162163
where point is stored. */
163-
uchar* end, /*!< in: end of wkb. */
164+
const uchar* end, /*!< in: end of wkb. */
164165
uint n_dims, /*!< in: dimensions. */
165166
uchar byte_order, /*!< in: byte order. */
166167
double* mbr) /*!< in/out: mbr,
@@ -195,9 +196,9 @@ static
195196
int
196197
rtree_get_geometry_mbr(
197198
/*===================*/
198-
uchar** wkb, /*!< in: pointer to wkb,
199+
const uchar** wkb, /*!< in: pointer to wkb,
199200
where point is stored. */
200-
uchar* end, /*!< in: end of wkb. */
201+
const uchar* end, /*!< in: end of wkb. */
201202
uint n_dims, /*!< in: dimensions. */
202203
double* mbr, /*!< in/out: mbr. */
203204
int top) /*!< in: if it is the top,
@@ -297,7 +298,7 @@ stored in "well-known binary representation" (wkb) format.
297298
int
298299
rtree_mbr_from_wkb(
299300
/*===============*/
300-
uchar* wkb, /*!< in: wkb */
301+
const uchar* wkb, /*!< in: wkb */
301302
uint size, /*!< in: size of wkb. */
302303
uint n_dims, /*!< in: dimensions. */
303304
double* mbr) /*!< in/out: mbr, which must

storage/innobase/gis/gis0rtree.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved.
4+
Copyright (c) 2019, MariaDB Corporation.
45
56
This program is free software; you can redistribute it and/or modify it under
67
the terms of the GNU General Public License as published by the Free Software
@@ -64,7 +65,7 @@ rtr_page_split_initialize_nodes(
6465
page_t* page;
6566
ulint n_uniq;
6667
ulint len;
67-
byte* source_cur;
68+
const byte* source_cur;
6869

6970
block = btr_cur_get_block(cursor);
7071
page = buf_block_get_frame(block);
@@ -104,7 +105,7 @@ rtr_page_split_initialize_nodes(
104105
}
105106

106107
/* Put the insert key to node list */
107-
source_cur = static_cast<byte*>(dfield_get_data(
108+
source_cur = static_cast<const byte*>(dfield_get_data(
108109
dtuple_get_nth_field(tuple, 0)));
109110
cur->coords = reserve_coords(buf_pos, SPDIMS);
110111
rec = (byte*) mem_heap_alloc(
@@ -1874,11 +1875,11 @@ rtr_estimate_n_rows_in_range(
18741875
ulint dtuple_f_len MY_ATTRIBUTE((unused));
18751876
rtr_mbr_t range_mbr;
18761877
double range_area;
1877-
byte* range_mbr_ptr;
18781878

18791879
dtuple_field = dtuple_get_nth_field(tuple, 0);
18801880
dtuple_f_len = dfield_get_len(dtuple_field);
1881-
range_mbr_ptr = reinterpret_cast<byte*>(dfield_get_data(dtuple_field));
1881+
const byte* range_mbr_ptr = static_cast<const byte*>(
1882+
dfield_get_data(dtuple_field));
18821883

18831884
ut_ad(dtuple_f_len >= DATA_MBR_LEN);
18841885
rtr_read_mbr(range_mbr_ptr, &range_mbr);

storage/innobase/gis/gis0sea.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,15 +1631,13 @@ rtr_get_mbr_from_tuple(
16311631
{
16321632
const dfield_t* dtuple_field;
16331633
ulint dtuple_f_len;
1634-
byte* data;
16351634

16361635
dtuple_field = dtuple_get_nth_field(dtuple, 0);
16371636
dtuple_f_len = dfield_get_len(dtuple_field);
16381637
ut_a(dtuple_f_len >= 4 * sizeof(double));
16391638

1640-
data = static_cast<byte*>(dfield_get_data(dtuple_field));
1641-
1642-
rtr_read_mbr(data, mbr);
1639+
rtr_read_mbr(static_cast<const byte*>(dfield_get_data(dtuple_field)),
1640+
mbr);
16431641
}
16441642

16451643
/****************************************************************//**

storage/innobase/handler/ha_innodb.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21784,7 +21784,7 @@ void innobase_free_row_for_vcol(VCOL_STORAGE *storage)
2178421784
to store the value in passed in "my_rec" */
2178521785
dfield_t*
2178621786
innobase_get_computed_value(
21787-
const dtuple_t* row,
21787+
dtuple_t* row,
2178821788
const dict_v_col_t* col,
2178921789
const dict_index_t* index,
2179021790
mem_heap_t** local_heap,

0 commit comments

Comments
 (0)