2014-02-26 19:11:54 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
|
2016-06-21 14:21:03 +02:00
|
|
|
Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved.
|
2020-01-17 13:13:03 +02:00
|
|
|
Copyright (c) 2017, 2020, MariaDB Corporation.
|
2014-02-26 19:11:54 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
Foundation; version 2 of the License.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
|
|
this program; if not, write to the Free Software Foundation, Inc.,
|
2019-05-11 19:25:02 +03:00
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
|
2014-02-26 19:11:54 +01:00
|
|
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/*******************************************************************//**
|
|
|
|
@file include/rem0cmp.h
|
|
|
|
Comparison services for records
|
|
|
|
|
|
|
|
Created 7/1/1994 Heikki Tuuri
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#ifndef rem0cmp_h
|
|
|
|
#define rem0cmp_h
|
|
|
|
|
|
|
|
#include "data0data.h"
|
|
|
|
#include "data0type.h"
|
2018-11-19 11:42:14 +02:00
|
|
|
#include "rem0types.h"
|
|
|
|
#include "page0types.h"
|
2014-02-26 19:11:54 +01:00
|
|
|
|
|
|
|
/*************************************************************//**
|
|
|
|
Returns TRUE if two columns are equal for comparison purposes.
|
2016-08-12 11:17:45 +03:00
|
|
|
@return TRUE if the columns are considered equal in comparisons */
|
2014-02-26 19:11:54 +01:00
|
|
|
ibool
|
|
|
|
cmp_cols_are_equal(
|
|
|
|
/*===============*/
|
|
|
|
const dict_col_t* col1, /*!< in: column 1 */
|
|
|
|
const dict_col_t* col2, /*!< in: column 2 */
|
|
|
|
ibool check_charsets);
|
|
|
|
/*!< in: whether to check charsets */
|
2016-08-12 11:17:45 +03:00
|
|
|
/** Compare two data fields.
|
|
|
|
@param[in] mtype main type
|
|
|
|
@param[in] prtype precise type
|
|
|
|
@param[in] data1 data field
|
|
|
|
@param[in] len1 length of data1 in bytes, or UNIV_SQL_NULL
|
|
|
|
@param[in] data2 data field
|
|
|
|
@param[in] len2 length of data2 in bytes, or UNIV_SQL_NULL
|
|
|
|
@return the comparison result of data1 and data2
|
|
|
|
@retval 0 if data1 is equal to data2
|
|
|
|
@retval negative if data1 is less than data2
|
|
|
|
@retval positive if data1 is greater than data2 */
|
2014-02-26 19:11:54 +01:00
|
|
|
int
|
|
|
|
cmp_data_data(
|
2016-08-12 11:17:45 +03:00
|
|
|
ulint mtype,
|
|
|
|
ulint prtype,
|
|
|
|
const byte* data1,
|
|
|
|
ulint len1,
|
|
|
|
const byte* data2,
|
|
|
|
ulint len2)
|
2017-05-18 15:20:57 +03:00
|
|
|
MY_ATTRIBUTE((warn_unused_result));
|
2014-02-26 19:11:54 +01:00
|
|
|
|
2016-08-12 11:17:45 +03:00
|
|
|
/** Compare two data fields.
|
|
|
|
@param[in] dfield1 data field; must have type field set
|
|
|
|
@param[in] dfield2 data field
|
|
|
|
@return the comparison result of dfield1 and dfield2
|
|
|
|
@retval 0 if dfield1 is equal to dfield2
|
|
|
|
@retval negative if dfield1 is less than dfield2
|
|
|
|
@retval positive if dfield1 is greater than dfield2 */
|
2014-02-26 19:11:54 +01:00
|
|
|
UNIV_INLINE
|
|
|
|
int
|
|
|
|
cmp_dfield_dfield(
|
|
|
|
/*==============*/
|
|
|
|
const dfield_t* dfield1,/*!< in: data field; must have type field set */
|
|
|
|
const dfield_t* dfield2);/*!< in: data field */
|
2016-08-12 11:17:45 +03:00
|
|
|
|
|
|
|
|
|
|
|
/** Compare a GIS data tuple to a physical record.
|
|
|
|
@param[in] dtuple data tuple
|
2020-01-17 13:13:03 +02:00
|
|
|
@param[in] rec R-tree record
|
2016-08-12 11:17:45 +03:00
|
|
|
@param[in] offsets rec_get_offsets(rec)
|
|
|
|
@param[in] mode compare mode
|
|
|
|
@retval negative if dtuple is less than rec */
|
|
|
|
int
|
|
|
|
cmp_dtuple_rec_with_gis(
|
|
|
|
/*====================*/
|
|
|
|
const dtuple_t* dtuple,
|
|
|
|
const rec_t* rec,
|
MDEV-20950 Reduce size of record offsets
offset_t: this is a type which represents one record offset.
It's unsigned short int.
a lot of functions: replace ulint with offset_t
btr_pcur_restore_position_func(),
page_validate(),
row_ins_scan_sec_index_for_duplicate(),
row_upd_clust_rec_by_insert_inherit_func(),
row_vers_impl_x_locked_low(),
trx_undo_prev_version_build():
allocate record offsets on the stack instead of waiting for rec_get_offsets()
to allocate it from mem_heap_t. So, reducing memory allocations.
RECORD_OFFSET, INDEX_OFFSET:
now it's less convenient to store pointers in offset_t*
array. One pointer occupies now several offset_t. And those constant are start
indexes into array to places where to store pointer values
REC_OFFS_HEADER_SIZE: adjusted for the new reality
REC_OFFS_NORMAL_SIZE:
increase size from 100 to 300 which means less heap allocations.
And sizeof(offset_t[REC_OFFS_NORMAL_SIZE]) now is 600 bytes which
is smaller than previous 800 bytes.
REC_OFFS_SEC_INDEX_SIZE: adjusted for the new reality
rem0rec.h, rem0rec.ic, rem0rec.cc:
various arguments, return values and local variables types were changed to
fix numerous integer conversions issues.
enum field_type_t:
offset types concept was introduces which replaces old offset flags stuff.
Like in earlier version, 2 upper bits are used to store offset type.
And this enum represents those types.
REC_OFFS_SQL_NULL, REC_OFFS_MASK: removed
get_type(), set_type(), get_value(), combine():
these are convenience functions to work with offsets and it's types
rec_offs_base()[0]:
still uses an old scheme with flags REC_OFFS_COMPACT and REC_OFFS_EXTERNAL
rec_offs_base()[i]:
these have type offset_t now. Two upper bits contains type.
2019-11-04 22:30:12 +03:00
|
|
|
const offset_t* offsets,
|
2016-08-12 11:17:45 +03:00
|
|
|
page_cur_mode_t mode)
|
2016-09-06 09:43:16 +03:00
|
|
|
MY_ATTRIBUTE((nonnull));
|
|
|
|
|
|
|
|
/** Compare a GIS data tuple to a physical record in rtree non-leaf node.
|
|
|
|
We need to check the page number field, since we don't store pk field in
|
|
|
|
rtree non-leaf node.
|
|
|
|
@param[in] dtuple data tuple
|
|
|
|
@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 */
|
|
|
|
int
|
|
|
|
cmp_dtuple_rec_with_gis_internal(
|
|
|
|
const dtuple_t* dtuple,
|
|
|
|
const rec_t* rec,
|
MDEV-20950 Reduce size of record offsets
offset_t: this is a type which represents one record offset.
It's unsigned short int.
a lot of functions: replace ulint with offset_t
btr_pcur_restore_position_func(),
page_validate(),
row_ins_scan_sec_index_for_duplicate(),
row_upd_clust_rec_by_insert_inherit_func(),
row_vers_impl_x_locked_low(),
trx_undo_prev_version_build():
allocate record offsets on the stack instead of waiting for rec_get_offsets()
to allocate it from mem_heap_t. So, reducing memory allocations.
RECORD_OFFSET, INDEX_OFFSET:
now it's less convenient to store pointers in offset_t*
array. One pointer occupies now several offset_t. And those constant are start
indexes into array to places where to store pointer values
REC_OFFS_HEADER_SIZE: adjusted for the new reality
REC_OFFS_NORMAL_SIZE:
increase size from 100 to 300 which means less heap allocations.
And sizeof(offset_t[REC_OFFS_NORMAL_SIZE]) now is 600 bytes which
is smaller than previous 800 bytes.
REC_OFFS_SEC_INDEX_SIZE: adjusted for the new reality
rem0rec.h, rem0rec.ic, rem0rec.cc:
various arguments, return values and local variables types were changed to
fix numerous integer conversions issues.
enum field_type_t:
offset types concept was introduces which replaces old offset flags stuff.
Like in earlier version, 2 upper bits are used to store offset type.
And this enum represents those types.
REC_OFFS_SQL_NULL, REC_OFFS_MASK: removed
get_type(), set_type(), get_value(), combine():
these are convenience functions to work with offsets and it's types
rec_offs_base()[0]:
still uses an old scheme with flags REC_OFFS_COMPACT and REC_OFFS_EXTERNAL
rec_offs_base()[i]:
these have type offset_t now. Two upper bits contains type.
2019-11-04 22:30:12 +03:00
|
|
|
const offset_t* offsets);
|
2016-09-06 09:43:16 +03:00
|
|
|
|
2016-08-12 11:17:45 +03:00
|
|
|
/** Compare a data tuple to a physical record.
|
|
|
|
@param[in] dtuple data tuple
|
|
|
|
@param[in] rec B-tree record
|
|
|
|
@param[in] offsets rec_get_offsets(rec)
|
|
|
|
@param[in] n_cmp number of fields to compare
|
|
|
|
@param[in,out] matched_fields number of completely matched fields
|
|
|
|
@return the comparison result of dtuple and rec
|
|
|
|
@retval 0 if dtuple is equal to rec
|
|
|
|
@retval negative if dtuple is less than rec
|
|
|
|
@retval positive if dtuple is greater than rec */
|
2014-02-26 19:11:54 +01:00
|
|
|
int
|
|
|
|
cmp_dtuple_rec_with_match_low(
|
2016-08-12 11:17:45 +03:00
|
|
|
const dtuple_t* dtuple,
|
|
|
|
const rec_t* rec,
|
MDEV-20950 Reduce size of record offsets
offset_t: this is a type which represents one record offset.
It's unsigned short int.
a lot of functions: replace ulint with offset_t
btr_pcur_restore_position_func(),
page_validate(),
row_ins_scan_sec_index_for_duplicate(),
row_upd_clust_rec_by_insert_inherit_func(),
row_vers_impl_x_locked_low(),
trx_undo_prev_version_build():
allocate record offsets on the stack instead of waiting for rec_get_offsets()
to allocate it from mem_heap_t. So, reducing memory allocations.
RECORD_OFFSET, INDEX_OFFSET:
now it's less convenient to store pointers in offset_t*
array. One pointer occupies now several offset_t. And those constant are start
indexes into array to places where to store pointer values
REC_OFFS_HEADER_SIZE: adjusted for the new reality
REC_OFFS_NORMAL_SIZE:
increase size from 100 to 300 which means less heap allocations.
And sizeof(offset_t[REC_OFFS_NORMAL_SIZE]) now is 600 bytes which
is smaller than previous 800 bytes.
REC_OFFS_SEC_INDEX_SIZE: adjusted for the new reality
rem0rec.h, rem0rec.ic, rem0rec.cc:
various arguments, return values and local variables types were changed to
fix numerous integer conversions issues.
enum field_type_t:
offset types concept was introduces which replaces old offset flags stuff.
Like in earlier version, 2 upper bits are used to store offset type.
And this enum represents those types.
REC_OFFS_SQL_NULL, REC_OFFS_MASK: removed
get_type(), set_type(), get_value(), combine():
these are convenience functions to work with offsets and it's types
rec_offs_base()[0]:
still uses an old scheme with flags REC_OFFS_COMPACT and REC_OFFS_EXTERNAL
rec_offs_base()[i]:
these have type offset_t now. Two upper bits contains type.
2019-11-04 22:30:12 +03:00
|
|
|
const offset_t* offsets,
|
2016-08-12 11:17:45 +03:00
|
|
|
ulint n_cmp,
|
|
|
|
ulint* matched_fields)
|
2016-06-21 14:21:03 +02:00
|
|
|
MY_ATTRIBUTE((nonnull));
|
2016-08-12 11:17:45 +03:00
|
|
|
#define cmp_dtuple_rec_with_match(tuple,rec,offsets,fields) \
|
2014-02-26 19:11:54 +01:00
|
|
|
cmp_dtuple_rec_with_match_low( \
|
2016-08-12 11:17:45 +03:00
|
|
|
tuple,rec,offsets,dtuple_get_n_fields_cmp(tuple),fields)
|
|
|
|
/** Compare a data tuple to a physical record.
|
|
|
|
@param[in] dtuple data tuple
|
|
|
|
@param[in] rec B-tree or R-tree index record
|
|
|
|
@param[in] index index tree
|
|
|
|
@param[in] offsets rec_get_offsets(rec)
|
|
|
|
@param[in,out] matched_fields number of completely matched fields
|
|
|
|
@param[in,out] matched_bytes number of matched bytes in the first
|
|
|
|
field that is not matched
|
|
|
|
@return the comparison result of dtuple and rec
|
|
|
|
@retval 0 if dtuple is equal to rec
|
|
|
|
@retval negative if dtuple is less than rec
|
|
|
|
@retval positive if dtuple is greater than rec */
|
|
|
|
int
|
|
|
|
cmp_dtuple_rec_with_match_bytes(
|
|
|
|
const dtuple_t* dtuple,
|
|
|
|
const rec_t* rec,
|
|
|
|
const dict_index_t* index,
|
MDEV-20950 Reduce size of record offsets
offset_t: this is a type which represents one record offset.
It's unsigned short int.
a lot of functions: replace ulint with offset_t
btr_pcur_restore_position_func(),
page_validate(),
row_ins_scan_sec_index_for_duplicate(),
row_upd_clust_rec_by_insert_inherit_func(),
row_vers_impl_x_locked_low(),
trx_undo_prev_version_build():
allocate record offsets on the stack instead of waiting for rec_get_offsets()
to allocate it from mem_heap_t. So, reducing memory allocations.
RECORD_OFFSET, INDEX_OFFSET:
now it's less convenient to store pointers in offset_t*
array. One pointer occupies now several offset_t. And those constant are start
indexes into array to places where to store pointer values
REC_OFFS_HEADER_SIZE: adjusted for the new reality
REC_OFFS_NORMAL_SIZE:
increase size from 100 to 300 which means less heap allocations.
And sizeof(offset_t[REC_OFFS_NORMAL_SIZE]) now is 600 bytes which
is smaller than previous 800 bytes.
REC_OFFS_SEC_INDEX_SIZE: adjusted for the new reality
rem0rec.h, rem0rec.ic, rem0rec.cc:
various arguments, return values and local variables types were changed to
fix numerous integer conversions issues.
enum field_type_t:
offset types concept was introduces which replaces old offset flags stuff.
Like in earlier version, 2 upper bits are used to store offset type.
And this enum represents those types.
REC_OFFS_SQL_NULL, REC_OFFS_MASK: removed
get_type(), set_type(), get_value(), combine():
these are convenience functions to work with offsets and it's types
rec_offs_base()[0]:
still uses an old scheme with flags REC_OFFS_COMPACT and REC_OFFS_EXTERNAL
rec_offs_base()[i]:
these have type offset_t now. Two upper bits contains type.
2019-11-04 22:30:12 +03:00
|
|
|
const offset_t* offsets,
|
2016-08-12 11:17:45 +03:00
|
|
|
ulint* matched_fields,
|
|
|
|
ulint* matched_bytes)
|
2016-09-06 09:43:16 +03:00
|
|
|
MY_ATTRIBUTE((warn_unused_result));
|
2016-08-12 11:17:45 +03:00
|
|
|
/** Compare a data tuple to a physical record.
|
2014-02-26 19:11:54 +01:00
|
|
|
@see cmp_dtuple_rec_with_match
|
2016-08-12 11:17:45 +03:00
|
|
|
@param[in] dtuple data tuple
|
|
|
|
@param[in] rec B-tree record
|
|
|
|
@param[in] offsets rec_get_offsets(rec)
|
|
|
|
@return the comparison result of dtuple and rec
|
|
|
|
@retval 0 if dtuple is equal to rec
|
|
|
|
@retval negative if dtuple is less than rec
|
|
|
|
@retval positive if dtuple is greater than rec */
|
2014-02-26 19:11:54 +01:00
|
|
|
int
|
|
|
|
cmp_dtuple_rec(
|
2016-08-12 11:17:45 +03:00
|
|
|
const dtuple_t* dtuple,
|
|
|
|
const rec_t* rec,
|
MDEV-20950 Reduce size of record offsets
offset_t: this is a type which represents one record offset.
It's unsigned short int.
a lot of functions: replace ulint with offset_t
btr_pcur_restore_position_func(),
page_validate(),
row_ins_scan_sec_index_for_duplicate(),
row_upd_clust_rec_by_insert_inherit_func(),
row_vers_impl_x_locked_low(),
trx_undo_prev_version_build():
allocate record offsets on the stack instead of waiting for rec_get_offsets()
to allocate it from mem_heap_t. So, reducing memory allocations.
RECORD_OFFSET, INDEX_OFFSET:
now it's less convenient to store pointers in offset_t*
array. One pointer occupies now several offset_t. And those constant are start
indexes into array to places where to store pointer values
REC_OFFS_HEADER_SIZE: adjusted for the new reality
REC_OFFS_NORMAL_SIZE:
increase size from 100 to 300 which means less heap allocations.
And sizeof(offset_t[REC_OFFS_NORMAL_SIZE]) now is 600 bytes which
is smaller than previous 800 bytes.
REC_OFFS_SEC_INDEX_SIZE: adjusted for the new reality
rem0rec.h, rem0rec.ic, rem0rec.cc:
various arguments, return values and local variables types were changed to
fix numerous integer conversions issues.
enum field_type_t:
offset types concept was introduces which replaces old offset flags stuff.
Like in earlier version, 2 upper bits are used to store offset type.
And this enum represents those types.
REC_OFFS_SQL_NULL, REC_OFFS_MASK: removed
get_type(), set_type(), get_value(), combine():
these are convenience functions to work with offsets and it's types
rec_offs_base()[0]:
still uses an old scheme with flags REC_OFFS_COMPACT and REC_OFFS_EXTERNAL
rec_offs_base()[i]:
these have type offset_t now. Two upper bits contains type.
2019-11-04 22:30:12 +03:00
|
|
|
const offset_t* offsets);
|
2014-02-26 19:11:54 +01:00
|
|
|
/**************************************************************//**
|
|
|
|
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.
|
2016-08-12 11:17:45 +03:00
|
|
|
@return TRUE if prefix */
|
2014-02-26 19:11:54 +01:00
|
|
|
ibool
|
|
|
|
cmp_dtuple_is_prefix_of_rec(
|
|
|
|
/*========================*/
|
|
|
|
const dtuple_t* dtuple, /*!< in: data tuple */
|
|
|
|
const rec_t* rec, /*!< in: physical record */
|
MDEV-20950 Reduce size of record offsets
offset_t: this is a type which represents one record offset.
It's unsigned short int.
a lot of functions: replace ulint with offset_t
btr_pcur_restore_position_func(),
page_validate(),
row_ins_scan_sec_index_for_duplicate(),
row_upd_clust_rec_by_insert_inherit_func(),
row_vers_impl_x_locked_low(),
trx_undo_prev_version_build():
allocate record offsets on the stack instead of waiting for rec_get_offsets()
to allocate it from mem_heap_t. So, reducing memory allocations.
RECORD_OFFSET, INDEX_OFFSET:
now it's less convenient to store pointers in offset_t*
array. One pointer occupies now several offset_t. And those constant are start
indexes into array to places where to store pointer values
REC_OFFS_HEADER_SIZE: adjusted for the new reality
REC_OFFS_NORMAL_SIZE:
increase size from 100 to 300 which means less heap allocations.
And sizeof(offset_t[REC_OFFS_NORMAL_SIZE]) now is 600 bytes which
is smaller than previous 800 bytes.
REC_OFFS_SEC_INDEX_SIZE: adjusted for the new reality
rem0rec.h, rem0rec.ic, rem0rec.cc:
various arguments, return values and local variables types were changed to
fix numerous integer conversions issues.
enum field_type_t:
offset types concept was introduces which replaces old offset flags stuff.
Like in earlier version, 2 upper bits are used to store offset type.
And this enum represents those types.
REC_OFFS_SQL_NULL, REC_OFFS_MASK: removed
get_type(), set_type(), get_value(), combine():
these are convenience functions to work with offsets and it's types
rec_offs_base()[0]:
still uses an old scheme with flags REC_OFFS_COMPACT and REC_OFFS_EXTERNAL
rec_offs_base()[i]:
these have type offset_t now. Two upper bits contains type.
2019-11-04 22:30:12 +03:00
|
|
|
const offset_t* offsets);/*!< in: array returned by rec_get_offsets() */
|
2016-08-12 11:17:45 +03:00
|
|
|
/** Compare two physical records that contain the same number of columns,
|
2014-02-26 19:11:54 +01:00
|
|
|
none of which are stored externally.
|
2016-08-12 11:17:45 +03:00
|
|
|
@retval positive if rec1 (including non-ordering columns) is greater than rec2
|
|
|
|
@retval negative if rec1 (including non-ordering columns) is less than rec2
|
2014-02-26 19:11:54 +01:00
|
|
|
@retval 0 if rec1 is a duplicate of rec2 */
|
|
|
|
int
|
|
|
|
cmp_rec_rec_simple(
|
|
|
|
/*===============*/
|
|
|
|
const rec_t* rec1, /*!< in: physical record */
|
|
|
|
const rec_t* rec2, /*!< in: physical record */
|
MDEV-20950 Reduce size of record offsets
offset_t: this is a type which represents one record offset.
It's unsigned short int.
a lot of functions: replace ulint with offset_t
btr_pcur_restore_position_func(),
page_validate(),
row_ins_scan_sec_index_for_duplicate(),
row_upd_clust_rec_by_insert_inherit_func(),
row_vers_impl_x_locked_low(),
trx_undo_prev_version_build():
allocate record offsets on the stack instead of waiting for rec_get_offsets()
to allocate it from mem_heap_t. So, reducing memory allocations.
RECORD_OFFSET, INDEX_OFFSET:
now it's less convenient to store pointers in offset_t*
array. One pointer occupies now several offset_t. And those constant are start
indexes into array to places where to store pointer values
REC_OFFS_HEADER_SIZE: adjusted for the new reality
REC_OFFS_NORMAL_SIZE:
increase size from 100 to 300 which means less heap allocations.
And sizeof(offset_t[REC_OFFS_NORMAL_SIZE]) now is 600 bytes which
is smaller than previous 800 bytes.
REC_OFFS_SEC_INDEX_SIZE: adjusted for the new reality
rem0rec.h, rem0rec.ic, rem0rec.cc:
various arguments, return values and local variables types were changed to
fix numerous integer conversions issues.
enum field_type_t:
offset types concept was introduces which replaces old offset flags stuff.
Like in earlier version, 2 upper bits are used to store offset type.
And this enum represents those types.
REC_OFFS_SQL_NULL, REC_OFFS_MASK: removed
get_type(), set_type(), get_value(), combine():
these are convenience functions to work with offsets and it's types
rec_offs_base()[0]:
still uses an old scheme with flags REC_OFFS_COMPACT and REC_OFFS_EXTERNAL
rec_offs_base()[i]:
these have type offset_t now. Two upper bits contains type.
2019-11-04 22:30:12 +03:00
|
|
|
const offset_t* offsets1,/*!< in: rec_get_offsets(rec1, ...) */
|
|
|
|
const offset_t* offsets2,/*!< in: rec_get_offsets(rec2, ...) */
|
2014-02-26 19:11:54 +01:00
|
|
|
const dict_index_t* index, /*!< in: data dictionary index */
|
|
|
|
struct TABLE* table) /*!< in: MySQL table, for reporting
|
|
|
|
duplicate key value if applicable,
|
|
|
|
or NULL */
|
2016-06-21 14:21:03 +02:00
|
|
|
MY_ATTRIBUTE((nonnull(1,2,3,4), warn_unused_result));
|
2016-08-12 11:17:45 +03:00
|
|
|
|
2020-01-17 13:13:03 +02:00
|
|
|
/** Compare two B-tree or R-tree records.
|
2016-08-12 11:17:45 +03:00
|
|
|
Only the common first fields are compared, and externally stored field
|
|
|
|
are treated as equal.
|
2020-01-17 13:13:03 +02:00
|
|
|
@param[in] rec1 record (possibly not on an index page)
|
|
|
|
@param[in] rec2 B-tree or R-tree record in an index page
|
2016-08-12 11:17:45 +03:00
|
|
|
@param[in] offsets1 rec_get_offsets(rec1, index)
|
|
|
|
@param[in] offsets2 rec_get_offsets(rec2, index)
|
2020-01-17 13:13:03 +02:00
|
|
|
@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
|
2016-08-12 11:17:45 +03:00
|
|
|
@param[out] matched_fields number of completely matched fields
|
|
|
|
within the first field not completely matched
|
2020-01-17 13:13:03 +02:00
|
|
|
@retval 0 if rec1 is equal to rec2
|
|
|
|
@retval negative if rec1 is less than rec2
|
|
|
|
@retval positive if rec1 is greater than rec2 */
|
2014-02-26 19:11:54 +01:00
|
|
|
int
|
|
|
|
cmp_rec_rec(
|
2016-08-12 11:17:45 +03:00
|
|
|
const rec_t* rec1,
|
|
|
|
const rec_t* rec2,
|
MDEV-20950 Reduce size of record offsets
offset_t: this is a type which represents one record offset.
It's unsigned short int.
a lot of functions: replace ulint with offset_t
btr_pcur_restore_position_func(),
page_validate(),
row_ins_scan_sec_index_for_duplicate(),
row_upd_clust_rec_by_insert_inherit_func(),
row_vers_impl_x_locked_low(),
trx_undo_prev_version_build():
allocate record offsets on the stack instead of waiting for rec_get_offsets()
to allocate it from mem_heap_t. So, reducing memory allocations.
RECORD_OFFSET, INDEX_OFFSET:
now it's less convenient to store pointers in offset_t*
array. One pointer occupies now several offset_t. And those constant are start
indexes into array to places where to store pointer values
REC_OFFS_HEADER_SIZE: adjusted for the new reality
REC_OFFS_NORMAL_SIZE:
increase size from 100 to 300 which means less heap allocations.
And sizeof(offset_t[REC_OFFS_NORMAL_SIZE]) now is 600 bytes which
is smaller than previous 800 bytes.
REC_OFFS_SEC_INDEX_SIZE: adjusted for the new reality
rem0rec.h, rem0rec.ic, rem0rec.cc:
various arguments, return values and local variables types were changed to
fix numerous integer conversions issues.
enum field_type_t:
offset types concept was introduces which replaces old offset flags stuff.
Like in earlier version, 2 upper bits are used to store offset type.
And this enum represents those types.
REC_OFFS_SQL_NULL, REC_OFFS_MASK: removed
get_type(), set_type(), get_value(), combine():
these are convenience functions to work with offsets and it's types
rec_offs_base()[0]:
still uses an old scheme with flags REC_OFFS_COMPACT and REC_OFFS_EXTERNAL
rec_offs_base()[i]:
these have type offset_t now. Two upper bits contains type.
2019-11-04 22:30:12 +03:00
|
|
|
const offset_t* offsets1,
|
|
|
|
const offset_t* offsets2,
|
2016-08-12 11:17:45 +03:00
|
|
|
const dict_index_t* index,
|
2020-01-17 13:13:03 +02:00
|
|
|
bool nulls_unequal = false,
|
|
|
|
ulint* matched_fields = NULL)
|
|
|
|
MY_ATTRIBUTE((nonnull(1,2,3,4,5)));
|
2014-02-26 19:11:54 +01:00
|
|
|
|
2016-08-12 11:17:45 +03:00
|
|
|
/** Compare two data fields.
|
|
|
|
@param[in] dfield1 data field
|
|
|
|
@param[in] dfield2 data field
|
|
|
|
@return the comparison result of dfield1 and dfield2
|
|
|
|
@retval 0 if dfield1 is equal to dfield2, or a prefix of dfield1
|
|
|
|
@retval negative if dfield1 is less than dfield2
|
|
|
|
@retval positive if dfield1 is greater than dfield2 */
|
2014-02-26 19:11:54 +01:00
|
|
|
UNIV_INLINE
|
|
|
|
int
|
2016-08-12 11:17:45 +03:00
|
|
|
cmp_dfield_dfield_like_prefix(
|
|
|
|
const dfield_t* dfield1,
|
|
|
|
const dfield_t* dfield2);
|
2014-02-26 19:11:54 +01:00
|
|
|
|
|
|
|
#include "rem0cmp.ic"
|
|
|
|
|
|
|
|
#endif
|