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

MySQL数据库

开发平台:

Visual C++

  1. /******************************************************
  2. Data types
  3. (c) 1996 Innobase Oy
  4. Created 1/16/1996 Heikki Tuuri
  5. *******************************************************/
  6. #include "data0type.h"
  7. #ifdef UNIV_NONINL
  8. #include "data0type.ic"
  9. #endif
  10. dtype_t dtype_binary_val = {DATA_BINARY, 0, 0, 0};
  11. dtype_t*  dtype_binary  = &dtype_binary_val;
  12. /*************************************************************************
  13. Validates a data type structure. */
  14. ibool
  15. dtype_validate(
  16. /*===========*/
  17. /* out: TRUE if ok */
  18. dtype_t* type) /* in: type struct to validate */
  19. {
  20. ut_a(type);
  21. ut_a((type->mtype >= DATA_VARCHAR) && (type->mtype <= DATA_SYS));
  22. if (type->mtype == DATA_SYS) {
  23. ut_a(type->prtype >= DATA_ROW_ID);
  24. ut_a(type->prtype <= DATA_MIX_ID);
  25. }
  26. return(TRUE);
  27. }
  28. /*************************************************************************
  29. Prints a data type structure. */
  30. void
  31. dtype_print(
  32. /*========*/
  33. dtype_t* type) /* in: type */
  34. {
  35. ulint mtype;
  36. ulint prtype;
  37. ut_a(type);
  38. printf("DATA TYPE: ");
  39. mtype = type->mtype;
  40. prtype = type->prtype;
  41. if (mtype == DATA_VARCHAR) {
  42. printf("DATA_VARCHAR");
  43. } else if (mtype == DATA_CHAR) {
  44. printf("DATA_CHAR");
  45. } else if (mtype == DATA_BINARY) {
  46. printf("DATA_BINARY");
  47. } else if (mtype == DATA_INT) {
  48. printf("DATA_INT");
  49. } else if (mtype == DATA_MYSQL) {
  50. printf("DATA_MYSQL");
  51. } else if (mtype == DATA_SYS) {
  52. printf("DATA_SYS");
  53. } else {
  54. printf("unknown type %lu", mtype);
  55. }
  56. if ((type->mtype == DATA_SYS)
  57.    || (type->mtype == DATA_VARCHAR)
  58.    || (type->mtype == DATA_CHAR)) {
  59. printf(" ");
  60. if (prtype == DATA_ROW_ID) {
  61. printf("DATA_ROW_ID");
  62. } else if (prtype == DATA_ROLL_PTR) {
  63. printf("DATA_ROLL_PTR");
  64. } else if (prtype == DATA_MIX_ID) {
  65. printf("DATA_MIX_ID");
  66. } else if (prtype == DATA_ENGLISH) {
  67. printf("DATA_ENGLISH");
  68. } else if (prtype == DATA_FINNISH) {
  69. printf("DATA_FINNISH");
  70. } else {
  71. printf("unknown prtype %lu", mtype);
  72. }
  73. }
  74. printf("; len %lu prec %lun", type->len, type->prec);
  75. }