Drizzled Public API Documentation

rem0cmp.h File Reference
#include "univ.i"
#include "data0data.h"
#include "data0type.h"
#include "dict0dict.h"
#include "rem0rec.h"

Go to the source code of this file.

Functions

UNIV_INTERN ibool cmp_cols_are_equal (const dict_col_t *col1, const dict_col_t *col2, ibool check_charsets)
UNIV_INLINE int cmp_data_data (ulint mtype, ulint prtype, const byte *data1, ulint len1, const byte *data2, ulint len2)
UNIV_INTERN int cmp_data_data_slow (ulint mtype, ulint prtype, const byte *data1, ulint len1, const byte *data2, ulint len2)
UNIV_INLINE int cmp_dfield_dfield (const dfield_t *dfield1, const dfield_t *dfield2)
UNIV_INTERN int cmp_dtuple_rec_with_match (const dtuple_t *dtuple, const rec_t *rec, const ulint *offsets, ulint *matched_fields, ulint *matched_bytes)
UNIV_INTERN int cmp_dtuple_rec (const dtuple_t *dtuple, const rec_t *rec, const ulint *offsets)
UNIV_INTERN ibool cmp_dtuple_is_prefix_of_rec (const dtuple_t *dtuple, const rec_t *rec, const ulint *offsets)
UNIV_INTERN int cmp_rec_rec_simple (const rec_t *rec1, const rec_t *rec2, const ulint *offsets1, const ulint *offsets2, const dict_index_t *index, ibool *null_eq)
UNIV_INTERN int cmp_rec_rec_with_match (const rec_t *rec1, const rec_t *rec2, const ulint *offsets1, const ulint *offsets2, dict_index_t *index, ulint *matched_fields, ulint *matched_bytes)
UNIV_INLINE int cmp_rec_rec (const rec_t *rec1, const rec_t *rec2, const ulint *offsets1, const ulint *offsets2, dict_index_t *index)

Detailed Description

Comparison services for records

Created 7/1/1994 Heikki Tuuri

Definition in file rem0cmp.h.

Function Documentation

UNIV_INTERN ibool cmp_cols_are_equal ( const dict_col_t col1,
const dict_col_t col2,
ibool  check_charsets 
)

Returns TRUE if two columns are equal for comparison purposes.

Returns
TRUE if the columns are considered equal in comparisons in: whether to check charsets

Returns TRUE if two columns are equal for comparison purposes.

Returns
TRUE if the columns are considered equal in comparisons
Parameters
col1in: column 1
col2in: column 2
check_charsetsin: whether to check charsets

Definition at line 112 of file rem0cmp.cc.

References cmp_cols_are_equal(), dtype_get_charset_coll(), dict_col_struct::len, dict_col_struct::mtype, and dict_col_struct::prtype.

Referenced by cmp_cols_are_equal().

UNIV_INLINE int cmp_data_data ( ulint  mtype,
ulint  prtype,
const byte *  data1,
ulint  len1,
const byte *  data2,
ulint  len2 
)

This function is used to compare two data fields for which we know the data type.

Returns
1, 0, -1, if data1 is greater, equal, less than data2, respectively in: data field length or UNIV_SQL_NULL
Parameters
mtypein: main type
prtypein: precise type
data1in: data field (== a pointer to a memory buffer)
len1in: data field length or UNIV_SQL_NULL
data2in: data field (== a pointer to a memory buffer)

Referenced by dict_load_foreigns().

UNIV_INTERN int cmp_data_data_slow ( ulint  mtype,
ulint  prtype,
const byte *  data1,
ulint  len1,
const byte *  data2,
ulint  len2 
)

This function is used to compare two data fields for which we know the data type.

Returns
1, 0, -1, if data1 is greater, equal, less than data2, respectively in: data field length or UNIV_SQL_NULL

This function is used to compare two data fields for which we know the data type.

Returns
1, 0, -1, if data1 is greater, equal, less than data2, respectively
Parameters
mtypein: main type
prtypein: precise type
data1in: data field (== a pointer to a memory buffer)
len1in: data field length or UNIV_SQL_NULL
data2in: data field (== a pointer to a memory buffer)
len2in: data field length or UNIV_SQL_NULL

Definition at line 292 of file rem0cmp.cc.

References cmp_data_data_slow(), dtype_get_charset_coll(), and dtype_get_pad_char().

Referenced by cmp_data_data_slow().

UNIV_INLINE int cmp_dfield_dfield ( const dfield_t dfield1,
const dfield_t dfield2 
)

This function is used to compare two dfields where at least the first has its data type field set.

Returns
1, 0, -1, if dfield1 is greater, equal, less than dfield2, respectively in: data field
Parameters
dfield1in: data field; must have type field set

Referenced by dtuple_coll_cmp(), and eval_cmp().

UNIV_INTERN ibool cmp_dtuple_is_prefix_of_rec ( const dtuple_t dtuple,
const rec_t *  rec,
const ulint *  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.

Returns
TRUE if prefix in: array returned by rec_get_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.

Returns
TRUE if prefix
Parameters
dtuplein: data tuple
recin: physical record
offsetsin: array returned by rec_get_offsets()

Definition at line 662 of file rem0cmp.cc.

References cmp_dtuple_is_prefix_of_rec(), cmp_dtuple_rec_with_match(), dfield_get_len(), dtuple_get_n_fields(), rec_offs_n_fields(), rec_offs_validate(), and ut_ad.

Referenced by cmp_dtuple_is_prefix_of_rec(), and row_search_for_mysql().

UNIV_INTERN int cmp_dtuple_rec ( const dtuple_t dtuple,
const rec_t *  rec,
const ulint *  offsets 
)

Compares a data tuple to a physical record.

See Also
cmp_dtuple_rec_with_match
Returns
1, 0, -1, if dtuple is greater, equal, less than rec, respectively in: array returned by rec_get_offsets()

Compares a data tuple to a physical record.

See Also
cmp_dtuple_rec_with_match
Returns
1, 0, -1, if dtuple is greater, equal, less than rec, respectively
Parameters
dtuplein: data tuple
recin: physical record
offsetsin: array returned by rec_get_offsets()

Definition at line 642 of file rem0cmp.cc.

References cmp_dtuple_rec(), cmp_dtuple_rec_with_match(), rec_offs_validate(), and ut_ad.

Referenced by btr_page_split_and_insert(), btr_pcur_restore_position_func(), cmp_dtuple_rec(), row_ins_check_foreign_constraint(), row_search_for_mysql(), and row_vers_impl_x_locked_off_kernel().

UNIV_INTERN int cmp_dtuple_rec_with_match ( const dtuple_t dtuple,
const rec_t *  rec,
const ulint *  offsets,
ulint *  matched_fields,
ulint *  matched_bytes 
)

This function is used to compare a data tuple to a physical record. Only dtuple->n_fields_cmp first fields are taken into account for the the data tuple! If we denote by n = n_fields_cmp, then rec must have either m >= n fields, or it must differ from dtuple in some of the m fields rec has. If rec has an externally stored field we do not compare it but return with value 0 if such a comparison should be made.

Returns
1, 0, -1, if dtuple is greater, equal, less than rec, respectively, when only the common first fields are compared, or until the first externally stored field in rec in/out: number of already matched bytes within the first field not completely matched; when function returns, contains the value for current comparison

This function is used to compare a data tuple to a physical record. Only dtuple->n_fields_cmp first fields are taken into account for the the data tuple! If we denote by n = n_fields_cmp, then rec must have either m >= n fields, or it must differ from dtuple in some of the m fields rec has. If rec has an externally stored field we do not compare it but return with value 0 if such a comparison should be made.

Returns
1, 0, -1, if dtuple is greater, equal, less than rec, respectively, when only the common first fields are compared, or until the first externally stored field in rec
Parameters
dtuplein: data tuple
recin: physical record which differs from dtuple in some of the common fields, or which has an equal number or more fields than dtuple
offsetsin: array returned by rec_get_offsets()
matched_fieldsin/out: number of already completely matched fields; when function returns, contains the value for current comparison
matched_bytesin/out: number of already matched bytes within the first field not completely matched; when function returns, contains the value for current comparison

Definition at line 411 of file rem0cmp.cc.

References cmp_dtuple_rec_with_match(), dfield_get_len(), dtuple_check_typed(), dtuple_get_info_bits(), dtuple_get_n_fields_cmp(), dtype_get_charset_coll(), dtype_get_pad_char(), dtype_struct::mtype, dtype_struct::prtype, rec_get_info_bits(), rec_offs_comp(), rec_offs_n_fields(), rec_offs_nth_extern(), rec_offs_validate(), and ut_ad.

Referenced by cmp_dtuple_is_prefix_of_rec(), cmp_dtuple_rec(), cmp_dtuple_rec_with_match(), page_cur_search_with_match(), and row_check_index_for_mysql().

UNIV_INLINE int cmp_rec_rec ( const rec_t *  rec1,
const rec_t *  rec2,
const ulint *  offsets1,
const ulint *  offsets2,
dict_index_t index 
)

This function is used to compare two physical records. Only the common first fields are compared.

Returns
1, 0 , -1 if rec1 is greater, equal, less, respectively, than rec2; only the common first fields are compared in: data dictionary index
Parameters
rec1in: physical record
rec2in: physical record
offsets1in: rec_get_offsets(rec1, index)
offsets2in: rec_get_offsets(rec2, index)

Referenced by btr_pcur_restore_position_func(), and page_validate().

UNIV_INTERN int cmp_rec_rec_simple ( const rec_t *  rec1,
const rec_t *  rec2,
const ulint *  offsets1,
const ulint *  offsets2,
const dict_index_t index,
ibool *  null_eq 
)

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

Returns
1, 0, -1 if rec1 is greater, equal, less, respectively, than rec2 out: set to TRUE if found matching null values

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

Returns
1, 0, -1 if rec1 is greater, equal, less, respectively, than rec2

< length of current field in rec1

< pointer to the current byte in rec1 field

< value of current byte to be compared in rec1

< length of current field in rec2

< pointer to the current byte in rec2 field

< value of current byte to be compared in rec2

< current field number

Parameters
rec1in: physical record
rec2in: physical record
offsets1in: rec_get_offsets(rec1, ...)
offsets2in: rec_get_offsets(rec2, ...)
indexin: data dictionary index
null_eqout: set to TRUE if found matching null values

Definition at line 702 of file rem0cmp.cc.

References cmp_rec_rec_simple(), dict_index_get_n_unique(), dict_index_get_nth_col(), dtype_get_charset_coll(), dtype_get_pad_char(), dict_col_struct::mtype, dict_col_struct::prtype, rec_offs_comp(), rec_offs_n_fields(), rec_offs_nth_extern(), and ut_ad.

Referenced by cmp_rec_rec_simple().

UNIV_INTERN int cmp_rec_rec_with_match ( const rec_t *  rec1,
const rec_t *  rec2,
const ulint *  offsets1,
const ulint *  offsets2,
dict_index_t index,
ulint *  matched_fields,
ulint *  matched_bytes 
)

This function is used to compare two physical records. Only the common first fields are compared, and if an externally stored field is encountered, then 0 is returned.

Returns
1, 0, -1 if rec1 is greater, equal, less, respectively in/out: number of already matched bytes within the first field not completely matched; when the function returns, contains the value for the current comparison

This function is used to compare two physical records. Only the common first fields are compared, and if an externally stored field is encountered, then 0 is returned.

Returns
1, 0, -1 if rec1 is greater, equal, less, respectively
Parameters
rec1in: physical record
rec2in: physical record
offsets1in: rec_get_offsets(rec1, index)
offsets2in: rec_get_offsets(rec2, index)
indexin: data dictionary index
matched_fieldsin/out: number of already completely matched fields; when the function returns, contains the value the for current comparison
matched_bytesin/out: number of already matched bytes within the first field not completely matched; when the function returns, contains the value for the current comparison

Definition at line 857 of file rem0cmp.cc.

References cmp_rec_rec_with_match(), dict_index_get_nth_col(), DICT_UNIVERSAL, dtype_get_charset_coll(), dtype_get_pad_char(), dict_col_struct::mtype, dict_col_struct::prtype, rec_get_info_bits(), rec_offs_comp(), rec_offs_n_fields(), rec_offs_nth_extern(), rec_offs_validate(), dict_index_struct::type, and ut_ad.

Referenced by btr_estimate_number_of_different_key_vals(), and cmp_rec_rec_with_match().