1
/*****************************************************************************
3
Copyright (C) 1994, 2009, Innobase Oy. All Rights Reserved.
5
This program is free software; you can redistribute it and/or modify it under
6
the terms of the GNU General Public License as published by the Free Software
7
Foundation; version 2 of the License.
9
This program is distributed in the hope that it will be useful, but WITHOUT
10
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
You should have received a copy of the GNU General Public License along with
14
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15
St, Fifth Floor, Boston, MA 02110-1301 USA
17
*****************************************************************************/
19
/*******************************************************************//**
20
@file include/rem0cmp.h
21
Comparison services for records
23
Created 7/1/1994 Heikki Tuuri
24
************************************************************************/
30
#include "data0data.h"
31
#include "data0type.h"
32
#include "dict0dict.h"
35
/*************************************************************//**
36
Returns TRUE if two columns are equal for comparison purposes.
37
@return TRUE if the columns are considered equal in comparisons */
42
const dict_col_t* col1, /*!< in: column 1 */
43
const dict_col_t* col2, /*!< in: column 2 */
44
ibool check_charsets);
45
/*!< in: whether to check charsets */
46
/*************************************************************//**
47
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
/*************************************************************//**
63
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 */
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
/*************************************************************//**
79
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,
87
const dfield_t* dfield1,/*!< in: data field; must have type field set */
88
const dfield_t* dfield2);/*!< in: data field */
89
/*************************************************************//**
90
This function is used to compare a data tuple to a physical record.
91
Only dtuple->n_fields_cmp first fields are taken into account for
92
the the data tuple! If we denote by n = n_fields_cmp, then rec must
93
have either m >= n fields, or it must differ from dtuple in some of
94
the m fields rec has. If rec has an externally stored field we do not
95
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
cmp_dtuple_rec_with_match(
103
/*======================*/
104
const dtuple_t* dtuple, /*!< in: data tuple */
105
const rec_t* rec, /*!< in: physical record which differs from
106
dtuple in some of the common fields, or which
107
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
111
matched fields; when function returns,
112
contains the value for current comparison */
113
ulint* matched_bytes); /*!< in/out: number of already matched
114
bytes within the first field not completely
115
matched; when function returns, contains the
116
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 */
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
/**************************************************************//**
129
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 */
134
cmp_dtuple_is_prefix_of_rec(
135
/*========================*/
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
/*************************************************************//**
140
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 */
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
/*************************************************************//**
155
This function is used to compare two physical records. Only the common
156
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 */
161
cmp_rec_rec_with_match(
162
/*===================*/
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
169
matched fields; when the function returns,
170
contains the value the for current
172
ulint* matched_bytes);/*!< in/out: number of already matched
173
bytes within the first field not completely
174
matched; when the function returns, contains
175
the value for the current comparison */
176
/*************************************************************//**
177
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 */
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 */
193
#include "rem0cmp.ic"