Result Set Packets

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

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 will follow 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 resultset 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:

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 resultset rows.

Value
Protocol Column Type
Encoding

Value

Protocol Column Type

Encoding

0

MYSQL_TYPE_DECIMAL

1

MYSQL_TYPE_TINY

2

MYSQL_TYPE_SHORT

3

MYSQL_TYPE_LONG

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

byte encoding (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

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

Flag Value

Flag Name

Flag Description

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

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.

Extended metadata

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

  • while string has data

This page is licensed: CC BY-SA / Gnu FDL

Last updated

Was this helpful?