how to recovery innodb from Pages from .idb (Part II)
时间:2010-08-22 来源:Steven1981
-----------------------------------------
table_defs.h 可以从多种渠道得到:
1,如果你还拥有建表语句,那么你可以把表建起来,然后用"create_defs.pl"生成。
2,另外你也可以手动生成。但千万不要忘了两个内部字段(DB_TRX_ID,DB_ROLL_PTR)
下面有一个例子供参考:
|| #ifndef table_defs_h
|| #define table_defs_h
||
|| // Table definitions
|| table_def_t table_definitions[] = {
|| {
|| name: "some_table",
|| {
|| { /* int(11) */
|| name: "id",
|| type: FT_INT,
|| fixed_length: 4,
||
|| has_limits: TRUE,
|| limits: {
|| int_min_val: 1,
|| int_max_val: 10000
|| },
||
|| can_be_null: FALSE
|| },
|| { /* Innodb's internally used field */
|| name: "DB_TRX_ID",
|| type: FT_INTERNAL,
|| fixed_length: 6,
||
|| can_be_null: FALSE
|| },
|| { /* Innodb's internally used field */
|| name: "DB_ROLL_PTR",
|| type: FT_INTERNAL,
|| fixed_length: 7,
||
|| can_be_null: FALSE
|| },
|| { /* enum('yes','no') */
|| name: "auto_restart",
|| type: FT_ENUM,
|| fixed_length: 1,
||
|| has_limits: TRUE,
|| limits: {
|| enum_values_count: 2,
|| enum_values: { "yes", "no" }
|| },
||
|| can_be_null: FALSE
|| },
|| { /* int(11) */
|| name: "num_created_today",
|| type: FT_INT,
|| fixed_length: 4,
||
|| can_be_null: FALSE
|| },
|| { /* bigint(20) */
|| name: "time_yesterday",
|| type: FT_INT,
|| fixed_length: 8,
||
|| can_be_null: FALSE
|| },
|| { /* varchar(20) */
|| name: "from_username",
|| type: FT_CHAR,
|| min_length: 0,
|| max_length: 20,
||
|| has_limits: TRUE,
|| limits: {
|| char_min_len: 0,
|| char_max_len: 15,
|| char_ascii_only: TRUE
|| },
||
|| can_be_null: FALSE
|| },
|| { /* tinyint(1) */
|| name: "affiliate_admin",
|| type: FT_INT,
|| fixed_length: 1,
||
|| has_limits: TRUE,
|| limits: {
|| int_min_value: 0,
|| int_max_value: 1,
|| can_be_null: FALSE
|| },
||
|| can_be_null: TRUE
|| },
|| { type: FT_NONE }
|| }
|| }
|| };
||
|| #endif
这里有几个内部字段:
DB_TRX_ID - this field is managed by InnoDB internally and contains a ID of transaction which changed a record last time
DB_ROLL_PTR - one more internal InnoDB field (TODO: find out what is it used for).
DB_ROW_ID - this internally used field should be the first field in tables without primary keys
(it is an auto-increment field used by InnoDB to identify rows in such tables)
如果一个表有主键,那么这个字段不用加到table_defs.h
待续... ...