data0type.h
上传用户:tsgydb
上传日期:2007-04-14
资源大小:10674k
文件大小:7k
源码类别:

MySQL数据库

开发平台:

Visual C++

  1. /******************************************************
  2. Data types
  3. (c) 1996 Innobase Oy
  4. Created 1/16/1996 Heikki Tuuri
  5. *******************************************************/
  6. #ifndef data0type_h
  7. #define data0type_h
  8. #include "univ.i"
  9. /* SQL data type struct */
  10. typedef struct dtype_struct dtype_t;
  11. /* This variable is initialized as the standard binary variable length
  12. data type */
  13. extern dtype_t*  dtype_binary;
  14. /* Data main types of SQL data; NOTE! character data types requiring
  15. collation transformation must have the smallest codes! All codes must be
  16. less than 256! */
  17. #define DATA_VARCHAR 1 /* character varying */
  18. #define DATA_CHAR 2 /* fixed length character */
  19. #define DATA_FIXBINARY 3 /* binary string of fixed length */
  20. #define DATA_BINARY 4 /* binary string */
  21. #define DATA_BLOB 5 /* binary large object */
  22. #define DATA_INT 6 /* integer: can be any size 1 - 8 bytes */
  23. #define DATA_SYS_CHILD 7 /* address of the child page in node pointer */
  24. #define DATA_SYS 8 /* system column */
  25. /* Data types >= DATA_FLOAT must be compared using the whole field, not as
  26. binary strings */
  27. #define DATA_FLOAT 9
  28. #define DATA_DOUBLE 10
  29. #define DATA_DECIMAL 11 /* decimal number stored as an ASCII string */
  30. #define DATA_VARMYSQL 12 /* data types for which comparisons must be */
  31. #define DATA_MYSQL 13 /* made by MySQL */
  32. #define DATA_ERROR 111 /* error value */
  33. #define DATA_MTYPE_MAX 255
  34. /*-------------------------------------------*/
  35. /* Precise data types for system columns; NOTE: the values must run
  36. from 0 up in the order given! All codes must be less than 256! */
  37. #define DATA_ROW_ID 0 /* row id: a dulint */
  38. #define DATA_ROW_ID_LEN 6 /* stored length for row id */
  39. #define DATA_TRX_ID 1 /* transaction id: 6 bytes */
  40. #define DATA_TRX_ID_LEN 6
  41. #define DATA_ROLL_PTR 2 /* rollback data pointer: 7 bytes */
  42. #define DATA_ROLL_PTR_LEN 7
  43. #define DATA_MIX_ID 3 /* mixed index label: a dulint, stored in
  44. a row in a compressed form */
  45. #define DATA_MIX_ID_LEN 9 /* maximum stored length for mix id (in a
  46. compressed dulint form) */
  47. #define DATA_N_SYS_COLS 4  /* number of system columns defined above */
  48. #define DATA_NOT_NULL 256 /* this is ORed to the precise type when
  49. the column is declared as NOT NULL */
  50. #define DATA_UNSIGNED 512 /* this id ORed to the precise type when
  51. we have an unsigned integer type */
  52. /*-------------------------------------------*/
  53. /* Precise types of a char or varchar data. All codes must be less than 256! */
  54. #define DATA_ENGLISH 4 /* English language character string */
  55. #define DATA_FINNISH 5 /* Finnish */
  56. #define DATA_PRTYPE_MAX 255
  57. /* This many bytes we need to store the type information affecting the
  58. alphabetical order for a single field and decide the storage size of an
  59. SQL null*/
  60. #define DATA_ORDER_NULL_TYPE_BUF_SIZE 4
  61. /*************************************************************************
  62. Sets a data type structure. */
  63. UNIV_INLINE
  64. void
  65. dtype_set(
  66. /*======*/
  67. dtype_t* type, /* in: type struct to init */
  68. ulint mtype, /* in: main data type */
  69. ulint prtype, /* in: precise type */
  70. ulint len, /* in: length of type */
  71. ulint prec); /* in: precision of type */
  72. /*************************************************************************
  73. Copies a data type structure. */
  74. UNIV_INLINE
  75. void
  76. dtype_copy(
  77. /*=======*/
  78. dtype_t* type1, /* in: type struct to copy to */
  79. dtype_t* type2); /* in: type struct to copy from */
  80. /*************************************************************************
  81. Gets the SQL main data type. */
  82. UNIV_INLINE
  83. ulint
  84. dtype_get_mtype(
  85. /*============*/
  86. dtype_t* type);
  87. /*************************************************************************
  88. Gets the precise data type. */
  89. UNIV_INLINE
  90. ulint
  91. dtype_get_prtype(
  92. /*=============*/
  93. dtype_t* type);
  94. /*************************************************************************
  95. Gets the type length. */
  96. UNIV_INLINE
  97. ulint
  98. dtype_get_len(
  99. /*==========*/
  100. dtype_t* type);
  101. /*************************************************************************
  102. Gets the type precision. */
  103. UNIV_INLINE
  104. ulint
  105. dtype_get_prec(
  106. /*===========*/
  107. dtype_t* type);
  108. /*************************************************************************
  109. Gets the padding character code for the type. */
  110. UNIV_INLINE
  111. ulint
  112. dtype_get_pad_char(
  113. /*===============*/
  114. /* out: padding character code, or
  115. ULINT_UNDEFINED if no padding specified */
  116. dtype_t* type); /* in: typeumn */
  117. /*************************************************************************
  118. Transforms the character code so that it is ordered appropriately
  119. for the language. */
  120. UNIV_INLINE
  121. ulint
  122. dtype_collate(
  123. /*==========*/
  124. /* out: padding character */
  125. dtype_t* type, /* in: type */
  126. ulint code); /* in: character code stored in database
  127. record */
  128. /***************************************************************************
  129. Returns the size of a fixed size data type, 0 if not a fixed size type. */
  130. UNIV_INLINE
  131. ulint
  132. dtype_get_fixed_size(
  133. /*=================*/
  134. /* out: fixed size, or 0 */
  135. dtype_t* type); /* in: type */
  136. /***************************************************************************
  137. Returns a stored SQL NULL size for a type. For fixed length types it is
  138. the fixed length of the type, otherwise 0. */
  139. UNIV_INLINE
  140. ulint
  141. dtype_get_sql_null_size(
  142. /*====================*/
  143. /* out: SQL null storage size */
  144. dtype_t* type); /* in: type */
  145. /***************************************************************************
  146. Returns TRUE if a type is of a fixed size. */
  147. UNIV_INLINE
  148. ibool
  149. dtype_is_fixed_size(
  150. /*================*/
  151. /* out: TRUE if fixed size */
  152. dtype_t* type); /* in: type */
  153. /**************************************************************************
  154. Stores to a type the information which determines its alphabetical
  155. ordering. */
  156. UNIV_INLINE
  157. void
  158. dtype_store_for_order_and_null_size(
  159. /*================================*/
  160. byte* buf, /* in: buffer for DATA_ORDER_NULL_TYPE_BUF_SIZE
  161. bytes */
  162. dtype_t* type); /* in: type struct */
  163. /**************************************************************************
  164. Reads of a type the stored information which determines its alphabetical
  165. ordering. */
  166. UNIV_INLINE
  167. void
  168. dtype_read_for_order_and_null_size(
  169. /*===============================*/
  170. dtype_t* type, /* in: type struct */
  171. byte* buf); /* in: buffer for type order info */
  172. /*************************************************************************
  173. Validates a data type structure. */
  174. ibool
  175. dtype_validate(
  176. /*===========*/
  177. /* out: TRUE if ok */
  178. dtype_t* type); /* in: type struct to validate */
  179. /*************************************************************************
  180. Prints a data type structure. */
  181. void
  182. dtype_print(
  183. /*========*/
  184. dtype_t* type); /* in: type */
  185. /* Structure for an SQL data type */
  186. struct dtype_struct{
  187. ulint mtype; /* main data type */
  188. ulint prtype; /* precise type; MySQL data type */
  189. /* remaining two fields do not affect alphabetical ordering: */
  190. ulint len; /* length */
  191. ulint prec; /* precision */
  192. };
  193. #ifndef UNIV_NONINL
  194. #include "data0type.ic"
  195. #endif
  196. #endif