diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2017-09-21 08:12:19 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2017-09-21 08:12:19 +0300 |
commit | e3d44f5d62672478c40294d6e46d9f066e418cac (patch) | |
tree | 44b4d1b9d94ced780d4f369f84eddc36791470be /storage/innobase/include | |
parent | d176be8aeaecdb20a963fbd126929ddcd5bd98f3 (diff) | |
parent | f70865bc9e540767d8afc3cc2cbe0e1c92a8c0be (diff) | |
download | mariadb-git-e3d44f5d62672478c40294d6e46d9f066e418cac.tar.gz |
Merge bb-10.2-ext into 10.3
Diffstat (limited to 'storage/innobase/include')
-rw-r--r-- | storage/innobase/include/data0data.h | 10 | ||||
-rw-r--r-- | storage/innobase/include/dict0dict.h | 30 | ||||
-rw-r--r-- | storage/innobase/include/dict0dict.ic | 14 | ||||
-rw-r--r-- | storage/innobase/include/dict0mem.h | 4 | ||||
-rw-r--r-- | storage/innobase/include/gis0rtree.ic | 3 | ||||
-rw-r--r-- | storage/innobase/include/ha_prototypes.h | 1 | ||||
-rw-r--r-- | storage/innobase/include/page0cur.ic | 4 | ||||
-rw-r--r-- | storage/innobase/include/page0page.h | 318 | ||||
-rw-r--r-- | storage/innobase/include/page0page.ic | 240 | ||||
-rw-r--r-- | storage/innobase/include/rem0rec.h | 71 |
10 files changed, 281 insertions, 414 deletions
diff --git a/storage/innobase/include/data0data.h b/storage/innobase/include/data0data.h index 87a2228ff2d..b6187d46025 100644 --- a/storage/innobase/include/data0data.h +++ b/storage/innobase/include/data0data.h @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2017, 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 @@ -586,11 +587,10 @@ struct dfield_t{ unsigned len; /*!< data length; UNIV_SQL_NULL if SQL null */ dtype_t type; /*!< type of data */ - /** Create a deep copy of this object - @param[in] heap the memory heap in which the clone will be - created. - @return the cloned object. */ - dfield_t* clone(mem_heap_t* heap); + /** Create a deep copy of this object. + @param[in,out] heap memory heap in which the clone will be created + @return the cloned object */ + dfield_t* clone(mem_heap_t* heap) const; }; /** Structure for an SQL data tuple of fields (logical record) */ diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h index 7802366a149..ace0029e632 100644 --- a/storage/innobase/include/dict0dict.h +++ b/storage/innobase/include/dict0dict.h @@ -1451,17 +1451,31 @@ dict_index_copy_rec_order_prefix( copied prefix, or NULL */ ulint* buf_size)/*!< in/out: buffer size */ MY_ATTRIBUTE((nonnull, warn_unused_result)); -/**********************************************************************//** -Builds a typed data tuple out of a physical record. +/** Convert a physical record into a search tuple. +@param[in] rec index record (not necessarily in an index page) +@param[in] index index +@param[in] leaf whether rec is in a leaf page +@param[in] n_fields number of data fields +@param[in,out] heap memory heap for allocation @return own: data tuple */ dtuple_t* -dict_index_build_data_tuple( -/*========================*/ - dict_index_t* index, /*!< in: index */ - rec_t* rec, /*!< in: record for which to build data tuple */ - ulint n_fields,/*!< in: number of data fields */ - mem_heap_t* heap) /*!< in: memory heap where tuple created */ +dict_index_build_data_tuple_func( + const rec_t* rec, + const dict_index_t* index, +#ifdef UNIV_DEBUG + bool leaf, +#endif /* UNIV_DEBUG */ + ulint n_fields, + mem_heap_t* heap) MY_ATTRIBUTE((nonnull, warn_unused_result)); +#ifdef UNIV_DEBUG +# define dict_index_build_data_tuple(rec, index, leaf, n_fields, heap) \ + dict_index_build_data_tuple_func(rec, index, leaf, n_fields, heap) +#else /* UNIV_DEBUG */ +# define dict_index_build_data_tuple(rec, index, leaf, n_fields, heap) \ + dict_index_build_data_tuple_func(rec, index, n_fields, heap) +#endif /* UNIV_DEBUG */ + /*********************************************************************//** Gets the space id of the root of the index tree. @return space id */ diff --git a/storage/innobase/include/dict0dict.ic b/storage/innobase/include/dict0dict.ic index 9220e46e759..62561c8af4f 100644 --- a/storage/innobase/include/dict0dict.ic +++ b/storage/innobase/include/dict0dict.ic @@ -327,20 +327,6 @@ dict_index_is_unique( } /********************************************************************//** -Check whether the index is an universal index tree. -@return nonzero for universal tree, zero for other indexes */ -UNIV_INLINE -ulint -dict_index_is_univ( -/*===============*/ - const dict_index_t* index) /*!< in: index */ -{ - ut_ad(index->magic_n == DICT_INDEX_MAGIC_N); - - return(index->type & DICT_UNIVERSAL); -} - -/********************************************************************//** Check whether the index is a Spatial Index. @return nonzero for Spatial Index, zero for other indexes */ UNIV_INLINE diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h index 0155d1d5d20..034729e1595 100644 --- a/storage/innobase/include/dict0mem.h +++ b/storage/innobase/include/dict0mem.h @@ -66,8 +66,6 @@ combination of types */ auto-generated clustered indexes, also DICT_UNIQUE will be set */ #define DICT_UNIQUE 2 /*!< unique index */ -#define DICT_UNIVERSAL 4 /*!< index which can contain records from any - other index */ #define DICT_IBUF 8 /*!< insert buffer tree */ #define DICT_CORRUPT 16 /*!< bit to store the corrupted flag in SYS_INDEXES.TYPE */ @@ -864,6 +862,8 @@ struct dict_index_t{ data dictionary yet */ #ifdef UNIV_DEBUG + /** whether this is a dummy index object */ + bool is_dummy; uint32_t magic_n;/*!< magic number */ /** Value of dict_index_t::magic_n */ # define DICT_INDEX_MAGIC_N 76789786 diff --git a/storage/innobase/include/gis0rtree.ic b/storage/innobase/include/gis0rtree.ic index 7f64a9b13a1..e852ebd8028 100644 --- a/storage/innobase/include/gis0rtree.ic +++ b/storage/innobase/include/gis0rtree.ic @@ -57,7 +57,8 @@ rtr_page_cal_mbr( page = buf_block_get_frame(block); rec = page_rec_get_next(page_get_infimum_rec(page)); - offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, &heap); + offsets = rec_get_offsets(rec, index, offsets, page_is_leaf(page), + ULINT_UNDEFINED, &heap); do { /* The mbr address is in the first field. */ diff --git a/storage/innobase/include/ha_prototypes.h b/storage/innobase/include/ha_prototypes.h index 7b3726b1fef..459304fc712 100644 --- a/storage/innobase/include/ha_prototypes.h +++ b/storage/innobase/include/ha_prototypes.h @@ -43,7 +43,6 @@ class THD; #undef MYSQL_PFS #undef MYSQL_RENAME_INDEX #undef MYSQL_REPLACE_TRX_IN_THD -#undef MYSQL_SPATIAL_INDEX #undef MYSQL_STORE_FTS_DOC_ID /*******************************************************************//** diff --git a/storage/innobase/include/page0cur.ic b/storage/innobase/include/page0cur.ic index 5eb1bc0cbc5..3e6d40cba4a 100644 --- a/storage/innobase/include/page0cur.ic +++ b/storage/innobase/include/page0cur.ic @@ -280,7 +280,9 @@ page_cur_tuple_insert( rec = rec_convert_dtuple_to_rec((byte*) mem_heap_alloc(*heap, size), index, tuple, n_ext); - *offsets = rec_get_offsets(rec, index, *offsets, ULINT_UNDEFINED, heap); + *offsets = rec_get_offsets(rec, index, *offsets, + page_is_leaf(cursor->block->frame), + ULINT_UNDEFINED, heap); if (buf_block_get_page_zip(cursor->block)) { rec = page_cur_insert_rec_zip( diff --git a/storage/innobase/include/page0page.h b/storage/innobase/include/page0page.h index 9243bcaa717..3b6a0215249 100644 --- a/storage/innobase/include/page0page.h +++ b/storage/innobase/include/page0page.h @@ -167,25 +167,196 @@ directory. */ #define PAGE_DIR_SLOT_MIN_N_OWNED 4 extern my_bool srv_immediate_scrub_data_uncompressed; +#endif /* UNIV_INNOCHECKSUM */ -/************************************************************//** -Gets the start of a page. -@return start of the page */ -UNIV_INLINE +/** Get the start of a page frame. +@param[in] ptr pointer within a page frame +@return start of the page frame */ +MY_ATTRIBUTE((const)) +inline page_t* -page_align( -/*=======*/ - const void* ptr) /*!< in: pointer to page frame */ - MY_ATTRIBUTE((const)); -/************************************************************//** -Gets the offset within a page. +page_align(const void* ptr) +{ + return(static_cast<page_t*>(ut_align_down(ptr, UNIV_PAGE_SIZE))); +} + +/** Gets the byte offset within a page frame. +@param[in] ptr pointer within a page frame @return offset from the start of the page */ -UNIV_INLINE +MY_ATTRIBUTE((const)) +inline ulint -page_offset( -/*========*/ - const void* ptr) /*!< in: pointer to page frame */ - MY_ATTRIBUTE((const)); +page_offset(const void* ptr) +{ + return(ut_align_offset(ptr, UNIV_PAGE_SIZE)); +} + +/** Determine whether an index page is not in ROW_FORMAT=REDUNDANT. +@param[in] page index page +@return nonzero if ROW_FORMAT is one of COMPACT,DYNAMIC,COMPRESSED +@retval 0 if ROW_FORMAT=REDUNDANT */ +inline +byte +page_is_comp(const page_t* page) +{ + ut_ad(!ut_align_offset(page, UNIV_ZIP_SIZE_MIN)); + return(page[PAGE_HEADER + PAGE_N_HEAP] & 0x80); +} + +/** Determine whether an index page is empty. +@param[in] page index page +@return whether the page is empty (PAGE_N_RECS = 0) */ +inline +bool +page_is_empty(const page_t* page) +{ + ut_ad(!ut_align_offset(page, UNIV_ZIP_SIZE_MIN)); + return !*reinterpret_cast<const uint16_t*>(PAGE_HEADER + PAGE_N_RECS + + page); +} + +/** Determine whether an index page contains garbage. +@param[in] page index page +@return whether the page contains garbage (PAGE_GARBAGE is not 0) */ +inline +bool +page_has_garbage(const page_t* page) +{ + ut_ad(!ut_align_offset(page, UNIV_ZIP_SIZE_MIN)); + return *reinterpret_cast<const uint16_t*>(PAGE_HEADER + PAGE_GARBAGE + + page); +} + +/** Determine whether an B-tree or R-tree index page is a leaf page. +@param[in] page index page +@return true if the page is a leaf (PAGE_LEVEL = 0) */ +inline +bool +page_is_leaf(const page_t* page) +{ + ut_ad(!ut_align_offset(page, UNIV_ZIP_SIZE_MIN)); + return !*reinterpret_cast<const uint16_t*>(PAGE_HEADER + PAGE_LEVEL + + page); +} + +#ifndef UNIV_INNOCHECKSUM +/** Determine whether an index page record is not in ROW_FORMAT=REDUNDANT. +@param[in] rec record in an index page frame (not a copy) +@return nonzero if ROW_FORMAT is one of COMPACT,DYNAMIC,COMPRESSED +@retval 0 if ROW_FORMAT=REDUNDANT */ +inline +byte +page_rec_is_comp(const byte* rec) +{ + return(page_is_comp(page_align(rec))); +} + +/** Determine the offset of the infimum record on the page. +@param[in] page index page +@return offset of the infimum record in record list, relative from page */ +inline +unsigned +page_get_infimum_offset(const page_t* page) +{ + ut_ad(!page_offset(page)); + return page_is_comp(page) ? PAGE_NEW_INFIMUM : PAGE_OLD_INFIMUM; +} + +/** Determine the offset of the supremum record on the page. +@param[in] page index page +@return offset of the supremum record in record list, relative from page */ +inline +unsigned +page_get_supremum_offset(const page_t* page) +{ + ut_ad(!page_offset(page)); + return page_is_comp(page) ? PAGE_NEW_SUPREMUM : PAGE_OLD_SUPREMUM; +} + +/** Determine whether an index page record is a user record. +@param[in] offset record offset in the page +@retval true if a user record +@retval false if the infimum or supremum pseudo-record */ +inline +bool +page_rec_is_user_rec_low(ulint offset) +{ + compile_time_assert(PAGE_OLD_INFIMUM >= PAGE_NEW_INFIMUM); + compile_time_assert(PAGE_OLD_SUPREMUM >= PAGE_NEW_SUPREMUM); + compile_time_assert(PAGE_NEW_INFIMUM < PAGE_OLD_SUPREMUM); + compile_time_assert(PAGE_OLD_INFIMUM < PAGE_NEW_SUPREMUM); + compile_time_assert(PAGE_NEW_SUPREMUM < PAGE_OLD_SUPREMUM_END); + compile_time_assert(PAGE_OLD_SUPREMUM < PAGE_NEW_SUPREMUM_END); + ut_ad(offset >= PAGE_NEW_INFIMUM); + ut_ad(offset <= UNIV_PAGE_SIZE - PAGE_EMPTY_DIR_START); + + return(offset != PAGE_NEW_SUPREMUM + && offset != PAGE_NEW_INFIMUM + && offset != PAGE_OLD_INFIMUM + && offset != PAGE_OLD_SUPREMUM); +} + +/** Determine if a record is the supremum record on an index page. +@param[in] offset record offset in an index page +@return true if the supremum record */ +inline +bool +page_rec_is_supremum_low(ulint offset) +{ + ut_ad(offset >= PAGE_NEW_INFIMUM); + ut_ad(offset <= UNIV_PAGE_SIZE - PAGE_EMPTY_DIR_START); + return(offset == PAGE_NEW_SUPREMUM || offset == PAGE_OLD_SUPREMUM); +} + +/** Determine if a record is the infimum record on an index page. +@param[in] offset record offset in an index page +@return true if the infimum record */ +inline +bool +page_rec_is_infimum_low(ulint offset) +{ + ut_ad(offset >= PAGE_NEW_INFIMUM); + ut_ad(offset <= UNIV_PAGE_SIZE - PAGE_EMPTY_DIR_START); + return(offset == PAGE_NEW_INFIMUM || offset == PAGE_OLD_INFIMUM); +} + +/** Determine whether an B-tree or R-tree index record is in a leaf page. +@param[in] rec index record in an index page +@return true if the record is in a leaf page */ +inline +bool +page_rec_is_leaf(const page_t* rec) +{ + const page_t* page = page_align(rec); + ut_ad(rec - page >= page_get_infimum_offset(page)); + bool leaf = page_is_leaf(page); + ut_ad(!page_rec_is_comp(rec) + || !page_rec_is_user_rec_low(rec - page) + || leaf == !rec_get_node_ptr_flag(rec)); + return leaf; +} + +/** Determine whether an index page record is a user record. +@param[in] rec record in an index page +@return true if a user record */ +inline +bool +page_rec_is_user_rec(const rec_t* rec); + +/** Determine whether an index page record is the supremum record. +@param[in] rec record in an index page +@return true if the supremum record */ +inline +bool +page_rec_is_supremum(const rec_t* rec); + +/** Determine whether an index page record is the infimum record. +@param[in] rec record in an index page +@return true if the infimum record */ +inline +bool +page_rec_is_infimum(const rec_t* rec); + /*************************************************************//** Returns the max trx id field value. */ UNIV_INLINE @@ -321,22 +492,6 @@ page_header_reset_last_insert( page_zip_des_t* page_zip,/*!< in/out: compressed page whose uncompressed part will be updated, or NULL */ mtr_t* mtr); /*!< in: mtr */ -/************************************************************//** -Gets the offset of the first record on the page. -@return offset of the first record in record list, relative from page */ -UNIV_INLINE -ulint -page_get_infimum_offset( -/*====================*/ - const page_t* page); /*!< in: page which must have record(s) */ -/************************************************************//** -Gets the offset of the last record on the page. -@return offset of the last record in record list, relative from page */ -UNIV_INLINE -ulint -page_get_supremum_offset( -/*=====================*/ - const page_t* page); /*!< in: page which must have record(s) */ #define page_get_infimum_rec(page) ((page) + page_get_infimum_offset(page)) #define page_get_supremum_rec(page) ((page) + page_get_supremum_offset(page)) @@ -522,23 +677,7 @@ ulint page_dir_find_owner_slot( /*=====================*/ const rec_t* rec); /*!< in: the physical record */ -/************************************************************//** -Determine whether the page is in new-style compact format. -@return nonzero if the page is in compact format, zero if it is in -old-style format */ -UNIV_INLINE -ulint -page_is_comp( -/*=========*/ - const page_t* page); /*!< in: index page */ -/************************************************************//** -TRUE if the record is on a page in compact format. -@return nonzero if in compact format */ -UNIV_INLINE -ulint -page_rec_is_comp( -/*=============*/ - const rec_t* rec); /*!< in: record */ + /***************************************************************//** Returns the heap number of a record. @return heap number */ @@ -547,24 +686,6 @@ ulint page_rec_get_heap_no( /*=================*/ const rec_t* rec); /*!< in: the physical record */ -/************************************************************//** -Determine whether the page is a B-tree leaf. -@return true if the page is a B-tree leaf (PAGE_LEVEL = 0) */ -UNIV_INLINE -bool -page_is_leaf( -/*=========*/ - const page_t* page) /*!< in: page */ - MY_ATTRIBUTE((warn_unused_result)); -/************************************************************//** -Determine whether the page is empty. -@return true if the page is empty (PAGE_N_RECS = 0) */ -UNIV_INLINE -bool -page_is_empty( -/*==========*/ - const page_t* page) /*!< in: page */ - MY_ATTRIBUTE((warn_unused_result)); /** Determine whether a page is an index root page. @param[in] page page frame @return true if the page is a root page of an index */ @@ -574,15 +695,6 @@ page_is_root( const page_t* page) MY_ATTRIBUTE((warn_unused_result)); /************************************************************//** -Determine whether the page contains garbage. -@return true if the page contains garbage (PAGE_GARBAGE is not 0) */ -UNIV_INLINE -bool -page_has_garbage( -/*=============*/ - const page_t* page) /*!< in: page */ - MY_ATTRIBUTE((warn_unused_result)); -/************************************************************//** Gets the pointer to the next record on the page. @return pointer to next record */ UNIV_INLINE @@ -645,62 +757,6 @@ page_rec_get_prev( /*==============*/ rec_t* rec); /*!< in: pointer to record, must not be page infimum */ -/************************************************************//** -TRUE if the record is a user record on the page. -@return TRUE if a user record */ -UNIV_INLINE -ibool -page_rec_is_user_rec_low( -/*=====================*/ - ulint offset) /*!< in: record offset on page */ - MY_ATTRIBUTE((const)); -/************************************************************//** -TRUE if the record is the supremum record on a page. -@return TRUE if the supremum record */ -UNIV_INLINE -ibool -page_rec_is_supremum_low( -/*=====================*/ - ulint offset) /*!< in: record offset on page */ - MY_ATTRIBUTE((const)); -/************************************************************//** -TRUE if the record is the infimum record on a page. -@return TRUE if the infimum record */ -UNIV_INLINE -ibool -page_rec_is_infimum_low( -/*====================*/ - ulint offset) /*!< in: record offset on page */ - MY_ATTRIBUTE((const)); - -/************************************************************//** -TRUE if the record is a user record on the page. -@return TRUE if a user record */ -UNIV_INLINE -ibool -page_rec_is_user_rec( -/*=================*/ - const rec_t* rec) /*!< in: record */ - MY_ATTRIBUTE((warn_unused_result)); -/************************************************************//** -TRUE if the record is the supremum record on a page. -@return TRUE if the supremum record */ -UNIV_INLINE -ibool -page_rec_is_supremum( -/*=================*/ - const rec_t* rec) /*!< in: record */ - MY_ATTRIBUTE((warn_unused_result)); - -/************************************************************//** -TRUE if the record is the infimum record on a page. -@return TRUE if the infimum record */ -UNIV_INLINE -ibool -page_rec_is_infimum( -/*================*/ - const rec_t* rec) /*!< in: record */ - MY_ATTRIBUTE((warn_unused_result)); /************************************************************//** true if the record is the first user record on a page. diff --git a/storage/innobase/include/page0page.ic b/storage/innobase/include/page0page.ic index db98f2e6558..0062db56bfa 100644 --- a/storage/innobase/include/page0page.ic +++ b/storage/innobase/include/page0page.ic @@ -40,32 +40,7 @@ Created 2/2/1994 Heikki Tuuri #undef UNIV_INLINE #define UNIV_INLINE #endif -#endif /* !UNIV_INNOCHECKSUM */ -/************************************************************//** -Gets the start of a page. -@return start of the page */ -UNIV_INLINE -page_t* -page_align( -/*=======*/ - const void* ptr) /*!< in: pointer to page frame */ -{ - return((page_t*) ut_align_down(ptr, UNIV_PAGE_SIZE)); -} - -#ifndef UNIV_INNOCHECKSUM -/************************************************************//** -Gets the offset within a page. -@return offset from the start of the page */ -UNIV_INLINE -ulint -page_offset( -/*========*/ - const void* ptr) /*!< in: pointer to page frame */ -{ - return(ut_align_offset(ptr, UNIV_PAGE_SIZE)); -} /*************************************************************//** Returns the max trx id field value. */ UNIV_INLINE @@ -286,34 +261,6 @@ page_header_reset_last_insert( } } -#endif /* !UNIV_INNOCHECKSUM */ - -/************************************************************//** -Determine whether the page is in new-style compact format. -@return nonzero if the page is in compact format, zero if it is in -old-style format */ -UNIV_INLINE -ulint -page_is_comp( -/*=========*/ - const page_t* page) /*!< in: index page */ -{ - return(page[PAGE_HEADER + PAGE_N_HEAP] & 0x80); -} - -#ifndef UNIV_INNOCHECKSUM -/************************************************************//** -TRUE if the record is on a page in compact format. -@return nonzero if in compact format */ -UNIV_INLINE -ulint -page_rec_is_comp( -/*=============*/ - const rec_t* rec) /*!< in: record */ -{ - return(page_is_comp(page_align(rec))); -} - /***************************************************************//** Returns the heap number of a record. @return heap number */ @@ -330,33 +277,6 @@ page_rec_get_heap_no( } } -#endif /* !UNIV_INNOCHECKSUM */ - -/************************************************************//** -Determine whether the page is a B-tree leaf. -@return true if the page is a B-tree leaf (PAGE_LEVEL = 0) */ -UNIV_INLINE -bool -page_is_leaf( -/*=========*/ - const page_t* page) /*!< in: page */ -{ - return(!*(const uint16*) (page + (PAGE_HEADER + PAGE_LEVEL))); -} - -#ifndef UNIV_INNOCHECKSUM -/************************************************************//** -Determine whether the page is empty. -@return true if the page is empty (PAGE_N_RECS = 0) */ -UNIV_INLINE -bool -page_is_empty( -/*==========*/ - const page_t* page) /*!< in: page */ -{ - return(!*(const uint16*) (page + (PAGE_HEADER + PAGE_N_RECS))); -} - /** Determine whether a page is an index root page. @param[in] page page frame @return true if the page is a root page of an index */ @@ -382,162 +302,36 @@ page_is_root( == IB_UINT64_MAX); } -/************************************************************//** -Determine whether the page contains garbage. -@return true if the page contains garbage (PAGE_GARBAGE is not 0) */ -UNIV_INLINE +/** Determine whether an index page record is a user record. +@param[in] rec record in an index page +@return true if a user record */ +inline bool -page_has_garbage( -/*=============*/ - const page_t* page) /*!< in: page */ -{ - return(!!*(const uint16*) (page + (PAGE_HEADER + PAGE_GARBAGE))); -} - -/************************************************************//** -Gets the offset of the first record on the page. -@return offset of the first record in record list, relative from page */ -UNIV_INLINE -ulint -page_get_infimum_offset( -/*====================*/ - const page_t* page) /*!< in: page which must have record(s) */ -{ - ut_ad(page); - ut_ad(!page_offset(page)); - - if (page_is_comp(page)) { - return(PAGE_NEW_INFIMUM); - } else { - return(PAGE_OLD_INFIMUM); - } -} - -/************************************************************//** -Gets the offset of the last record on the page. -@return offset of the last record in record list, relative from page */ -UNIV_INLINE -ulint -page_get_supremum_offset( -/*=====================*/ - const page_t* page) /*!< in: page which must have record(s) */ -{ - ut_ad(page); - ut_ad(!page_offset(page)); - - if (page_is_comp(page)) { - return(PAGE_NEW_SUPREMUM); - } else { - return(PAGE_OLD_SUPREMUM); - } -} - -/************************************************************//** -TRUE if the record is a user record on the page. -@return TRUE if a user record */ -UNIV_INLINE -ibool -page_rec_is_user_rec_low( -/*=====================*/ - ulint offset) /*!< in: record offset on page */ -{ - ut_ad(offset >= PAGE_NEW_INFIMUM); -#if PAGE_OLD_INFIMUM < PAGE_NEW_INFIMUM -# error "PAGE_OLD_INFIMUM < PAGE_NEW_INFIMUM" -#endif -#if PAGE_OLD_SUPREMUM < PAGE_NEW_SUPREMUM -# error "PAGE_OLD_SUPREMUM < PAGE_NEW_SUPREMUM" -#endif -#if PAGE_NEW_INFIMUM > PAGE_OLD_SUPREMUM -# error "PAGE_NEW_INFIMUM > PAGE_OLD_SUPREMUM" -#endif -#if PAGE_OLD_INFIMUM > PAGE_NEW_SUPREMUM -# error "PAGE_OLD_INFIMUM > PAGE_NEW_SUPREMUM" -#endif -#if PAGE_NEW_SUPREMUM > PAGE_OLD_SUPREMUM_END -# error "PAGE_NEW_SUPREMUM > PAGE_OLD_SUPREMUM_END" -#endif -#if PAGE_OLD_SUPREMUM > PAGE_NEW_SUPREMUM_END -# error "PAGE_OLD_SUPREMUM > PAGE_NEW_SUPREMUM_END" -#endif - ut_ad(offset <= UNIV_PAGE_SIZE - PAGE_EMPTY_DIR_START); - - return(offset != PAGE_NEW_SUPREMUM - && offset != PAGE_NEW_INFIMUM - && offset != PAGE_OLD_INFIMUM - && offset != PAGE_OLD_SUPREMUM); -} - -/************************************************************//** -TRUE if the record is the supremum record on a page. -@return TRUE if the supremum record */ -UNIV_INLINE -ibool -page_rec_is_supremum_low( -/*=====================*/ - ulint offset) /*!< in: record offset on page */ -{ - ut_ad(offset >= PAGE_NEW_INFIMUM); - ut_ad(offset <= UNIV_PAGE_SIZE - PAGE_EMPTY_DIR_START); - - return(offset == PAGE_NEW_SUPREMUM - || offset == PAGE_OLD_SUPREMUM); -} - -/************************************************************//** -TRUE if the record is the infimum record on a page. -@return TRUE if the infimum record */ -UNIV_INLINE -ibool -page_rec_is_infimum_low( -/*====================*/ - ulint offset) /*!< in: record offset on page */ -{ - ut_ad(offset >= PAGE_NEW_INFIMUM); - ut_ad(offset <= UNIV_PAGE_SIZE - PAGE_EMPTY_DIR_START); - - return(offset == PAGE_NEW_INFIMUM || offset == PAGE_OLD_INFIMUM); -} - -/************************************************************//** -TRUE if the record is a user record on the page. -@return TRUE if a user record */ -UNIV_INLINE -ibool -page_rec_is_user_rec( -/*=================*/ - const rec_t* rec) /*!< in: record */ +page_rec_is_user_rec(const rec_t* rec) { ut_ad(page_rec_check(rec)); - return(page_rec_is_user_rec_low(page_offset(rec))); } -/************************************************************//** -TRUE if the record is the supremum record on a page. -@return TRUE if the supremum record */ -UNIV_INLINE -ibool -page_rec_is_supremum( -/*=================*/ - const rec_t* rec) /*!< in: record */ +/** Determine whether an index page record is the supremum record. +@param[in] rec record in an index page +@return true if the supremum record */ +inline +bool +page_rec_is_supremum(const rec_t* rec) { ut_ad(page_rec_check(rec)); - return(page_rec_is_supremum_low(page_offset(rec))); } -/************************************************************//** -TRUE if the record is the infimum record on a page. -@return TRUE if the infimum record */ -UNIV_INLINE -ibool -page_rec_is_infimum( -/*================*/ - const rec_t* rec) /*!< in: record */ +/** Determine whether an index page record is the infimum record. +@param[in] rec record in an index page +@return true if the infimum record */ +inline +bool +page_rec_is_infimum(const rec_t* rec) { ut_ad(page_rec_check(rec)); - return(page_rec_is_infimum_low(page_offset(rec))); } diff --git a/storage/innobase/include/rem0rec.h b/storage/innobase/include/rem0rec.h index 61220d4f533..6e927da9bd9 100644 --- a/storage/innobase/include/rem0rec.h +++ b/storage/innobase/include/rem0rec.h @@ -444,38 +444,41 @@ rec_get_n_extern_new( ulint n) /*!< in: number of columns to scan */ MY_ATTRIBUTE((nonnull, warn_unused_result)); -/******************************************************//** -The following function determines the offsets to each field -in the record. It can reuse a previously allocated array. +/** Determine the offsets to each field in an index record. +@param[in] rec physical record +@param[in] index the index that the record belongs to +@param[in,out] offsets array comprising offsets[0] allocated elements, + or an array from rec_get_offsets(), or NULL +@param[in] leaf whether this is a leaf-page record +@param[in] n_fields maximum number of offsets to compute + (ULINT_UNDEFINED to compute all offsets) +@param[in,out] heap memory heap @return the new offsets */ ulint* rec_get_offsets_func( -/*=================*/ - const rec_t* rec, /*!< in: physical record */ - const dict_index_t* index, /*!< in: record descriptor */ - ulint* offsets,/*!< in/out: array consisting of - offsets[0] allocated elements, - or an array from rec_get_offsets(), - or NULL */ - ulint n_fields,/*!< in: maximum number of - initialized fields - (ULINT_UNDEFINED if all fields) */ + const rec_t* rec, + const dict_index_t* index, + ulint* offsets, +#ifdef UNIV_DEBUG + bool leaf, +#endif /* UNIV_DEBUG */ + ulint n_fields, #ifdef UNIV_DEBUG const char* file, /*!< in: file name where called */ unsigned line, /*!< in: line number where called */ #endif /* UNIV_DEBUG */ mem_heap_t** heap) /*!< in/out: memory heap */ #ifdef UNIV_DEBUG - MY_ATTRIBUTE((nonnull(1,2,5,7),warn_unused_result)); + MY_ATTRIBUTE((nonnull(1,2,6,8),warn_unused_result)); #else /* UNIV_DEBUG */ MY_ATTRIBUTE((nonnull(1,2,5),warn_unused_result)); #endif /* UNIV_DEBUG */ #ifdef UNIV_DEBUG -# define rec_get_offsets(rec,index,offsets,n,heap) \ - rec_get_offsets_func(rec,index,offsets,n,__FILE__,__LINE__,heap) +# define rec_get_offsets(rec, index, offsets, leaf, n, heap) \ + rec_get_offsets_func(rec,index,offsets,leaf,n,__FILE__,__LINE__,heap) #else /* UNIV_DEBUG */ -# define rec_get_offsets(rec, index, offsets, n, heap) \ +# define rec_get_offsets(rec, index, offsets, leaf, n, heap) \ rec_get_offsets_func(rec, index, offsets, n, heap) #endif /* UNIV_DEBUG */ @@ -933,19 +936,31 @@ rec_get_converted_size( const dtuple_t* dtuple, /*!< in: data tuple */ ulint n_ext) /*!< in: number of externally stored columns */ MY_ATTRIBUTE((warn_unused_result, nonnull)); -/**************************************************************//** -Copies the first n fields of a physical record to a data tuple. -The fields are copied to the memory heap. */ +/** Copy the first n fields of a (copy of a) physical record to a data tuple. +The fields are copied into the memory heap. +@param[out] tuple data tuple +@param[in] rec index record, or a copy thereof +@param[in] is_leaf whether rec is a leaf page record +@param[in] n_fields number of fields to copy +@param[in,out] heap memory heap */ void -rec_copy_prefix_to_dtuple( -/*======================*/ - dtuple_t* tuple, /*!< out: data tuple */ - const rec_t* rec, /*!< in: physical record */ - const dict_index_t* index, /*!< in: record descriptor */ - ulint n_fields, /*!< in: number of fields - to copy */ - mem_heap_t* heap) /*!< in: memory heap */ +rec_copy_prefix_to_dtuple_func( + dtuple_t* tuple, + const rec_t* rec, + const dict_index_t* index, +#ifdef UNIV_DEBUG + bool is_leaf, +#endif /* UNIV_DEBUG */ + ulint n_fields, + mem_heap_t* heap) MY_ATTRIBUTE((nonnull)); +#ifdef UNIV_DEBUG +# define rec_copy_prefix_to_dtuple(tuple,rec,index,leaf,n_fields,heap) \ + rec_copy_prefix_to_dtuple_func(tuple,rec,index,leaf,n_fields,heap) +#else /* UNIV_DEBUG */ +# define rec_copy_prefix_to_dtuple(tuple,rec,index,leaf,n_fields,heap) \ + rec_copy_prefix_to_dtuple_func(tuple,rec,index,n_fields,heap) +#endif /* UNIV_DEBUG */ /***************************************************************//** Validates the consistency of a physical record. @return TRUE if ok */ |