Skip to content

Commit 4188502

Browse files
committed
Bug#30437378 : ASSERTION N_EXT == DTUPLE->GET_N_EXT() AT
REC_GET_CONVERTED_SIZE() IN REM0REC.IC Issue: n_ext information being passed from row_upd_clust_rec_by_insert() was number of ext columns that are part of index. But this information is being used as total number of ext columns in further function flow. which might differ. Fix: Looking closely at the code, it is seen that rec_get_converted_size() doesn't actually need number of ext fields. It just need to know if ext fields are there or not. - Added a new member function in dfield_t to return true if tuple has at least one ext fields. - Don't pass n_ext to rec_get_converted_size(). Instead call dfield_t->has_ext() to know if ext fields are there or not. - Remove the problematic assert as it is not needed now. - There were many places where n_ext was being passed to functions but it seems none of the places actual number was needed. Only information needed is if ext fields exists. Thus, did a complete cleanup of code wherever n_ext was being passed. RB : 23310 Reviewed by : Annamalai Gurusami <[email protected]> Jakub Lopuszanski <[email protected]>
1 parent d155853 commit 4188502

35 files changed

+195
-314
lines changed

storage/innobase/btr/btr0btr.cc

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,7 +1490,6 @@ rec_t *btr_root_raise_and_insert(
14901490
ulint **offsets, /*!< out: offsets on inserted record */
14911491
mem_heap_t **heap, /*!< in/out: pointer to memory heap, or NULL */
14921492
const dtuple_t *tuple, /*!< in: tuple to insert */
1493-
ulint n_ext, /*!< in: number of externally stored columns */
14941493
mtr_t *mtr) /*!< in: mtr */
14951494
{
14961495
dict_index_t *index;
@@ -1630,8 +1629,8 @@ rec_t *btr_root_raise_and_insert(
16301629

16311630
page_cur_set_before_first(root_block, page_cursor);
16321631

1633-
node_ptr_rec = page_cur_tuple_insert(page_cursor, node_ptr, index, offsets,
1634-
heap, 0, mtr);
1632+
node_ptr_rec =
1633+
page_cur_tuple_insert(page_cursor, node_ptr, index, offsets, heap, mtr);
16351634

16361635
/* The root page should only contain the node pointer
16371636
to new_page at this point. Thus, the data should fit. */
@@ -1649,11 +1648,11 @@ rec_t *btr_root_raise_and_insert(
16491648
/* Split the child and insert tuple */
16501649
if (dict_index_is_spatial(index)) {
16511650
/* Split rtree page and insert tuple */
1652-
return (rtr_page_split_and_insert(flags, cursor, offsets, heap, tuple,
1653-
n_ext, mtr));
1651+
return (
1652+
rtr_page_split_and_insert(flags, cursor, offsets, heap, tuple, mtr));
16541653
} else {
1655-
return (btr_page_split_and_insert(flags, cursor, offsets, heap, tuple,
1656-
n_ext, mtr));
1654+
return (
1655+
btr_page_split_and_insert(flags, cursor, offsets, heap, tuple, mtr));
16571656
}
16581657
}
16591658

@@ -1753,8 +1752,7 @@ ibool btr_page_get_split_rec_to_right(
17531752
the lower or upper half-page (determined by btr_page_tuple_smaller()) */
17541753
static rec_t *btr_page_get_split_rec(
17551754
btr_cur_t *cursor, /*!< in: cursor at which insert should be made */
1756-
const dtuple_t *tuple, /*!< in: tuple to insert */
1757-
ulint n_ext) /*!< in: number of externally stored columns */
1755+
const dtuple_t *tuple) /*!< in: tuple to insert */
17581756
{
17591757
page_t *page;
17601758
page_zip_des_t *page_zip;
@@ -1773,7 +1771,7 @@ static rec_t *btr_page_get_split_rec(
17731771

17741772
page = btr_cur_get_page(cursor);
17751773

1776-
insert_size = rec_get_converted_size(cursor->index, tuple, n_ext);
1774+
insert_size = rec_get_converted_size(cursor->index, tuple);
17771775
free_space = page_get_free_space_of_empty(page_is_comp(page));
17781776

17791777
page_zip = btr_cur_get_page_zip(cursor);
@@ -1871,7 +1869,6 @@ static MY_ATTRIBUTE((warn_unused_result)) bool btr_page_insert_fits(
18711869
ulint **offsets, /*!< in: rec_get_offsets(
18721870
split_rec, cursor->index); out: garbage */
18731871
const dtuple_t *tuple, /*!< in: tuple to insert */
1874-
ulint n_ext, /*!< in: number of externally stored columns */
18751872
mem_heap_t **heap) /*!< in: temporary memory heap */
18761873
{
18771874
page_t *page;
@@ -1887,7 +1884,7 @@ static MY_ATTRIBUTE((warn_unused_result)) bool btr_page_insert_fits(
18871884
ut_ad(!split_rec || !page_is_comp(page) == !rec_offs_comp(*offsets));
18881885
ut_ad(!split_rec || rec_offs_validate(split_rec, cursor->index, *offsets));
18891886

1890-
insert_size = rec_get_converted_size(cursor->index, tuple, n_ext);
1887+
insert_size = rec_get_converted_size(cursor->index, tuple);
18911888
free_space = page_get_free_space_of_empty(page_is_comp(page));
18921889

18931890
/* free_space is now the free space of a created new page */
@@ -1989,12 +1986,12 @@ void btr_insert_on_non_leaf_level_func(
19891986

19901987
err = btr_cur_optimistic_insert(
19911988
flags | BTR_NO_LOCKING_FLAG | BTR_KEEP_SYS_FLAG | BTR_NO_UNDO_LOG_FLAG,
1992-
&cursor, &offsets, &heap, tuple, &rec, &dummy_big_rec, 0, NULL, mtr);
1989+
&cursor, &offsets, &heap, tuple, &rec, &dummy_big_rec, NULL, mtr);
19931990

19941991
if (err == DB_FAIL) {
19951992
err = btr_cur_pessimistic_insert(
19961993
flags | BTR_NO_LOCKING_FLAG | BTR_KEEP_SYS_FLAG | BTR_NO_UNDO_LOG_FLAG,
1997-
&cursor, &offsets, &heap, tuple, &rec, &dummy_big_rec, 0, NULL, mtr);
1994+
&cursor, &offsets, &heap, tuple, &rec, &dummy_big_rec, NULL, mtr);
19981995
ut_a(err == DB_SUCCESS);
19991996
}
20001997

@@ -2181,15 +2178,13 @@ of a page.
21812178
@param[out] offsets offsets on inserted record
21822179
@param[in,out] heap memory heap for allocating offsets
21832180
@param[in] tuple tuple to insert
2184-
@param[in] n_ext number of externally stored columns
21852181
@param[in,out] mtr mini-transaction
21862182
@return inserted record (first record on the right sibling page);
21872183
the cursor will be positioned on the page infimum
21882184
@retval NULL if the operation was not performed */
21892185
static rec_t *btr_insert_into_right_sibling(uint32_t flags, btr_cur_t *cursor,
21902186
ulint **offsets, mem_heap_t *heap,
2191-
const dtuple_t *tuple, ulint n_ext,
2192-
mtr_t *mtr) {
2187+
const dtuple_t *tuple, mtr_t *mtr) {
21932188
buf_block_t *block = btr_cur_get_block(cursor);
21942189
page_t *page = buf_block_get_frame(block);
21952190
page_no_t next_page_no = btr_page_get_next(page, mtr);
@@ -2234,7 +2229,7 @@ static rec_t *btr_insert_into_right_sibling(uint32_t flags, btr_cur_t *cursor,
22342229
}
22352230

22362231
rec = page_cur_tuple_insert(&next_page_cursor, tuple, cursor->index, offsets,
2237-
&heap, n_ext, mtr);
2232+
&heap, mtr);
22382233

22392234
if (rec == NULL) {
22402235
if (is_leaf && next_block->page.size.is_compressed() &&
@@ -2307,7 +2302,6 @@ rec_t *btr_page_split_and_insert(
23072302
ulint **offsets, /*!< out: offsets on inserted record */
23082303
mem_heap_t **heap, /*!< in/out: pointer to memory heap, or NULL */
23092304
const dtuple_t *tuple, /*!< in: tuple to insert */
2310-
ulint n_ext, /*!< in: number of externally stored columns */
23112305
mtr_t *mtr) /*!< in: mtr */
23122306
{
23132307
buf_block_t *block;
@@ -2338,8 +2332,8 @@ rec_t *btr_page_split_and_insert(
23382332

23392333
if (dict_index_is_spatial(index)) {
23402334
/* Split rtree page and update parent */
2341-
return (rtr_page_split_and_insert(flags, cursor, offsets, heap, tuple,
2342-
n_ext, mtr));
2335+
return (
2336+
rtr_page_split_and_insert(flags, cursor, offsets, heap, tuple, mtr));
23432337
}
23442338

23452339
if (!*heap) {
@@ -2369,8 +2363,8 @@ rec_t *btr_page_split_and_insert(
23692363
ut_ad(!page_is_empty(page));
23702364

23712365
/* try to insert to the next page if possible before split */
2372-
rec = btr_insert_into_right_sibling(flags, cursor, offsets, *heap, tuple,
2373-
n_ext, mtr);
2366+
rec =
2367+
btr_insert_into_right_sibling(flags, cursor, offsets, *heap, tuple, mtr);
23742368

23752369
if (rec != NULL) {
23762370
return (rec);
@@ -2386,7 +2380,7 @@ rec_t *btr_page_split_and_insert(
23862380
if (n_iterations > 0) {
23872381
direction = FSP_UP;
23882382
hint_page_no = page_no + 1;
2389-
split_rec = btr_page_get_split_rec(cursor, tuple, n_ext);
2383+
split_rec = btr_page_get_split_rec(cursor, tuple);
23902384

23912385
if (split_rec == NULL) {
23922386
insert_left =
@@ -2454,10 +2448,10 @@ rec_t *btr_page_split_and_insert(
24542448
insert_empty:
24552449
ut_ad(!split_rec);
24562450
ut_ad(!insert_left);
2457-
buf = UT_NEW_ARRAY_NOKEY(
2458-
byte, rec_get_converted_size(cursor->index, tuple, n_ext));
2451+
buf =
2452+
UT_NEW_ARRAY_NOKEY(byte, rec_get_converted_size(cursor->index, tuple));
24592453

2460-
first_rec = rec_convert_dtuple_to_rec(buf, cursor->index, tuple, n_ext);
2454+
first_rec = rec_convert_dtuple_to_rec(buf, cursor->index, tuple);
24612455
move_limit = page_rec_get_next(btr_cur_get_rec(cursor));
24622456
}
24632457

@@ -2474,16 +2468,15 @@ rec_t *btr_page_split_and_insert(
24742468
if (split_rec) {
24752469
insert_will_fit =
24762470
!new_page_zip &&
2477-
btr_page_insert_fits(cursor, split_rec, offsets, tuple, n_ext, heap);
2471+
btr_page_insert_fits(cursor, split_rec, offsets, tuple, heap);
24782472
} else {
24792473
if (!insert_left) {
24802474
UT_DELETE_ARRAY(buf);
24812475
buf = NULL;
24822476
}
24832477

2484-
insert_will_fit =
2485-
!new_page_zip &&
2486-
btr_page_insert_fits(cursor, NULL, offsets, tuple, n_ext, heap);
2478+
insert_will_fit = !new_page_zip &&
2479+
btr_page_insert_fits(cursor, NULL, offsets, tuple, heap);
24872480
}
24882481

24892482
if (!srv_read_only_mode && !cursor->index->table->is_intrinsic() &&
@@ -2608,7 +2601,7 @@ rec_t *btr_page_split_and_insert(
26082601
page_cur_search(insert_block, cursor->index, tuple, page_cursor);
26092602

26102603
rec = page_cur_tuple_insert(page_cursor, tuple, cursor->index, offsets, heap,
2611-
n_ext, mtr);
2604+
mtr);
26122605

26132606
#ifdef UNIV_ZIP_DEBUG
26142607
{
@@ -2635,7 +2628,7 @@ rec_t *btr_page_split_and_insert(
26352628
}
26362629

26372630
rec = page_cur_tuple_insert(page_cursor, tuple, cursor->index, offsets, heap,
2638-
n_ext, mtr);
2631+
mtr);
26392632

26402633
if (rec == NULL) {
26412634
/* The insert did not fit on the page: loop back to the

storage/innobase/btr/btr0bulk.cc

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -167,18 +167,17 @@ dberr_t PageBulk::init() {
167167
@param[in] tuple tuple to insert
168168
@param[in] big_rec external record
169169
@param[in] rec_size record size
170-
@param[in] n_ext number of externally stored columns
171170
@return error code */
172171
dberr_t PageBulk::insert(const dtuple_t *tuple, const big_rec_t *big_rec,
173-
ulint rec_size, ulint n_ext) {
172+
ulint rec_size) {
174173
ulint *offsets = nullptr;
175174

176175
DBUG_EXECUTE_IF("BtrBulk_insert_inject_error", return DB_INTERRUPTED;);
177176

178177
/* Convert tuple to record. */
179178
byte *rec_mem = static_cast<byte *>(mem_heap_alloc(m_heap, rec_size));
180179

181-
rec_t *rec = rec_convert_dtuple_to_rec(rec_mem, m_index, tuple, n_ext);
180+
rec_t *rec = rec_convert_dtuple_to_rec(rec_mem, m_index, tuple);
182181
offsets = rec_get_offsets(rec, m_index, offsets, ULINT_UNDEFINED, &m_heap);
183182

184183
/* Insert the record.*/
@@ -891,10 +890,9 @@ dberr_t BtrBulk::prepareSpace(PageBulk *&page_bulk, ulint level,
891890
@param[in] big_rec big record vector, could be nullptr if there is no
892891
data to be stored externally.
893892
@param[in] rec_size record size
894-
@param[in] n_ext number of externally stored columns
895893
@return error code */
896894
dberr_t BtrBulk::insert(PageBulk *page_bulk, dtuple_t *tuple,
897-
big_rec_t *big_rec, ulint rec_size, ulint n_ext) {
895+
big_rec_t *big_rec, ulint rec_size) {
898896
dberr_t err = DB_SUCCESS;
899897

900898
if (big_rec != nullptr) {
@@ -910,7 +908,7 @@ dberr_t BtrBulk::insert(PageBulk *page_bulk, dtuple_t *tuple,
910908
}
911909
}
912910

913-
err = page_bulk->insert(tuple, big_rec, rec_size, n_ext);
911+
err = page_bulk->insert(tuple, big_rec, rec_size);
914912

915913
if (big_rec != nullptr) {
916914
/* Restore latches */
@@ -966,19 +964,18 @@ dberr_t BtrBulk::insert(dtuple_t *tuple, ulint level) {
966964
dtuple_get_info_bits(tuple) | REC_INFO_MIN_REC_FLAG);
967965
}
968966

969-
ulint n_ext = 0;
970-
ulint rec_size = rec_get_converted_size(m_index, tuple, n_ext);
967+
ulint rec_size = rec_get_converted_size(m_index, tuple);
971968
big_rec_t *big_rec = nullptr;
972969

973970
if (page_bulk->needExt(tuple, rec_size)) {
974971
/* The record is so big that we have to store some fields
975972
externally on separate database pages */
976-
big_rec = dtuple_convert_big_rec(m_index, 0, tuple, &n_ext);
973+
big_rec = dtuple_convert_big_rec(m_index, 0, tuple);
977974
if (big_rec == nullptr) {
978975
return (DB_TOO_BIG_RECORD);
979976
}
980977

981-
rec_size = rec_get_converted_size(m_index, tuple, n_ext);
978+
rec_size = rec_get_converted_size(m_index, tuple);
982979
}
983980

984981
if (page_bulk->isTableCompressed() && page_zip_is_too_big(m_index, tuple)) {
@@ -1000,7 +997,7 @@ dberr_t BtrBulk::insert(dtuple_t *tuple, ulint level) {
1000997
}
1001998
});
1002999

1003-
err = insert(page_bulk, tuple, big_rec, rec_size, n_ext);
1000+
err = insert(page_bulk, tuple, big_rec, rec_size);
10041001

10051002
func_exit:
10061003
if (big_rec != nullptr) {

0 commit comments

Comments
 (0)