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

MySQL数据库

开发平台:

Visual C++

  1. /******************************************************
  2. Data dictionary creation and booting
  3. (c) 1996 Innobase Oy
  4. Created 4/18/1996 Heikki Tuuri
  5. *******************************************************/
  6. #ifndef dict0boot_h
  7. #define dict0boot_h
  8. #include "univ.i"
  9. #include "mtr0mtr.h"
  10. #include "mtr0log.h"
  11. #include "ut0byte.h"
  12. #include "buf0buf.h"
  13. #include "fsp0fsp.h"
  14. #include "dict0dict.h"
  15. typedef byte dict_hdr_t;
  16. /**************************************************************************
  17. Gets a pointer to the dictionary header and x-latches its page. */
  18. UNIV_INLINE
  19. dict_hdr_t*
  20. dict_hdr_get(
  21. /*=========*/
  22. /* out: pointer to the dictionary header, 
  23. page x-latched */
  24. mtr_t* mtr); /* in: mtr */
  25. /**************************************************************************
  26. Returns a new row, table, index, or tree id. */
  27. UNIV_INLINE
  28. dulint
  29. dict_hdr_get_new_id(
  30. /*================*/
  31. /* out: the new id */
  32. ulint type); /* in: DICT_HDR_ROW_ID, ... */
  33. /**************************************************************************
  34. Returns a new row id. */
  35. UNIV_INLINE
  36. dulint
  37. dict_sys_get_new_row_id(void);
  38. /*=========================*/
  39. /* out: the new id */
  40. /**************************************************************************
  41. Reads a row id from a record or other 6-byte stored form. */
  42. UNIV_INLINE
  43. dulint
  44. dict_sys_read_row_id(
  45. /*=================*/
  46. /* out: row id */
  47. byte* field); /* in: record field */
  48. /**************************************************************************
  49. Writes a row id to a record or other 6-byte stored form. */
  50. UNIV_INLINE
  51. void
  52. dict_sys_write_row_id(
  53. /*==================*/
  54. byte* field, /* in: record field */
  55. dulint row_id);/* in: row id */
  56. /*********************************************************************
  57. Initializes the data dictionary memory structures when the database is
  58. started. This function is also called when the data dictionary is created. */
  59. void
  60. dict_boot(void);
  61. /*===========*/
  62. /*********************************************************************
  63. Creates and initializes the data dictionary at the database creation. */
  64. void
  65. dict_create(void);
  66. /*=============*/
  67. /* Space id and page no where the dictionary header resides */
  68. #define DICT_HDR_SPACE 0 /* the SYSTEM tablespace */
  69. #define DICT_HDR_PAGE_NO FSP_DICT_HDR_PAGE_NO
  70. /* The ids for the basic system tables and their indexes */
  71. #define DICT_TABLES_ID ut_dulint_create(0, 1)
  72. #define DICT_COLUMNS_ID ut_dulint_create(0, 2)
  73. #define DICT_INDEXES_ID ut_dulint_create(0, 3)
  74. #define DICT_FIELDS_ID ut_dulint_create(0, 4)
  75. /* The following is a secondary index on SYS_TABLES */
  76. #define DICT_TABLE_IDS_ID ut_dulint_create(0, 5)
  77. #define DICT_HDR_FIRST_ID 10 /* the ids for tables etc. start
  78. from this number, except for basic
  79. system tables and their above defined
  80. indexes; ibuf tables and indexes are
  81. assigned as the id the number
  82. DICT_IBUF_ID_MIN plus the space id */
  83. #define DICT_IBUF_ID_MIN ut_dulint_create(0xFFFFFFFF, 0)
  84. /* The offset of the dictionary header on the page */
  85. #define DICT_HDR FSEG_PAGE_DATA
  86. /*-------------------------------------------------------------*/
  87. /* Dictionary header offsets */
  88. #define DICT_HDR_ROW_ID 0 /* The latest assigned row id */
  89. #define DICT_HDR_TABLE_ID 8 /* The latest assigned table id */
  90. #define DICT_HDR_INDEX_ID 16 /* The latest assigned index id */
  91. #define DICT_HDR_MIX_ID 24 /* The latest assigned mix id */
  92. #define DICT_HDR_TABLES 32 /* Root of the table index tree */
  93. #define DICT_HDR_TABLE_IDS 36 /* Root of the table index tree */
  94. #define DICT_HDR_COLUMNS 40 /* Root of the column index tree */
  95. #define DICT_HDR_INDEXES 44 /* Root of the index index tree */
  96. #define DICT_HDR_FIELDS 48 /* Root of the index field index tree */
  97. #define DICT_HDR_FSEG_HEADER 56 /* Segment header for the tablespace
  98. segment into which the dictionary
  99. header is created */
  100. /*-------------------------------------------------------------*/
  101. /* The field number of the page number field in the sys_indexes table
  102. clustered index */
  103. #define DICT_SYS_INDEXES_PAGE_NO_FIELD  8
  104. #define DICT_SYS_INDEXES_SPACE_NO_FIELD  7
  105. /* When a row id which is zero modulo this number (which must be a power of
  106. two) is assigned, the field DICT_HDR_ROW_ID on the dictionary header page is
  107. updated */
  108. #define DICT_HDR_ROW_ID_WRITE_MARGIN 256
  109. #ifndef UNIV_NONINL
  110. #include "dict0boot.ic"
  111. #endif
  112. #endif