Result Set Packets

MariaDB Server sends the following packets as part of a result set: A resultset consists of different packets:



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:

Column Definition Packet

A column definition packet describes a column in the result set. It uses the following format:

This extended column type information can be used to find out more specific details about the column type.

For example:

  • For a POINT column, the column type field will be MYSQL_TYPE_GEOMETRY, but the extended type will indicate 'point'.
  • For a JSON column, the column type field will be MYSQL_TYPE_STRING, but the extended type will indicate 'json'.

Field types

The column type field in the column definition packet describes the base type of the column:

ValueProtocol Column TypeDescription
0MYSQL_TYPE_DECIMAL
1MYSQL_TYPE_TINY
2MYSQL_TYPE_SHORT
3MYSQL_TYPE_LONG
4MYSQL_TYPE_FLOAT
5MYSQL_TYPE_DOUBLE
6MYSQL_TYPE_NULL
7MYSQL_TYPE_TIMESTAMP
8MYSQL_TYPE_LONGLONG
9MYSQL_TYPE_INT24
10MYSQL_TYPE_DATE
11MYSQL_TYPE_TIME
12MYSQL_TYPE_DATETIME
13MYSQL_TYPE_YEAR
14MYSQL_TYPE_NEWDATE
15MYSQL_TYPE_VARCHAR
16MYSQL_TYPE_BIT
17MYSQL_TYPE_TIMESTAMP2
18MYSQL_TYPE_DATETIME2
19MYSQL_TYPE_TIME2
245MYSQL_TYPE_JSONOnly used with MySQL. MariaDB uses MYSQL_TYPE_STRING for JSON.
246MYSQL_TYPE_NEWDECIMAL
247MYSQL_TYPE_ENUM
248MYSQL_TYPE_SET
249MYSQL_TYPE_TINY_BLOB
250MYSQL_TYPE_MEDIUM_BLOB
251MYSQL_TYPE_LONG_BLOB
252MYSQL_TYPE_BLOB
253MYSQL_TYPE_VAR_STRING
254MYSQL_TYPE_STRING
255MYSQL_TYPE_GEOMETRY

Column 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:

Flag ValueFlag NameFlag Description
1NOT_NULLfield cannot be null
2PRIMARY_KEYfield is a primary key
4UNIQUE_KEYfield is unique
8MULTIPLE_KEYfield is in a multiple key
16BLOBis this field a Blob
32UNSIGNEDis this field unsigned
64ZEROFILL_FLAGis this field a zerofill
128BINARY_COLLATIONwhether this field has a binary collation
256ENUMField is an enumeration
512AUTO_INCREMENTfield auto-increment
1024TIMESTAMPfield is a timestamp value
2048SETfield is a SET
4096NO_DEFAULT_VALUE_FLAGfield doesn't have default value
8192ON_UPDATE_NOW_FLAGfield is set to NOW on UPDATE
32768NUM_FLAGfield is num

The BLOB flag cannot be used to determine if a column has binary data, because BINARY and VARBINARY columns are treated as strings, instead of blobs.

The BINARY_COLLATION flag can be used to determine if a string column has binary data.

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.