OK_Packet
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
int<1> 0x00 :
OK_Packet
header or (0xFE
ifCLIENT_DEPRECATE_EOF
is set).int affected rows.
int last insert id.
int<2> warning count.
If packet has more data:
string info.
If (status flags &
SERVER_SESSION_STATE_CHANGED
) andsession_tracking_supported
(see CLIENT_SESSION_TRACK):
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 SSL certificate verification signature. For the following OK_Packets
it contains (if present) various human-readable information.
Server status flag
Values of server status flags:
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_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_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 session change type for more information.
Session state info
While packet has remaining data:
Session change type
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
Session Data Change
Each type of data has its own kind of format:
SESSION_TRACK_SCHEMA
string new current schema.
SESSION_TRACK_SYSTEM_VARIABLES
While there is remaining data:
string variable data.
For each variable data:
SESSION_TRACK_STATE_CHANGE
Indicates if session state changes occurred. The value is represented as 1
.
string
1
if session state tracking was enabled.
SESSION_TRACK_GTIDS
This tracker is not implemented by MariaDB.
SESSION_TRACK_TRANSACTION_CHARACTERISTICS
string 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:
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>;
SESSION_TRACK_TRANSACTION_STATE
string Transaction state string.
The transaction state string is always 8 characters long. The characters, in order, are:
No transaction:
_
Explicit transaction:T
Implicit transaction:I
Transaction read safe:
_
Transaction read unsafe:r
Unknown transaction type:
_
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
Notes
To determine if session tracking is enabled, check if the CLIENT_SESSION_TRACK flag is set in
server_capabilities
.
This page is licensed: CC BY-SA / Gnu FDL
Last updated
Was this helpful?