diff --git a/storage/innobase/include/page0cur.ic b/storage/innobase/include/page0cur.ic index 8603977103b..f2a6356fbdb 100644 --- a/storage/innobase/include/page0cur.ic +++ b/storage/innobase/include/page0cur.ic @@ -191,7 +191,15 @@ static inline rec_t *page_cur_tuple_insert(page_cur_t *cursor, rec_t *rec; rec_t *insert_rec; - ulint size = rec_get_converted_size(index, tuple); + ulint size = 0; + ulint extra_size = 0; + if (dict_table_is_comp(index->table)) { + size = rec_get_converted_size_comp( + index, dtuple_get_info_bits(tuple) & REC_NEW_STATUS_MASK, + tuple->fields, tuple->n_fields, &extra_size); + } else { + size = rec_get_converted_size(index, tuple); + } if (!*heap) { *heap = mem_heap_create( @@ -201,7 +209,7 @@ static inline rec_t *page_cur_tuple_insert(page_cur_t *cursor, } rec = rec_convert_dtuple_to_rec((byte *)mem_heap_alloc(*heap, size), index, - tuple); + tuple, extra_size); *offsets = rec_get_offsets(rec, index, *offsets, ULINT_UNDEFINED, UT_LOCATION_HERE, heap); diff --git a/storage/innobase/include/rem0rec.h b/storage/innobase/include/rem0rec.h index 3b21609c733..1470b17b06a 100644 --- a/storage/innobase/include/rem0rec.h +++ b/storage/innobase/include/rem0rec.h @@ -457,7 +457,7 @@ buffer. @return pointer to the origin of physical record */ [[nodiscard]] rec_t *rec_convert_dtuple_to_rec(byte *buf, const dict_index_t *index, - const dtuple_t *dtuple); + const dtuple_t *dtuple, ulint extra_size = 0); /** Returns the extra size of an old-style physical record if we know its data size and number of fields. diff --git a/storage/innobase/rem/rem0rec.cc b/storage/innobase/rem/rem0rec.cc index 1bd35cf72ef..b4b0f0f3e36 100644 --- a/storage/innobase/rem/rem0rec.cc +++ b/storage/innobase/rem/rem0rec.cc @@ -1055,14 +1055,16 @@ beginning from the start of the given buffer. @return pointer to the origin of physical record */ static rec_t *rec_convert_dtuple_to_rec_new(byte *buf, const dict_index_t *index, - const dtuple_t *dtuple) { - ulint extra_size; + const dtuple_t *dtuple, + ulint extra_size) { ulint status; rec_t *rec; status = dtuple_get_info_bits(dtuple) & REC_NEW_STATUS_MASK; - rec_get_converted_size_comp(index, status, dtuple->fields, dtuple->n_fields, + if (extra_size == 0) { + rec_get_converted_size_comp(index, status, dtuple->fields, dtuple->n_fields, &extra_size); + } rec = buf + extra_size; auto rec_state = rec_convert_dtuple_to_rec_comp( @@ -1101,7 +1103,8 @@ rec_t *rec_convert_dtuple_to_rec( byte *buf, /*!< in: start address of the physical record */ const dict_index_t *index, /*!< in: record descriptor */ - const dtuple_t *dtuple) /*!< in: data tuple */ + const dtuple_t *dtuple, /*!< in: data tuple */ + ulint extra_size) { rec_t *rec; @@ -1112,7 +1115,7 @@ rec_t *rec_convert_dtuple_to_rec( ut_ad(dtuple_check_typed(dtuple)); if (dict_table_is_comp(index->table)) { - rec = rec_convert_dtuple_to_rec_new(buf, index, dtuple); + rec = rec_convert_dtuple_to_rec_new(buf, index, dtuple, extra_size); } else { rec = rec_convert_dtuple_to_rec_old(buf, index, dtuple); }