diff options
author | Olivier Bertrand <bertrandop@gmail.com> | 2020-03-12 19:16:36 +0100 |
---|---|---|
committer | Olivier Bertrand <bertrandop@gmail.com> | 2020-03-12 19:16:36 +0100 |
commit | d26b4eb4c071f39d2ff262026608d26e7a56309d (patch) | |
tree | f8ed01ab17f186aa3e0175c143d5345def73dc2c /storage/innobase/include | |
parent | 4ba36cfa0c677b7d094092d6aa5541c6c936a11f (diff) | |
parent | 51e9381dcc01ebd72d4f0adc057a64213f850d70 (diff) | |
download | mariadb-git-d26b4eb4c071f39d2ff262026608d26e7a56309d.tar.gz |
Pull new version from origin
Diffstat (limited to 'storage/innobase/include')
50 files changed, 559 insertions, 725 deletions
diff --git a/storage/innobase/include/btr0btr.h b/storage/innobase/include/btr0btr.h index d68b02eda4d..698343bf371 100644 --- a/storage/innobase/include/btr0btr.h +++ b/storage/innobase/include/btr0btr.h @@ -30,6 +30,7 @@ Created 6/2/1994 Heikki Tuuri #include "dict0dict.h" #include "data0data.h" +#include "rem0types.h" #include "page0cur.h" #include "btr0types.h" #include "gis0type.h" @@ -319,7 +320,7 @@ ulint btr_node_ptr_get_child_page_no( /*===========================*/ const rec_t* rec, /*!< in: node pointer record */ - const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ + const offset_t* offsets)/*!< in: array returned by rec_get_offsets() */ MY_ATTRIBUTE((warn_unused_result)); /** Create the root node for a new index tree. @@ -404,7 +405,7 @@ btr_root_raise_and_insert( on the root page; when the function returns, the cursor is positioned on the predecessor of the inserted record */ - ulint** offsets,/*!< out: offsets on inserted record */ + offset_t** offsets,/*!< out: offsets on inserted record */ mem_heap_t** heap, /*!< in/out: pointer to memory heap that can be emptied, or NULL */ const dtuple_t* tuple, /*!< in: tuple to insert */ @@ -487,7 +488,7 @@ btr_page_split_and_insert( btr_cur_t* cursor, /*!< in: cursor at which to insert; when the function returns, the cursor is positioned on the predecessor of the inserted record */ - ulint** offsets,/*!< out: offsets on inserted record */ + offset_t** offsets,/*!< out: offsets on inserted record */ mem_heap_t** heap, /*!< in/out: pointer to memory heap that can be emptied, or NULL */ const dtuple_t* tuple, /*!< in: tuple to insert */ diff --git a/storage/innobase/include/btr0btr.ic b/storage/innobase/include/btr0btr.ic index c3f0d5e305e..5bb7318fefb 100644 --- a/storage/innobase/include/btr0btr.ic +++ b/storage/innobase/include/btr0btr.ic @@ -192,7 +192,7 @@ ulint btr_node_ptr_get_child_page_no( /*===========================*/ const rec_t* rec, /*!< in: node pointer record */ - const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ + const offset_t* offsets)/*!< in: array returned by rec_get_offsets() */ { const byte* field; ulint len; diff --git a/storage/innobase/include/btr0bulk.h b/storage/innobase/include/btr0bulk.h index 2a434c673cb..9384cb578ed 100644 --- a/storage/innobase/include/btr0bulk.h +++ b/storage/innobase/include/btr0bulk.h @@ -28,6 +28,7 @@ Created 03/11/2014 Shaohua Wang #define btr0bulk_h #include "dict0dict.h" +#include "rem0types.h" #include "page0cur.h" #include <vector> @@ -103,7 +104,7 @@ public: /** Insert a record in the page. @param[in] rec record @param[in] offsets record offsets */ - void insert(const rec_t* rec, ulint* offsets); + void insert(const rec_t* rec, offset_t* offsets); /** Mark end of insertion to the page. Scan all records to set page dirs, and set page header members. */ @@ -127,7 +128,7 @@ public: @param[in] big_rec external recrod @param[in] offsets record offsets @return error code */ - dberr_t storeExt(const big_rec_t* big_rec, ulint* offsets); + dberr_t storeExt(const big_rec_t* big_rec, offset_t* offsets); /** Get node pointer @return node pointer */ diff --git a/storage/innobase/include/btr0cur.h b/storage/innobase/include/btr0cur.h index c748b4fbc41..13a420fd912 100644 --- a/storage/innobase/include/btr0cur.h +++ b/storage/innobase/include/btr0cur.h @@ -1,7 +1,7 @@ /***************************************************************************** -Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2019, MariaDB Corporation. +Copyright (c) 1994, 2019, Oracle and/or its affiliates. All Rights Reserved. +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 @@ -30,6 +30,7 @@ Created 10/16/1994 Heikki Tuuri #include "dict0dict.h" #include "page0cur.h" #include "btr0types.h" +#include "rem0types.h" #include "gis0type.h" #include "my_base.h" @@ -271,7 +272,7 @@ btr_cur_optimistic_insert( specified */ btr_cur_t* cursor, /*!< in: cursor on page after which to insert; cursor stays valid */ - ulint** offsets,/*!< out: offsets on *rec */ + offset_t** offsets,/*!< out: offsets on *rec */ mem_heap_t** heap, /*!< in/out: pointer to memory heap */ dtuple_t* entry, /*!< in/out: entry to insert */ rec_t** rec, /*!< out: pointer to inserted record if @@ -307,7 +308,7 @@ btr_cur_pessimistic_insert( insertion will certainly succeed */ btr_cur_t* cursor, /*!< in: cursor after which to insert; cursor stays valid */ - ulint** offsets,/*!< out: offsets on *rec */ + offset_t** offsets,/*!< out: offsets on *rec */ mem_heap_t** heap, /*!< in/out: pointer to memory heap that can be emptied */ dtuple_t* entry, /*!< in/out: entry to insert */ @@ -341,7 +342,7 @@ btr_cur_update_alloc_zip_func( page_cur_t* cursor, /*!< in/out: B-tree page cursor */ dict_index_t* index, /*!< in: the index corresponding to cursor */ #ifdef UNIV_DEBUG - ulint* offsets,/*!< in/out: offsets of the cursor record */ + offset_t* offsets,/*!< in/out: offsets of the cursor record */ #endif /* UNIV_DEBUG */ ulint length, /*!< in: size needed */ bool create, /*!< in: true=delete-and-insert, @@ -368,7 +369,7 @@ btr_cur_update_in_place( btr_cur_t* cursor, /*!< in: cursor on the record to update; cursor stays valid and positioned on the same record */ - ulint* offsets,/*!< in/out: offsets on cursor->page_cur.rec */ + offset_t* offsets,/*!< in/out: offsets on cursor->page_cur.rec */ const upd_t* update, /*!< in: update vector */ ulint cmpl_info,/*!< in: compiler info on secondary index updates */ @@ -410,7 +411,7 @@ btr_cur_optimistic_update( btr_cur_t* cursor, /*!< in: cursor on the record to update; cursor stays valid and positioned on the same record */ - ulint** offsets,/*!< out: offsets on cursor->page_cur.rec */ + offset_t** offsets,/*!< out: offsets on cursor->page_cur.rec */ mem_heap_t** heap, /*!< in/out: pointer to NULL or memory heap */ const upd_t* update, /*!< in: update vector; this must also contain trx id and roll ptr fields */ @@ -437,7 +438,7 @@ btr_cur_pessimistic_update( btr_cur_t* cursor, /*!< in/out: cursor on the record to update; cursor may become invalid if *big_rec == NULL || !(flags & BTR_KEEP_POS_FLAG) */ - ulint** offsets,/*!< out: offsets on cursor->page_cur.rec */ + offset_t** offsets,/*!< out: offsets on cursor->page_cur.rec */ mem_heap_t** offsets_heap, /*!< in/out: pointer to memory heap that can be emptied */ @@ -469,7 +470,7 @@ btr_cur_del_mark_set_clust_rec( buf_block_t* block, /*!< in/out: buffer block of the record */ rec_t* rec, /*!< in/out: record */ dict_index_t* index, /*!< in: clustered index of the record */ - const ulint* offsets,/*!< in: rec_get_offsets(rec) */ + const offset_t* offsets,/*!< in: rec_get_offsets(rec) */ que_thr_t* thr, /*!< in: query thread */ const dtuple_t* entry, /*!< in: dtuple for the deleting record */ mtr_t* mtr) /*!< in/out: mini-transaction */ @@ -636,7 +637,7 @@ btr_estimate_number_of_different_key_vals( ulint btr_rec_get_externally_stored_len( const rec_t* rec, - const ulint* offsets); + const offset_t* offsets); /*******************************************************************//** Marks non-updated off-page fields as disowned by this record. The ownership @@ -650,7 +651,7 @@ btr_cur_disown_inherited_fields( part will be updated, or NULL */ rec_t* rec, /*!< in/out: record in a clustered index */ dict_index_t* index, /*!< in: index of the page */ - const ulint* offsets,/*!< in: array returned by rec_get_offsets() */ + const offset_t* offsets,/*!< in: array returned by rec_get_offsets() */ const upd_t* update, /*!< in: update vector */ mtr_t* mtr) /*!< in/out: mini-transaction */ MY_ATTRIBUTE((nonnull(2,3,4,5,6))); @@ -689,7 +690,7 @@ btr_store_big_rec_extern_fields( btr_pcur_t* pcur, /*!< in/out: a persistent cursor. if btr_mtr is restarted, then this can be repositioned. */ - ulint* offsets, /*!< in/out: rec_get_offsets() on + offset_t* offsets, /*!< in/out: rec_get_offsets() on pcur. the "external storage" flags in offsets will correctly correspond to rec when this function returns */ @@ -720,7 +721,7 @@ btr_free_externally_stored_field( byte* field_ref, /*!< in/out: field reference */ const rec_t* rec, /*!< in: record containing field_ref, for page_zip_write_blob_ptr(), or NULL */ - const ulint* offsets, /*!< in: rec_get_offsets(rec, index), + const offset_t* offsets, /*!< in: rec_get_offsets(rec, index), or NULL */ page_zip_des_t* page_zip, /*!< in: compressed page corresponding to rec, or NULL if rec == NULL */ @@ -777,24 +778,12 @@ protected by a lock or a page latch byte* btr_rec_copy_externally_stored_field( const rec_t* rec, - const ulint* offsets, + const offset_t* offsets, const page_size_t& page_size, ulint no, ulint* len, mem_heap_t* heap); -/*******************************************************************//** -Flags the data tuple fields that are marked as extern storage in the -update vector. We use this function to remember which fields we must -mark as extern storage in a record inserted for an update. -@return number of flagged external columns */ -ulint -btr_push_update_extern_fields( -/*==========================*/ - dtuple_t* tuple, /*!< in/out: data tuple */ - const upd_t* update, /*!< in: update vector */ - mem_heap_t* heap) /*!< in: memory heap */ - MY_ATTRIBUTE((nonnull)); /***********************************************************//** Sets a secondary index record's delete mark to the given value. This function is only used by the insert buffer merge mechanism. */ diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index f04d3fe038f..c9529ee4b73 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -706,6 +706,27 @@ buf_page_is_corrupted( #endif MY_ATTRIBUTE((warn_unused_result)); +inline void *aligned_malloc(size_t size, size_t align) +{ +#ifdef _MSC_VER + return _aligned_malloc(size, align); +#else + void *result; + if (posix_memalign(&result, align, size)) + result= NULL; + return result; +#endif +} + +inline void aligned_free(void *ptr) +{ +#ifdef _MSC_VER + _aligned_free(ptr); +#else + free(ptr); +#endif +} + #ifndef UNIV_INNOCHECKSUM /**********************************************************************//** Gets the space id, page offset, and byte offset within page of a diff --git a/storage/innobase/include/buf0buf.ic b/storage/innobase/include/buf0buf.ic index df364401172..79ec1e5d80b 100644 --- a/storage/innobase/include/buf0buf.ic +++ b/storage/innobase/include/buf0buf.ic @@ -113,7 +113,17 @@ ulint buf_pool_get_n_pages(void) /*======================*/ { - return buf_pool_get_curr_size() >> srv_page_size_shift; + if (!buf_pool_ptr) + return buf_pool_get_curr_size() >> srv_page_size_shift; + + ulint chunk_size= 0; + for (uint i= 0; i < srv_buf_pool_instances; i++) + { + buf_pool_t* buf_pool = buf_pool_from_array(i); + for (uint j= 0; j < buf_pool->n_chunks; j++) + chunk_size+= buf_pool->chunks[j].size; + } + return chunk_size; } /********************************************************************//** diff --git a/storage/innobase/include/dict0crea.h b/storage/innobase/include/dict0crea.h index 2a302dabae8..8ab987cd39a 100644 --- a/storage/innobase/include/dict0crea.h +++ b/storage/innobase/include/dict0crea.h @@ -224,16 +224,6 @@ dict_replace_tablespace_in_dictionary( const char* path, trx_t* trx); -/** Delete records from SYS_TABLESPACES and SYS_DATAFILES associated -with a particular tablespace ID. -@param[in] space Tablespace ID -@param[in,out] trx Current transaction -@return DB_SUCCESS if OK, dberr_t if the operation failed */ -dberr_t -dict_delete_tablespace_and_datafiles( - ulint space, - trx_t* trx); - /********************************************************************//** Add a foreign key definition to the data dictionary tables. @return error code or DB_SUCCESS */ diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h index df114b305c3..1a22470569e 100644 --- a/storage/innobase/include/dict0mem.h +++ b/storage/innobase/include/dict0mem.h @@ -832,10 +832,6 @@ a certain index.*/ system clustered index when there is no primary key. */ const char innobase_index_reserve_name[] = "GEN_CLUST_INDEX"; -/* Estimated number of offsets in records (based on columns) -to start with. */ -#define OFFS_IN_REC_NORMAL_SIZE 100 - /** Data structure for an index. Most fields will be initialized to 0, NULL or FALSE in dict_mem_index_create(). */ struct dict_index_t{ @@ -1112,7 +1108,7 @@ struct dict_index_t{ @param[in] offsets offsets @return true if row is historical */ bool - vers_history_row(const rec_t* rec, const ulint* offsets); + vers_history_row(const rec_t* rec, const offset_t* offsets); /** Check if record in secondary index is historical row. @param[in] rec record in a secondary index @@ -1607,10 +1603,14 @@ struct dict_table_t { /** Add the table definition to the data dictionary cache */ void add_to_cache(); + /** @return whether the table is versioned. + It is assumed that both vers_start and vers_end set to 0 + iff table is not versioned. In any other case, + these fields correspond to actual positions in cols[]. */ bool versioned() const { return vers_start || vers_end; } bool versioned_by_id() const { - return vers_start && cols[vers_start].mtype == DATA_INT; + return versioned() && cols[vers_start].mtype == DATA_INT; } void inc_fk_checks() diff --git a/storage/innobase/include/dyn0buf.h b/storage/innobase/include/dyn0buf.h index db809c908ae..f66c7e3d405 100644 --- a/storage/innobase/include/dyn0buf.h +++ b/storage/innobase/include/dyn0buf.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2013, 2016, 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 @@ -29,7 +29,8 @@ Created 2013-03-16 Sunny Bains #include "mem0mem.h" #include "dyn0types.h" -#include "ut0lst.h" +#include "intrusive_list.h" + /** Class that manages dynamic buffers. It uses a UT_LIST of mtr_buf_t::block_t instances. We don't use STL containers in @@ -40,17 +41,11 @@ backend for the custom allocator because we would like the data in the blocks to be contiguous. */ class mtr_buf_t { public: - - class block_t; - - typedef UT_LIST_NODE_T(block_t) block_node_t; - typedef UT_LIST_BASE_NODE_T(block_t) block_list_t; - /** SIZE - sizeof(m_node) + sizeof(m_used) */ enum { MAX_DATA_SIZE = DYN_ARRAY_DATA_SIZE - - sizeof(block_node_t) + sizeof(ib_uint32_t) }; + - sizeof(intrusive::list_node<>) + sizeof(uint32_t) }; - class block_t { + class block_t : public intrusive::list_node<> { public: block_t() @@ -158,9 +153,6 @@ public: /** Storage */ byte m_data[MAX_DATA_SIZE]; - /** Doubly linked list node. */ - block_node_t m_node; - /** number of data bytes used in this block; DYN_BLOCK_FULL_FLAG is set when the block becomes full */ uint32_t m_used; @@ -168,13 +160,14 @@ public: friend class mtr_buf_t; }; + typedef intrusive::list<block_t> list_t; + /** Default constructor */ mtr_buf_t() : m_heap(), m_size() { - UT_LIST_INIT(m_list, &block_t::m_node); push_back(&m_first_block); } @@ -192,11 +185,11 @@ public: m_heap = NULL; /* Initialise the list and add the first block. */ - UT_LIST_INIT(m_list, &block_t::m_node); - push_back(&m_first_block); + m_list.clear(); + m_list.push_back(m_first_block); } else { m_first_block.init(); - ut_ad(UT_LIST_GET_LEN(m_list) == 1); + ut_ad(m_list.size() == 1); } m_size = 0; @@ -228,7 +221,7 @@ public: @param ptr end of used space */ void close(const byte* ptr) { - ut_ad(UT_LIST_GET_LEN(m_list) > 0); + ut_ad(!m_list.empty()); block_t* block = back(); m_size -= block->used(); @@ -310,11 +303,9 @@ public: #ifdef UNIV_DEBUG ulint total_size = 0; - for (const block_t* block = UT_LIST_GET_FIRST(m_list); - block != NULL; - block = UT_LIST_GET_NEXT(m_node, block)) { - - total_size += block->used(); + for (list_t::iterator it = m_list.begin(), end = m_list.end(); + it != end; ++it) { + total_size += it->used(); } ut_ad(total_size == m_size); @@ -328,12 +319,11 @@ public: template <typename Functor> bool for_each_block(Functor& functor) const { - for (const block_t* block = UT_LIST_GET_FIRST(m_list); - block != NULL; - block = UT_LIST_GET_NEXT(m_node, block)) { + for (list_t::iterator it = m_list.begin(), end = m_list.end(); + it != end; ++it) { - if (!functor(block)) { - return(false); + if (!functor(&*it)) { + return false; } } @@ -346,12 +336,12 @@ public: template <typename Functor> bool for_each_block_in_reverse(Functor& functor) const { - for (block_t* block = UT_LIST_GET_LAST(m_list); - block != NULL; - block = UT_LIST_GET_PREV(m_node, block)) { + for (list_t::reverse_iterator it = m_list.rbegin(), + end = m_list.rend(); + it != end; ++it) { - if (!functor(block)) { - return(false); + if (!functor(&*it)) { + return false; } } @@ -364,12 +354,12 @@ public: template <typename Functor> bool for_each_block_in_reverse(const Functor& functor) const { - for (block_t* block = UT_LIST_GET_LAST(m_list); - block != NULL; - block = UT_LIST_GET_PREV(m_node, block)) { + for (list_t::reverse_iterator it = m_list.rbegin(), + end = m_list.rend(); + it != end; ++it) { - if (!functor(block)) { - return(false); + if (!functor(&*it)) { + return false; } } @@ -381,8 +371,7 @@ public: block_t* front() MY_ATTRIBUTE((warn_unused_result)) { - ut_ad(UT_LIST_GET_LEN(m_list) > 0); - return(UT_LIST_GET_FIRST(m_list)); + return &m_list.front(); } /** @@ -403,14 +392,13 @@ private: void push_back(block_t* block) { block->init(); - - UT_LIST_ADD_LAST(m_list, block); + m_list.push_back(*block); } /** @return the last block in the list */ block_t* back() const { - return(UT_LIST_GET_LAST(m_list)); + return &const_cast<block_t&>(m_list.back()); } /* @@ -433,25 +421,21 @@ private: @return the block containing the pos. */ block_t* find(ulint& pos) { - block_t* block; + ut_ad(!m_list.empty()); - ut_ad(UT_LIST_GET_LEN(m_list) > 0); + for (list_t::iterator it = m_list.begin(), end = m_list.end(); + it != end; ++it) { - for (block = UT_LIST_GET_FIRST(m_list); - block != NULL; - block = UT_LIST_GET_NEXT(m_node, block)) { + if (pos < it->used()) { + ut_ad(it->used() >= pos); - if (pos < block->used()) { - break; + return &*it; } - pos -= block->used(); + pos -= it->used(); } - ut_ad(block != NULL); - ut_ad(block->used() >= pos); - - return(block); + return NULL; } /** @@ -477,7 +461,7 @@ private: mem_heap_t* m_heap; /** Allocated blocks */ - block_list_t m_list; + list_t m_list; /** Total size used by all blocks */ ulint m_size; diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index 0818d3f0ed1..d9840ea80f5 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2019, MariaDB Corporation. +Copyright (c) 2013, 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 @@ -32,6 +32,10 @@ Created 10/25/1995 Heikki Tuuri #include "log0recv.h" #include "dict0types.h" #include "page0size.h" +#include "intrusive_list.h" + +struct unflushed_spaces_tag_t; +struct rotation_list_tag_t; // Forward declaration extern my_bool srv_use_doublewrite_buf; @@ -73,7 +77,9 @@ fil_type_is_data( struct fil_node_t; /** Tablespace or log data space */ -struct fil_space_t { +struct fil_space_t : intrusive::list_node<unflushed_spaces_tag_t>, + intrusive::list_node<rotation_list_tag_t> +{ ulint id; /*!< space id */ hash_node_t hash; /*!< hash chain node */ char* name; /*!< Tablespace name */ @@ -151,9 +157,6 @@ struct fil_space_t { ulint n_pending_ios; rw_lock_t latch; /*!< latch protecting the file space storage allocation */ - UT_LIST_NODE_T(fil_space_t) unflushed_spaces; - /*!< list of spaces with at least one unflushed - file we have written to */ UT_LIST_NODE_T(fil_space_t) named_spaces; /*!< list of spaces for which MLOG_FILE_NAME records have been issued */ @@ -162,8 +165,6 @@ struct fil_space_t { bool is_in_unflushed_spaces() const; UT_LIST_NODE_T(fil_space_t) space_list; /*!< list of all spaces */ - /** other tablespaces needing key rotation */ - UT_LIST_NODE_T(fil_space_t) rotation_list; /** Checks that this tablespace needs key rotation. @return true if in a rotation list */ bool is_in_rotation_list() const; @@ -350,7 +351,7 @@ struct fil_node_t { /** Value of fil_node_t::magic_n */ #define FIL_NODE_MAGIC_N 89389 -/** Common InnoDB file extentions */ +/** Common InnoDB file extensions */ enum ib_extention { NO_EXT = 0, IBD = 1, @@ -579,8 +580,6 @@ struct fil_system_t { { UT_LIST_INIT(LRU, &fil_node_t::LRU); UT_LIST_INIT(space_list, &fil_space_t::space_list); - UT_LIST_INIT(rotation_list, &fil_space_t::rotation_list); - UT_LIST_INIT(unflushed_spaces, &fil_space_t::unflushed_spaces); UT_LIST_INIT(named_spaces, &fil_space_t::named_spaces); } @@ -616,8 +615,8 @@ public: not put to this list: they are opened after the startup, and kept open until shutdown */ - UT_LIST_BASE_NODE_T(fil_space_t) unflushed_spaces; - /*!< base node for the list of those + intrusive::list<fil_space_t, unflushed_spaces_tag_t> unflushed_spaces; + /*!< list of those tablespaces whose files contain unflushed writes; those spaces have at least one file node where @@ -637,7 +636,7 @@ public: record has been written since the latest redo log checkpoint. Protected only by log_sys.mutex. */ - UT_LIST_BASE_NODE_T(fil_space_t) rotation_list; + intrusive::list<fil_space_t, rotation_list_tag_t> rotation_list; /*!< list of all file spaces needing key rotation.*/ diff --git a/storage/innobase/include/fil0fil.ic b/storage/innobase/include/fil0fil.ic index 457b5e1a03e..31466f38546 100644 --- a/storage/innobase/include/fil0fil.ic +++ b/storage/innobase/include/fil0fil.ic @@ -69,7 +69,7 @@ fil_get_page_type_name( case FIL_PAGE_TYPE_ZBLOB2: return "ZBLOB2"; case FIL_PAGE_TYPE_UNKNOWN: - return "OLD UNKOWN PAGE TYPE"; + return "OLD UNKNOWN PAGE TYPE"; default: return "PAGE TYPE CORRUPTED"; } diff --git a/storage/innobase/include/gis0geo.h b/storage/innobase/include/gis0geo.h index 3b71815d0fe..dea6d63f4e0 100644 --- a/storage/innobase/include/gis0geo.h +++ b/storage/innobase/include/gis0geo.h @@ -54,19 +54,6 @@ enum wkbByteOrder wkbNDR = 1 /* Little Endian */ }; -/** Get the wkb of default POINT value, which represents POINT(0 0) -if it's of dimension 2, etc. -@param[in] n_dims dimensions -@param[out] wkb wkb buffer for default POINT -@param[in] len length of wkb buffer -@return non-0 indicate the length of wkb of the default POINT, -0 if the buffer is too small */ -uint -get_wkb_of_default_point( - uint n_dims, - uchar* wkb, - uint len); - /*************************************************************//** Calculate minimal bounding rectangle (mbr) of the spatial object stored in "well-known binary representation" (wkb) format. diff --git a/storage/innobase/include/gis0rtree.h b/storage/innobase/include/gis0rtree.h index 126ca680c1d..b863f1cf3ef 100644 --- a/storage/innobase/include/gis0rtree.h +++ b/storage/innobase/include/gis0rtree.h @@ -28,6 +28,7 @@ Created 2013/03/27 Jimmy Yang and Allen Lai #define gis0rtree_h #include "btr0cur.h" +#include "rem0types.h" /* Whether MBR 'a' contains 'b' */ #define MBR_CONTAIN_CMP(a, b) \ @@ -88,7 +89,7 @@ rtr_page_split_and_insert( btr_cur_t* cursor, /*!< in/out: cursor at which to insert; when the function returns, the cursor is positioned on the predecessor of the inserted record */ - ulint** offsets,/*!< out: offsets on inserted record */ + offset_t** offsets,/*!< out: offsets on inserted record */ mem_heap_t** heap, /*!< in/out: pointer to memory heap, or NULL */ const dtuple_t* tuple, /*!< in: tuple to insert */ ulint n_ext, /*!< in: number of externally stored columns */ @@ -150,7 +151,7 @@ rtr_rec_cal_increase( dtuple in some of the common fields, or which has an equal number or more fields than dtuple */ - const ulint* offsets,/*!< in: array returned by rec_get_offsets() */ + const offset_t* offsets,/*!< in: array returned by rec_get_offsets() */ double* area); /*!< out: increased area */ /****************************************************************//** @@ -273,7 +274,7 @@ void rtr_get_mbr_from_rec( /*=================*/ const rec_t* rec, /*!< in: data tuple */ - const ulint* offsets,/*!< in: offsets array */ + const offset_t* offsets,/*!< in: offsets array */ rtr_mbr_t* mbr); /*!< out MBR */ /****************************************************************//** @@ -305,10 +306,10 @@ rtr_page_get_father( Returns the father block to a page. It is assumed that mtr holds an X or SX latch on the tree. @return rec_get_offsets() of the node pointer record */ -ulint* +offset_t* rtr_page_get_father_block( /*======================*/ - ulint* offsets,/*!< in: work area for the return value */ + offset_t* offsets,/*!< in: work area for the return value */ mem_heap_t* heap, /*!< in: memory heap to use */ dict_index_t* index, /*!< in: b-tree index */ buf_block_t* block, /*!< in: child page in the index */ @@ -415,8 +416,8 @@ rtr_merge_and_update_mbr( /*=====================*/ btr_cur_t* cursor, /*!< in/out: cursor */ btr_cur_t* cursor2, /*!< in: the other cursor */ - ulint* offsets, /*!< in: rec offsets */ - ulint* offsets2, /*!< in: rec offsets */ + offset_t* offsets, /*!< in: rec offsets */ + offset_t* offsets2, /*!< in: rec offsets */ page_t* child_page, /*!< in: the child page. */ mtr_t* mtr); /*!< in: mtr */ @@ -436,8 +437,8 @@ rtr_merge_mbr_changed( /*==================*/ btr_cur_t* cursor, /*!< in: cursor */ btr_cur_t* cursor2, /*!< in: the other cursor */ - ulint* offsets, /*!< in: rec offsets */ - ulint* offsets2, /*!< in: rec offsets */ + offset_t* offsets, /*!< in: rec offsets */ + offset_t* offsets2, /*!< in: rec offsets */ rtr_mbr_t* new_mbr); /*!< out: MBR to update */ @@ -448,7 +449,7 @@ bool rtr_update_mbr_field( /*=================*/ btr_cur_t* cursor, /*!< in: cursor pointed to rec.*/ - ulint* offsets, /*!< in: offsets on rec. */ + offset_t* offsets, /*!< in: offsets on rec. */ btr_cur_t* cursor2, /*!< in/out: cursor pointed to rec that should be deleted. this cursor is for btr_compress to diff --git a/storage/innobase/include/gis0rtree.ic b/storage/innobase/include/gis0rtree.ic index d9309550a5f..03e23830e70 100644 --- a/storage/innobase/include/gis0rtree.ic +++ b/storage/innobase/include/gis0rtree.ic @@ -40,7 +40,7 @@ rtr_page_cal_mbr( rec_t* rec; const byte* field; ulint len; - ulint* offsets = NULL; + offset_t* offsets = NULL; double bmin, bmax; double* amin; double* amax; diff --git a/storage/innobase/include/handler0alter.h b/storage/innobase/include/handler0alter.h index 45811c591c9..9b70c607459 100644 --- a/storage/innobase/include/handler0alter.h +++ b/storage/innobase/include/handler0alter.h @@ -22,6 +22,8 @@ this program; if not, write to the Free Software Foundation, Inc., Smart ALTER TABLE *******************************************************/ +#include "rem0types.h" + /*************************************************************//** Copies an InnoDB record to table->record[0]. */ void @@ -30,7 +32,7 @@ innobase_rec_to_mysql( struct TABLE* table, /*!< in/out: MySQL table */ const rec_t* rec, /*!< in: record */ const dict_index_t* index, /*!< in: index */ - const ulint* offsets)/*!< in: rec_get_offsets( + const offset_t* offsets)/*!< in: rec_get_offsets( rec, index, ...) */ MY_ATTRIBUTE((nonnull)); diff --git a/storage/innobase/include/hash0hash.h b/storage/innobase/include/hash0hash.h index 5d317a23d4e..4f55b051d80 100644 --- a/storage/innobase/include/hash0hash.h +++ b/storage/innobase/include/hash0hash.h @@ -184,6 +184,18 @@ do {\ HASH_INVALIDATE(DATA, NAME);\ } while (0) +#define HASH_REPLACE(TYPE, NAME, TABLE, FOLD, DATA_OLD, DATA_NEW) \ + do { \ + (DATA_NEW)->NAME = (DATA_OLD)->NAME; \ + \ + hash_cell_t& cell3333 \ + = TABLE->array[hash_calc_hash(FOLD, TABLE)]; \ + TYPE** struct3333 = (TYPE**)&cell3333.node; \ + while (*struct3333 != DATA_OLD) { \ + struct3333 = &((*struct3333)->NAME); \ + } \ + *struct3333 = DATA_NEW; \ + } while (0) /*******************************************************************//** Gets the first struct in a hash chain, NULL if none. */ diff --git a/storage/innobase/include/lock0lock.h b/storage/innobase/include/lock0lock.h index 8ae0b062729..11000620e8c 100644 --- a/storage/innobase/include/lock0lock.h +++ b/storage/innobase/include/lock0lock.h @@ -300,7 +300,7 @@ lock_clust_rec_modify_check_and_lock( const rec_t* rec, /*!< in: record which should be modified */ dict_index_t* index, /*!< in: clustered index */ - const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */ + const offset_t* offsets,/*!< in: rec_get_offsets(rec, index) */ que_thr_t* thr) /*!< in: query thread */ MY_ATTRIBUTE((warn_unused_result)); /*********************************************************************//** @@ -338,7 +338,7 @@ lock_sec_rec_read_check_and_lock( be read or passed over by a read cursor */ dict_index_t* index, /*!< in: secondary index */ - const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */ + const offset_t* offsets,/*!< in: rec_get_offsets(rec, index) */ lock_mode mode, /*!< in: mode of the lock which the read cursor should set on records: LOCK_S or LOCK_X; the @@ -366,7 +366,7 @@ lock_clust_rec_read_check_and_lock( be read or passed over by a read cursor */ dict_index_t* index, /*!< in: clustered index */ - const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */ + const offset_t* offsets,/*!< in: rec_get_offsets(rec, index) */ lock_mode mode, /*!< in: mode of the lock which the read cursor should set on records: LOCK_S or LOCK_X; the @@ -415,7 +415,7 @@ lock_clust_rec_cons_read_sees( const rec_t* rec, /*!< in: user record which should be read or passed over by a read cursor */ dict_index_t* index, /*!< in: clustered index */ - const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */ + const offset_t* offsets,/*!< in: rec_get_offsets(rec, index) */ ReadView* view); /*!< in: consistent read view */ /*********************************************************************//** Checks that a non-clustered index record is seen in a consistent read. @@ -547,7 +547,7 @@ lock_report_trx_id_insanity( trx_id_t trx_id, /*!< in: trx id */ const rec_t* rec, /*!< in: user record */ dict_index_t* index, /*!< in: index */ - const ulint* offsets, /*!< in: rec_get_offsets(rec, index) */ + const offset_t* offsets, /*!< in: rec_get_offsets(rec, index) */ trx_id_t max_trx_id); /*!< in: trx_sys.get_max_trx_id() */ /*********************************************************************//** Prints info of locks for all transactions. @@ -772,7 +772,7 @@ lock_check_trx_id_sanity( trx_id_t trx_id, /*!< in: trx id */ const rec_t* rec, /*!< in: user record */ dict_index_t* index, /*!< in: index */ - const ulint* offsets); /*!< in: rec_get_offsets(rec, index) */ + const offset_t* offsets); /*!< in: rec_get_offsets(rec, index) */ #ifdef UNIV_DEBUG /*******************************************************************//** Check if the transaction holds any locks on the sys tables diff --git a/storage/innobase/include/lock0priv.h b/storage/innobase/include/lock0priv.h index 9b80f593e30..5e00e1bb6f1 100644 --- a/storage/innobase/include/lock0priv.h +++ b/storage/innobase/include/lock0priv.h @@ -35,6 +35,7 @@ those functions in lock/ */ #endif #include "hash0hash.h" +#include "rem0types.h" #include "trx0trx.h" #ifndef UINT32_MAX @@ -468,7 +469,7 @@ lock_clust_rec_some_has_impl( /*=========================*/ const rec_t* rec, /*!< in: user record */ const dict_index_t* index, /*!< in: clustered index */ - const ulint* offsets)/*!< in: rec_get_offsets(rec, index) */ + const offset_t* offsets)/*!< in: rec_get_offsets(rec, index) */ MY_ATTRIBUTE((warn_unused_result)); /*********************************************************************//** diff --git a/storage/innobase/include/lock0priv.ic b/storage/innobase/include/lock0priv.ic index 80a63271256..7062e3f7082 100644 --- a/storage/innobase/include/lock0priv.ic +++ b/storage/innobase/include/lock0priv.ic @@ -59,7 +59,7 @@ lock_clust_rec_some_has_impl( /*=========================*/ const rec_t* rec, /*!< in: user record */ const dict_index_t* index, /*!< in: clustered index */ - const ulint* offsets)/*!< in: rec_get_offsets(rec, index) */ + const offset_t* offsets)/*!< in: rec_get_offsets(rec, index) */ { ut_ad(dict_index_is_clust(index)); ut_ad(page_rec_is_user_rec(rec)); diff --git a/storage/innobase/include/log0recv.h b/storage/innobase/include/log0recv.h index a4f8aab4e02..280f7840d50 100644 --- a/storage/innobase/include/log0recv.h +++ b/storage/innobase/include/log0recv.h @@ -119,14 +119,19 @@ bool recv_sys_add_to_parsing_buf(const byte* log_block, lsn_t scanned_lsn); /** Parse log records from a buffer and optionally store them to a hash table to wait merging to file pages. -@param[in] checkpoint_lsn the LSN of the latest checkpoint -@param[in] store whether to store page operations -@param[in] apply whether to apply the records +@param[in] checkpoint_lsn the LSN of the latest checkpoint +@param[in] store whether to store page operations +@param[in] available_memory memory to read the redo logs +@param[in] apply whether to apply the records @return whether MLOG_CHECKPOINT record was seen the first time, or corruption was noticed */ -bool recv_parse_log_recs(lsn_t checkpoint_lsn, store_t store, bool apply); +bool recv_parse_log_recs( + lsn_t checkpoint_lsn, + store_t* store, + ulint available_memory, + bool apply); -/** Moves the parsing buffer data left to the buffer start. */ +/** Moves the parsing buffer data left to the buffer start */ void recv_sys_justify_left_parsing_buf(); /** Report optimized DDL operation (without redo log), diff --git a/storage/innobase/include/mem0mem.h b/storage/innobase/include/mem0mem.h index fa22b3d3086..18ae845955a 100644 --- a/storage/innobase/include/mem0mem.h +++ b/storage/innobase/include/mem0mem.h @@ -291,13 +291,6 @@ mem_heap_printf( const char* format, /*!< in: format string */ ...) MY_ATTRIBUTE ((format (printf, 2, 3))); -/** Checks that an object is a memory heap (or a block of it) -@param[in] heap Memory heap to check */ -UNIV_INLINE -void -mem_block_validate( - const mem_heap_t* heap); - #ifdef UNIV_DEBUG /** Validates the contents of a memory heap. Asserts that the memory heap is consistent @@ -312,7 +305,6 @@ mem_heap_validate( /** The info structure stored at the beginning of a heap block */ struct mem_block_info_t { - ulint magic_n;/* magic number for debugging */ #ifdef UNIV_DEBUG char file_name[8];/* file name where the mem heap was created */ unsigned line; /*!< line number where the mem heap was created */ @@ -347,9 +339,6 @@ struct mem_block_info_t { otherwise, this is NULL */ }; -#define MEM_BLOCK_MAGIC_N 764741555 -#define MEM_FREED_BLOCK_MAGIC_N 547711122 - /* Header size for a memory heap block */ #define MEM_BLOCK_HEADER_SIZE UT_CALC_ALIGN(sizeof(mem_block_info_t),\ UNIV_MEM_ALIGNMENT) diff --git a/storage/innobase/include/mem0mem.ic b/storage/innobase/include/mem0mem.ic index 3b4992a1a98..2a88c0f1065 100644 --- a/storage/innobase/include/mem0mem.ic +++ b/storage/innobase/include/mem0mem.ic @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2014, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 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 @@ -144,16 +144,6 @@ mem_block_get_start(mem_block_t* block) return(block->start); } -/** Checks that an object is a memory heap block -@param[in] block Memory block to check. */ -UNIV_INLINE -void -mem_block_validate( - const mem_block_t* block) -{ - ut_a(block->magic_n == MEM_BLOCK_MAGIC_N); -} - /** Allocates and zero-fills n bytes of memory from a memory heap. @param[in] heap memory heap @param[in] n number of bytes; if the heap is allowed to grow into @@ -186,8 +176,6 @@ mem_heap_alloc( byte* buf; ulint free; - ut_d(mem_block_validate(heap)); - block = UT_LIST_GET_LAST(heap->base); n += REDZONE_SIZE; @@ -230,8 +218,6 @@ mem_heap_get_heap_top( mem_block_t* block; byte* buf; - ut_d(mem_block_validate(heap)); - block = UT_LIST_GET_LAST(heap->base); buf = (byte*) block + mem_block_get_free(block); @@ -322,8 +308,6 @@ mem_heap_get_top( mem_block_t* block; byte* buf; - ut_d(mem_block_validate(heap)); - block = UT_LIST_GET_LAST(heap->base); buf = (byte*) block + mem_block_get_free(block) - MEM_SPACE_NEEDED(n); @@ -343,8 +327,6 @@ mem_heap_free_top( { mem_block_t* block; - ut_d(mem_block_validate(heap)); - n += REDZONE_SIZE; block = UT_LIST_GET_LAST(heap->base); @@ -420,8 +402,6 @@ mem_heap_free( mem_block_t* block; mem_block_t* prev_block; - ut_d(mem_block_validate(heap)); - block = UT_LIST_GET_LAST(heap->base); if (heap->free_block) { @@ -448,11 +428,7 @@ mem_heap_get_size( /*==============*/ mem_heap_t* heap) /*!< in: heap */ { - ulint size = 0; - - ut_d(mem_block_validate(heap)); - - size = heap->total_size; + ulint size = heap->total_size; if (heap->free_block) { size += srv_page_size; diff --git a/storage/innobase/include/mtr0log.h b/storage/innobase/include/mtr0log.h index eaf2fad9e7f..dc76b40a3db 100644 --- a/storage/innobase/include/mtr0log.h +++ b/storage/innobase/include/mtr0log.h @@ -109,14 +109,6 @@ mlog_catenate_string( const byte* str, /*!< in: string to write */ ulint len); /*!< in: string length */ /********************************************************//** -Catenates a compressed ulint to mlog. */ -UNIV_INLINE -void -mlog_catenate_ulint_compressed( -/*===========================*/ - mtr_t* mtr, /*!< in: mtr */ - ulint val); /*!< in: value to write */ -/********************************************************//** Catenates a compressed 64-bit integer to mlog. */ UNIV_INLINE void diff --git a/storage/innobase/include/mtr0log.ic b/storage/innobase/include/mtr0log.ic index b7ba92ff1a5..70bcaf43b9e 100644 --- a/storage/innobase/include/mtr0log.ic +++ b/storage/innobase/include/mtr0log.ic @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, MariaDB Corporation. +Copyright (c) 2017, 2019, 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 @@ -118,30 +118,6 @@ mlog_catenate_ulint( } /********************************************************//** -Catenates a compressed ulint to mlog. */ -UNIV_INLINE -void -mlog_catenate_ulint_compressed( -/*===========================*/ - mtr_t* mtr, /*!< in: mtr */ - ulint val) /*!< in: value to write */ -{ - byte* log_ptr; - - log_ptr = mlog_open(mtr, 10); - - /* If no logging is requested, we may return now */ - if (log_ptr == NULL) { - - return; - } - - log_ptr += mach_write_compressed(log_ptr, val); - - mlog_close(mtr, log_ptr); -} - -/********************************************************//** Catenates a compressed 64-bit integer to mlog. */ UNIV_INLINE void @@ -187,7 +163,6 @@ mlog_write_initial_log_record_low( || type == MLOG_FILE_CREATE2 || type == MLOG_FILE_RENAME2 || type == MLOG_INDEX_LOAD - || type == MLOG_TRUNCATE || type == MLOG_FILE_WRITE_CRYPT_DATA || mtr->is_named_space(space_id)); diff --git a/storage/innobase/include/page0cur.h b/storage/innobase/include/page0cur.h index f21506d0475..5accbcd76d5 100644 --- a/storage/innobase/include/page0cur.h +++ b/storage/innobase/include/page0cur.h @@ -29,6 +29,7 @@ Created 10/4/1994 Heikki Tuuri #include "buf0types.h" #include "page0page.h" +#include "rem0types.h" #include "rem0rec.h" #include "data0data.h" #include "mtr0mtr.h" @@ -151,7 +152,7 @@ page_cur_tuple_insert( page_cur_t* cursor, /*!< in/out: a page cursor */ const dtuple_t* tuple, /*!< in: pointer to a data tuple */ dict_index_t* index, /*!< in: record descriptor */ - ulint** offsets,/*!< out: offsets on *rec */ + offset_t** offsets,/*!< out: offsets on *rec */ mem_heap_t** heap, /*!< in/out: pointer to memory heap, or NULL */ ulint n_ext, /*!< in: number of externally stored columns */ mtr_t* mtr) /*!< in: mini-transaction handle, or NULL */ @@ -175,7 +176,7 @@ page_cur_rec_insert( page_cur_t* cursor, /*!< in/out: a page cursor */ const rec_t* rec, /*!< in: record to insert */ dict_index_t* index, /*!< in: record descriptor */ - ulint* offsets,/*!< in/out: rec_get_offsets(rec, index) */ + offset_t* offsets,/*!< in/out: rec_get_offsets(rec, index) */ mtr_t* mtr); /*!< in: mini-transaction handle, or NULL */ /***********************************************************//** Inserts a record next to page cursor on an uncompressed page. @@ -189,7 +190,7 @@ page_cur_insert_rec_low( which the new record is inserted */ dict_index_t* index, /*!< in: record descriptor */ const rec_t* rec, /*!< in: pointer to a physical record */ - ulint* offsets,/*!< in/out: rec_get_offsets(rec, index) */ + offset_t* offsets,/*!< in/out: rec_get_offsets(rec, index) */ mtr_t* mtr) /*!< in: mini-transaction handle, or NULL */ MY_ATTRIBUTE((nonnull(1,2,3,4), warn_unused_result)); @@ -211,7 +212,7 @@ page_cur_insert_rec_zip( page_cur_t* cursor, /*!< in/out: page cursor */ dict_index_t* index, /*!< in: record descriptor */ const rec_t* rec, /*!< in: pointer to a physical record */ - ulint* offsets,/*!< in/out: rec_get_offsets(rec, index) */ + offset_t* offsets,/*!< in/out: rec_get_offsets(rec, index) */ mtr_t* mtr) /*!< in: mini-transaction handle, or NULL */ MY_ATTRIBUTE((nonnull(1,2,3,4), warn_unused_result)); /*************************************************************//** @@ -237,7 +238,7 @@ page_cur_delete_rec( /*================*/ page_cur_t* cursor, /*!< in/out: a page cursor */ const dict_index_t* index, /*!< in: record descriptor */ - const ulint* offsets,/*!< in: rec_get_offsets( + const offset_t* offsets,/*!< in: rec_get_offsets( cursor->rec, index) */ mtr_t* mtr); /*!< in: mini-transaction handle */ @@ -385,14 +386,14 @@ page_delete_rec( page_cur_t* pcur, /*!< in/out: page cursor on record to delete */ page_zip_des_t* page_zip,/*!< in: compressed page descriptor */ - const ulint* offsets);/*!< in: offsets for record */ + const offset_t* offsets);/*!< in: offsets for record */ /** Index page cursor */ struct page_cur_t{ const dict_index_t* index; rec_t* rec; /*!< pointer to a record on page */ - ulint* offsets; + offset_t* offsets; buf_block_t* block; /*!< pointer to the block containing rec */ }; diff --git a/storage/innobase/include/page0cur.ic b/storage/innobase/include/page0cur.ic index dff829089bb..1ccb7f9a80d 100644 --- a/storage/innobase/include/page0cur.ic +++ b/storage/innobase/include/page0cur.ic @@ -259,7 +259,7 @@ page_cur_tuple_insert( page_cur_t* cursor, /*!< in/out: a page cursor */ const dtuple_t* tuple, /*!< in: pointer to a data tuple */ dict_index_t* index, /*!< in: record descriptor */ - ulint** offsets,/*!< out: offsets on *rec */ + offset_t** offsets,/*!< out: offsets on *rec */ mem_heap_t** heap, /*!< in/out: pointer to memory heap, or NULL */ ulint n_ext, /*!< in: number of externally stored columns */ mtr_t* mtr) /*!< in: mini-transaction handle, or NULL */ @@ -312,7 +312,7 @@ page_cur_rec_insert( page_cur_t* cursor, /*!< in/out: a page cursor */ const rec_t* rec, /*!< in: record to insert */ dict_index_t* index, /*!< in: record descriptor */ - ulint* offsets,/*!< in/out: rec_get_offsets(rec, index) */ + offset_t* offsets,/*!< in/out: rec_get_offsets(rec, index) */ mtr_t* mtr) /*!< in: mini-transaction handle, or NULL */ { if (buf_block_get_page_zip(cursor->block)) { diff --git a/storage/innobase/include/page0page.h b/storage/innobase/include/page0page.h index e6df074e4a9..0876bc54aaf 100644 --- a/storage/innobase/include/page0page.h +++ b/storage/innobase/include/page0page.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2019, MariaDB Corporation. +Copyright (c) 1994, 2019, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2013, 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 @@ -32,6 +32,7 @@ Created 2/2/1994 Heikki Tuuri #include "buf0buf.h" #include "data0data.h" #include "dict0dict.h" +#include "rem0types.h" #include "rem0rec.h" #endif /* !UNIV_INNOCHECKSUM*/ #include "fsp0fsp.h" @@ -857,6 +858,22 @@ page_rec_is_last( MY_ATTRIBUTE((warn_unused_result)); /************************************************************//** +true if distance between the records (measured in number of times we have to +move to the next record) is at most the specified value +@param[in] left_rec lefter record +@param[in] right_rec righter record +@param[in] val specified value to compare +@return true if the distance is smaller than the value */ +UNIV_INLINE +bool +page_rec_distance_is_at_most( +/*=========================*/ + const rec_t* left_rec, + const rec_t* right_rec, + ulint val) + MY_ATTRIBUTE((warn_unused_result)); + +/************************************************************//** true if the record is the second last user record on a page. @return true if the second last user record */ UNIV_INLINE @@ -963,7 +980,7 @@ page_mem_free( rec_t* rec, /*!< in: pointer to the (origin of) record */ const dict_index_t* index, /*!< in: index of rec */ - const ulint* offsets);/*!< in: array returned by + const offset_t* offsets);/*!< in: array returned by rec_get_offsets() */ /** Read the PAGE_DIRECTION field from a byte. @@ -1223,7 +1240,7 @@ void page_rec_print( /*===========*/ const rec_t* rec, /*!< in: physical record */ - const ulint* offsets);/*!< in: record descriptor */ + const offset_t* offsets);/*!< in: record descriptor */ # ifdef UNIV_BTR_PRINT /***************************************************************//** This is used to print the contents of the directory for @@ -1270,7 +1287,7 @@ ibool page_rec_validate( /*==============*/ const rec_t* rec, /*!< in: physical record */ - const ulint* offsets);/*!< in: array returned by rec_get_offsets() */ + const offset_t* offsets);/*!< in: array returned by rec_get_offsets() */ #ifdef UNIV_DEBUG /***************************************************************//** Checks that the first directory slot points to the infimum record and diff --git a/storage/innobase/include/page0page.ic b/storage/innobase/include/page0page.ic index e5368938531..94887a0925a 100644 --- a/storage/innobase/include/page0page.ic +++ b/storage/innobase/include/page0page.ic @@ -1,7 +1,7 @@ /***************************************************************************** -Copyright (c) 1994, 2015, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2019, MariaDB Corporation. +Copyright (c) 1994, 2019, Oracle and/or its affiliates. All Rights Reserved. +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 @@ -359,6 +359,26 @@ page_rec_is_last( } /************************************************************//** +true if distance between the records (measured in number of times we have to +move to the next record) is at most the specified value */ +UNIV_INLINE +bool +page_rec_distance_is_at_most( +/*=========================*/ + const rec_t* left_rec, + const rec_t* right_rec, + ulint val) +{ + for (ulint i = 0; i <= val; i++) { + if (left_rec == right_rec) { + return (true); + } + left_rec = page_rec_get_next_const(left_rec); + } + return (false); +} + +/************************************************************//** true if the record is the second last user record on a page. @return true if the second last user record */ UNIV_INLINE @@ -660,6 +680,7 @@ page_rec_get_next_low( } ut_ad(page_rec_is_infimum(rec) + || (!page_is_leaf(page) && !page_has_prev(page)) || !(rec_get_info_bits(page + offs, comp) & REC_INFO_MIN_REC_FLAG)); @@ -1004,7 +1025,7 @@ page_mem_free( rec_t* rec, /*!< in: pointer to the (origin of) record */ const dict_index_t* index, /*!< in: index of rec */ - const ulint* offsets) /*!< in: array returned by + const offset_t* offsets) /*!< in: array returned by rec_get_offsets() */ { rec_t* free; diff --git a/storage/innobase/include/page0types.h b/storage/innobase/include/page0types.h index 02d0cf29ec5..4debd639fa4 100644 --- a/storage/innobase/include/page0types.h +++ b/storage/innobase/include/page0types.h @@ -28,6 +28,7 @@ Created 2/2/1994 Heikki Tuuri #include "dict0types.h" #include "mtr0types.h" +#include "rem0types.h" #include <map> @@ -184,7 +185,7 @@ page_zip_dir_delete( page_zip_des_t* page_zip,/*!< in/out: compressed page */ byte* rec, /*!< in: deleted record */ dict_index_t* index, /*!< in: index of rec */ - const ulint* offsets,/*!< in: rec_get_offsets(rec) */ + const offset_t* offsets,/*!< in: rec_get_offsets(rec) */ const byte* free) /*!< in: previous start of the free list */ MY_ATTRIBUTE((nonnull(1,2,3,4))); diff --git a/storage/innobase/include/page0zip.h b/storage/innobase/include/page0zip.h index 8672def36e6..899cc1aab22 100644 --- a/storage/innobase/include/page0zip.h +++ b/storage/innobase/include/page0zip.h @@ -47,6 +47,7 @@ Created June 2005 by Marko Makela #endif /* !UNIV_INNOCHECKSUM */ #include "buf0types.h" +#include "rem0types.h" #ifndef UNIV_INNOCHECKSUM #include "dict0types.h" @@ -287,7 +288,7 @@ page_zip_write_rec( page_zip_des_t* page_zip,/*!< in/out: compressed page */ const byte* rec, /*!< in: record being written */ dict_index_t* index, /*!< in: the index the record belongs to */ - const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */ + const offset_t* offsets,/*!< in: rec_get_offsets(rec, index) */ ulint create) /*!< in: nonzero=insert, zero=update */ MY_ATTRIBUTE((nonnull)); @@ -312,7 +313,7 @@ page_zip_write_blob_ptr( const byte* rec, /*!< in/out: record whose data is being written */ dict_index_t* index, /*!< in: index of the page */ - const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */ + const offset_t* offsets,/*!< in: rec_get_offsets(rec, index) */ ulint n, /*!< in: column index */ mtr_t* mtr); /*!< in: mini-transaction handle, or NULL if no logging is needed */ @@ -351,7 +352,7 @@ void page_zip_write_trx_id_and_roll_ptr( page_zip_des_t* page_zip, byte* rec, - const ulint* offsets, + const offset_t* offsets, ulint trx_id_col, trx_id_t trx_id, roll_ptr_t roll_ptr, @@ -415,7 +416,7 @@ page_zip_dir_delete( page_zip_des_t* page_zip, /*!< in/out: compressed page */ byte* rec, /*!< in: deleted record */ const dict_index_t* index, /*!< in: index of rec */ - const ulint* offsets, /*!< in: rec_get_offsets(rec) */ + const offset_t* offsets, /*!< in: rec_get_offsets(rec) */ const byte* free) /*!< in: previous start of the free list */ MY_ATTRIBUTE((nonnull(1,2,3,4))); diff --git a/storage/innobase/include/pars0grm.h b/storage/innobase/include/pars0grm.h index 90a7468bc9a..58d424abfdc 100644 --- a/storage/innobase/include/pars0grm.h +++ b/storage/innobase/include/pars0grm.h @@ -1,8 +1,9 @@ -/* A Bison parser, made by GNU Bison 3.0.4. */ +/* A Bison parser, made by GNU Bison 3.4.2. */ /* Bison interface for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation, + Inc. 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 @@ -30,6 +31,9 @@ This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ +/* Undocumented macros, especially those whose name start with YY_, + are private implementation details. Do not rely on them. */ + #ifndef YY_YY_PARS0GRM_TAB_H_INCLUDED # define YY_YY_PARS0GRM_TAB_H_INCLUDED /* Debug traces. */ @@ -58,91 +62,71 @@ extern int yydebug; PARS_NE_TOKEN = 268, PARS_PROCEDURE_TOKEN = 269, PARS_IN_TOKEN = 270, - PARS_OUT_TOKEN = 271, - PARS_BINARY_TOKEN = 272, - PARS_BLOB_TOKEN = 273, - PARS_INT_TOKEN = 274, - PARS_FLOAT_TOKEN = 275, - PARS_CHAR_TOKEN = 276, - PARS_IS_TOKEN = 277, - PARS_BEGIN_TOKEN = 278, - PARS_END_TOKEN = 279, - PARS_IF_TOKEN = 280, - PARS_THEN_TOKEN = 281, - PARS_ELSE_TOKEN = 282, - PARS_ELSIF_TOKEN = 283, - PARS_LOOP_TOKEN = 284, - PARS_WHILE_TOKEN = 285, - PARS_RETURN_TOKEN = 286, - PARS_SELECT_TOKEN = 287, - PARS_SUM_TOKEN = 288, - PARS_COUNT_TOKEN = 289, - PARS_DISTINCT_TOKEN = 290, - PARS_FROM_TOKEN = 291, - PARS_WHERE_TOKEN = 292, - PARS_FOR_TOKEN = 293, - PARS_DDOT_TOKEN = 294, - PARS_READ_TOKEN = 295, - PARS_ORDER_TOKEN = 296, - PARS_BY_TOKEN = 297, - PARS_ASC_TOKEN = 298, - PARS_DESC_TOKEN = 299, - PARS_INSERT_TOKEN = 300, - PARS_INTO_TOKEN = 301, - PARS_VALUES_TOKEN = 302, - PARS_UPDATE_TOKEN = 303, - PARS_SET_TOKEN = 304, - PARS_DELETE_TOKEN = 305, - PARS_CURRENT_TOKEN = 306, - PARS_OF_TOKEN = 307, - PARS_CREATE_TOKEN = 308, - PARS_TABLE_TOKEN = 309, - PARS_INDEX_TOKEN = 310, - PARS_UNIQUE_TOKEN = 311, - PARS_CLUSTERED_TOKEN = 312, - PARS_ON_TOKEN = 313, - PARS_ASSIGN_TOKEN = 314, - PARS_DECLARE_TOKEN = 315, - PARS_CURSOR_TOKEN = 316, - PARS_SQL_TOKEN = 317, - PARS_OPEN_TOKEN = 318, - PARS_FETCH_TOKEN = 319, - PARS_CLOSE_TOKEN = 320, - PARS_NOTFOUND_TOKEN = 321, - PARS_TO_CHAR_TOKEN = 322, - PARS_TO_NUMBER_TOKEN = 323, - PARS_TO_BINARY_TOKEN = 324, - PARS_BINARY_TO_NUMBER_TOKEN = 325, - PARS_SUBSTR_TOKEN = 326, - PARS_REPLSTR_TOKEN = 327, - PARS_CONCAT_TOKEN = 328, - PARS_INSTR_TOKEN = 329, - PARS_LENGTH_TOKEN = 330, - PARS_SYSDATE_TOKEN = 331, - PARS_PRINTF_TOKEN = 332, - PARS_ASSERT_TOKEN = 333, - PARS_RND_TOKEN = 334, - PARS_RND_STR_TOKEN = 335, - PARS_ROW_PRINTF_TOKEN = 336, - PARS_COMMIT_TOKEN = 337, - PARS_ROLLBACK_TOKEN = 338, - PARS_WORK_TOKEN = 339, - PARS_UNSIGNED_TOKEN = 340, - PARS_EXIT_TOKEN = 341, - PARS_FUNCTION_TOKEN = 342, - PARS_LOCK_TOKEN = 343, - PARS_SHARE_TOKEN = 344, - PARS_MODE_TOKEN = 345, - PARS_LIKE_TOKEN = 346, - PARS_LIKE_TOKEN_EXACT = 347, - PARS_LIKE_TOKEN_PREFIX = 348, - PARS_LIKE_TOKEN_SUFFIX = 349, - PARS_LIKE_TOKEN_SUBSTR = 350, - PARS_TABLE_NAME_TOKEN = 351, - PARS_COMPACT_TOKEN = 352, - PARS_BLOCK_SIZE_TOKEN = 353, - PARS_BIGINT_TOKEN = 354, - NEG = 355 + PARS_INT_TOKEN = 271, + PARS_CHAR_TOKEN = 272, + PARS_IS_TOKEN = 273, + PARS_BEGIN_TOKEN = 274, + PARS_END_TOKEN = 275, + PARS_IF_TOKEN = 276, + PARS_THEN_TOKEN = 277, + PARS_ELSE_TOKEN = 278, + PARS_ELSIF_TOKEN = 279, + PARS_LOOP_TOKEN = 280, + PARS_WHILE_TOKEN = 281, + PARS_RETURN_TOKEN = 282, + PARS_SELECT_TOKEN = 283, + PARS_COUNT_TOKEN = 284, + PARS_FROM_TOKEN = 285, + PARS_WHERE_TOKEN = 286, + PARS_FOR_TOKEN = 287, + PARS_DDOT_TOKEN = 288, + PARS_ORDER_TOKEN = 289, + PARS_BY_TOKEN = 290, + PARS_ASC_TOKEN = 291, + PARS_DESC_TOKEN = 292, + PARS_INSERT_TOKEN = 293, + PARS_INTO_TOKEN = 294, + PARS_VALUES_TOKEN = 295, + PARS_UPDATE_TOKEN = 296, + PARS_SET_TOKEN = 297, + PARS_DELETE_TOKEN = 298, + PARS_CURRENT_TOKEN = 299, + PARS_OF_TOKEN = 300, + PARS_CREATE_TOKEN = 301, + PARS_TABLE_TOKEN = 302, + PARS_INDEX_TOKEN = 303, + PARS_UNIQUE_TOKEN = 304, + PARS_CLUSTERED_TOKEN = 305, + PARS_ON_TOKEN = 306, + PARS_ASSIGN_TOKEN = 307, + PARS_DECLARE_TOKEN = 308, + PARS_CURSOR_TOKEN = 309, + PARS_SQL_TOKEN = 310, + PARS_OPEN_TOKEN = 311, + PARS_FETCH_TOKEN = 312, + PARS_CLOSE_TOKEN = 313, + PARS_NOTFOUND_TOKEN = 314, + PARS_TO_BINARY_TOKEN = 315, + PARS_SUBSTR_TOKEN = 316, + PARS_CONCAT_TOKEN = 317, + PARS_INSTR_TOKEN = 318, + PARS_LENGTH_TOKEN = 319, + PARS_COMMIT_TOKEN = 320, + PARS_ROLLBACK_TOKEN = 321, + PARS_WORK_TOKEN = 322, + PARS_EXIT_TOKEN = 323, + PARS_FUNCTION_TOKEN = 324, + PARS_LOCK_TOKEN = 325, + PARS_SHARE_TOKEN = 326, + PARS_MODE_TOKEN = 327, + PARS_LIKE_TOKEN = 328, + PARS_LIKE_TOKEN_EXACT = 329, + PARS_LIKE_TOKEN_PREFIX = 330, + PARS_LIKE_TOKEN_SUFFIX = 331, + PARS_LIKE_TOKEN_SUBSTR = 332, + PARS_TABLE_NAME_TOKEN = 333, + PARS_BIGINT_TOKEN = 334, + NEG = 335 }; #endif diff --git a/storage/innobase/include/pars0pars.h b/storage/innobase/include/pars0pars.h index 857c5c2742c..73a19dd24d8 100644 --- a/storage/innobase/include/pars0pars.h +++ b/storage/innobase/include/pars0pars.h @@ -48,29 +48,15 @@ extern int yydebug; NOT re-entrant */ extern sym_tab_t* pars_sym_tab_global; -extern pars_res_word_t pars_to_char_token; -extern pars_res_word_t pars_to_number_token; extern pars_res_word_t pars_to_binary_token; -extern pars_res_word_t pars_binary_to_number_token; extern pars_res_word_t pars_substr_token; -extern pars_res_word_t pars_replstr_token; extern pars_res_word_t pars_concat_token; extern pars_res_word_t pars_length_token; extern pars_res_word_t pars_instr_token; -extern pars_res_word_t pars_sysdate_token; -extern pars_res_word_t pars_printf_token; -extern pars_res_word_t pars_assert_token; -extern pars_res_word_t pars_rnd_token; -extern pars_res_word_t pars_rnd_str_token; extern pars_res_word_t pars_count_token; -extern pars_res_word_t pars_sum_token; -extern pars_res_word_t pars_distinct_token; -extern pars_res_word_t pars_binary_token; -extern pars_res_word_t pars_blob_token; extern pars_res_word_t pars_int_token; extern pars_res_word_t pars_bigint_token; extern pars_res_word_t pars_char_token; -extern pars_res_word_t pars_float_token; extern pars_res_word_t pars_update_token; extern pars_res_word_t pars_asc_token; extern pars_res_word_t pars_desc_token; @@ -236,17 +222,6 @@ pars_insert_statement( que_node_t* values_list, /*!< in: value expression list or NULL */ sel_node_t* select); /*!< in: select condition or NULL */ /*********************************************************************//** -Parses a procedure parameter declaration. -@return own: symbol table node of type SYM_VAR */ -sym_node_t* -pars_parameter_declaration( -/*=======================*/ - sym_node_t* node, /*!< in: symbol table node allocated for the - id of the parameter */ - ulint param_type, - /*!< in: PARS_INPUT or PARS_OUTPUT */ - pars_res_word_t* type); /*!< in: pointer to a type token */ -/*********************************************************************//** Parses an elsif element. @return elsif node */ elsif_node_t* @@ -358,8 +333,6 @@ pars_column_def( pars_res_word_t* type, /*!< in: data type */ sym_node_t* len, /*!< in: length of column, or NULL */ - void* is_unsigned, /*!< in: if not NULL, column - is of type UNSIGNED. */ void* is_not_null); /*!< in: if not NULL, column is of type NOT NULL. */ /*********************************************************************//** @@ -370,9 +343,7 @@ pars_create_table( /*==============*/ sym_node_t* table_sym, /*!< in: table name node in the symbol table */ - sym_node_t* column_defs, /*!< in: list of column names */ - sym_node_t* compact, /* in: non-NULL if COMPACT table. */ - sym_node_t* block_size); /* in: block size (can be NULL) */ + sym_node_t* column_defs); /*!< in: list of column names */ /*********************************************************************//** Parses an index creation operation. @return index create subgraph */ @@ -394,7 +365,6 @@ pars_procedure_definition( /*======================*/ sym_node_t* sym_node, /*!< in: procedure id node in the symbol table */ - sym_node_t* param_list, /*!< in: parameter declaration list */ que_node_t* stat_list); /*!< in: statement list */ /*************************************************************//** @@ -672,7 +642,6 @@ struct proc_node_t{ que_common_t common; /*!< type: QUE_NODE_PROC */ sym_node_t* proc_id; /*!< procedure name symbol in the symbol table of this same procedure */ - sym_node_t* param_list; /*!< input and output parameters */ que_node_t* stat_list; /*!< statement list */ sym_tab_t* sym_tab; /*!< symbol table of this procedure */ }; @@ -747,7 +716,7 @@ struct col_assign_node_t{ #define PARS_FUNC_LOGICAL 2 /*!< AND, OR, NOT */ #define PARS_FUNC_CMP 3 /*!< comparison operators */ #define PARS_FUNC_PREDEFINED 4 /*!< TO_NUMBER, SUBSTR, ... */ -#define PARS_FUNC_AGGREGATE 5 /*!< COUNT, DISTINCT, SUM */ +#define PARS_FUNC_AGGREGATE 5 /*!< COUNT */ #define PARS_FUNC_OTHER 6 /*!< these are not real functions, e.g., := */ /* @} */ diff --git a/storage/innobase/include/rem0cmp.h b/storage/innobase/include/rem0cmp.h index 9582b0df393..af1b145b0d9 100644 --- a/storage/innobase/include/rem0cmp.h +++ b/storage/innobase/include/rem0cmp.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 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 @@ -80,7 +80,7 @@ cmp_dfield_dfield( /** Compare a GIS data tuple to a physical record. @param[in] dtuple data tuple -@param[in] rec B-tree record +@param[in] rec R-tree record @param[in] offsets rec_get_offsets(rec) @param[in] mode compare mode @retval negative if dtuple is less than rec */ @@ -89,7 +89,7 @@ cmp_dtuple_rec_with_gis( /*====================*/ const dtuple_t* dtuple, const rec_t* rec, - const ulint* offsets, + const offset_t* offsets, page_cur_mode_t mode) MY_ATTRIBUTE((nonnull)); @@ -105,7 +105,7 @@ int cmp_dtuple_rec_with_gis_internal( const dtuple_t* dtuple, const rec_t* rec, - const ulint* offsets); + const offset_t* offsets); /** Compare a data tuple to a physical record. @param[in] dtuple data tuple @@ -121,7 +121,7 @@ int cmp_dtuple_rec_with_match_low( const dtuple_t* dtuple, const rec_t* rec, - const ulint* offsets, + const offset_t* offsets, ulint n_cmp, ulint* matched_fields) MY_ATTRIBUTE((nonnull)); @@ -145,7 +145,7 @@ cmp_dtuple_rec_with_match_bytes( const dtuple_t* dtuple, const rec_t* rec, const dict_index_t* index, - const ulint* offsets, + const offset_t* offsets, ulint* matched_fields, ulint* matched_bytes) MY_ATTRIBUTE((warn_unused_result)); @@ -162,7 +162,7 @@ int cmp_dtuple_rec( const dtuple_t* dtuple, const rec_t* rec, - const ulint* offsets); + const offset_t* offsets); /**************************************************************//** Checks if a dtuple is a prefix of a record. The last field in dtuple is allowed to be a prefix of the corresponding field in the record. @@ -172,7 +172,7 @@ cmp_dtuple_is_prefix_of_rec( /*========================*/ const dtuple_t* dtuple, /*!< in: data tuple */ const rec_t* rec, /*!< in: physical record */ - const ulint* offsets);/*!< in: array returned by rec_get_offsets() */ + const offset_t* offsets);/*!< in: array returned by rec_get_offsets() */ /** Compare two physical records that contain the same number of columns, none of which are stored externally. @retval positive if rec1 (including non-ordering columns) is greater than rec2 @@ -183,58 +183,40 @@ cmp_rec_rec_simple( /*===============*/ const rec_t* rec1, /*!< in: physical record */ const rec_t* rec2, /*!< in: physical record */ - const ulint* offsets1,/*!< in: rec_get_offsets(rec1, ...) */ - const ulint* offsets2,/*!< in: rec_get_offsets(rec2, ...) */ + const offset_t* offsets1,/*!< in: rec_get_offsets(rec1, ...) */ + const offset_t* offsets2,/*!< in: rec_get_offsets(rec2, ...) */ const dict_index_t* index, /*!< in: data dictionary index */ struct TABLE* table) /*!< in: MySQL table, for reporting duplicate key value if applicable, or NULL */ MY_ATTRIBUTE((nonnull(1,2,3,4), warn_unused_result)); -/** Compare two B-tree records. -@param[in] rec1 B-tree record -@param[in] rec2 B-tree record -@param[in] offsets1 rec_get_offsets(rec1, index) -@param[in] offsets2 rec_get_offsets(rec2, index) -@param[in] index B-tree index -@param[in] nulls_unequal true if this is for index cardinality -statistics estimation, and innodb_stats_method=nulls_unequal -or innodb_stats_method=nulls_ignored -@param[out] matched_fields number of completely matched fields -within the first field not completely matched -@return the comparison result -@retval 0 if rec1 is equal to rec2 -@retval negative if rec1 is less than rec2 -@retval positive if rec2 is greater than rec2 */ -int -cmp_rec_rec_with_match( - const rec_t* rec1, - const rec_t* rec2, - const ulint* offsets1, - const ulint* offsets2, - const dict_index_t* index, - bool nulls_unequal, - ulint* matched_fields); -/** Compare two B-tree records. +/** Compare two B-tree or R-tree records. Only the common first fields are compared, and externally stored field are treated as equal. -@param[in] rec1 B-tree record -@param[in] rec2 B-tree record +@param[in] rec1 record (possibly not on an index page) +@param[in] rec2 B-tree or R-tree record in an index page @param[in] offsets1 rec_get_offsets(rec1, index) @param[in] offsets2 rec_get_offsets(rec2, index) +@param[in] nulls_unequal true if this is for index cardinality + statistics estimation with + innodb_stats_method=nulls_unequal + or innodb_stats_method=nulls_ignored @param[out] matched_fields number of completely matched fields within the first field not completely matched -@return positive, 0, negative if rec1 is greater, equal, less, than rec2, -respectively */ -UNIV_INLINE +@retval 0 if rec1 is equal to rec2 +@retval negative if rec1 is less than rec2 +@retval positive if rec1 is greater than rec2 */ int cmp_rec_rec( const rec_t* rec1, const rec_t* rec2, - const ulint* offsets1, - const ulint* offsets2, + const offset_t* offsets1, + const offset_t* offsets2, const dict_index_t* index, - ulint* matched_fields = NULL); + bool nulls_unequal = false, + ulint* matched_fields = NULL) + MY_ATTRIBUTE((nonnull(1,2,3,4,5))); /** Compare two data fields. @param[in] dfield1 data field diff --git a/storage/innobase/include/rem0cmp.ic b/storage/innobase/include/rem0cmp.ic index 2412d22e8fa..4230543615a 100644 --- a/storage/innobase/include/rem0cmp.ic +++ b/storage/innobase/include/rem0cmp.ic @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 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 @@ -52,40 +53,6 @@ cmp_dfield_dfield( dfield_get_len(dfield2))); } -/** Compare two B-tree records. -Only the common first fields are compared, and externally stored field -are treated as equal. -@param[in] rec1 B-tree record -@param[in] rec2 B-tree record -@param[in] offsets1 rec_get_offsets(rec1, index) -@param[in] offsets2 rec_get_offsets(rec2, index) -@param[out] matched_fields number of completely matched fields - within the first field not completely matched -@return positive, 0, negative if rec1 is greater, equal, less, than rec2, -respectively */ -UNIV_INLINE -int -cmp_rec_rec( - const rec_t* rec1, - const rec_t* rec2, - const ulint* offsets1, - const ulint* offsets2, - const dict_index_t* index, - ulint* matched_fields) -{ - ulint match_f; - int ret; - - ret = cmp_rec_rec_with_match( - rec1, rec2, offsets1, offsets2, index, false, &match_f); - - if (matched_fields != NULL) { - *matched_fields = match_f; - } - - return(ret); -} - /** Compare two data fields. @param[in] dfield1 data field @param[in] dfield2 data field diff --git a/storage/innobase/include/rem0rec.h b/storage/innobase/include/rem0rec.h index 0c49c223e10..4b7812e3bd6 100644 --- a/storage/innobase/include/rem0rec.h +++ b/storage/innobase/include/rem0rec.h @@ -90,45 +90,86 @@ The status is stored in the low-order bits. */ /* Length of a B-tree node pointer, in bytes */ #define REC_NODE_PTR_SIZE 4 +#ifndef UNIV_INNOCHECKSUM /** SQL null flag in a 1-byte offset of ROW_FORMAT=REDUNDANT records */ -#define REC_1BYTE_SQL_NULL_MASK 0x80UL +static const offset_t REC_1BYTE_SQL_NULL_MASK= 0x80; /** SQL null flag in a 2-byte offset of ROW_FORMAT=REDUNDANT records */ -#define REC_2BYTE_SQL_NULL_MASK 0x8000UL +static const offset_t REC_2BYTE_SQL_NULL_MASK= 0x8000; /** In a 2-byte offset of ROW_FORMAT=REDUNDANT records, the second most significant bit denotes that the tail of a field is stored off-page. */ -#define REC_2BYTE_EXTERN_MASK 0x4000UL +static const offset_t REC_2BYTE_EXTERN_MASK= 0x4000; + +static const size_t RECORD_OFFSET= 2; +static const size_t INDEX_OFFSET= + RECORD_OFFSET + sizeof(rec_t *) / sizeof(offset_t); +#endif /* UNIV_INNOCHECKSUM */ -#ifdef UNIV_DEBUG -/* Length of the rec_get_offsets() header */ -# define REC_OFFS_HEADER_SIZE 4 -#else /* UNIV_DEBUG */ /* Length of the rec_get_offsets() header */ -# define REC_OFFS_HEADER_SIZE 2 +static const size_t REC_OFFS_HEADER_SIZE= +#ifdef UNIV_DEBUG +#ifndef UNIV_INNOCHECKSUM + sizeof(rec_t *) / sizeof(offset_t) + + sizeof(dict_index_t *) / sizeof(offset_t) + +#endif /* UNIV_INNOCHECKSUM */ #endif /* UNIV_DEBUG */ + 2; /* Number of elements that should be initially allocated for the offsets[] array, first passed to rec_get_offsets() */ -#define REC_OFFS_NORMAL_SIZE OFFS_IN_REC_NORMAL_SIZE -#define REC_OFFS_SMALL_SIZE 10 +static const size_t REC_OFFS_NORMAL_SIZE= 300; +static const size_t REC_OFFS_SMALL_SIZE= 18; +static const size_t REC_OFFS_SEC_INDEX_SIZE= + /* PK max key parts */ 16 + /* sec idx max key parts */ 16 + + /* child page number for non-leaf pages */ 1; /** Get the base address of offsets. The extra_size is stored at this position, and following positions hold the end offsets of the fields. */ #define rec_offs_base(offsets) (offsets + REC_OFFS_HEADER_SIZE) +#ifndef UNIV_INNOCHECKSUM +/* Offset consists of two parts: 2 upper bits is type and all other bits is +value */ + +/** Only 4 different values is possible! */ +enum field_type_t +{ + /** normal field */ + STORED_IN_RECORD= 0 << 14, + /** this field is stored off-page */ + STORED_OFFPAGE= 1 << 14, + /** just an SQL NULL */ + SQL_NULL= 2 << 14, + /** instantly added field */ + DEFAULT= 3 << 14, +}; + +/** without 2 upper bits */ +static const offset_t DATA_MASK= 0x3fff; +/** 2 upper bits */ +static const offset_t TYPE_MASK= ~DATA_MASK; +inline field_type_t get_type(offset_t n) +{ + return static_cast<field_type_t>(n & TYPE_MASK); +} +inline void set_type(offset_t &n, field_type_t type) +{ + n= (n & DATA_MASK) | static_cast<offset_t>(type); +} +inline offset_t get_value(offset_t n) { return n & DATA_MASK; } +inline offset_t combine(offset_t value, field_type_t type) +{ + return get_value(value) | static_cast<offset_t>(type); +} + /** Compact flag ORed to the extra size returned by rec_get_offsets() */ -const ulint REC_OFFS_COMPACT = ~(ulint(~0) >> 1); -/** SQL NULL flag in offsets returned by rec_get_offsets() */ -const ulint REC_OFFS_SQL_NULL = REC_OFFS_COMPACT; +const offset_t REC_OFFS_COMPACT= ~(offset_t(~0) >> 1); /** External flag in offsets returned by rec_get_offsets() */ -const ulint REC_OFFS_EXTERNAL = REC_OFFS_COMPACT >> 1; +const offset_t REC_OFFS_EXTERNAL= REC_OFFS_COMPACT >> 1; /** Default value flag in offsets returned by rec_get_offsets() */ -const ulint REC_OFFS_DEFAULT = REC_OFFS_COMPACT >> 2; -/** Mask for offsets returned by rec_get_offsets() */ -const ulint REC_OFFS_MASK = REC_OFFS_DEFAULT - 1; - -#ifndef UNIV_INNOCHECKSUM +const offset_t REC_OFFS_DEFAULT= REC_OFFS_COMPACT >> 2; +const offset_t REC_OFFS_MASK= REC_OFFS_DEFAULT - 1; /******************************************************//** The following function is used to get the pointer of the next chained record on the same page. @@ -463,7 +504,7 @@ offsets form. If the field is SQL null, the flag is ORed in the returned value. @return offset of the start of the field, SQL null flag ORed */ UNIV_INLINE -ulint +uint8_t rec_1_get_field_end_info( /*=====================*/ const rec_t* rec, /*!< in: record */ @@ -477,7 +518,7 @@ value. @return offset of the start of the field, SQL null flag and extern storage flag ORed */ UNIV_INLINE -ulint +uint16_t rec_2_get_field_end_info( /*=====================*/ const rec_t* rec, /*!< in: record */ @@ -518,11 +559,11 @@ rec_get_n_extern_new( (ULINT_UNDEFINED to compute all offsets) @param[in,out] heap memory heap @return the new offsets */ -ulint* +offset_t* rec_get_offsets_func( const rec_t* rec, const dict_index_t* index, - ulint* offsets, + offset_t* offsets, bool leaf, ulint n_fields, #ifdef UNIV_DEBUG @@ -557,7 +598,7 @@ rec_get_offsets_reverse( const dict_index_t* index, /*!< in: record descriptor */ ulint node_ptr,/*!< in: nonzero=node pointer, 0=leaf node */ - ulint* offsets)/*!< in/out: array consisting of + offset_t* offsets)/*!< in/out: array consisting of offsets[0] allocated elements */ MY_ATTRIBUTE((nonnull)); #ifdef UNIV_DEBUG @@ -570,7 +611,7 @@ bool rec_offs_validate( const rec_t* rec, const dict_index_t* index, - const ulint* offsets) + const offset_t* offsets) MY_ATTRIBUTE((nonnull(3), warn_unused_result)); /** Update debug data in offsets, in order to tame rec_offs_validate(). @param[in] rec record @@ -582,7 +623,7 @@ rec_offs_make_valid( const rec_t* rec, const dict_index_t* index, bool leaf, - ulint* offsets) + offset_t* offsets) MY_ATTRIBUTE((nonnull)); #else # define rec_offs_make_valid(rec, index, leaf, offsets) @@ -619,17 +660,16 @@ The following function is used to get an offset to the nth data field in a record. @return offset from the origin of rec */ UNIV_INLINE -ulint +offset_t rec_get_nth_field_offs( /*===================*/ - const ulint* offsets,/*!< in: array returned by rec_get_offsets() */ + const offset_t* offsets,/*!< in: array returned by rec_get_offsets() */ ulint n, /*!< in: index of the field */ ulint* len) /*!< out: length of the field; UNIV_SQL_NULL if SQL null */ MY_ATTRIBUTE((nonnull)); #define rec_get_nth_field(rec, offsets, n, len) \ ((rec) + rec_get_nth_field_offs(offsets, n, len)) - /******************************************************//** Determine if the offsets are for a record containing null BLOB pointers. @return first field containing a null BLOB pointer, or NULL if none found */ @@ -638,7 +678,7 @@ const byte* rec_offs_any_null_extern( /*=====================*/ const rec_t* rec, /*!< in: record */ - const ulint* offsets) /*!< in: rec_get_offsets(rec) */ + const offset_t* offsets) /*!< in: rec_get_offsets(rec) */ MY_ATTRIBUTE((warn_unused_result)); /** Mark the nth field as externally stored. @@ -646,7 +686,7 @@ rec_offs_any_null_extern( @param[in] n nth field */ void rec_offs_make_nth_extern( - ulint* offsets, + offset_t* offsets, const ulint n); /** Determine the number of allocated elements for an array of offsets. @@ -654,7 +694,7 @@ rec_offs_make_nth_extern( @return number of elements */ inline ulint -rec_offs_get_n_alloc(const ulint* offsets) +rec_offs_get_n_alloc(const offset_t* offsets) { ulint n_alloc; ut_ad(offsets); @@ -669,7 +709,7 @@ rec_offs_get_n_alloc(const ulint* offsets) @return number of fields */ inline ulint -rec_offs_n_fields(const ulint* offsets) +rec_offs_n_fields(const offset_t* offsets) { ulint n_fields; ut_ad(offsets); @@ -685,19 +725,12 @@ rec_offs_n_fields(const ulint* offsets) @param[in] offsets rec_get_offsets() @param[in] n nth field @param[in] flag flag to extract -@return the flag of the record field */ -inline -ulint -rec_offs_nth_flag(const ulint* offsets, ulint n, ulint flag) +@return type of the record field */ +inline field_type_t rec_offs_nth_type(const offset_t *offsets, ulint n) { - ut_ad(rec_offs_validate(NULL, NULL, offsets)); - ut_ad(n < rec_offs_n_fields(offsets)); - /* The DEFAULT, NULL, EXTERNAL flags are mutually exclusive. */ - ut_ad(ut_is_2pow(rec_offs_base(offsets)[1 + n] - & (REC_OFFS_DEFAULT - | REC_OFFS_SQL_NULL - | REC_OFFS_EXTERNAL))); - return rec_offs_base(offsets)[1 + n] & flag; + ut_ad(rec_offs_validate(NULL, NULL, offsets)); + ut_ad(n < rec_offs_n_fields(offsets)); + return get_type(rec_offs_base(offsets)[1 + n]); } /** Determine if a record field is missing @@ -705,11 +738,9 @@ rec_offs_nth_flag(const ulint* offsets, ulint n, ulint flag) @param[in] offsets rec_get_offsets() @param[in] n nth field @return nonzero if default bit is set */ -inline -ulint -rec_offs_nth_default(const ulint* offsets, ulint n) +inline ulint rec_offs_nth_default(const offset_t *offsets, ulint n) { - return rec_offs_nth_flag(offsets, n, REC_OFFS_DEFAULT); + return rec_offs_nth_type(offsets, n) == DEFAULT; } /** Determine if a record field is SQL NULL @@ -717,11 +748,9 @@ rec_offs_nth_default(const ulint* offsets, ulint n) @param[in] offsets rec_get_offsets() @param[in] n nth field @return nonzero if SQL NULL set */ -inline -ulint -rec_offs_nth_sql_null(const ulint* offsets, ulint n) +inline ulint rec_offs_nth_sql_null(const offset_t *offsets, ulint n) { - return rec_offs_nth_flag(offsets, n, REC_OFFS_SQL_NULL); + return rec_offs_nth_type(offsets, n) == SQL_NULL; } /** Determine if a record field is stored off-page. @@ -729,54 +758,46 @@ rec_offs_nth_sql_null(const ulint* offsets, ulint n) @param[in] n nth field Returns nonzero if the extern bit is set in nth field of rec. @return nonzero if externally stored */ -inline -ulint -rec_offs_nth_extern(const ulint* offsets, ulint n) +inline ulint rec_offs_nth_extern(const offset_t *offsets, ulint n) { - return rec_offs_nth_flag(offsets, n, REC_OFFS_EXTERNAL); + return rec_offs_nth_type(offsets, n) == STORED_OFFPAGE; } /** Get a global flag of a record. @param[in] offsets rec_get_offsets() @param[in] flag flag to extract @return the flag of the record field */ -inline -ulint -rec_offs_any_flag(const ulint* offsets, ulint flag) +inline ulint rec_offs_any_flag(const offset_t *offsets, ulint flag) { - ut_ad(rec_offs_validate(NULL, NULL, offsets)); - return *rec_offs_base(offsets) & flag; + ut_ad(rec_offs_validate(NULL, NULL, offsets)); + return *rec_offs_base(offsets) & flag; } /** Determine if the offsets are for a record containing off-page columns. @param[in] offsets rec_get_offsets() @return nonzero if any off-page columns exist */ -inline bool rec_offs_any_extern(const ulint* offsets) +inline bool rec_offs_any_extern(const offset_t *offsets) { - return rec_offs_any_flag(offsets, REC_OFFS_EXTERNAL); + return rec_offs_any_flag(offsets, REC_OFFS_EXTERNAL); } /** Determine if the offsets are for a record that is missing fields. @param[in] offsets rec_get_offsets() @return nonzero if any fields need to be replaced with dict_index_t::instant_field_value() */ -inline -ulint -rec_offs_any_default(const ulint* offsets) +inline ulint rec_offs_any_default(const offset_t *offsets) { - return rec_offs_any_flag(offsets, REC_OFFS_DEFAULT); + return rec_offs_any_flag(offsets, REC_OFFS_DEFAULT); } /** Determine if the offsets are for other than ROW_FORMAT=REDUNDANT. @param[in] offsets rec_get_offsets() @return nonzero if ROW_FORMAT is COMPACT,DYNAMIC or COMPRESSED @retval 0 if ROW_FORMAT=REDUNDANT */ -inline -ulint -rec_offs_comp(const ulint* offsets) +inline ulint rec_offs_comp(const offset_t *offsets) { - ut_ad(rec_offs_validate(NULL, NULL, offsets)); - return(*rec_offs_base(offsets) & REC_OFFS_COMPACT); + ut_ad(rec_offs_validate(NULL, NULL, offsets)); + return (*rec_offs_base(offsets) & REC_OFFS_COMPACT); } /** Determine if the record is the metadata pseudo-record @@ -806,7 +827,7 @@ const byte* rec_get_nth_cfield( const rec_t* rec, const dict_index_t* index, - const ulint* offsets, + const offset_t* offsets, ulint n, ulint* len) { @@ -824,7 +845,7 @@ UNIV_INLINE ulint rec_offs_nth_size( /*==============*/ - const ulint* offsets,/*!< in: array returned by rec_get_offsets() */ + const offset_t* offsets,/*!< in: array returned by rec_get_offsets() */ ulint n) /*!< in: nth field */ MY_ATTRIBUTE((warn_unused_result)); @@ -835,7 +856,7 @@ UNIV_INLINE ulint rec_offs_n_extern( /*==============*/ - const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ + const offset_t* offsets)/*!< in: array returned by rec_get_offsets() */ MY_ATTRIBUTE((warn_unused_result)); /***********************************************************//** This is used to modify the value of an already existing field in a record. @@ -848,7 +869,7 @@ void rec_set_nth_field( /*==============*/ rec_t* rec, /*!< in: record */ - const ulint* offsets,/*!< in: array returned by rec_get_offsets() */ + const offset_t* offsets,/*!< in: array returned by rec_get_offsets() */ ulint n, /*!< in: index number of the field */ const void* data, /*!< in: pointer to the data if not SQL null */ ulint len) /*!< in: length of the data or UNIV_SQL_NULL. @@ -876,7 +897,7 @@ UNIV_INLINE void rec_offs_set_n_alloc( /*=================*/ - ulint* offsets, /*!< out: array for rec_get_offsets(), + offset_t*offsets, /*!< out: array for rec_get_offsets(), must be allocated */ ulint n_alloc) /*!< in: number of elements */ MY_ATTRIBUTE((nonnull)); @@ -892,7 +913,7 @@ UNIV_INLINE ulint rec_offs_data_size( /*===============*/ - const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ + const offset_t* offsets)/*!< in: array returned by rec_get_offsets() */ MY_ATTRIBUTE((warn_unused_result)); /**********************************************************//** Returns the total size of record minus data size of record. @@ -903,7 +924,7 @@ UNIV_INLINE ulint rec_offs_extra_size( /*================*/ - const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ + const offset_t* offsets)/*!< in: array returned by rec_get_offsets() */ MY_ATTRIBUTE((warn_unused_result)); /**********************************************************//** Returns the total size of a physical record. @@ -912,7 +933,7 @@ UNIV_INLINE ulint rec_offs_size( /*==========*/ - const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ + const offset_t* offsets)/*!< in: array returned by rec_get_offsets() */ MY_ATTRIBUTE((warn_unused_result)); #ifdef UNIV_DEBUG /**********************************************************//** @@ -923,7 +944,7 @@ byte* rec_get_start( /*==========*/ const rec_t* rec, /*!< in: pointer to record */ - const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ + const offset_t* offsets)/*!< in: array returned by rec_get_offsets() */ MY_ATTRIBUTE((warn_unused_result)); /**********************************************************//** Returns a pointer to the end of the record. @@ -933,7 +954,7 @@ byte* rec_get_end( /*========*/ const rec_t* rec, /*!< in: pointer to record */ - const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ + const offset_t* offsets)/*!< in: array returned by rec_get_offsets() */ MY_ATTRIBUTE((warn_unused_result)); #else /* UNIV_DEBUG */ # define rec_get_start(rec, offsets) ((rec) - rec_offs_extra_size(offsets)) @@ -950,7 +971,7 @@ rec_t* rec_copy( void* buf, const rec_t* rec, - const ulint* offsets); + const offset_t* offsets); /** Determine the size of a data tuple prefix in a temporary file. @param[in] index clustered or secondary index @@ -979,7 +1000,7 @@ void rec_init_offsets_temp( const rec_t* rec, const dict_index_t* index, - ulint* offsets, + offset_t* offsets, ulint n_core, const dict_col_t::def_t*def_val, rec_comp_status_t status = REC_STATUS_ORDINARY) @@ -993,7 +1014,7 @@ void rec_init_offsets_temp( const rec_t* rec, const dict_index_t* index, - ulint* offsets) + offset_t* offsets) MY_ATTRIBUTE((nonnull)); /** Convert a data tuple prefix to the temporary file format. @@ -1115,7 +1136,7 @@ ibool rec_validate( /*=========*/ const rec_t* rec, /*!< in: physical record */ - const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ + const offset_t* offsets)/*!< in: array returned by rec_get_offsets() */ MY_ATTRIBUTE((nonnull)); /***************************************************************//** Prints an old-style physical record. */ @@ -1132,7 +1153,7 @@ rec_print_mbr_rec( /*==========*/ FILE* file, /*!< in: file where to print */ const rec_t* rec, /*!< in: physical record */ - const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ + const offset_t* offsets)/*!< in: array returned by rec_get_offsets() */ MY_ATTRIBUTE((nonnull)); /***************************************************************//** Prints a physical record. */ @@ -1141,7 +1162,7 @@ rec_print_new( /*==========*/ FILE* file, /*!< in: file where to print */ const rec_t* rec, /*!< in: physical record */ - const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ + const offset_t* offsets)/*!< in: array returned by rec_get_offsets() */ MY_ATTRIBUTE((nonnull)); /***************************************************************//** Prints a physical record. */ @@ -1163,7 +1184,7 @@ rec_print( std::ostream& o, const rec_t* rec, ulint info, - const ulint* offsets); + const offset_t* offsets); /** Wrapper for pretty-printing a record */ struct rec_index_print @@ -1190,14 +1211,14 @@ operator<<(std::ostream& o, const rec_index_print& r); struct rec_offsets_print { /** Constructor */ - rec_offsets_print(const rec_t* rec, const ulint* offsets) : + rec_offsets_print(const rec_t* rec, const offset_t* offsets) : m_rec(rec), m_offsets(offsets) {} /** Record */ const rec_t* m_rec; /** Offsets to each field */ - const ulint* m_offsets; + const offset_t* m_offsets; }; /** Display a record. @@ -1214,7 +1235,7 @@ public: /** Construct a pretty-printed record. @param rec record with header @param offsets rec_get_offsets(rec, ...) */ - rec_printer(const rec_t* rec, const ulint* offsets) + rec_printer(const rec_t* rec, const offset_t* offsets) : std::ostringstream () { @@ -1227,7 +1248,7 @@ public: @param rec record, possibly lacking header @param info rec_get_info_bits(rec) @param offsets rec_get_offsets(rec, ...) */ - rec_printer(const rec_t* rec, ulint info, const ulint* offsets) + rec_printer(const rec_t* rec, ulint info, const offset_t* offsets) : std::ostringstream () { diff --git a/storage/innobase/include/rem0rec.ic b/storage/innobase/include/rem0rec.ic index 17dd8aa3d7a..1564bdfdcc0 100644 --- a/storage/innobase/include/rem0rec.ic +++ b/storage/innobase/include/rem0rec.ic @@ -1,7 +1,7 @@ /***************************************************************************** -Copyright (c) 1994, 2015, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2019, MariaDB Corporation. +Copyright (c) 1994, 2019, Oracle and/or its affiliates. All Rights Reserved. +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 @@ -816,7 +816,7 @@ offsets form. If the field is SQL null, the flag is ORed in the returned value. @return offset of the start of the field, SQL null flag ORed */ UNIV_INLINE -ulint +uint8_t rec_1_get_field_end_info( /*=====================*/ const rec_t* rec, /*!< in: record */ @@ -835,7 +835,7 @@ value. @return offset of the start of the field, SQL null flag and extern storage flag ORed */ UNIV_INLINE -ulint +uint16_t rec_2_get_field_end_info( /*=====================*/ const rec_t* rec, /*!< in: record */ @@ -868,13 +868,13 @@ UNIV_INLINE void rec_offs_set_n_alloc( /*=================*/ - ulint* offsets, /*!< out: array for rec_get_offsets(), + offset_t*offsets, /*!< out: array for rec_get_offsets(), must be allocated */ ulint n_alloc) /*!< in: number of elements */ { ut_ad(n_alloc > REC_OFFS_HEADER_SIZE); UNIV_MEM_ALLOC(offsets, n_alloc * sizeof *offsets); - offsets[0] = n_alloc; + offsets[0] = static_cast<offset_t>(n_alloc); } /************************************************************//** @@ -882,36 +882,27 @@ The following function is used to get an offset to the nth data field in a record. @return offset from the origin of rec */ UNIV_INLINE -ulint +offset_t rec_get_nth_field_offs( /*===================*/ - const ulint* offsets,/*!< in: array returned by rec_get_offsets() */ + const offset_t* offsets,/*!< in: array returned by rec_get_offsets() */ ulint n, /*!< in: index of the field */ ulint* len) /*!< out: length of the field; UNIV_SQL_NULL if SQL null; UNIV_SQL_DEFAULT is default value */ { - ulint offs; - ulint length; ut_ad(n < rec_offs_n_fields(offsets)); - if (n == 0) { - offs = 0; - } else { - offs = rec_offs_base(offsets)[n] & REC_OFFS_MASK; - } - - length = rec_offs_base(offsets)[1 + n]; + offset_t offs = n == 0 ? 0 : get_value(rec_offs_base(offsets)[n]); + offset_t next_offs = rec_offs_base(offsets)[1 + n]; - if (length & REC_OFFS_SQL_NULL) { - length = UNIV_SQL_NULL; - } else if (length & REC_OFFS_DEFAULT) { - length = UNIV_SQL_DEFAULT; + if (get_type(next_offs) == SQL_NULL) { + *len = UNIV_SQL_NULL; + } else if (get_type(next_offs) == DEFAULT) { + *len = UNIV_SQL_DEFAULT; } else { - length &= REC_OFFS_MASK; - length -= offs; + *len = get_value(next_offs) - offs; } - *len = length; return(offs); } @@ -923,7 +914,7 @@ const byte* rec_offs_any_null_extern( /*=====================*/ const rec_t* rec, /*!< in: record */ - const ulint* offsets) /*!< in: rec_get_offsets(rec) */ + const offset_t* offsets) /*!< in: rec_get_offsets(rec) */ { ulint i; ut_ad(rec_offs_validate(rec, NULL, offsets)); @@ -958,16 +949,16 @@ UNIV_INLINE ulint rec_offs_nth_size( /*==============*/ - const ulint* offsets,/*!< in: array returned by rec_get_offsets() */ + const offset_t* offsets,/*!< in: array returned by rec_get_offsets() */ ulint n) /*!< in: nth field */ { ut_ad(rec_offs_validate(NULL, NULL, offsets)); ut_ad(n < rec_offs_n_fields(offsets)); if (!n) { - return(rec_offs_base(offsets)[1 + n] & REC_OFFS_MASK); + return get_value(rec_offs_base(offsets)[1 + n]); } - return((rec_offs_base(offsets)[1 + n] - rec_offs_base(offsets)[n]) - & REC_OFFS_MASK); + return get_value((rec_offs_base(offsets)[1 + n])) + - get_value(rec_offs_base(offsets)[n]); } /******************************************************//** @@ -977,7 +968,7 @@ UNIV_INLINE ulint rec_offs_n_extern( /*==============*/ - const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ + const offset_t* offsets)/*!< in: array returned by rec_get_offsets() */ { ulint n = 0; @@ -1175,7 +1166,7 @@ void rec_set_nth_field( /*==============*/ rec_t* rec, /*!< in: record */ - const ulint* offsets,/*!< in: array returned by rec_get_offsets() */ + const offset_t* offsets,/*!< in: array returned by rec_get_offsets() */ ulint n, /*!< in: index number of the field */ const void* data, /*!< in: pointer to the data if not SQL null */ @@ -1231,16 +1222,16 @@ UNIV_INLINE void rec_offs_set_n_fields( /*==================*/ - ulint* offsets, /*!< in/out: array returned by + offset_t* offsets, /*!< in/out: array returned by rec_get_offsets() */ - ulint n_fields) /*!< in: number of fields */ + ulint n_fields) /*!< in: number of fields */ { ut_ad(offsets); ut_ad(n_fields > 0); ut_ad(n_fields <= REC_MAX_N_FIELDS); ut_ad(n_fields + REC_OFFS_HEADER_SIZE <= rec_offs_get_n_alloc(offsets)); - offsets[1] = n_fields; + offsets[1] = static_cast<offset_t>(n_fields); } /**********************************************************//** @@ -1253,13 +1244,12 @@ UNIV_INLINE ulint rec_offs_data_size( /*===============*/ - const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ + const offset_t* offsets)/*!< in: array returned by rec_get_offsets() */ { ulint size; ut_ad(rec_offs_validate(NULL, NULL, offsets)); - size = rec_offs_base(offsets)[rec_offs_n_fields(offsets)] - & REC_OFFS_MASK; + size = get_value(rec_offs_base(offsets)[rec_offs_n_fields(offsets)]); ut_ad(size < srv_page_size); return(size); } @@ -1273,7 +1263,7 @@ UNIV_INLINE ulint rec_offs_extra_size( /*================*/ - const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ + const offset_t* offsets)/*!< in: array returned by rec_get_offsets() */ { ulint size; ut_ad(rec_offs_validate(NULL, NULL, offsets)); @@ -1289,7 +1279,7 @@ UNIV_INLINE ulint rec_offs_size( /*==========*/ - const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ + const offset_t* offsets)/*!< in: array returned by rec_get_offsets() */ { return(rec_offs_data_size(offsets) + rec_offs_extra_size(offsets)); } @@ -1303,7 +1293,7 @@ byte* rec_get_end( /*========*/ const rec_t* rec, /*!< in: pointer to record */ - const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ + const offset_t* offsets)/*!< in: array returned by rec_get_offsets() */ { ut_ad(rec_offs_validate(rec, NULL, offsets)); return(const_cast<rec_t*>(rec + rec_offs_data_size(offsets))); @@ -1317,7 +1307,7 @@ byte* rec_get_start( /*==========*/ const rec_t* rec, /*!< in: pointer to record */ - const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ + const offset_t* offsets)/*!< in: array returned by rec_get_offsets() */ { ut_ad(rec_offs_validate(rec, NULL, offsets)); return(const_cast<rec_t*>(rec - rec_offs_extra_size(offsets))); @@ -1334,7 +1324,7 @@ rec_t* rec_copy( void* buf, const rec_t* rec, - const ulint* offsets) + const offset_t* offsets) { ulint extra_len; ulint data_len; @@ -1420,6 +1410,11 @@ rec_get_converted_size( data_size = dtuple_get_data_size(dtuple, 0); + /* If primary key is being updated then the new record inherits + externally stored fields from the delete-marked old record. + In that case, n_ext may be less value than + dtuple_get_n_ext(tuple). */ + ut_ad(n_ext <= dtuple_get_n_ext(dtuple)); extra_size = rec_get_converted_extra_size( data_size, dtuple_get_n_fields(dtuple), n_ext); diff --git a/storage/innobase/include/rem0types.h b/storage/innobase/include/rem0types.h index 38a5ba66f76..754781d62d1 100644 --- a/storage/innobase/include/rem0types.h +++ b/storage/innobase/include/rem0types.h @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2019, 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 @@ -29,6 +30,9 @@ Created 5/30/1994 Heikki Tuuri /* We define the physical record simply as an array of bytes */ typedef byte rec_t; +/** This type represents a field offset in a rec_t* */ +typedef unsigned short int offset_t; + /* Maximum values for various fields (for non-blob tuples) */ #define REC_MAX_N_FIELDS (1024 - 1) #define REC_MAX_HEAP_NO (2 * 8192 - 1) diff --git a/storage/innobase/include/row0ftsort.h b/storage/innobase/include/row0ftsort.h index b735576fbbb..9e5360625f4 100644 --- a/storage/innobase/include/row0ftsort.h +++ b/storage/innobase/include/row0ftsort.h @@ -30,6 +30,7 @@ Created 10/13/2010 Jimmy Yang #include "data0data.h" #include "fts0fts.h" #include "fts0priv.h" +#include "rem0types.h" #include "row0merge.h" #include "btr0bulk.h" @@ -250,7 +251,7 @@ row_merge_fts_sel_propagate( int* sel_tree, /*<! in: selection tree */ ulint level, /*<! in: selection tree level */ const mrec_t** mrec, /*<! in: sort record */ - ulint** offsets, /*<! in: record offsets */ + offset_t** offsets, /*<! in: record offsets */ dict_index_t* index); /*<! in: FTS index */ /********************************************************************//** Read sorted file containing index data tuples and insert these data diff --git a/storage/innobase/include/row0log.h b/storage/innobase/include/row0log.h index d6350705d55..e6f60345703 100644 --- a/storage/innobase/include/row0log.h +++ b/storage/innobase/include/row0log.h @@ -136,7 +136,7 @@ row_log_table_delete( page X-latched */ dict_index_t* index, /*!< in/out: clustered index, S-latched or X-latched */ - const ulint* offsets,/*!< in: rec_get_offsets(rec,index) */ + const offset_t* offsets,/*!< in: rec_get_offsets(rec,index) */ const byte* sys) /*!< in: DB_TRX_ID,DB_ROLL_PTR that should be logged, or NULL to use those in rec */ ATTRIBUTE_COLD __attribute__((nonnull(1,2,3))); @@ -151,7 +151,7 @@ row_log_table_update( page X-latched */ dict_index_t* index, /*!< in/out: clustered index, S-latched or X-latched */ - const ulint* offsets,/*!< in: rec_get_offsets(rec,index) */ + const offset_t* offsets,/*!< in: rec_get_offsets(rec,index) */ const dtuple_t* old_pk);/*!< in: row_log_table_get_pk() before the update */ @@ -167,7 +167,7 @@ row_log_table_get_pk( page X-latched */ dict_index_t* index, /*!< in/out: clustered index, S-latched or X-latched */ - const ulint* offsets,/*!< in: rec_get_offsets(rec,index), + const offset_t* offsets,/*!< in: rec_get_offsets(rec,index), or NULL */ byte* sys, /*!< out: DB_TRX_ID,DB_ROLL_PTR for row_log_table_delete(), or NULL */ @@ -184,7 +184,7 @@ row_log_table_insert( page X-latched */ dict_index_t* index, /*!< in/out: clustered index, S-latched or X-latched */ - const ulint* offsets);/*!< in: rec_get_offsets(rec,index) */ + const offset_t* offsets);/*!< in: rec_get_offsets(rec,index) */ /******************************************************//** Notes that a BLOB is being freed during online ALTER TABLE. */ void diff --git a/storage/innobase/include/row0merge.h b/storage/innobase/include/row0merge.h index 27bd19252ac..fd9050d0a48 100644 --- a/storage/innobase/include/row0merge.h +++ b/storage/innobase/include/row0merge.h @@ -489,7 +489,7 @@ row_merge_read_rec( const mrec_t** mrec, /*!< out: pointer to merge record, or NULL on end of list (non-NULL on I/O error) */ - ulint* offsets,/*!< out: offsets of mrec */ + offset_t* offsets,/*!< out: offsets of mrec */ row_merge_block_t* crypt_block, /*!< in: crypt buf or NULL */ ulint space) /*!< in: space id */ MY_ATTRIBUTE((warn_unused_result)); diff --git a/storage/innobase/include/row0row.h b/storage/innobase/include/row0row.h index afcae89a0ab..d4d979cdad5 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 @@ -44,7 +44,7 @@ ulint row_get_trx_id_offset( /*==================*/ const dict_index_t* index, /*!< in: clustered index */ - const ulint* offsets)/*!< in: record offsets */ + const offset_t* offsets)/*!< in: record offsets */ MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Reads the trx id field from a clustered index record. @@ -55,7 +55,7 @@ row_get_rec_trx_id( /*===============*/ const rec_t* rec, /*!< in: record */ const dict_index_t* index, /*!< in: clustered index */ - const ulint* offsets)/*!< in: rec_get_offsets(rec, index) */ + const offset_t* offsets)/*!< in: rec_get_offsets(rec, index) */ MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Reads the roll pointer field from a clustered index record. @@ -66,7 +66,7 @@ row_get_rec_roll_ptr( /*=================*/ const rec_t* rec, /*!< in: record */ const dict_index_t* index, /*!< in: clustered index */ - const ulint* offsets)/*!< in: rec_get_offsets(rec, index) */ + const offset_t* offsets)/*!< in: rec_get_offsets(rec, index) */ MY_ATTRIBUTE((nonnull, warn_unused_result)); /* Flags for row build type. */ @@ -138,7 +138,7 @@ row_build( this record must be at least s-latched and the latch held as long as the row dtuple is used! */ - const ulint* offsets,/*!< in: rec_get_offsets(rec,index) + const offset_t* offsets,/*!< in: rec_get_offsets(rec,index) or NULL, in which case this function will invoke rec_get_offsets() */ const dict_table_t* col_table, @@ -189,7 +189,7 @@ row_build_w_add_vcol( ulint type, const dict_index_t* index, const rec_t* rec, - const ulint* offsets, + const offset_t* offsets, const dict_table_t* col_table, const dtuple_t* defaults, const dict_add_v_col_t* add_v, @@ -206,9 +206,7 @@ row_rec_to_index_entry_low( /*=======================*/ const rec_t* rec, /*!< in: record in the index */ const dict_index_t* index, /*!< in: index */ - const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */ - ulint* n_ext, /*!< out: number of externally - stored columns */ + const offset_t* offsets,/*!< in: rec_get_offsets(rec, index) */ mem_heap_t* heap) /*!< in: memory heap from which the memory needed is allocated */ MY_ATTRIBUTE((warn_unused_result)); @@ -221,9 +219,7 @@ row_rec_to_index_entry( /*===================*/ const rec_t* rec, /*!< in: record in the index */ const dict_index_t* index, /*!< in: index */ - const ulint* offsets,/*!< in/out: rec_get_offsets(rec) */ - ulint* n_ext, /*!< out: number of externally - stored columns */ + const offset_t* offsets,/*!< in/out: rec_get_offsets(rec) */ mem_heap_t* heap) /*!< in: memory heap from which the memory needed is allocated */ MY_ATTRIBUTE((warn_unused_result)); @@ -266,7 +262,7 @@ row_build_row_ref_in_tuple( held as long as the row reference is used! */ const dict_index_t* index, /*!< in: secondary index */ - ulint* offsets)/*!< in: rec_get_offsets(rec, index) + offset_t* offsets)/*!< in: rec_get_offsets(rec, index) or NULL */ MY_ATTRIBUTE((nonnull(1,2,3))); /*******************************************************************//** @@ -284,7 +280,7 @@ row_build_row_ref_fast( const rec_t* rec, /*!< in: secondary index record; must be preserved while ref is used, as we do not copy field values to heap */ - const ulint* offsets);/*!< in: array returned by rec_get_offsets() */ + const offset_t* offsets);/*!< in: array returned by rec_get_offsets() */ /***************************************************************//** Searches the clustered index record for a row, if we have the row reference. diff --git a/storage/innobase/include/row0row.ic b/storage/innobase/include/row0row.ic index 4e3cf58cfc5..14f9f47ba7e 100644 --- a/storage/innobase/include/row0row.ic +++ b/storage/innobase/include/row0row.ic @@ -37,7 +37,7 @@ ulint row_get_trx_id_offset( /*==================*/ const dict_index_t* index, /*!< in: clustered index */ - const ulint* offsets)/*!< in: record offsets */ + const offset_t* offsets)/*!< in: record offsets */ { ulint pos; ulint offset; @@ -64,7 +64,7 @@ row_get_rec_trx_id( /*===============*/ const rec_t* rec, /*!< in: record */ const dict_index_t* index, /*!< in: clustered index */ - const ulint* offsets)/*!< in: rec_get_offsets(rec, index) */ + const offset_t* offsets)/*!< in: rec_get_offsets(rec, index) */ { ulint offset; @@ -89,7 +89,7 @@ row_get_rec_roll_ptr( /*=================*/ const rec_t* rec, /*!< in: record */ const dict_index_t* index, /*!< in: clustered index */ - const ulint* offsets)/*!< in: rec_get_offsets(rec, index) */ + const offset_t* offsets)/*!< in: rec_get_offsets(rec, index) */ { ulint offset; @@ -148,7 +148,7 @@ row_build_row_ref_fast( const rec_t* rec, /*!< in: secondary index record; must be preserved while ref is used, as we do not copy field values to heap */ - const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ + const offset_t* offsets)/*!< in: array returned by rec_get_offsets() */ { dfield_t* dfield; const byte* field; diff --git a/storage/innobase/include/row0upd.h b/storage/innobase/include/row0upd.h index 7d716f960c5..51ed7a7f006 100644 --- a/storage/innobase/include/row0upd.h +++ b/storage/innobase/include/row0upd.h @@ -28,6 +28,7 @@ Created 12/27/1996 Heikki Tuuri #define row0upd_h #include "data0data.h" +#include "rem0types.h" #include "row0types.h" #include "btr0types.h" #include "trx0types.h" @@ -123,7 +124,7 @@ row_upd_rec_sys_fields( page_zip_des_t* page_zip,/*!< in/out: compressed page whose uncompressed part will be updated, or NULL */ dict_index_t* index, /*!< in: clustered index */ - const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */ + const offset_t* offsets,/*!< in: rec_get_offsets(rec, index) */ const trx_t* trx, /*!< in: transaction */ roll_ptr_t roll_ptr);/*!< in: DB_ROLL_PTR to the undo log */ /*********************************************************************//** @@ -165,7 +166,7 @@ ibool row_upd_changes_field_size_or_external( /*===================================*/ dict_index_t* index, /*!< in: index */ - const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */ + const offset_t* offsets,/*!< in: rec_get_offsets(rec, index) */ const upd_t* update);/*!< in: update vector */ /***********************************************************//** Returns true if row update contains disowned external fields. @@ -186,7 +187,7 @@ row_upd_rec_in_place( /*=================*/ rec_t* rec, /*!< in/out: record where replaced */ dict_index_t* index, /*!< in: the index the record belongs to */ - const ulint* offsets,/*!< in: array returned by rec_get_offsets() */ + const offset_t* offsets,/*!< in: array returned by rec_get_offsets() */ const upd_t* update, /*!< in: update vector */ page_zip_des_t* page_zip);/*!< in: compressed page with enough space available, or NULL */ @@ -201,7 +202,7 @@ row_upd_build_sec_rec_difference_binary( /*====================================*/ const rec_t* rec, /*!< in: secondary index record */ dict_index_t* index, /*!< in: index */ - const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */ + const offset_t* offsets,/*!< in: rec_get_offsets(rec, index) */ const dtuple_t* entry, /*!< in: entry to insert */ mem_heap_t* heap) /*!< in: memory heap from which allocated */ MY_ATTRIBUTE((warn_unused_result, nonnull)); @@ -227,7 +228,7 @@ row_upd_build_difference_binary( dict_index_t* index, const dtuple_t* entry, const rec_t* rec, - const ulint* offsets, + const offset_t* offsets, bool no_sys, trx_t* trx, mem_heap_t* heap, @@ -399,7 +400,7 @@ row_upd_rec_sys_fields_in_recovery( /*===============================*/ rec_t* rec, /*!< in/out: record */ page_zip_des_t* page_zip,/*!< in/out: compressed page, or NULL */ - const ulint* offsets,/*!< in: array returned by rec_get_offsets() */ + const offset_t* offsets,/*!< in: array returned by rec_get_offsets() */ ulint pos, /*!< in: TRX_ID position in rec */ trx_id_t trx_id, /*!< in: transaction id */ roll_ptr_t roll_ptr);/*!< in: roll ptr of the undo log record */ diff --git a/storage/innobase/include/row0upd.ic b/storage/innobase/include/row0upd.ic index 0a6c33653a0..c8e72f45491 100644 --- a/storage/innobase/include/row0upd.ic +++ b/storage/innobase/include/row0upd.ic @@ -163,7 +163,7 @@ row_upd_rec_sys_fields( page_zip_des_t* page_zip,/*!< in/out: compressed page whose uncompressed part will be updated, or NULL */ dict_index_t* index, /*!< in: clustered index */ - const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */ + const offset_t* offsets,/*!< in: rec_get_offsets(rec, index) */ const trx_t* trx, /*!< in: transaction */ roll_ptr_t roll_ptr)/*!< in: DB_ROLL_PTR to the undo log */ { diff --git a/storage/innobase/include/row0vers.h b/storage/innobase/include/row0vers.h index 948804beafc..0603f7c894c 100644 --- a/storage/innobase/include/row0vers.h +++ b/storage/innobase/include/row0vers.h @@ -52,7 +52,7 @@ row_vers_impl_x_locked( trx_t* caller_trx, const rec_t* rec, dict_index_t* index, - const ulint* offsets); + const offset_t* offsets); /** Finds out if a version of the record, where the version >= the current purge view, should have ientry as its secondary index entry. We check @@ -98,7 +98,7 @@ row_vers_build_for_consistent_read( mtr_t* mtr, /*!< in: mtr holding the latch on rec; it will also hold the latch on purge_view */ dict_index_t* index, /*!< in: the clustered index */ - ulint** offsets,/*!< in/out: offsets returned by + offset_t** offsets,/*!< in/out: offsets returned by rec_get_offsets(rec, index) */ ReadView* view, /*!< in: the consistent read view */ mem_heap_t** offset_heap,/*!< in/out: memory heap from which @@ -126,7 +126,7 @@ row_vers_build_for_semi_consistent_read( of this records */ mtr_t* mtr, /*!< in: mtr holding the latch on rec */ dict_index_t* index, /*!< in: the clustered index */ - ulint** offsets,/*!< in/out: offsets returned by + offset_t** offsets,/*!< in/out: offsets returned by rec_get_offsets(rec, index) */ mem_heap_t** offset_heap,/*!< in/out: memory heap from which the offsets are allocated */ diff --git a/storage/innobase/include/trx0rec.h b/storage/innobase/include/trx0rec.h index f169dd8871e..e2c2fbd8204 100644 --- a/storage/innobase/include/trx0rec.h +++ b/storage/innobase/include/trx0rec.h @@ -191,7 +191,7 @@ trx_undo_report_row_operation( const rec_t* rec, /*!< in: case of an update or delete marking, the record in the clustered index; NULL if insert */ - const ulint* offsets, /*!< in: rec_get_offsets(rec) */ + const offset_t* offsets, /*!< in: rec_get_offsets(rec) */ roll_ptr_t* roll_ptr) /*!< out: DB_ROLL_PTR to the undo log record */ MY_ATTRIBUTE((nonnull(1,2,8), warn_unused_result)); @@ -224,7 +224,7 @@ trx_undo_prev_version_build( index_rec page and purge_view */ const rec_t* rec, /*!< in: version of a clustered index record */ dict_index_t* index, /*!< in: clustered index */ - ulint* offsets,/*!< in/out: rec_get_offsets(rec, index) */ + offset_t* offsets,/*!< in/out: rec_get_offsets(rec, index) */ mem_heap_t* heap, /*!< in: memory heap from which the memory needed is allocated */ rec_t** old_vers,/*!< out, own: previous version, or NULL if diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h index da690a3c65e..8cd4d2018c6 100644 --- a/storage/innobase/include/trx0trx.h +++ b/storage/innobase/include/trx0trx.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 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 @@ -342,13 +342,6 @@ bool trx_is_interrupted( /*===============*/ const trx_t* trx); /*!< in: transaction */ -/**********************************************************************//** -Determines if the currently running transaction is in strict mode. -@return TRUE if strict */ -ibool -trx_is_strict( -/*==========*/ - trx_t* trx); /*!< in: transaction */ /*******************************************************************//** Calculates the "weight" of a transaction. The weight of one transaction diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i index 19a03009ad5..ab30024116e 100644 --- a/storage/innobase/include/univ.i +++ b/storage/innobase/include/univ.i @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2019, MariaDB Corporation. +Copyright (c) 2013, 2020, MariaDB Corporation. Copyright (c) 2008, Google Inc. Portions of this file contain modifications contributed and copyrighted by diff --git a/storage/innobase/include/ut0rnd.h b/storage/innobase/include/ut0rnd.h index e8604ffa1c3..9af8687bfd0 100644 --- a/storage/innobase/include/ut0rnd.h +++ b/storage/innobase/include/ut0rnd.h @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2019, 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 @@ -27,37 +28,49 @@ Created 1/20/1994 Heikki Tuuri #define ut0rnd_h #include "ut0byte.h" +#include <my_sys.h> #ifndef UNIV_INNOCHECKSUM -/** The 'character code' for end of field or string (used -in folding records */ -#define UT_END_OF_FIELD 257 +/** Seed value of ut_rnd_gen() */ +extern int32 ut_rnd_current; + +/** @return a pseudo-random 32-bit number */ +inline uint32_t ut_rnd_gen() +{ + /* This is a Galois linear-feedback shift register. + https://en.wikipedia.org/wiki/Linear-feedback_shift_register#Galois_LFSRs + The generating primitive Galois Field polynomial is the Castagnoli + polynomial that was made popular by CRC-32C: + x^32+x^28+x^27+x^26+x^25+x^23+x^22+x^20+ + x^19+x^18+x^14+x^13+x^11+x^10+x^9+x^8+x^6+1 */ + const uint32_t crc32c= 0x1edc6f41; + + uint32_t rnd= my_atomic_load32_explicit(&ut_rnd_current, + MY_MEMORY_ORDER_RELAXED); + + if (UNIV_UNLIKELY(rnd == 0)) + { + rnd= static_cast<uint32_t>(my_interval_timer()); + if (!rnd) rnd= 1; + } + else + { + bool lsb= rnd & 1; + rnd>>= 1; + if (lsb) + rnd^= crc32c; + } + + my_atomic_store32_explicit(&ut_rnd_current, rnd, MY_MEMORY_ORDER_RELAXED); + return rnd; +} + +/** @return a random number between 0 and n-1, inclusive */ +inline ulint ut_rnd_interval(ulint n) +{ + return n > 1 ? static_cast<ulint>(ut_rnd_gen() % n) : 0; +} -/********************************************************//** -This is used to set the random number seed. */ -UNIV_INLINE -void -ut_rnd_set_seed( -/*============*/ - ulint seed); /*!< in: seed */ -/********************************************************//** -The following function generates a series of 'random' ulint integers. -@return the next 'random' number */ -UNIV_INLINE -ulint -ut_rnd_gen_next_ulint( -/*==================*/ - ulint rnd); /*!< in: the previous random number value */ -/*********************************************************//** -The following function generates 'random' ulint integers which -enumerate the value space (let there be N of them) of ulint integers -in a pseudo-random fashion. Note that the same integer is repeated -always after N calls to the generator. -@return the 'random' number */ -UNIV_INLINE -ulint -ut_rnd_gen_ulint(void); -/*==================*/ /*******************************************************//** The following function generates a hash value for a ulint integer to a hash table of size table_size, which should be a prime or some diff --git a/storage/innobase/include/ut0rnd.ic b/storage/innobase/include/ut0rnd.ic index 2516d20f296..c0105160a42 100644 --- a/storage/innobase/include/ut0rnd.ic +++ b/storage/innobase/include/ut0rnd.ic @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, MariaDB Corporation. +Copyright (c) 2017, 2019, 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 @@ -29,74 +29,6 @@ Created 5/30/1994 Heikki Tuuri #ifndef UNIV_INNOCHECKSUM -#define UT_RND1 151117737 -#define UT_RND2 119785373 -#define UT_RND3 85689495 -#define UT_RND4 76595339 -#define UT_SUM_RND2 98781234 -#define UT_SUM_RND3 126792457 -#define UT_SUM_RND4 63498502 -#define UT_XOR_RND1 187678878 -#define UT_XOR_RND2 143537923 - -/** Seed value of ut_rnd_gen_ulint() */ -extern ulint ut_rnd_ulint_counter; - -/********************************************************//** -This is used to set the random number seed. */ -UNIV_INLINE -void -ut_rnd_set_seed( -/*============*/ - ulint seed) /*!< in: seed */ -{ - ut_rnd_ulint_counter = seed; -} - -/********************************************************//** -The following function generates a series of 'random' ulint integers. -@return the next 'random' number */ -UNIV_INLINE -ulint -ut_rnd_gen_next_ulint( -/*==================*/ - ulint rnd) /*!< in: the previous random number value */ -{ - ulint n_bits; - - n_bits = 8 * sizeof(ulint); - - rnd = UT_RND2 * rnd + UT_SUM_RND3; - rnd = UT_XOR_RND1 ^ rnd; - rnd = (rnd << 20) + (rnd >> (n_bits - 20)); - rnd = UT_RND3 * rnd + UT_SUM_RND4; - rnd = UT_XOR_RND2 ^ rnd; - rnd = (rnd << 20) + (rnd >> (n_bits - 20)); - rnd = UT_RND1 * rnd + UT_SUM_RND2; - - return(rnd); -} - -/********************************************************//** -The following function generates 'random' ulint integers which -enumerate the value space of ulint integers in a pseudo random -fashion. Note that the same integer is repeated always after -2 to power 32 calls to the generator (if ulint is 32-bit). -@return the 'random' number */ -UNIV_INLINE -ulint -ut_rnd_gen_ulint(void) -/*==================*/ -{ - ulint rnd; - - ut_rnd_ulint_counter = UT_RND1 * ut_rnd_ulint_counter + UT_RND2; - - rnd = ut_rnd_gen_next_ulint(ut_rnd_ulint_counter); - - return(rnd); -} - /*******************************************************//** The following function generates a hash value for a ulint integer to a hash table of size table_size, which should be a prime |