MySQL 9.1.0
Source Code Documentation
|
In MySQL 5.0 the protocol was extended to handle:
Multi-resultsets are sent by a stored program if more than one resultset was generated inside of it. e.g.:
results in:
05 00 00 03 fe 00 00 0a 00
with its status-flag being 0x0A
05 00 00 03 fe 00 00 0a 00
with its status-flag being 0x0A
If the SERVER_MORE_RESULTS_EXISTS flag ise set, that indicates more resultsets will follow.
The trailing OK_Packet is the response to the CALL
statement and contains the affected_rows
count of the last statement. In our case we inserted 2 rows, but only the affected_rows
of the last INSERT
statement is returned as part of the OK_Packet. If the last statement is a SELECT
, the affected_rows
count is 0.
As of MySQL 5.7.5, the resultset is followed by an OK_Packet, and this OK_Packet has the SERVER_MORE_RESULTS_EXISTS flag set to start the processing of the next resultset.
The client has to announce that it wants multi-resultsets by either setting the CLIENT_MULTI_RESULTS or CLIENT_PS_MULTI_RESULTS capability flags.
Starting with MySQL 5.5.3, prepared statements can bind OUT parameters of stored procedures. They are returned as an extra resultset in the multi-resultset response. The client announces it can handle OUT parameters by setting the CLIENT_PS_MULTI_RESULTS capability.
To distinguish a normal resultset from an OUT parameter set, the EOF_Packet or (if CLIENT_DEPRECATE_EOF capability flag is set) OK_Packet that follows its field definition has the SERVER_PS_OUT_PARAMS flag set.
A multi-statement is permitting COM_QUERY to send more than one query to the server, separated by ;
characters.
The client musst announce that it wants multi-statements by either setting the CLIENT_MULTI_STATEMENTS capability or by using COM_SET_OPTION