Decouple binary protocol from prepared statements
Implement possibility to use binary answer without "prepare" stage.
The similar approach is described here: http://
Blueprint information
- Status:
- Started
- Approver:
- None
- Priority:
- Medium
- Drafter:
- Vlad Lesin
- Direction:
- Approved
- Assignee:
- Vlad Lesin
- Definition:
- Drafting
- Series goal:
- Accepted for 5.6
- Implementation:
-
Needs Code Review
- Milestone target:
- None
- Started by
- Laurynas Biveinis
- Completed by
Whiteboard
The task can be splitted in server and client parts.
Server-side.
If we look into mysqld_
Protocol *save_protocol= thd->protocol;
thd->protocol= &thd->protocol_
stmt->prepare(...);
thd->protocol= save_protocol;
The THD class contains this members:
Protocol *protocol; // Current protocol
Protocol_text protocol_text; // Normal protocol
Protocol_binary protocol_binary; // Binary protocol
So for server-side is enough to add new command COM_STMT_QUERY which would do absolutely the same things as COM_QUERY does but with replacing thd->protocol with &thd->protocol_
Client side.
Standard C API has already have all necessary infrastructure to parse binary protocol. So the task is to use this infrastructure. The idea is to add new function mysql_stmt_query() which would send COM_STMT_QUERY to server, initialize MYSQL_STMT object to use it for parsing result with standard functions for parsing the result of "execute prepared statement". As well mysql_stmt_
There are two functions to execute prepared and non-prepared queries correspondingly: mysql_stmt_
The task is to mix these two functions (mysql_
The sequence of C API calls to send query and receive and parse binary answer would look like this:
MYSQL *con = mysql_init(...);
mysql_real_
MYSQL_BIND stmt_result[n];
/* fill result info here */
...
MYSQL_STMT *stmt = mysql_stmt_
mysql_stmt_
mysql_stmt_
mysql_stmt_
while(!
{
...
}
mysql_stmt_
mysql_stmt_
mysql_close(con);
UPD: mysql_stmt_query() and mysql_stmt_