~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/include/rem0cmp.h

  • Committer: Brian Aker
  • Date: 2009-02-21 00:18:15 UTC
  • Revision ID: brian@tangent.org-20090221001815-x20e8h71e984lvs1
Completion (?) of uint conversion.

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., 51 Franklin
15
 
St, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
 
*****************************************************************************/
18
 
 
19
 
/*******************************************************************//**
20
 
@file include/rem0cmp.h
 
1
/***********************************************************************
21
2
Comparison services for records
22
3
 
 
4
(c) 1994-2001 Innobase Oy
 
5
 
23
6
Created 7/1/1994 Heikki Tuuri
24
7
************************************************************************/
25
8
 
32
15
#include "dict0dict.h"
33
16
#include "rem0rec.h"
34
17
 
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. */
38
20
UNIV_INTERN
39
21
ibool
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
48
 
data type.
49
 
@return 1, 0, -1, if data1 is greater, equal, less than data2, respectively */
 
32
data type. */
50
33
UNIV_INLINE
51
34
int
52
35
cmp_data_data(
53
36
/*==========*/
54
 
        ulint           mtype,  /*!< in: main type */
55
 
        ulint           prtype, /*!< in: precise type */
56
 
        const byte*     data1,  /*!< in: data field (== a pointer to a memory
57
 
                                buffer) */
58
 
        ulint           len1,   /*!< in: data field length or UNIV_SQL_NULL */
59
 
        const byte*     data2,  /*!< in: data field (== a pointer to a memory
60
 
                                buffer) */
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
 
42
                                buffer) */
 
43
        ulint           len1,   /* in: data field length or UNIV_SQL_NULL */
 
44
        const byte*     data2,  /* in: data field (== a pointer to a memory
 
45
                                buffer) */
 
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
64
 
data type.
65
 
@return 1, 0, -1, if data1 is greater, equal, less than data2, respectively */
 
49
data type. */
66
50
UNIV_INTERN
67
51
int
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
73
 
                                buffer) */
74
 
        ulint           len1,   /*!< in: data field length or UNIV_SQL_NULL */
75
 
        const byte*     data2,  /*!< in: data field (== a pointer to a memory
76
 
                                buffer) */
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
 
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
/*****************************************************************
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,
82
 
respectively */
 
66
has its data type field set. */
83
67
UNIV_INLINE
84
68
int
85
69
cmp_dfield_dfield(
86
70
/*==============*/
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
96
 
made.
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 */
 
82
made. */
100
83
UNIV_INTERN
101
84
int
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
 
91
                                rec */
 
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
108
96
                                dtuple */
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. */
121
107
UNIV_INTERN
122
108
int
123
109
cmp_dtuple_rec(
124
110
/*===========*/
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. */
132
120
UNIV_INTERN
133
121
ibool
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. */
143
132
UNIV_INTERN
144
133
int
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. */
159
148
UNIV_INTERN
160
149
int
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
171
163
                                comparison */
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. */
181
171
UNIV_INLINE
182
172
int
183
173
cmp_rec_rec(
184
174
/*========*/
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 */
190
183
 
191
184
 
192
185
#ifndef UNIV_NONINL