32
15
#include "dict0dict.h"
33
16
#include "rem0rec.h"
35
/*************************************************************//**
36
Returns TRUE if two columns are equal for comparison purposes.
37
@return TRUE if the columns are considered equal in comparisons */
18
/*****************************************************************
19
Returns TRUE if two columns are equal for comparison purposes. */
40
22
cmp_cols_are_equal(
41
23
/*===============*/
42
const dict_col_t* col1, /*!< in: column 1 */
43
const dict_col_t* col2, /*!< in: column 2 */
24
/* out: TRUE if the columns are
25
considered equal in comparisons */
26
const dict_col_t* col1, /* in: column 1 */
27
const dict_col_t* col2, /* in: column 2 */
44
28
ibool check_charsets);
45
/*!< in: whether to check charsets */
46
/*************************************************************//**
29
/* in: whether to check charsets */
30
/*****************************************************************
47
31
This function is used to compare two data fields for which we know the
49
@return 1, 0, -1, if data1 is greater, equal, less than data2, respectively */
54
ulint mtype, /*!< in: main type */
55
ulint prtype, /*!< in: precise type */
56
const byte* data1, /*!< in: data field (== a pointer to a memory
58
ulint len1, /*!< in: data field length or UNIV_SQL_NULL */
59
const byte* data2, /*!< in: data field (== a pointer to a memory
61
ulint len2); /*!< in: data field length or UNIV_SQL_NULL */
62
/*************************************************************//**
37
/* out: 1, 0, -1, if data1 is greater, equal,
38
less than data2, respectively */
39
ulint mtype, /* in: main type */
40
ulint prtype, /* in: precise type */
41
const byte* data1, /* in: data field (== a pointer to a memory
43
ulint len1, /* in: data field length or UNIV_SQL_NULL */
44
const byte* data2, /* in: data field (== a pointer to a memory
46
ulint len2); /* in: data field length or UNIV_SQL_NULL */
47
/*****************************************************************
63
48
This function is used to compare two data fields for which we know the
65
@return 1, 0, -1, if data1 is greater, equal, less than data2, respectively */
68
52
cmp_data_data_slow(
69
53
/*===============*/
70
ulint mtype, /*!< in: main type */
71
ulint prtype, /*!< in: precise type */
72
const byte* data1, /*!< in: data field (== a pointer to a memory
74
ulint len1, /*!< in: data field length or UNIV_SQL_NULL */
75
const byte* data2, /*!< in: data field (== a pointer to a memory
77
ulint len2); /*!< in: data field length or UNIV_SQL_NULL */
78
/*************************************************************//**
54
/* out: 1, 0, -1, if data1 is greater, equal,
55
less than data2, respectively */
56
ulint mtype, /* in: main type */
57
ulint prtype, /* in: precise type */
58
const byte* data1, /* in: data field (== a pointer to a memory
60
ulint len1, /* in: data field length or UNIV_SQL_NULL */
61
const byte* data2, /* in: data field (== a pointer to a memory
63
ulint len2); /* in: data field length or UNIV_SQL_NULL */
64
/*****************************************************************
79
65
This function is used to compare two dfields where at least the first
80
has its data type field set.
81
@return 1, 0, -1, if dfield1 is greater, equal, less than dfield2,
66
has its data type field set. */
87
const dfield_t* dfield1,/*!< in: data field; must have type field set */
88
const dfield_t* dfield2);/*!< in: data field */
89
/*************************************************************//**
71
/* out: 1, 0, -1, if dfield1 is greater, equal,
72
less than dfield2, respectively */
73
const dfield_t* dfield1,/* in: data field; must have type field set */
74
const dfield_t* dfield2);/* in: data field */
75
/*****************************************************************
90
76
This function is used to compare a data tuple to a physical record.
91
77
Only dtuple->n_fields_cmp first fields are taken into account for
92
78
the the data tuple! If we denote by n = n_fields_cmp, then rec must
93
79
have either m >= n fields, or it must differ from dtuple in some of
94
80
the m fields rec has. If rec has an externally stored field we do not
95
81
compare it but return with value 0 if such a comparison should be
97
@return 1, 0, -1, if dtuple is greater, equal, less than rec,
98
respectively, when only the common first fields are compared, or until
99
the first externally stored field in rec */
102
85
cmp_dtuple_rec_with_match(
103
86
/*======================*/
104
const dtuple_t* dtuple, /*!< in: data tuple */
105
const rec_t* rec, /*!< in: physical record which differs from
87
/* out: 1, 0, -1, if dtuple is greater, equal,
88
less than rec, respectively, when only the
89
common first fields are compared, or
90
until the first externally stored field in
92
const dtuple_t* dtuple, /* in: data tuple */
93
const rec_t* rec, /* in: physical record which differs from
106
94
dtuple in some of the common fields, or which
107
95
has an equal number or more fields than
109
const ulint* offsets,/*!< in: array returned by rec_get_offsets() */
110
ulint* matched_fields, /*!< in/out: number of already completely
97
const ulint* offsets,/* in: array returned by rec_get_offsets() */
98
ulint* matched_fields, /* in/out: number of already completely
111
99
matched fields; when function returns,
112
100
contains the value for current comparison */
113
ulint* matched_bytes); /*!< in/out: number of already matched
101
ulint* matched_bytes); /* in/out: number of already matched
114
102
bytes within the first field not completely
115
103
matched; when function returns, contains the
116
104
value for current comparison */
117
/**************************************************************//**
118
Compares a data tuple to a physical record.
119
@see cmp_dtuple_rec_with_match
120
@return 1, 0, -1, if dtuple is greater, equal, less than rec, respectively */
105
/******************************************************************
106
Compares a data tuple to a physical record. */
125
const dtuple_t* dtuple, /*!< in: data tuple */
126
const rec_t* rec, /*!< in: physical record */
127
const ulint* offsets);/*!< in: array returned by rec_get_offsets() */
128
/**************************************************************//**
111
/* out: 1, 0, -1, if dtuple is greater, equal,
112
less than rec, respectively; see the comments
113
for cmp_dtuple_rec_with_match */
114
const dtuple_t* dtuple, /* in: data tuple */
115
const rec_t* rec, /* in: physical record */
116
const ulint* offsets);/* in: array returned by rec_get_offsets() */
117
/******************************************************************
129
118
Checks if a dtuple is a prefix of a record. The last field in dtuple
130
is allowed to be a prefix of the corresponding field in the record.
131
@return TRUE if prefix */
119
is allowed to be a prefix of the corresponding field in the record. */
134
122
cmp_dtuple_is_prefix_of_rec(
135
123
/*========================*/
136
const dtuple_t* dtuple, /*!< in: data tuple */
137
const rec_t* rec, /*!< in: physical record */
138
const ulint* offsets);/*!< in: array returned by rec_get_offsets() */
139
/*************************************************************//**
124
/* out: TRUE if prefix */
125
const dtuple_t* dtuple, /* in: data tuple */
126
const rec_t* rec, /* in: physical record */
127
const ulint* offsets);/* in: array returned by rec_get_offsets() */
128
#ifndef UNIV_HOTBACKUP
129
/*****************************************************************
140
130
Compare two physical records that contain the same number of columns,
141
none of which are stored externally.
142
@return 1, 0, -1 if rec1 is greater, equal, less, respectively, than rec2 */
131
none of which are stored externally. */
145
134
cmp_rec_rec_simple(
146
135
/*===============*/
147
const rec_t* rec1, /*!< in: physical record */
148
const rec_t* rec2, /*!< in: physical record */
149
const ulint* offsets1,/*!< in: rec_get_offsets(rec1, ...) */
150
const ulint* offsets2,/*!< in: rec_get_offsets(rec2, ...) */
151
const dict_index_t* index, /*!< in: data dictionary index */
152
ibool* null_eq);/*!< out: set to TRUE if
153
found matching null values */
154
/*************************************************************//**
136
/* out: 1, 0 , -1 if rec1 is greater,
137
equal, less, respectively, than rec2 */
138
const rec_t* rec1, /* in: physical record */
139
const rec_t* rec2, /* in: physical record */
140
const ulint* offsets1,/* in: rec_get_offsets(rec1, index) */
141
const ulint* offsets2,/* in: rec_get_offsets(rec2, index) */
142
const dict_index_t* index); /* in: data dictionary index */
143
#endif /* !UNIV_HOTBACKUP */
144
/*****************************************************************
155
145
This function is used to compare two physical records. Only the common
156
146
first fields are compared, and if an externally stored field is
157
encountered, then 0 is returned.
158
@return 1, 0, -1 if rec1 is greater, equal, less, respectively */
147
encountered, then 0 is returned. */
161
150
cmp_rec_rec_with_match(
162
151
/*===================*/
163
const rec_t* rec1, /*!< in: physical record */
164
const rec_t* rec2, /*!< in: physical record */
165
const ulint* offsets1,/*!< in: rec_get_offsets(rec1, index) */
166
const ulint* offsets2,/*!< in: rec_get_offsets(rec2, index) */
167
dict_index_t* index, /*!< in: data dictionary index */
168
ulint* matched_fields, /*!< in/out: number of already completely
152
/* out: 1, 0 , -1 if rec1 is greater, equal,
153
less, respectively, than rec2; only the common
154
first fields are compared */
155
const rec_t* rec1, /* in: physical record */
156
const rec_t* rec2, /* in: physical record */
157
const ulint* offsets1,/* in: rec_get_offsets(rec1, index) */
158
const ulint* offsets2,/* in: rec_get_offsets(rec2, index) */
159
dict_index_t* index, /* in: data dictionary index */
160
ulint* matched_fields, /* in/out: number of already completely
169
161
matched fields; when the function returns,
170
162
contains the value the for current
172
ulint* matched_bytes);/*!< in/out: number of already matched
164
ulint* matched_bytes);/* in/out: number of already matched
173
165
bytes within the first field not completely
174
166
matched; when the function returns, contains
175
167
the value for the current comparison */
176
/*************************************************************//**
168
/*****************************************************************
177
169
This function is used to compare two physical records. Only the common
178
first fields are compared.
179
@return 1, 0 , -1 if rec1 is greater, equal, less, respectively, than
180
rec2; only the common first fields are compared */
170
first fields are compared. */
185
const rec_t* rec1, /*!< in: physical record */
186
const rec_t* rec2, /*!< in: physical record */
187
const ulint* offsets1,/*!< in: rec_get_offsets(rec1, index) */
188
const ulint* offsets2,/*!< in: rec_get_offsets(rec2, index) */
189
dict_index_t* index); /*!< in: data dictionary index */
175
/* out: 1, 0 , -1 if rec1 is greater, equal,
176
less, respectively, than rec2; only the common
177
first fields are compared */
178
const rec_t* rec1, /* in: physical record */
179
const rec_t* rec2, /* in: physical record */
180
const ulint* offsets1,/* in: rec_get_offsets(rec1, index) */
181
const ulint* offsets2,/* in: rec_get_offsets(rec2, index) */
182
dict_index_t* index); /* in: data dictionary index */
192
185
#ifndef UNIV_NONINL