A result set consists of a sequence of packets including column counts, column definitions, and row data, terminated by an EOF or OK packet.
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) .
n .
If error:
.
Else:
If CLIENT_DEPRECATE_EOF capability:
with a 0xFE header.
It would be unsafe to assume that any packet with a 0xFE header is an or an , because 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 or an , you must also check that the packet length is less than 0xFFFFFF.
The column count packet describes the number of columns in the result set. It uses the following format:
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 or the result set rows if the CLIENT_DEPRECATE_EOF capability is set.
A column definition packet describes a column in the result set. It uses the following format:
catalog (always 'def').
schema.
table alias.
table.
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.
The column details flag describes certain column attributes and whether certain column options are set.
It is a bitmask with the following flags:
This extended column type information can be used to find out more specific details about the column type:
For a column, the column type field is MYSQL_TYPE_GEOMETRY, but the extended type indicates 'point'.
For a column, the column type field is MYSQL_TYPE_STRING, but the extended type indicates 'json'.
While string has data:
This page is licensed: CC BY-SA / Gnu FDL
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 -
4
MYSQL_TYPE_FLOAT
5
MYSQL_TYPE_DOUBLE
6
MYSQL_TYPE_NULL
Not used, nullness is indicated by the NULL-bitmap in the result
7
MYSQL_TYPE_TIMESTAMP
8
MYSQL_TYPE_LONGLONG
9
MYSQL_TYPE_INT24
10
MYSQL_TYPE_DATE
11
MYSQL_TYPE_TIME
12
MYSQL_TYPE_DATETIME
13
MYSQL_TYPE_YEAR
14
MYSQL_TYPE_NEWDATE
15
MYSQL_TYPE_VARCHAR
16
MYSQL_TYPE_BIT
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
245
MYSQL_TYPE_JSON
(only used with MySQL, MariaDB uses MYSQL_TYPE_STRING for JSON)
246
MYSQL_TYPE_NEWDECIMAL
247
MYSQL_TYPE_ENUM
248
MYSQL_TYPE_SET
249
MYSQL_TYPE_TINY_BLOB
250
MYSQL_TYPE_MEDIUM_BLOB
251
MYSQL_TYPE_LONG_BLOB
252
MYSQL_TYPE_BLOB
253
MYSQL_TYPE_VAR_STRING
254
MYSQL_TYPE_STRING
255
MYSQL_TYPE_GEOMETRY
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
int<1> data type: 0x00:type, 0x01: format.
string value.
0
MYSQL_TYPE_DECIMAL
1
MYSQL_TYPE_TINY
2
MYSQL_TYPE_SHORT
3
MYSQL_TYPE_LONG
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