Result Set Packets
MariaDB Server sends the following packets as part of a result set.
A result set consists of different packets:
If not (
MARIADB_CLIENT_CACHE_METADATA
capability set)OR
(send metadata == 1):For each column (for instance,
column_count
times):
If not (
CLIENT_DEPRECATE_EOF
capability set) EOF_Packet.If error:
Else:
If
CLIENT_DEPRECATE_EOF
capability:OK_Packet with a
0xFE
header.
Else EOF_Packet.
It would be unsafe to assume that any packet with a 0xFE header is an OK packet (OK_Packet) or an EOF packet (EOF_Packet), because result-set row packets (ResultsetRow) can also begin with 0xFE when using the text protocol with a field length greater than 0xFFFFFF. To safely confirm that a packet with a 0xFE header is an OK packet (OK_Packet) or an EOF packet (EOF_Packet), you must also check that the packet length is less than 0xFFFFFF.
Column Count Packet
The column count packet describes the number of columns in the result set. It uses the following format:
int column count.
If (
MARIADB_CLIENT_CACHE_METADATA
capability set):int<1> metadata follows (0 / 1).
The metadata indicator byte is only present if both the client and the server declare the MARIADB_CLIENT_CACHE_METADATA
capability.
If the metadata byte is set to 1
, the normal metadata follows the column definitions. If the metadata byte is set to 0
, the Column Count Packet is immediately followed by the second EOF packet (EOF_Packet) or the result set rows if the CLIENT_DEPRECATE_EOF
capability is set.
Column Definition Packet
A column definition packet describes a column in the result set. It uses the following format:
string catalog (always 'def').
string schema.
string table alias.
string table.
string column alias.
string column.
If extended type supported (see
MARIADB_CLIENT_EXTENDED_METADATA
):int length of fixed fields (=0xC).
int<2> character set number.
int<4> max. column size.
int<1> decimals.
int<2> - unused -
Field types
The column type field in the column definition packet describes the base type of the column. It also indicates how the values are encoded for COM_STMT_EXECUTE
parameters and binary result set rows.
6
MYSQL_TYPE_NULL
Not used, nullness is indicated by the NULL-bitmap in the result
17
MYSQL_TYPE_TIMESTAMP2
Used only in the replication protocol
18
MYSQL_TYPE_DATETIME2
Used only in the replication protocol
19
MYSQL_TYPE_TIME2
Used only in the replication protocol
Field Details Flag
The column details flag describes certain column attributes and whether certain column options are set.
It is a bitmask with the following flags:
1
NOT_NULL
field cannot be null
2
PRIMARY_KEY
field is a primary key
4
UNIQUE_KEY
field is unique
8
MULTIPLE_KEY
field is in a multiple key
16
BLOB
is this field a Blob
32
UNSIGNED
is this field unsigned
64
ZEROFILL_FLAG
is this field a zerofill
128
BINARY_COLLATION
whether this field has a binary collation
256
ENUM
Field is an enumeration
512
AUTO_INCREMENT
field auto-increment
1024
TIMESTAMP
field is a timestamp value
2048
SET
field is a SET
4096
NO_DEFAULT_VALUE_FLAG
field doesn't have default value
8192
ON_UPDATE_NOW_FLAG
field is set to NOW on UPDATE
32768
NUM_FLAG
field is num
Extended Metadata
This extended column type information can be used to find out more specific details about the column type:
For a POINT column, the column type field is
MYSQL_TYPE_GEOMETRY
, but the extended type indicates 'point'.For a JSON column, the column type field is
MYSQL_TYPE_STRING
, but the extended type indicates 'json'.
This page is licensed: CC BY-SA / Gnu FDL
Last updated
Was this helpful?