~drizzle-trunk/drizzle/development

1 by brian
clean slate
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
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
	byte*		data1,	/* in: data field (== a pointer to a memory
42
				buffer) */
43
	ulint		len1,	/* in: data field length or UNIV_SQL_NULL */
44
	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
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
	byte*		data1,	/* in: data field (== a pointer to a memory
59
				buffer) */
60
	ulint		len1,	/* in: data field length or UNIV_SQL_NULL */
61
	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
	dfield_t*	dfield1,/* in: data field; must have type field set */
74
	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
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
	dtuple_t*	dtuple,	/* in: data tuple */
93
	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
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
	dtuple_t*	dtuple,	/* in: data tuple */
115
	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
121
ibool
122
cmp_dtuple_is_prefix_of_rec(
123
/*========================*/
124
				/* out: TRUE if prefix */
125
	dtuple_t*	dtuple,	/* in: data tuple */
126
	rec_t*		rec,	/* in: physical record */
127
	const ulint*	offsets);/* in: array returned by rec_get_offsets() */
128
/*****************************************************************
129
This function is used to compare two physical records. Only the common
130
first fields are compared, and if an externally stored field is
131
encountered, then 0 is returned. */
132
133
int
134
cmp_rec_rec_with_match(
135
/*===================*/
136
				/* out: 1, 0 , -1 if rec1 is greater, equal,
137
				less, respectively, than rec2; only the common
138
				first fields are compared */
139
	rec_t*		rec1,	/* in: physical record */
140
	rec_t*		rec2,	/* in: physical record */
141
	const ulint*	offsets1,/* in: rec_get_offsets(rec1, index) */
142
	const ulint*	offsets2,/* in: rec_get_offsets(rec2, index) */
143
	dict_index_t*	index,	/* in: data dictionary index */
144
	ulint*		matched_fields, /* in/out: number of already completely
145
				matched fields; when the function returns,
146
				contains the value the for current
147
				comparison */
148
	ulint*		matched_bytes);/* in/out: number of already matched
149
				bytes within the first field not completely
150
				matched; when the function returns, contains
151
				the value for the current comparison */
152
/*****************************************************************
153
This function is used to compare two physical records. Only the common
154
first fields are compared. */
155
UNIV_INLINE
156
int
157
cmp_rec_rec(
158
/*========*/
159
				/* out: 1, 0 , -1 if rec1 is greater, equal,
160
				less, respectively, than rec2; only the common
161
				first fields are compared */
162
	rec_t*		rec1,	/* in: physical record */
163
	rec_t*		rec2,	/* in: physical record */
164
	const ulint*	offsets1,/* in: rec_get_offsets(rec1, index) */
165
	const ulint*	offsets2,/* in: rec_get_offsets(rec2, index) */
166
	dict_index_t*	index);	/* in: data dictionary index */
167
168
169
#ifndef UNIV_NONINL
170
#include "rem0cmp.ic"
171
#endif
172
173
#endif