You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

186 lines
6.5 KiB

17 years ago
17 years ago
17 years ago
16 years ago
16 years ago
16 years ago
16 years ago
16 years ago
16 years ago
16 years ago
16 years ago
16 years ago
16 years ago
16 years ago
16 years ago
  1. /*****************************************************************************
  2. Copyright (c) 1994, 2011, Oracle and/or its affiliates. All Rights Reserved.
  3. This program is free software; you can redistribute it and/or modify it under
  4. the terms of the GNU General Public License as published by the Free Software
  5. Foundation; version 2 of the License.
  6. This program is distributed in the hope that it will be useful, but WITHOUT
  7. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License along with
  10. this program; if not, write to the Free Software Foundation, Inc.,
  11. 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
  12. *****************************************************************************/
  13. /*******************************************************************//**
  14. @file include/rem0cmp.ic
  15. Comparison services for records
  16. Created 7/1/1994 Heikki Tuuri
  17. ************************************************************************/
  18. /*************************************************************//**
  19. This function is used to compare two data fields for which we know the
  20. data type.
  21. @return 1, 0, -1, if data1 is greater, equal, less than data2, respectively */
  22. UNIV_INLINE
  23. int
  24. cmp_data_data(
  25. /*==========*/
  26. ulint mtype, /*!< in: main type */
  27. ulint prtype, /*!< in: precise type */
  28. const byte* data1, /*!< in: data field (== a pointer to a memory
  29. buffer) */
  30. ulint len1, /*!< in: data field length or UNIV_SQL_NULL */
  31. const byte* data2, /*!< in: data field (== a pointer to a memory
  32. buffer) */
  33. ulint len2) /*!< in: data field length or UNIV_SQL_NULL */
  34. {
  35. return(cmp_data_data_slow(mtype, prtype, data1, len1, data2, len2));
  36. }
  37. /*****************************************************************
  38. This function is used to compare two (CHAR) data fields for the LIKE
  39. operator. */
  40. UNIV_INLINE
  41. int
  42. cmp_data_data_like_prefix(
  43. /*======================*/
  44. /* out: 1, 0, -1, if data1 is greater, equal,
  45. less than data2, respectively */
  46. byte* data1, /* in: data field (== a pointer to a memory
  47. buffer) */
  48. ulint len1, /* in: data field length or UNIV_SQL_NULL */
  49. byte* data2, /* in: data field (== a pointer to a memory
  50. buffer) */
  51. ulint len2) /* in: data field length or UNIV_SQL_NULL */
  52. {
  53. return(cmp_data_data_slow_like_prefix(data1, len1, data2, len2));
  54. }
  55. /*****************************************************************
  56. This function is used to compare two (CHAR) data fields for the LIKE
  57. operator. */
  58. UNIV_INLINE
  59. int
  60. cmp_data_data_like_suffix(
  61. /*======================*/
  62. /* out: 1, 0, -1, if data1 is greater, equal,
  63. less than data2, respectively */
  64. byte* data1, /* in: data field (== a pointer to a memory
  65. buffer) */
  66. ulint len1, /* in: data field length or UNIV_SQL_NULL */
  67. byte* data2, /* in: data field (== a pointer to a memory
  68. buffer) */
  69. ulint len2) /* in: data field length or UNIV_SQL_NULL */
  70. {
  71. return(cmp_data_data_slow_like_suffix(data1, len1, data2, len2));
  72. }
  73. /*****************************************************************
  74. This function is used to compare two (CHAR) data fields for the LIKE
  75. operator. */
  76. UNIV_INLINE
  77. int
  78. cmp_data_data_like_substr(
  79. /*======================*/
  80. /* out: 1, 0, -1, if data1 is greater, equal,
  81. less than data2, respectively */
  82. byte* data1, /* in: data field (== a pointer to a memory
  83. buffer) */
  84. ulint len1, /* in: data field length or UNIV_SQL_NULL */
  85. byte* data2, /* in: data field (== a pointer to a memory
  86. buffer) */
  87. ulint len2) /* in: data field length or UNIV_SQL_NULL */
  88. {
  89. return(cmp_data_data_slow_like_substr(data1, len1, data2, len2));
  90. }
  91. /*************************************************************//**
  92. This function is used to compare two dfields where at least the first
  93. has its data type field set.
  94. @return 1, 0, -1, if dfield1 is greater, equal, less than dfield2,
  95. respectively */
  96. UNIV_INLINE
  97. int
  98. cmp_dfield_dfield(
  99. /*==============*/
  100. const dfield_t* dfield1,/*!< in: data field; must have type field set */
  101. const dfield_t* dfield2)/*!< in: data field */
  102. {
  103. const dtype_t* type;
  104. ut_ad(dfield_check_typed(dfield1));
  105. type = dfield_get_type(dfield1);
  106. return(cmp_data_data(type->mtype, type->prtype,
  107. (const byte*) dfield_get_data(dfield1),
  108. dfield_get_len(dfield1),
  109. (const byte*) dfield_get_data(dfield2),
  110. dfield_get_len(dfield2)));
  111. }
  112. /*****************************************************************
  113. This function is used to compare two dfields where at least the first
  114. has its data type field set. */
  115. UNIV_INLINE
  116. int
  117. cmp_dfield_dfield_like_suffix(
  118. /*==========================*/
  119. /* out: 1, 0, -1, if dfield1 is greater, equal,
  120. less than dfield2, respectively */
  121. dfield_t* dfield1,/* in: data field; must have type field set */
  122. dfield_t* dfield2)/* in: data field */
  123. {
  124. ut_ad(dfield_check_typed(dfield1));
  125. return(cmp_data_data_like_suffix(
  126. (byte*) dfield_get_data(dfield1),
  127. dfield_get_len(dfield1),
  128. (byte*) dfield_get_data(dfield2),
  129. dfield_get_len(dfield2)));
  130. }
  131. /*****************************************************************
  132. This function is used to compare two dfields where at least the first
  133. has its data type field set. */
  134. UNIV_INLINE
  135. int
  136. cmp_dfield_dfield_like_substr(
  137. /*==========================*/
  138. /* out: 1, 0, -1, if dfield1 is greater, equal,
  139. less than dfield2, respectively */
  140. dfield_t* dfield1,/* in: data field; must have type field set */
  141. dfield_t* dfield2)/* in: data field */
  142. {
  143. ut_ad(dfield_check_typed(dfield1));
  144. return(cmp_data_data_like_substr(
  145. (byte*) dfield_get_data(dfield1),
  146. dfield_get_len(dfield1),
  147. (byte*) dfield_get_data(dfield2),
  148. dfield_get_len(dfield2)));
  149. }
  150. /*************************************************************//**
  151. This function is used to compare two physical records. Only the common
  152. first fields are compared.
  153. @return 1, 0 , -1 if rec1 is greater, equal, less, respectively, than
  154. rec2; only the common first fields are compared */
  155. UNIV_INLINE
  156. int
  157. cmp_rec_rec(
  158. /*========*/
  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. dict_index_t* index) /*!< in: data dictionary index */
  164. {
  165. ulint match_f = 0;
  166. ulint match_b = 0;
  167. return(cmp_rec_rec_with_match(rec1, rec2, offsets1, offsets2, index,
  168. FALSE, &match_f, &match_b));
  169. }