Used for row-based binary logging beginning with MySQL 5.1.5.The TABLE_MAP_EVENT defines the structure if the tables that are about to be changed.mysql
用於從MySQL 5.1.5開始的基於行的二進制日誌記錄。每一個ROW_EVENT以前都有一個TABLE_MAP_EVENT,用於描述表的內部ID和結構定義。
1)觸發條件sql
# ROW格式中每一個ROW_EVENT以前
2)存儲格式數據庫
一、事件頭,佔用19個字節。 二、事件體部分: 固定數據部分: # table id:6 bytes //6個字節存儲table id # 2 bytes:Reserved for future use //2個字節保留將來使用 可變數據部分: # 1 byte. The length of the database name. //數據庫名長度:1字節 # Variable-sized. The database name (null-terminated). //數據庫名:可變長度 # 1 byte. The length of the table name. //表長度:1字節 # Variable-sized. The table name (null-terminated). //表名:可變長度 # Packed integer. The number of columns in the table. //表的行數: # Variable-sized. An array of column types, one byte per column. To find the meanings of these values, look at enum_field_types in the mysql_com.h header file. //列類型數組,每一列1個字節 # Packed integer. The length of the metadata block. //元數據塊的長度 # Variable-sized. The metadata block; see log_event.h for contents and format. //元數據塊 # Variable-sized. Bit-field indicating whether each column can be NULL, one bit per column. For this field, the amount of storage required for N columns is INT((N+7)/8) bytes. //位字段,指示每一個列是否能夠爲空,每一個列一位。若是表有N列,須要:INT((N+7)/8) 字節
3)實戰分析數組
結合hexdump出來的數據和mysqlbinlog解析出的日誌進行分析:ui
-------公有事件頭-------- 一、timestamp(4): 21 2e 0e 5b 二、event_type(1):13,十進制19:TABLE_MAP_EVENT = 19 三、server id(4):5c 27 6b 94 十進制:2490050396 四、event size(4):2e 00 00 00,十進制:46 五、log_pos(4):aa 01 00 00 ,十進制:426 也就是end_log_pos=426 六、flags(2):00 00,等於0表示該日誌文件關閉狀態 --------固定數據部分(私有事件頭)----- 一、table id(6):b1 01 00 00 00 00,十進制433,table_id=433 二、reserve(2):01 00,十進制:1,未被使用 ---------可變數據部分(事件體)-------- 三、db name len(1):06,數據庫名佔用6個字節,即darren 四、db name(6):64 61 72 72 65 6e,查詢asci碼,對應darren 五、00 六、table name len(1):01,表名佔用1個字節 七、table name(1):74,asci碼對應字母t,即表名是t 八、00 九、column count(1):01,即列的個數1 十、column type(1):03,表示MYSQL_TYPE_LONG 十一、column metadata len(1):00,1個字節 十二、column metadata:無 1三、null bitmap(1):00,0表沒有列能夠爲NULL,若是是01表示該列能夠爲NULL 1四、crc32(4):8f cb 07 7d,表明CRC32=0x7d07cb8f,不在事件體裏,能夠認爲每一個事件都存在footer