~stewart/haildb/trunk

« back to all changes in this revision

Viewing changes to include/rem0cmp.h

  • Committer: Stewart Smith
  • Date: 2010-04-09 07:57:43 UTC
  • Revision ID: stewart@flamingspork.com-20100409075743-jfh1oml3el1uouvh
Embedded InnoDB 1.0.0 released

2009-04-21      The InnoDB Team

        Embedded InnoDB 1.0.0 released

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************************
 
2
 
 
3
Copyright (c) 1994, 2009, Innobase Oy. All Rights Reserved.
 
4
 
 
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.
 
8
 
 
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.
 
12
 
 
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., 59 Temple
 
15
Place, Suite 330, Boston, MA 02111-1307 USA
 
16
 
 
17
*****************************************************************************/
 
18
 
 
19
/***********************************************************************
 
20
Comparison services for records
 
21
 
 
22
Created 7/1/1994 Heikki Tuuri
 
23
************************************************************************/
 
24
 
 
25
#ifndef rem0cmp_h
 
26
#define rem0cmp_h
 
27
 
 
28
#include "univ.i"
 
29
#include "data0data.h"
 
30
#include "data0type.h"
 
31
#include "dict0dict.h"
 
32
#include "rem0rec.h"
 
33
 
 
34
/*****************************************************************
 
35
Returns TRUE if two columns are equal for comparison purposes. */
 
36
UNIV_INTERN
 
37
ibool
 
38
cmp_cols_are_equal(
 
39
/*===============*/
 
40
                                        /* out: TRUE if the columns are
 
41
                                        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
 
48
data type. */
 
49
UNIV_INLINE
 
50
int
 
51
cmp_data_data(
 
52
/*==========*/
 
53
                                /* out: 1, 0, -1, if data1 is greater, equal,
 
54
                                less than data2, respectively */
 
55
        void*           cmp_ctx,/* in: client compare context */
 
56
        ulint           mtype,  /* in: main type */
 
57
        ulint           prtype, /* in: precise type */
 
58
        const byte*     data1,  /* in: data field (== a pointer to a memory
 
59
                                buffer) */
 
60
        ulint           len1,   /* in: data field length or UNIV_SQL_NULL */
 
61
        const byte*     data2,  /* in: data field (== a pointer to a memory
 
62
                                buffer) */
 
63
        ulint           len2);  /* in: data field length or UNIV_SQL_NULL */
 
64
/*****************************************************************
 
65
This function is used to compare two data fields for which we know the
 
66
data type. */
 
67
UNIV_INTERN
 
68
int
 
69
cmp_data_data_slow(
 
70
/*===============*/
 
71
                                /* out: 1, 0, -1, if data1 is greater, equal,
 
72
                                less than data2, respectively */
 
73
        void*           cmp_ctx,/* in: client compare context */
 
74
        ulint           mtype,  /* in: main type */
 
75
        ulint           prtype, /* in: precise type */
 
76
        const byte*     data1,  /* in: data field (== a pointer to a memory
 
77
                                buffer) */
 
78
        ulint           len1,   /* in: data field length or UNIV_SQL_NULL */
 
79
        const byte*     data2,  /* in: data field (== a pointer to a memory
 
80
                                buffer) */
 
81
        ulint           len2);  /* in: data field length or UNIV_SQL_NULL */
 
82
/*****************************************************************
 
83
This function is used to compare two dfields where at least the first
 
84
has its data type field set. */
 
85
UNIV_INLINE
 
86
int
 
87
cmp_dfield_dfield(
 
88
/*==============*/
 
89
                                /* out: 1, 0, -1, if dfield1 is greater, equal,
 
90
                                less than dfield2, respectively */
 
91
        void*           cmp_ctx,/* in: client compare context */
 
92
        const dfield_t* dfield1,/* in: data field; must have type field set */
 
93
        const dfield_t* dfield2);/* in: data field */
 
94
/*****************************************************************
 
95
This function is used to compare a data tuple to a physical record.
 
96
Only dtuple->n_fields_cmp first fields are taken into account for
 
97
the the data tuple! If we denote by n = n_fields_cmp, then rec must
 
98
have either m >= n fields, or it must differ from dtuple in some of
 
99
the m fields rec has. If rec has an externally stored field we do not
 
100
compare it but return with value 0 if such a comparison should be
 
101
made. */
 
102
UNIV_INTERN
 
103
int
 
104
cmp_dtuple_rec_with_match(
 
105
/*======================*/
 
106
                                /* out: 1, 0, -1, if dtuple is greater, equal,
 
107
                                less than rec, respectively, when only the
 
108
                                common first fields are compared, or
 
109
                                until the first externally stored field in
 
110
                                rec */
 
111
        void*           cmp_ctx,/* in: client compare context */
 
112
        const dtuple_t* dtuple, /* in: data tuple */
 
113
        const rec_t*    rec,    /* in: physical record which differs from
 
114
                                dtuple in some of the common fields, or which
 
115
                                has an equal number or more fields than
 
116
                                dtuple */
 
117
        const ulint*    offsets,/* in: array returned by rec_get_offsets() */
 
118
        ulint*          matched_fields, /* in/out: number of already completely
 
119
                                matched fields; when function returns,
 
120
                                contains the value for current comparison */
 
121
        ulint*          matched_bytes); /* in/out: number of already matched
 
122
                                bytes within the first field not completely
 
123
                                matched; when function returns, contains the
 
124
                                value for current comparison */
 
125
/******************************************************************
 
126
Compares a data tuple to a physical record. */
 
127
UNIV_INTERN
 
128
int
 
129
cmp_dtuple_rec(
 
130
/*===========*/
 
131
                                /* out: 1, 0, -1, if dtuple is greater, equal,
 
132
                                less than rec, respectively; see the comments
 
133
                                for cmp_dtuple_rec_with_match */
 
134
        void*           cmp_ctx,/* in: client compare context */
 
135
        const dtuple_t* dtuple, /* in: data tuple */
 
136
        const rec_t*    rec,    /* in: physical record */
 
137
        const ulint*    offsets);/* in: array returned by rec_get_offsets() */
 
138
/******************************************************************
 
139
Checks if a dtuple is a prefix of a record. The last field in dtuple
 
140
is allowed to be a prefix of the corresponding field in the record. */
 
141
UNIV_INTERN
 
142
ibool
 
143
cmp_dtuple_is_prefix_of_rec(
 
144
/*========================*/
 
145
                                /* out: TRUE if prefix */
 
146
        void*           cmp_ctx,/* in: client compare context */
 
147
        const dtuple_t* dtuple, /* in: data tuple */
 
148
        const rec_t*    rec,    /* in: physical record */
 
149
        const ulint*    offsets);/* in: array returned by rec_get_offsets() */
 
150
/*****************************************************************
 
151
Compare two physical records that contain the same number of columns,
 
152
none of which are stored externally. */
 
153
UNIV_INTERN
 
154
int
 
155
cmp_rec_rec_simple(
 
156
/*===============*/
 
157
                                        /* out: 1, 0 , -1 if rec1 is greater,
 
158
                                        equal, less, respectively, than rec2 */
 
159
        const rec_t*            rec1,   /* in: physical record */
 
160
        const 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
        const dict_index_t*     index); /* in: data dictionary index */
 
164
/*****************************************************************
 
165
This function is used to compare two physical records. Only the common
 
166
first fields are compared, and if an externally stored field is
 
167
encountered, then 0 is returned. */
 
168
UNIV_INTERN
 
169
int
 
170
cmp_rec_rec_with_match(
 
171
/*===================*/
 
172
                                /* out: 1, 0 , -1 if rec1 is greater, equal,
 
173
                                less, respectively, than rec2; only the common
 
174
                                first fields are compared */
 
175
        const rec_t*    rec1,   /* in: physical record */
 
176
        const rec_t*    rec2,   /* in: physical record */
 
177
        const ulint*    offsets1,/* in: rec_get_offsets(rec1, index) */
 
178
        const ulint*    offsets2,/* in: rec_get_offsets(rec2, index) */
 
179
        dict_index_t*   index,  /* in: data dictionary index */
 
180
        ulint*          matched_fields, /* in/out: number of already completely
 
181
                                matched fields; when the function returns,
 
182
                                contains the value the for current
 
183
                                comparison */
 
184
        ulint*          matched_bytes);/* in/out: number of already matched
 
185
                                bytes within the first field not completely
 
186
                                matched; when the function returns, contains
 
187
                                the value for the current comparison */
 
188
/*****************************************************************
 
189
This function is used to compare two physical records. Only the common
 
190
first fields are compared. */
 
191
UNIV_INLINE
 
192
int
 
193
cmp_rec_rec(
 
194
/*========*/
 
195
                                /* out: 1, 0 , -1 if rec1 is greater, equal,
 
196
                                less, respectively, than rec2; only the common
 
197
                                first fields are compared */
 
198
        const rec_t*    rec1,   /* in: physical record */
 
199
        const rec_t*    rec2,   /* in: physical record */
 
200
        const ulint*    offsets1,/* in: rec_get_offsets(rec1, index) */
 
201
        const ulint*    offsets2,/* in: rec_get_offsets(rec2, index) */
 
202
        dict_index_t*   index); /* in: data dictionary index */
 
203
 
 
204
 
 
205
#ifndef UNIV_NONINL
 
206
#include "rem0cmp.ic"
 
207
#endif
 
208
 
 
209
#endif