All pages
Powered by GitBook
1 of 1

Loading...

OK_Packet

The OK_Packet is sent by the server to indicate the successful completion of a command, conveying affected row counts and server status flags.

OK_Packet is sent by the server to the client and indicates a successful completion of a command sent by the client before.

Direction

Server to client.

Fields

  • 0x00 : OK_Packet header or (0xFE if CLIENT_DEPRECATE_EOF is set).

  • affected rows.

  • last insert id.

The length-encoded info string is not always included in the packet. Check the length of the packet to detect if there is data after the warning count. For the first OK_Packet in the connection it contains (if present) the . For the following OK_Packets it contains (if present) various human-readable information.

Server status flag

Values of server status flags:

Flag
Value
Details

Session state info

  • While packet has remaining data:

    • .

    • If (session-change-type != SESSION_TRACK_STATE_CHANGE):

Session change type

Change Type
Flag

Session Data Change

Each type of data has its own kind of format:

SESSION_TRACK_SCHEMA

  • new current schema.

SESSION_TRACK_SYSTEM_VARIABLES

While there is remaining data:

  • variable data.

For each variable data:

  • variable name.

  • variable value.

Possible tracked variables list is tracked by special variable value description:

  • : format is mariadb/mysql:[<user>[:<password>]@]<host>[:<port>]/[<db>[?<opt1>=<value1>[&<opt2>=<value2>]]]. Possible options:

    • ttl

SESSION_TRACK_STATE_CHANGE

Indicates if session state changes occurred. The value is represented as 1.

  • 1 if session state tracking was enabled.

SESSION_TRACK_GTIDS

This tracker is not implemented by MariaDB.

SESSION_TRACK_TRANSACTION_CHARACTERISTICS

  • Transaction characteristics.

Transaction characteristics is the set of SQL statements that reproduce the type and state of the current transaction. It can consist of the following SQL statements:

SESSION_TRACK_TRANSACTION_STATE

  • Transaction state string.

The transaction state string is always 8 characters long. The characters, in order, are:

  1. No transaction: _ Explicit transaction: T Implicit transaction: I

  2. Transaction read safe: _ Transaction read unsafe: r

  3. Unknown transaction type: _

Notes

  • To determine if session tracking is enabled, check if the flag is set in server_capabilities.

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

int<2> server status.

  • int<2> warning count.

  • If packet has more data:

    • string info.

    • If (status flags & SERVER_SESSION_STATE_CHANGED) and session_tracking_supported (see CLIENT_SESSION_TRACK):

      • .

  • SERVER_QUERY_NO_INDEX_USED

    32

    The query did not use an index.

    SERVER_STATUS_CURSOR_EXISTS

    64

    When using COM_STMT_FETCH, indicate that current cursor still has result.

    SERVER_STATUS_LAST_ROW_SENT

    128

    When using COM_STMT_FETCH, indicate that current cursor has finished to send results.

    SERVER_STATUS_DB_DROPPED

    1<<8

    Database has been dropped.

    SERVER_STATUS_NO_BACKSLASH_ESCAPES

    1<<9

    Current escape mode is "no backslash escape".

    SERVER_STATUS_METADATA_CHANGED

    1<<10

    A DDL change did have an impact on an existing PREPARE (an automatic re-prepare has been executed).

    SERVER_QUERY_WAS_SLOW

    1<<11

    The query was slower than .

    SERVER_PS_OUT_PARAMS

    1<<12

    This result set contains stored procedure output parameter.

    SERVER_STATUS_IN_TRANS_READONLY

    1<<13

    Current transaction is a read-only transaction.

    SERVER_SESSION_STATE_CHANGED

    1<<14

    Session state change. See for more information.

    int total length.
  • string session data change.

  • : cache timeout in ms to remember redirection, in order to reconnect directly to new host. 0=no caching
    Read-only transaction:
    R
  • Transaction write safe: _ Transaction write unsafe: w

  • Unknown transaction type: _ Read-write transaction: W

  • Transaction statement safe: _ Transaction statement unsafe: s

  • Transaction does not have resultsets: _ Transaction with result sets: S

  • No locked tables: _ Tables have been locked: L

  • SERVER_STATUS_IN_TRANS

    1

    A transaction is currently active.

    SERVER_STATUS_AUTOCOMMIT

    2

    Autocommit mode is set.

    SERVER_MORE_RESULTS_EXISTS

    8

    More results exists (more packets will follow).

    SERVER_QUERY_NO_GOOD_INDEX_USED

    16

    Set if EXPLAIN would've shown Range checked for each record.

    0

    SESSION_TRACK_SYSTEM_VARIABLES

    1

    SESSION_TRACK_SCHEMA

    2

    SESSION_TRACK_STATE_CHANGE

    3

    SESSION_TRACK_GTIDS

    4

    SESSION_TRACK_TRANSACTION_CHARACTERISTICS

    5

    SESSION_TRACK_TRANSACTION_STATE

    int<1>
    int
    int
    SSL certificate verification signature
    int<1>
    session change type
    string
    string
    string
    string
    session_track_system_variables
    redirect_url
    string
    string
    string
    CLIENT_SESSION_TRACK
    SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
    SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
    SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
    SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
    START TRANSACTION;
    START TRANSACTION WITH CONSISTENT SNAPSHOT;
    START TRANSACTION WITH CONSISTENT SNAPSHOT, READ ONLY;
    START TRANSACTION WITH CONSISTENT SNAPSHOT, READ WRITE;
    SET TRANSACTION READ ONLY;
    SET TRANSACTION READ WRITE;
    XA START <XA specification>;
    string
    session state info
    long_query_time
    session change type