Resultset row
A result Set Row is a data representing a database result set unit, which is usually generated by executing a statement that queries the database. Using COM_STMT_EXECUTE resutsetrow will be in binary format, others in Text format.
Text resultset row
- for each column
- string<lenenc> column data
Data are the byte representation of the String according to client character collation.
Binary resultset row
- byte<1> 0x00 header
- byte<(number_of_columns + 9) / 8> NULL-Bitmap
- for each column
- if column value is not null
- if MYSQL_TYPE_DOUBLE type : DOUBLE Binary encoding
- if MYSQL_TYPE_BIGINT type : BIGINT Binary encoding
- if MYSQL_TYPE_INTEGER type : INTEGER Binary encoding
- if MYSQL_TYPE_MEDIUMINT type : MEDIUMINT Binary encoding
- if MYSQL_TYPE_FLOAT type : FLOAT Binary encoding
- if MYSQL_TYPE_SMALLINT type : SMALLINTBinary encoding
- if MYSQL_TYPE_YEAR type : YEAR Binary encoding
- if MYSQL_TYPE_TINYINT type : TINYINT Binary encoding
- if MYSQL_TYPE_DATE type : DATE Binary encoding
- if MYSQL_TYPE_TIMESTAMP type : TIMESTAMP Binary encoding
- if MYSQL_TYPE_DATETIME type : DATETIME Binary encoding
- if MYSQL_TYPE_TIME type : TIME Binary encoding
- if MYSQL_TYPE_NEWDECIMAL type : DECIMAL Binary encoding
- if MYSQL_TYPE_TINY_BLOB, MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_LONG_BLOB, MYSQL_TYPE_BLOB, MYSQL_TYPE_GEOMETRY,MYSQL_TYPE_STRING, MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VAR_STRING): byte<lenenc> value
- if column value is not null
NULL-Bitmap values
The NULL-Bitmap indicate if parameters for a column is null (one bit per parameter) beginning with 3rd bit. NULL-bitmap size is (number_of_columns + 9) / 8.
DECIMAL Binary encoding.
DECIMAL has no fixed size, so will be encoded as string<lenenc>. An DECIMAL(10,2) with value of -15.5 is stored as
06 45 49 53 46 53 48 . - 1 5 . 5 0
DOUBLE Binary encoding.
DOUBLE is the IEEE 754 floating-point value in Little-endian format on 8 bytes.
BIGINT Binary encoding.
BIGINT is the value in Little-endian format on 8 bytes. Signed is defined by Column field detail flag
INTEGER Binary encoding.
INTEGER is the value in Little-endian format on 4 bytes. Signed is defined by Column field detail flag
MEDIUMINT Binary encoding.
MEDIUMINT is similar to INTEGER Binary encoding, even if MEDIUM int is 3-bytes encoded server side. (Last byte will always be 0x00).
FLOAT Binary encoding.
FLOAT is the IEEE 754 floating-point value in Little-endian format on 4 bytes.
SMALLINT Binary encoding.
SMALLINT is the value in Little-endian format on 2 bytes. Signed is defined by Column field detail flag
YEAR Binary encoding.
YEAR use the same format than SMALLINT.
TINYINT Binary encoding.
TINYINT is the value of 1 byte. Signed is defined by Column field detail flag
DATE Binary encoding.
Data is encoded in 5 bytes.
byte position | description |
1 | data length : 4 |
2-3 | year on 2 bytes little-endian format |
4 | Month ( 1=january) |
5 | day of month |
TIMESTAMP Binary encoding.
Data is encoded in 8 bytes without fractional seconds, 12 bytes with fractional seconds.
byte position | description |
1 | data length : 7 without fractional seconds, 11 with fractional seconds |
2-3 | year on 2 bytes little-endian format |
4 | Month ( 1=january) |
5 | days of month |
6 | hour of day (0 if DATE type) |
7 | minutes (0 if DATE type) |
8 | secondes (0 if DATE type) |
9-12 | micro-second on 4 bytes little-endian format (only if data-length is > 7) |
DATETIME Binary encoding
DATETIME use the same format than TIMESTAMP Binary encoding
TIME Binary encoding.
Data is encoded in 9 bytes without fractional seconds, 13 bytes with fractional seconds.
byte position | description |
1 | data length : 8 without fractional seconds, 12 with fractional seconds |
2 | is negative |
3-6 | date on 4 bytes little-endian format |
7 | hour of day |
8 | minutes |
9 | secondes |
10-13 | micro-second on 4 bytes little-endian format (only if data-length is > 7) |