~percona-dev/percona-innodb-plugin/percona-innodb-1.0

« back to all changes in this revision

Viewing changes to include/rem0cmp.h

  • Committer: Vadim Tkachenko
  • Date: 2008-12-01 02:05:57 UTC
  • Revision ID: vadim@percona.com-20081201020557-p7k2m94mjtdg1a83
New rw-locks

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***********************************************************************
 
2
Comparison services for records
 
3
 
 
4
(c) 1994-2001 Innobase Oy
 
5
 
 
6
Created 7/1/1994 Heikki Tuuri
 
7
************************************************************************/
 
8
 
 
9
#ifndef rem0cmp_h
 
10
#define rem0cmp_h
 
11
 
 
12
#include "univ.i"
 
13
#include "data0data.h"
 
14
#include "data0type.h"
 
15
#include "dict0dict.h"
 
16
#include "rem0rec.h"
 
17
 
 
18
/*****************************************************************
 
19
Returns TRUE if two columns are equal for comparison purposes. */
 
20
UNIV_INTERN
 
21
ibool
 
22
cmp_cols_are_equal(
 
23
/*===============*/
 
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 */
 
28
        ibool                   check_charsets);
 
29
                                        /* in: whether to check charsets */
 
30
/*****************************************************************
 
31
This function is used to compare two data fields for which we know the
 
32
data type. */
 
33
UNIV_INLINE
 
34
int
 
35
cmp_data_data(
 
36
/*==========*/
 
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
/*****************************************************************
 
48
This function is used to compare two data fields for which we know the
 
49
data type. */
 
50
UNIV_INTERN
 
51
int
 
52
cmp_data_data_slow(
 
53
/*===============*/
 
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
/*****************************************************************
 
65
This function is used to compare two dfields where at least the first
 
66
has its data type field set. */
 
67
UNIV_INLINE
 
68
int
 
69
cmp_dfield_dfield(
 
70
/*==============*/
 
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
/*****************************************************************
 
76
This function is used to compare a data tuple to a physical record.
 
77
Only dtuple->n_fields_cmp first fields are taken into account for
 
78
the the data tuple! If we denote by n = n_fields_cmp, then rec must
 
79
have either m >= n fields, or it must differ from dtuple in some of
 
80
the m fields rec has. If rec has an externally stored field we do not
 
81
compare it but return with value 0 if such a comparison should be
 
82
made. */
 
83
UNIV_INTERN
 
84
int
 
85
cmp_dtuple_rec_with_match(
 
86
/*======================*/
 
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
 
94
                                dtuple in some of the common fields, or which
 
95
                                has an equal number or more fields than
 
96
                                dtuple */
 
97
        const ulint*    offsets,/* in: array returned by rec_get_offsets() */
 
98
        ulint*          matched_fields, /* in/out: number of already completely
 
99
                                matched fields; when function returns,
 
100
                                contains the value for current comparison */
 
101
        ulint*          matched_bytes); /* in/out: number of already matched
 
102
                                bytes within the first field not completely
 
103
                                matched; when function returns, contains the
 
104
                                value for current comparison */
 
105
/******************************************************************
 
106
Compares a data tuple to a physical record. */
 
107
UNIV_INTERN
 
108
int
 
109
cmp_dtuple_rec(
 
110
/*===========*/
 
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
/******************************************************************
 
118
Checks if a dtuple is a prefix of a record. The last field in dtuple
 
119
is allowed to be a prefix of the corresponding field in the record. */
 
120
UNIV_INTERN
 
121
ibool
 
122
cmp_dtuple_is_prefix_of_rec(
 
123
/*========================*/
 
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
/*****************************************************************
 
130
Compare two physical records that contain the same number of columns,
 
131
none of which are stored externally. */
 
132
UNIV_INTERN
 
133
int
 
134
cmp_rec_rec_simple(
 
135
/*===============*/
 
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
/*****************************************************************
 
145
This function is used to compare two physical records. Only the common
 
146
first fields are compared, and if an externally stored field is
 
147
encountered, then 0 is returned. */
 
148
UNIV_INTERN
 
149
int
 
150
cmp_rec_rec_with_match(
 
151
/*===================*/
 
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
 
161
                                matched fields; when the function returns,
 
162
                                contains the value the for current
 
163
                                comparison */
 
164
        ulint*          matched_bytes);/* in/out: number of already matched
 
165
                                bytes within the first field not completely
 
166
                                matched; when the function returns, contains
 
167
                                the value for the current comparison */
 
168
/*****************************************************************
 
169
This function is used to compare two physical records. Only the common
 
170
first fields are compared. */
 
171
UNIV_INLINE
 
172
int
 
173
cmp_rec_rec(
 
174
/*========*/
 
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 */
 
183
 
 
184
 
 
185
#ifndef UNIV_NONINL
 
186
#include "rem0cmp.ic"
 
187
#endif
 
188
 
 
189
#endif