00001 /*********************************************************************** 00002 Comparison services for records 00003 00004 (c) 1994-2001 Innobase Oy 00005 00006 Created 7/1/1994 Heikki Tuuri 00007 ************************************************************************/ 00008 00009 #ifndef rem0cmp_h 00010 #define rem0cmp_h 00011 00012 #include "univ.i" 00013 #include "data0data.h" 00014 #include "data0type.h" 00015 #include "dict0dict.h" 00016 #include "rem0rec.h" 00017 00018 /***************************************************************** 00019 Returns TRUE if two types are equal for comparison purposes. */ 00020 00021 ibool 00022 cmp_types_are_equal( 00023 /*================*/ 00024 /* out: TRUE if the types are considered 00025 equal in comparisons */ 00026 dtype_t* type1, /* in: type 1 */ 00027 dtype_t* type2, /* in: type 2 */ 00028 ibool check_charsets); /* in: whether to check charsets */ 00029 /***************************************************************** 00030 This function is used to compare two data fields for which we know the 00031 data type. */ 00032 UNIV_INLINE 00033 int 00034 cmp_data_data( 00035 /*==========*/ 00036 /* out: 1, 0, -1, if data1 is greater, equal, 00037 less than data2, respectively */ 00038 dtype_t* cur_type,/* in: data type of the fields */ 00039 byte* data1, /* in: data field (== a pointer to a memory 00040 buffer) */ 00041 ulint len1, /* in: data field length or UNIV_SQL_NULL */ 00042 byte* data2, /* in: data field (== a pointer to a memory 00043 buffer) */ 00044 ulint len2); /* in: data field length or UNIV_SQL_NULL */ 00045 /***************************************************************** 00046 This function is used to compare two data fields for which we know the 00047 data type. */ 00048 00049 int 00050 cmp_data_data_slow( 00051 /*===============*/ 00052 /* out: 1, 0, -1, if data1 is greater, equal, 00053 less than data2, respectively */ 00054 dtype_t* cur_type,/* in: data type of the fields */ 00055 byte* data1, /* in: data field (== a pointer to a memory 00056 buffer) */ 00057 ulint len1, /* in: data field length or UNIV_SQL_NULL */ 00058 byte* data2, /* in: data field (== a pointer to a memory 00059 buffer) */ 00060 ulint len2); /* in: data field length or UNIV_SQL_NULL */ 00061 /***************************************************************** 00062 This function is used to compare two dfields where at least the first 00063 has its data type field set. */ 00064 UNIV_INLINE 00065 int 00066 cmp_dfield_dfield( 00067 /*==============*/ 00068 /* out: 1, 0, -1, if dfield1 is greater, equal, 00069 less than dfield2, respectively */ 00070 dfield_t* dfield1,/* in: data field; must have type field set */ 00071 dfield_t* dfield2);/* in: data field */ 00072 /***************************************************************** 00073 This function is used to compare a data tuple to a physical record. 00074 Only dtuple->n_fields_cmp first fields are taken into account for 00075 the the data tuple! If we denote by n = n_fields_cmp, then rec must 00076 have either m >= n fields, or it must differ from dtuple in some of 00077 the m fields rec has. If rec has an externally stored field we do not 00078 compare it but return with value 0 if such a comparison should be 00079 made. */ 00080 00081 int 00082 cmp_dtuple_rec_with_match( 00083 /*======================*/ 00084 /* out: 1, 0, -1, if dtuple is greater, equal, 00085 less than rec, respectively, when only the 00086 common first fields are compared, or 00087 until the first externally stored field in 00088 rec */ 00089 dtuple_t* dtuple, /* in: data tuple */ 00090 rec_t* rec, /* in: physical record which differs from 00091 dtuple in some of the common fields, or which 00092 has an equal number or more fields than 00093 dtuple */ 00094 const ulint* offsets,/* in: array returned by rec_get_offsets() */ 00095 ulint* matched_fields, /* in/out: number of already completely 00096 matched fields; when function returns, 00097 contains the value for current comparison */ 00098 ulint* matched_bytes); /* in/out: number of already matched 00099 bytes within the first field not completely 00100 matched; when function returns, contains the 00101 value for current comparison */ 00102 /****************************************************************** 00103 Compares a data tuple to a physical record. */ 00104 00105 int 00106 cmp_dtuple_rec( 00107 /*===========*/ 00108 /* out: 1, 0, -1, if dtuple is greater, equal, 00109 less than rec, respectively; see the comments 00110 for cmp_dtuple_rec_with_match */ 00111 dtuple_t* dtuple, /* in: data tuple */ 00112 rec_t* rec, /* in: physical record */ 00113 const ulint* offsets);/* in: array returned by rec_get_offsets() */ 00114 /****************************************************************** 00115 Checks if a dtuple is a prefix of a record. The last field in dtuple 00116 is allowed to be a prefix of the corresponding field in the record. */ 00117 00118 ibool 00119 cmp_dtuple_is_prefix_of_rec( 00120 /*========================*/ 00121 /* out: TRUE if prefix */ 00122 dtuple_t* dtuple, /* in: data tuple */ 00123 rec_t* rec, /* in: physical record */ 00124 const ulint* offsets);/* in: array returned by rec_get_offsets() */ 00125 /***************************************************************** 00126 This function is used to compare two physical records. Only the common 00127 first fields are compared, and if an externally stored field is 00128 encountered, then 0 is returned. */ 00129 00130 int 00131 cmp_rec_rec_with_match( 00132 /*===================*/ 00133 /* out: 1, 0 , -1 if rec1 is greater, equal, 00134 less, respectively, than rec2; only the common 00135 first fields are compared */ 00136 rec_t* rec1, /* in: physical record */ 00137 rec_t* rec2, /* in: physical record */ 00138 const ulint* offsets1,/* in: rec_get_offsets(rec1, index) */ 00139 const ulint* offsets2,/* in: rec_get_offsets(rec2, index) */ 00140 dict_index_t* index, /* in: data dictionary index */ 00141 ulint* matched_fields, /* in/out: number of already completely 00142 matched fields; when the function returns, 00143 contains the value the for current 00144 comparison */ 00145 ulint* matched_bytes);/* in/out: number of already matched 00146 bytes within the first field not completely 00147 matched; when the function returns, contains 00148 the value for the current comparison */ 00149 /***************************************************************** 00150 This function is used to compare two physical records. Only the common 00151 first fields are compared. */ 00152 UNIV_INLINE 00153 int 00154 cmp_rec_rec( 00155 /*========*/ 00156 /* out: 1, 0 , -1 if rec1 is greater, equal, 00157 less, respectively, than rec2; only the common 00158 first fields are compared */ 00159 rec_t* rec1, /* in: physical record */ 00160 rec_t* rec2, /* in: physical record */ 00161 const ulint* offsets1,/* in: rec_get_offsets(rec1, index) */ 00162 const ulint* offsets2,/* in: rec_get_offsets(rec2, index) */ 00163 dict_index_t* index); /* in: data dictionary index */ 00164 00165 00166 #ifndef UNIV_NONINL 00167 #include "rem0cmp.ic" 00168 #endif 00169 00170 #endif
1.4.7

