From c3695b4058ea9a8849c22aabeabc76448fe548f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 17 Jan 2020 11:11:19 +0200 Subject: MDEV-21511: Remove unnecessary code Now that we will be invoking dtuple_get_n_ext() instead of letting btr_push_update_extern_fields() update an already calculated value, it is unnecessary to calculate the n_ext upfront. row_rec_to_index_entry(), row_rec_to_index_entry_low(): Remove the output parameter n_ext. --- storage/innobase/btr/btr0cur.cc | 15 +++++---------- storage/innobase/include/row0row.h | 6 +----- storage/innobase/row/row0ftsort.cc | 5 ++--- storage/innobase/row/row0log.cc | 7 +++---- storage/innobase/row/row0merge.cc | 12 +++--------- storage/innobase/row/row0mysql.cc | 3 +-- storage/innobase/row/row0row.cc | 11 ++--------- storage/innobase/row/row0upd.cc | 9 +++------ storage/innobase/row/row0vers.cc | 6 ++---- storage/innobase/trx/trx0rec.cc | 7 ++----- 10 files changed, 24 insertions(+), 57 deletions(-) diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index 72f061f2a5f..b764f103a46 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -3969,7 +3969,6 @@ btr_cur_optimistic_update( dtuple_t* new_entry; roll_ptr_t roll_ptr; ulint i; - ulint n_ext; block = btr_cur_get_block(cursor); page = buf_block_get_frame(block); @@ -4042,10 +4041,8 @@ any_extern: + DTUPLE_EST_ALLOC(rec_offs_n_fields(*offsets))); } - new_entry = row_rec_to_index_entry(rec, index, *offsets, - &n_ext, *heap); - /* We checked above that there are no externally stored fields. */ - ut_a(!n_ext); + new_entry = row_rec_to_index_entry(rec, index, *offsets, *heap); + ut_ad(!dtuple_get_n_ext(new_entry)); /* The page containing the clustered index record corresponding to new_entry is latched in mtr. @@ -4293,7 +4290,6 @@ btr_cur_pessimistic_update( roll_ptr_t roll_ptr; ibool was_first; ulint n_reserved = 0; - ulint n_ext; ulint max_ins_size = 0; *offsets = NULL; @@ -4358,7 +4354,7 @@ btr_cur_pessimistic_update( ut_ad(rec_offs_validate(rec, index, *offsets)); dtuple_t* new_entry = row_rec_to_index_entry( - rec, index, *offsets, &n_ext, entry_heap); + rec, index, *offsets, entry_heap); /* The page containing the clustered index record corresponding to new_entry is latched in mtr. If the @@ -4375,9 +4371,6 @@ btr_cur_pessimistic_update( ut_ad(!page_is_comp(page) || !rec_get_node_ptr_flag(rec)); ut_ad(rec_offs_validate(rec, index, *offsets)); - /* Get number of externally stored columns in updated record */ - n_ext = dtuple_get_n_ext(new_entry); - if ((flags & BTR_NO_UNDO_LOG_FLAG) && rec_offs_any_extern(*offsets)) { /* We are in a transaction rollback undoing a row @@ -4397,6 +4390,8 @@ btr_cur_pessimistic_update( index, rec, page_zip, *offsets, update, true, mtr); } + ulint n_ext = dtuple_get_n_ext(new_entry); + if (page_zip_rec_needs_ext( rec_get_converted_size(index, new_entry, n_ext), page_is_comp(page), diff --git a/storage/innobase/include/row0row.h b/storage/innobase/include/row0row.h index a4d3f2cf03d..b7030e91098 100644 --- a/storage/innobase/include/row0row.h +++ b/storage/innobase/include/row0row.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2017, MariaDB Corporation. +Copyright (c) 2016, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -207,8 +207,6 @@ row_rec_to_index_entry_low( const rec_t* rec, /*!< in: record in the index */ const dict_index_t* index, /*!< in: index */ const offset_t* offsets,/*!< in: rec_get_offsets(rec, index) */ - ulint* n_ext, /*!< out: number of externally - stored columns */ mem_heap_t* heap) /*!< in: memory heap from which the memory needed is allocated */ MY_ATTRIBUTE((warn_unused_result)); @@ -222,8 +220,6 @@ row_rec_to_index_entry( const rec_t* rec, /*!< in: record in the index */ const dict_index_t* index, /*!< in: index */ const offset_t* offsets,/*!< in/out: rec_get_offsets(rec) */ - ulint* n_ext, /*!< out: number of externally - stored columns */ mem_heap_t* heap) /*!< in: memory heap from which the memory needed is allocated */ MY_ATTRIBUTE((warn_unused_result)); diff --git a/storage/innobase/row/row0ftsort.cc b/storage/innobase/row/row0ftsort.cc index 68ac044416f..e3b608769e1 100644 --- a/storage/innobase/row/row0ftsort.cc +++ b/storage/innobase/row/row0ftsort.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2010, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2015, 2019, MariaDB Corporation. +Copyright (c) 2015, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -1720,7 +1720,6 @@ row_fts_merge_insert( corresponding FTS index auxiliary tables */ for (;;) { dtuple_t* dtuple; - ulint n_ext; int min_rec = 0; if (fts_sort_pll_degree <= 2) { @@ -1763,7 +1762,7 @@ row_fts_merge_insert( } dtuple = row_rec_to_index_entry_low( - mrec[min_rec], index, offsets[min_rec], &n_ext, + mrec[min_rec], index, offsets[min_rec], tuple_heap); row_fts_insert_tuple( diff --git a/storage/innobase/row/row0log.cc b/storage/innobase/row/row0log.cc index 6c28919555b..87eb9a7a8ff 100644 --- a/storage/innobase/row/row0log.cc +++ b/storage/innobase/row/row0log.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2011, 2018, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2019, MariaDB Corporation. +Copyright (c) 2017, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -3314,7 +3314,6 @@ row_log_apply_op( enum row_op op; ulint extra_size; ulint data_size; - ulint n_ext; dtuple_t* entry; trx_id_t trx_id; @@ -3392,10 +3391,10 @@ corrupted: } entry = row_rec_to_index_entry_low( - mrec - data_size, index, offsets, &n_ext, heap); + mrec - data_size, index, offsets, heap); /* Online index creation is only implemented for secondary indexes, which never contain off-page columns. */ - ut_ad(n_ext == 0); + ut_ad(dtuple_get_n_ext(entry) == 0); row_log_apply_op_low(index, dup, error, offsets_heap, has_index_lock, op, trx_id, entry); diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index c4689e9a377..d218c166a1b 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2005, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2014, 2019, MariaDB Corporation. +Copyright (c) 2014, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -3393,7 +3393,6 @@ row_merge_insert_index_tuples( double curr_progress = 0; dict_index_t* old_index = NULL; const mrec_t* mrec = NULL; - ulint n_ext = 0; mtr_t mtr; @@ -3459,8 +3458,6 @@ row_merge_insert_index_tuples( row buffer to data tuple record */ row_merge_mtuple_to_dtuple( index, dtuple, &row_buf->tuples[n_rows]); - - n_ext = dtuple_get_n_ext(dtuple); n_rows++; /* BLOB pointers must be copied from dtuple */ mrec = NULL; @@ -3479,7 +3476,7 @@ row_merge_insert_index_tuples( } dtuple = row_rec_to_index_entry_low( - mrec, index, offsets, &n_ext, tuple_heap); + mrec, index, offsets, tuple_heap); } old_index = dict_table_get_first_index(old_table); @@ -3492,10 +3489,7 @@ row_merge_insert_index_tuples( } } - if (!n_ext) { - /* There are no externally stored columns. */ - } else { - ut_ad(dict_index_is_clust(index)); + if (dict_index_is_clust(index) && dtuple_get_n_ext(dtuple)) { /* Off-page columns can be fetched safely when concurrent modifications to the table are disabled. (Purge can process delete-marked diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index f1019bd7f0d..708d2724595 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -4652,7 +4652,6 @@ row_scan_index_for_mysql( ulint i; ulint cnt; mem_heap_t* heap = NULL; - ulint n_ext; offset_t offsets_[REC_OFFS_NORMAL_SIZE]; offset_t* offsets; rec_offs_init(offsets_); @@ -4793,7 +4792,7 @@ not_ok: mem_heap_empty(heap); prev_entry = row_rec_to_index_entry( - rec, index, offsets, &n_ext, heap); + rec, index, offsets, heap); if (UNIV_LIKELY_NULL(tmp_heap)) { mem_heap_free(tmp_heap); diff --git a/storage/innobase/row/row0row.cc b/storage/innobase/row/row0row.cc index c6aedbe2eb5..816e53a8d5e 100644 --- a/storage/innobase/row/row0row.cc +++ b/storage/innobase/row/row0row.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2018, 2019, MariaDB Corporation. +Copyright (c) 2018, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -653,8 +653,6 @@ row_rec_to_index_entry_low( const rec_t* rec, /*!< in: record in the index */ const dict_index_t* index, /*!< in: index */ const offset_t* offsets,/*!< in: rec_get_offsets(rec, index) */ - ulint* n_ext, /*!< out: number of externally - stored columns */ mem_heap_t* heap) /*!< in: memory heap from which the memory needed is allocated */ { @@ -672,8 +670,6 @@ row_rec_to_index_entry_low( /* Because this function may be invoked by row0merge.cc on a record whose header is in different format, the check rec_offs_validate(rec, index, offsets) must be avoided here. */ - ut_ad(n_ext); - *n_ext = 0; rec_len = rec_offs_n_fields(offsets); @@ -698,7 +694,6 @@ row_rec_to_index_entry_low( if (rec_offs_nth_extern(offsets, i)) { dfield_set_ext(dfield); - (*n_ext)++; } } @@ -717,8 +712,6 @@ row_rec_to_index_entry( const rec_t* rec, /*!< in: record in the index */ const dict_index_t* index, /*!< in: index */ const offset_t* offsets,/*!< in: rec_get_offsets(rec) */ - ulint* n_ext, /*!< out: number of externally - stored columns */ mem_heap_t* heap) /*!< in: memory heap from which the memory needed is allocated */ { @@ -739,7 +732,7 @@ row_rec_to_index_entry( rec_offs_make_valid(copy_rec, index, const_cast(offsets)); entry = row_rec_to_index_entry_low( - copy_rec, index, offsets, n_ext, heap); + copy_rec, index, offsets, heap); rec_offs_make_valid(rec, index, const_cast(offsets)); dtuple_set_info_bits(entry, diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc index 367e6c8e263..fd7d622aa69 100644 --- a/storage/innobase/row/row0upd.cc +++ b/storage/innobase/row/row0upd.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2015, 2019, MariaDB Corporation. +Copyright (c) 2015, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -223,7 +223,6 @@ row_upd_check_references_constraints( dtuple_t* entry; trx_t* trx; const rec_t* rec; - ulint n_ext; dberr_t err; ibool got_s_lock = FALSE; @@ -240,7 +239,7 @@ row_upd_check_references_constraints( heap = mem_heap_create(500); - entry = row_rec_to_index_entry(rec, index, offsets, &n_ext, heap); + entry = row_rec_to_index_entry(rec, index, offsets, heap); mtr_commit(mtr); @@ -373,7 +372,6 @@ wsrep_row_upd_check_foreign_constraints( dtuple_t* entry; trx_t* trx; const rec_t* rec; - ulint n_ext; dberr_t err; ibool got_s_lock = FALSE; ibool opened = FALSE; @@ -391,8 +389,7 @@ wsrep_row_upd_check_foreign_constraints( heap = mem_heap_create(500); - entry = row_rec_to_index_entry(rec, index, offsets, - &n_ext, heap); + entry = row_rec_to_index_entry(rec, index, offsets, heap); mtr_commit(mtr); diff --git a/storage/innobase/row/row0vers.cc b/storage/innobase/row/row0vers.cc index c977a58c340..3a4b560670f 100644 --- a/storage/innobase/row/row0vers.cc +++ b/storage/innobase/row/row0vers.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2019, MariaDB Corporation. +Copyright (c) 2017, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -136,15 +136,13 @@ row_vers_impl_x_locked_low( const ulint rec_del = rec_get_deleted_flag(rec, comp); if (dict_index_has_virtual(index)) { - ulint n_ext; ulint est_size = DTUPLE_EST_ALLOC(index->n_fields); /* Allocate the dtuple for virtual columns extracted from undo log with its own heap, so to avoid it being freed as we iterating in the version loop below. */ v_heap = mem_heap_create(est_size); - ientry = row_rec_to_index_entry( - rec, index, offsets, &n_ext, v_heap); + ientry = row_rec_to_index_entry(rec, index, offsets, v_heap); } /* We look up if some earlier version, which was modified by diff --git a/storage/innobase/trx/trx0rec.cc b/storage/innobase/trx/trx0rec.cc index 0987d294ca8..3e41cb5ad1f 100644 --- a/storage/innobase/trx/trx0rec.cc +++ b/storage/innobase/trx/trx0rec.cc @@ -2404,8 +2404,6 @@ trx_undo_prev_version_build( ut_a(ptr); if (row_upd_changes_field_size_or_external(index, offsets, update)) { - ulint n_ext; - /* We should confirm the existence of disowned external data, if the previous version record is delete marked. If the trx_id of the previous record is seen by purge view, we should treat @@ -2446,15 +2444,14 @@ trx_undo_prev_version_build( those fields that update updates to become externally stored fields. Store the info: */ - entry = row_rec_to_index_entry( - rec, index, offsets, &n_ext, heap); + entry = row_rec_to_index_entry(rec, index, offsets, heap); /* The page containing the clustered index record corresponding to entry is latched in mtr. Thus the following call is safe. */ row_upd_index_replace_new_col_vals(entry, index, update, heap); /* Get number of externally stored columns in updated record */ - n_ext = dtuple_get_n_ext(entry); + const ulint n_ext = dtuple_get_n_ext(entry); buf = static_cast(mem_heap_alloc( heap, rec_get_converted_size(index, entry, n_ext))); -- cgit v1.2.1