In row-based mode, every row operation event is preceded by a
Table_map_log_event which maps a table definition to a number. The table
definition consists of database name, table name, and column definitions. The
Post-Header has the following components:
Body for Table_map_log_event
| Name |
Format |
Description |
| database_name |
one byte string length, followed by null-terminated string |
The name of the database in which the table resides. The name is
represented as a one byte unsigned integer representing the number of bytes
in the name, followed by length bytes containing the database name, followed
by a terminating 0 byte. (Note the redundancy in the representation of the
length.) |
| table_name |
one byte string length, followed by null-terminated string |
The name of the table, encoded the same way as the database name above. |
| column_count |
packed_integer "Packed Integer" |
The number of columns in the table, represented as a packed
variable-length integer. |
| column_type |
List of column_count 1 byte enumeration values |
The type of each column in the table, listed from left to right. Each
byte is mapped to a column type according to the enumeration type
enum_field_types defined in mysql_com.h. The mapping of types to numbers is
listed in the table Table_table_map_log_event_column_types "below" (along
with description of the associated metadata field). |
| metadata_length |
packed_integer "Packed Integer" |
The length of the following metadata block |
| metadata |
list of metadata for each column |
For each column from left to right, a chunk of data who's length and
semantics depends on the type of the column. The length and semantics for the
metadata for each column are listed in the table
Table_table_map_log_event_column_types "below". |
| null_bits |
column_count bits, rounded up to nearest byte |
For each column, a bit indicating whether data in the column can be NULL
or not. The number of bytes needed for this is int((column_count+7)/8). The
flag for the first column from the left is in the least-significant bit of
the first byte, the second is in the second least significant bit of the
first byte, the ninth is in the least significant bit of the second byte, and
so on. |
The table below lists all column types, along with the numerical identifier
for it and the size and interpretation of meta-data used to describe the
type.
Table_map_log_event column types: numerical identifier and
metadata
| Name |
Identifier |
Size of metadata in bytes |
Description of metadata |
| MYSQL_TYPE_DECIMAL |
0 |
0 |
No column metadata. |
| MYSQL_TYPE_TINY |
1 |
0 |
No column metadata. |
| MYSQL_TYPE_SHORT |
2 |
0 |
No column metadata. |
| MYSQL_TYPE_LONG |
3 |
0 |
No column metadata. |
| MYSQL_TYPE_FLOAT |
4 |
1 byte |
1 byte unsigned integer, representing the "pack_length", which is equal
to sizeof(float) on the server from which the event originates. |
| MYSQL_TYPE_DOUBLE |
5 |
1 byte |
1 byte unsigned integer, representing the "pack_length", which is equal
to sizeof(double) on the server from which the event originates. |
| MYSQL_TYPE_NULL |
6 |
0 |
No column metadata. |
| MYSQL_TYPE_TIMESTAMP |
7 |
0 |
No column metadata. |
| MYSQL_TYPE_LONGLONG |
8 |
0 |
No column metadata. |
| MYSQL_TYPE_INT24 |
9 |
0 |
No column metadata. |
| MYSQL_TYPE_DATE |
10 |
0 |
No column metadata. |
| MYSQL_TYPE_TIME |
11 |
0 |
No column metadata. |
| MYSQL_TYPE_DATETIME |
12 |
0 |
No column metadata. |
| MYSQL_TYPE_YEAR |
13 |
0 |
No column metadata. |
| MYSQL_TYPE_NEWDATE |
14 |
– |
This enumeration value is only used internally and cannot exist in a
binlog. |
| MYSQL_TYPE_VARCHAR |
15 |
2 bytes |
2 byte unsigned integer representing the maximum length of the string. |
| MYSQL_TYPE_BIT |
16 |
2 bytes |
A 1 byte unsigned int representing the length in bits of the bitfield (0
to 64), followed by a 1 byte unsigned int representing the number of bytes
occupied by the bitfield. The number of bytes is either int((length+7)/8) or
int(length/8). |
| MYSQL_TYPE_NEWDECIMAL |
246 |
2 bytes |
A 1 byte unsigned int representing the precision, followed by a 1 byte
unsigned int representing the number of decimals. |
| MYSQL_TYPE_ENUM |
247 |
– |
This enumeration value is only used internally and cannot exist in a
binlog. |
| MYSQL_TYPE_SET |
248 |
– |
This enumeration value is only used internally and cannot exist in a
binlog. |
| MYSQL_TYPE_TINY_BLOB |
249 |
– |
This enumeration value is only used internally and cannot exist in a
binlog. |
| MYSQL_TYPE_MEDIUM_BLOB |
250 |
– |
This enumeration value is only used internally and cannot exist in a
binlog. |
| MYSQL_TYPE_LONG_BLOB |
251 |
– |
This enumeration value is only used internally and cannot exist in a
binlog. |
| MYSQL_TYPE_BLOB |
252 |
1 byte |
The pack length, i.e., the number of bytes needed to represent the length
of the blob: 1, 2, 3, or 4. |
| MYSQL_TYPE_VAR_STRING |
253 |
2 bytes |
This is used to store both strings and enumeration values. The first byte
is a enumeration value storing the real type, which may be either
MYSQL_TYPE_VAR_STRING or MYSQL_TYPE_ENUM. The second byte is a 1 byte
unsigned integer representing the field size, i.e., the number of bytes
needed to store the length of the string. |
| MYSQL_TYPE_STRING |
254 |
2 bytes |
The first byte is always MYSQL_TYPE_VAR_STRING (i.e., 253). The second
byte is the field size, i.e., the number of bytes in the representation of
size of the string: 3 or 4. |
| MYSQL_TYPE_GEOMETRY |
255 |
1 byte |
The pack length, i.e., the number of bytes needed to represent the length
of the geometry: 1, 2, 3, or 4. |