MySQL 9.1.0
Source Code Documentation
rem0cmp.h File Reference

Comparison services for records. More...

#include <my_sys.h>
#include "data0data.h"
#include "data0type.h"
#include "dict0dict.h"
#include "ha_prototypes.h"
#include "rem0rec.h"
#include "rem0cmp.ic"

Go to the source code of this file.

Namespaces

namespace  dd
 The version of the current data dictionary table definitions.
 

Functions

bool cmp_cols_are_equal (const dict_col_t *col1, const dict_col_t *col2, bool check_charsets)
 Returns true if two columns are equal for comparison purposes. More...
 
int cmp_data_data (ulint mtype, ulint prtype, bool is_asc, const byte *data1, ulint len1, const byte *data2, ulint len2)
 Compare two data fields. More...
 
static int cmp_dfield_dfield (const dfield_t *dfield1, const dfield_t *dfield2, bool is_asc)
 Compare two data fields. More...
 
static int cmp_multi_value_dfield_dfield (const dfield_t *dfield1, const dfield_t *dfield2)
 Compare two data fields, the first one can be of any form of multi-value field, while the second one must be one field from multi-value index. More...
 
int cmp_dtuple_rec_with_gis (const dtuple_t *dtuple, const rec_t *rec, const ulint *offsets, page_cur_mode_t mode, const dd::Spatial_reference_system *srs)
 Compare a GIS data tuple to a physical record. More...
 
int cmp_dtuple_rec_with_gis_internal (const dtuple_t *dtuple, const rec_t *rec, const ulint *offsets, const dd::Spatial_reference_system *srs)
 Compare a GIS data tuple to a physical record in rtree non-leaf node. More...
 
int cmp_dtuple_rec_with_match_low (const dtuple_t *dtuple, const rec_t *rec, const dict_index_t *index, const ulint *offsets, ulint n_cmp, ulint *matched_fields)
 Compare a data tuple to a physical record. More...
 
int cmp_dtuple_rec_with_match_bytes (const dtuple_t *dtuple, const rec_t *rec, const dict_index_t *index, const ulint *offsets, ulint *matched_fields, ulint *matched_bytes)
 Compare a data tuple to a physical record. More...
 
int cmp_dtuple_rec (const dtuple_t *dtuple, const rec_t *rec, const dict_index_t *index, const ulint *offsets)
 Compare a data tuple to a physical record. More...
 
bool cmp_dtuple_is_prefix_of_rec (const dtuple_t *dtuple, const rec_t *rec, const dict_index_t *index, const ulint *offsets)
 Check if a dtuple is a prefix of a record. More...
 
int cmp_rec_rec_simple (const rec_t *rec1, const rec_t *rec2, const ulint *offsets1, const ulint *offsets2, const dict_index_t *index, struct TABLE *table)
 Compare two physical records that contain the same number of columns, none of which are stored externally. More...
 
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 spatial_index_non_leaf, bool nulls_unequal, ulint *matched_fields, bool cmp_btree_recs=true)
 Compare two B-tree records. More...
 
static int cmp_rec_rec (const rec_t *rec1, const rec_t *rec2, const ulint *offsets1, const ulint *offsets2, const dict_index_t *index, bool spatial_index_non_leaf, ulint *matched_fields=nullptr, bool cmp_btree_recs=true)
 Compare two B-tree records. More...
 
static bool cmp_dfield_dfield_eq_prefix (const dfield_t *dfield1, const dfield_t *dfield2)
 Compare two data fields. More...
 

Variables

constexpr auto DISABLE_MIN_REC_FLAG_CHECK = ULINT_UNDEFINED
 Disable the min flag during row comparisons. More...
 

Detailed Description

Comparison services for records.

Created 7/1/1994 Heikki Tuuri

Function Documentation

◆ cmp_cols_are_equal()

bool cmp_cols_are_equal ( const dict_col_t col1,
const dict_col_t col2,
bool  check_charsets 
)

Returns true if two columns are equal for comparison purposes.

Parameters
[in]col1Column to compare.
[in]col2Column to compare.
[in]check_charsetsif true then check the character sets.
Returns
true if the columns are considered equal in comparisons. in: whether to check charsets

◆ cmp_data_data()

int cmp_data_data ( ulint  mtype,
ulint  prtype,
bool  is_asc,
const byte data1,
ulint  len1,
const byte data2,
ulint  len2 
)

Compare two data fields.

Parameters
[in]mtypemain type
[in]prtypeprecise type
[in]is_asctrue=ascending, false=descending order
[in]data1data field
[in]len1length of data1 in bytes, or UNIV_SQL_NULL
[in]data2data field
[in]len2length of data2 in bytes, or UNIV_SQL_NULL
Returns
the comparison result of data1 and data2
Return values
0if data1 is equal to data2
negativeif data1 is less than data2
positiveif data1 is greater than data2

◆ cmp_dfield_dfield()

static int cmp_dfield_dfield ( const dfield_t dfield1,
const dfield_t dfield2,
bool  is_asc 
)
inlinestatic

Compare two data fields.

Parameters
[in]dfield1data field; must have type field set
[in]dfield2data field
[in]is_asctrue=ASC, false=DESC
Returns
the comparison result of dfield1 and dfield2
Return values
0if dfield1 is equal to dfield2
negativeif dfield1 is less than dfield2
positiveif dfield1 is greater than dfield2

◆ cmp_dfield_dfield_eq_prefix()

static bool cmp_dfield_dfield_eq_prefix ( const dfield_t dfield1,
const dfield_t dfield2 
)
inlinestatic

Compare two data fields.

Parameters
[in]dfield1data field
[in]dfield2data field
Returns
the comparison result of dfield1 and dfield2
Return values
trueif dfield1 is equal to dfield2, or a prefix of dfield1
falseotherwise

◆ cmp_dtuple_is_prefix_of_rec()

bool cmp_dtuple_is_prefix_of_rec ( const dtuple_t dtuple,
const rec_t rec,
const dict_index_t index,
const ulint offsets 
)

Check if a dtuple is a prefix of a record.

Parameters
[in]dtupledata tuple
[in]recB-tree record
[in]indexB-tree index
[in]offsetsrec_get_offsets(rec)
Returns
true if prefix

◆ cmp_dtuple_rec()

int cmp_dtuple_rec ( const dtuple_t dtuple,
const rec_t rec,
const dict_index_t index,
const ulint offsets 
)

Compare a data tuple to a physical record.

See also
cmp_dtuple_rec_with_match
Parameters
[in]dtupledata tuple
[in]recrecord
[in]indexindex
[in]offsetsrec_get_offsets(rec)
Returns
the comparison result of dtuple and rec
Return values
0if dtuple is equal to rec
negativeif dtuple is less than rec
positiveif dtuple is greater than rec

◆ cmp_dtuple_rec_with_gis()

int cmp_dtuple_rec_with_gis ( const dtuple_t dtuple,
const rec_t rec,
const ulint offsets,
page_cur_mode_t  mode,
const dd::Spatial_reference_system srs 
)

Compare a GIS data tuple to a physical record.

Parameters
[in]dtupledata tuple
[in]recB-tree record
[in]offsetsrec_get_offsets(rec)
[in]modecompare mode
[in]srsSpatial reference system of R-tree
Return values
negativeif dtuple is less than rec

◆ cmp_dtuple_rec_with_gis_internal()

int cmp_dtuple_rec_with_gis_internal ( const dtuple_t dtuple,
const rec_t rec,
const ulint offsets,
const dd::Spatial_reference_system srs 
)

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.

Parameters
[in]dtupledata tuple
[in]recR-tree record
[in]offsetsrec_get_offsets(rec)
[in]srsSpatial referenxe system
Return values
negativeif dtuple is less than rec

◆ cmp_dtuple_rec_with_match_bytes()

int cmp_dtuple_rec_with_match_bytes ( const dtuple_t dtuple,
const rec_t rec,
const dict_index_t index,
const ulint offsets,
ulint matched_fields,
ulint matched_bytes 
)

Compare a data tuple to a physical record.

Parameters
[in]dtupledata tuple
[in]recB-tree or R-tree index record
[in]indexindex tree
[in]offsetsrec_get_offsets(rec)
[in,out]matched_fieldsnumber of completely matched fields
[in,out]matched_bytesnumber of matched bytes in the first field that is not matched
Returns
the comparison result of dtuple and rec
Return values
0if dtuple is equal to rec
negativeif dtuple is less than rec
positiveif dtuple is greater than rec

◆ cmp_dtuple_rec_with_match_low()

int cmp_dtuple_rec_with_match_low ( const dtuple_t dtuple,
const rec_t rec,
const dict_index_t index,
const ulint offsets,
ulint  n_cmp,
ulint matched_fields 
)

Compare a data tuple to a physical record.

Parameters
[in]dtupledata tuple
[in]recrecord
[in]indexindex
[in]offsetsrec_get_offsets(rec)
[in]n_cmpnumber of fields to compare
[in,out]matched_fieldsnumber of completely matched fields
Returns
the comparison result of dtuple and rec
Return values
0if dtuple is equal to rec
negativeif dtuple is less than rec
positiveif dtuple is greater than rec

◆ cmp_multi_value_dfield_dfield()

static int cmp_multi_value_dfield_dfield ( const dfield_t dfield1,
const dfield_t dfield2 
)
inlinestatic

Compare two data fields, the first one can be of any form of multi-value field, while the second one must be one field from multi-value index.

Parameters
[in]dfield1multi-value data field;
[in]dfield2data field; must have type field set
Returns
0 if dfield1 has dfield2 or they are equal if both NULL, otherwise 1

◆ cmp_rec_rec()

static int cmp_rec_rec ( const rec_t rec1,
const rec_t rec2,
const ulint offsets1,
const ulint offsets2,
const dict_index_t index,
bool  spatial_index_non_leaf,
ulint matched_fields = nullptr,
bool  cmp_btree_recs = true 
)
inlinestatic

Compare two B-tree records.

Only the common first fields are compared, and externally stored field are treated as equal.

Parameters
[in]rec1B-tree record
[in]rec2B-tree record
[in]offsets1rec_get_offsets(rec1, index)
[in]offsets2rec_get_offsets(rec2, index)
[in]indexB-tree index
[in]spatial_index_non_leaftrue if spatial index non leaf records
[out]matched_fieldsnumber of completely matched fields within the first field not completely matched
[in]cmp_btree_recstrue if the both the records are b-tree records
Returns
positive, 0, negative if rec1 is greater, equal, less, than rec2, respectively

◆ cmp_rec_rec_simple()

int cmp_rec_rec_simple ( const rec_t rec1,
const rec_t rec2,
const ulint offsets1,
const ulint offsets2,
const dict_index_t index,
struct TABLE table 
)

Compare two physical records that contain the same number of columns, none of which are stored externally.

Parameters
[in]rec1Physical record 1 to compare
[in]rec2Physical record 2 to compare
[in]offsets1rec_get_offsets(rec1, ...)
[in]offsets2rec_get_offsets(rec2, ...)
[in]indexData dictionary index
[in]tableMySQL table, for reporting duplicate key value if applicable, or nullptr
Return values
positiveif rec1 (including non-ordering columns) is greater than rec2
negativeif rec1 (including non-ordering columns) is less than rec2
0if rec1 is a duplicate of rec2

◆ cmp_rec_rec_with_match()

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  spatial_index_non_leaf,
bool  nulls_unequal,
ulint matched_fields,
bool  cmp_btree_recs = true 
)

Compare two B-tree records.

Parameters
[in]rec1B-tree record
[in]rec2B-tree record
[in]offsets1rec_get_offsets(rec1, index)
[in]offsets2rec_get_offsets(rec2, index)
[in]indexB-tree index
[in]spatial_index_non_leaftrue if record is in spatial non leaf page
[in]nulls_unequaltrue if this is for index cardinality statistics estimation, and innodb_stats_method=nulls_unequal or innodb_stats_method=nulls_ignored
[out]matched_fieldsnumber of completely matched fields within the first field not completely matched
[in]cmp_btree_recstrue if we're comparing two b-tree records
Returns
the comparison result
Return values
0if rec1 is equal to rec2
negativeif rec1 is less than rec2
positiveif rec2 is greater than rec2

Variable Documentation

◆ DISABLE_MIN_REC_FLAG_CHECK

constexpr auto DISABLE_MIN_REC_FLAG_CHECK = ULINT_UNDEFINED
constexpr

Disable the min flag during row comparisons.