1
/***********************************************************************
2
Comparison services for records
4
(c) 1994-2001 Innobase Oy
6
Created 7/1/1994 Heikki Tuuri
7
************************************************************************/
13
#include "data0data.h"
14
#include "data0type.h"
15
#include "dict0dict.h"
18
/*****************************************************************
19
Returns TRUE if two types are equal for comparison purposes. */
24
/* out: TRUE if the types are considered
25
equal in comparisons */
26
dtype_t* type1, /* in: type 1 */
27
dtype_t* type2, /* in: type 2 */
28
ibool check_charsets); /* in: whether to check charsets */
29
/*****************************************************************
30
This function is used to compare two data fields for which we know the
36
/* out: 1, 0, -1, if data1 is greater, equal,
37
less than data2, respectively */
38
dtype_t* cur_type,/* in: data type of the fields */
39
byte* data1, /* in: data field (== a pointer to a memory
41
ulint len1, /* in: data field length or UNIV_SQL_NULL */
42
byte* data2, /* in: data field (== a pointer to a memory
44
ulint len2); /* in: data field length or UNIV_SQL_NULL */
45
/*****************************************************************
46
This function is used to compare two data fields for which we know the
52
/* out: 1, 0, -1, if data1 is greater, equal,
53
less than data2, respectively */
54
dtype_t* cur_type,/* in: data type of the fields */
55
byte* data1, /* in: data field (== a pointer to a memory
57
ulint len1, /* in: data field length or UNIV_SQL_NULL */
58
byte* data2, /* in: data field (== a pointer to a memory
60
ulint len2); /* in: data field length or UNIV_SQL_NULL */
61
/*****************************************************************
62
This function is used to compare two dfields where at least the first
63
has its data type field set. */
68
/* out: 1, 0, -1, if dfield1 is greater, equal,
69
less than dfield2, respectively */
70
dfield_t* dfield1,/* in: data field; must have type field set */
71
dfield_t* dfield2);/* in: data field */
72
/*****************************************************************
73
This function is used to compare a data tuple to a physical record.
74
Only dtuple->n_fields_cmp first fields are taken into account for
75
the the data tuple! If we denote by n = n_fields_cmp, then rec must
76
have either m >= n fields, or it must differ from dtuple in some of
77
the m fields rec has. If rec has an externally stored field we do not
78
compare it but return with value 0 if such a comparison should be
82
cmp_dtuple_rec_with_match(
83
/*======================*/
84
/* out: 1, 0, -1, if dtuple is greater, equal,
85
less than rec, respectively, when only the
86
common first fields are compared, or
87
until the first externally stored field in
89
dtuple_t* dtuple, /* in: data tuple */
90
rec_t* rec, /* in: physical record which differs from
91
dtuple in some of the common fields, or which
92
has an equal number or more fields than
94
const ulint* offsets,/* in: array returned by rec_get_offsets() */
95
ulint* matched_fields, /* in/out: number of already completely
96
matched fields; when function returns,
97
contains the value for current comparison */
98
ulint* matched_bytes); /* in/out: number of already matched
99
bytes within the first field not completely
100
matched; when function returns, contains the
101
value for current comparison */
102
/******************************************************************
103
Compares a data tuple to a physical record. */
108
/* out: 1, 0, -1, if dtuple is greater, equal,
109
less than rec, respectively; see the comments
110
for cmp_dtuple_rec_with_match */
111
dtuple_t* dtuple, /* in: data tuple */
112
rec_t* rec, /* in: physical record */
113
const ulint* offsets);/* in: array returned by rec_get_offsets() */
114
/******************************************************************
115
Checks if a dtuple is a prefix of a record. The last field in dtuple
116
is allowed to be a prefix of the corresponding field in the record. */
119
cmp_dtuple_is_prefix_of_rec(
120
/*========================*/
121
/* out: TRUE if prefix */
122
dtuple_t* dtuple, /* in: data tuple */
123
rec_t* rec, /* in: physical record */
124
const ulint* offsets);/* in: array returned by rec_get_offsets() */
125
/*****************************************************************
126
This function is used to compare two physical records. Only the common
127
first fields are compared, and if an externally stored field is
128
encountered, then 0 is returned. */
131
cmp_rec_rec_with_match(
132
/*===================*/
133
/* out: 1, 0 , -1 if rec1 is greater, equal,
134
less, respectively, than rec2; only the common
135
first fields are compared */
136
rec_t* rec1, /* in: physical record */
137
rec_t* rec2, /* in: physical record */
138
const ulint* offsets1,/* in: rec_get_offsets(rec1, index) */
139
const ulint* offsets2,/* in: rec_get_offsets(rec2, index) */
140
dict_index_t* index, /* in: data dictionary index */
141
ulint* matched_fields, /* in/out: number of already completely
142
matched fields; when the function returns,
143
contains the value the for current
145
ulint* matched_bytes);/* in/out: number of already matched
146
bytes within the first field not completely
147
matched; when the function returns, contains
148
the value for the current comparison */
149
/*****************************************************************
150
This function is used to compare two physical records. Only the common
151
first fields are compared. */
156
/* out: 1, 0 , -1 if rec1 is greater, equal,
157
less, respectively, than rec2; only the common
158
first fields are compared */
159
rec_t* rec1, /* in: physical record */
160
rec_t* rec2, /* in: physical record */
161
const ulint* offsets1,/* in: rec_get_offsets(rec1, index) */
162
const ulint* offsets2,/* in: rec_get_offsets(rec2, index) */
163
dict_index_t* index); /* in: data dictionary index */
167
#include "rem0cmp.ic"