All pages
Powered by GitBook
1 of 1

Loading...

Result Set Packets

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:

  • Result set metadata.

    • 1 column count packet.

  • 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.

Column Count Packet

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.

Column Definition Packet

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

  • catalog (always 'def').

  • schema.

  • table alias.

  • table.

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.

Value
Protocol Column Type
Encoding

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:

Flag Value
Flag Name
Flag Description

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

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

Extended Metadata

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

Else EOF_Packet.

string column alias.

  • string column.

  • If extended type supported (see MARIADB_CLIENT_EXTENDED_METADATA ):

    • string extended metadata.

  • int length of fixed fields (=0xC).

  • int<2> character set number.

  • int<4> max. column size.

  • int<1> Field types.

  • int<2> Field detail flag.

  • 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

    byte encoding

    1

    MYSQL_TYPE_TINY

    TINYINT Binary encoding

    2

    MYSQL_TYPE_SHORT

    SMALLINT Binary encoding

    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

    Column Definition packet
    EOF_Packet
    result set row
    ERR_Packet
    OK_Packet
    OK packet (OK_Packet)
    EOF packet (EOF_Packet)
    result-set row packets (ResultsetRow)
    OK packet (OK_Packet)
    EOF packet (EOF_Packet)
    int
    EOF packet (EOF_Packet)
    string
    string
    string
    string
    BINARY
    VARBINARY
    POINT
    JSON

    field is in a multiple key

    INTEGER Binary encoding
    FLOAT Binary encoding
    DOUBLE Binary encoding
    TIMESTAMP Binary encoding
    BIGINT Binary encoding
    INTEGER Binary encoding
    TIMESTAMP Binary encoding
    TIME Binary encoding
    TIMESTAMP Binary encoding
    SMALLINT Binary encoding
    byte encoding
    byte encoding
    byte encoding
    byte encoding
    byte encoding
    byte encoding
    byte encoding
    byte encoding
    byte encoding
    byte encoding
    byte encoding
    byte encoding
    byte encoding
    byte encoding