Stubs for types/names of placeholders, cursor flags and array execution count

implemented in the client library and server.
Warning: this makes the new client library and server incompatible with all 
previous versions and 5.0.
parent eedb8ce9
...@@ -1846,6 +1846,16 @@ my_bool cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt) ...@@ -1846,6 +1846,16 @@ my_bool cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt)
field_count= uint2korr(pos); pos+= 2; field_count= uint2korr(pos); pos+= 2;
param_count= uint2korr(pos); pos+= 2; param_count= uint2korr(pos); pos+= 2;
if (param_count != 0)
{
MYSQL_DATA *param_data;
/* skip parameters data: we don't support it yet */
if (!(param_data= (*mysql->methods->read_rows)(mysql, (MYSQL_FIELD*)0, 7)))
DBUG_RETURN(1);
free_rows(param_data);
}
if (field_count != 0) if (field_count != 0)
{ {
if (!(mysql->server_status & SERVER_STATUS_AUTOCOMMIT)) if (!(mysql->server_status & SERVER_STATUS_AUTOCOMMIT))
...@@ -2322,15 +2332,17 @@ static my_bool execute(MYSQL_STMT * stmt, char *packet, ulong length) ...@@ -2322,15 +2332,17 @@ static my_bool execute(MYSQL_STMT * stmt, char *packet, ulong length)
{ {
MYSQL *mysql= stmt->mysql; MYSQL *mysql= stmt->mysql;
NET *net= &mysql->net; NET *net= &mysql->net;
char buff[MYSQL_STMT_HEADER]; char buff[4 /* size of stmt id */ +
5 /* execution flags */];
DBUG_ENTER("execute"); DBUG_ENTER("execute");
DBUG_PRINT("enter",("packet: %s, length :%d",packet ? packet :" ", length)); DBUG_PRINT("enter",("packet: %s, length :%d",packet ? packet :" ", length));
mysql->last_used_con= mysql; mysql->last_used_con= mysql;
int4store(buff, stmt->stmt_id); /* Send stmt id to server */ int4store(buff, stmt->stmt_id); /* Send stmt id to server */
if (cli_advanced_command(mysql, COM_EXECUTE, buff, buff[4]= (char) 0; /* no flags */
MYSQL_STMT_HEADER, packet, int4store(buff+5, 1); /* iteration count */
length, 1) || if (cli_advanced_command(mysql, COM_EXECUTE, buff, sizeof(buff),
packet, length, 1) ||
(*mysql->methods->read_query_result)(mysql)) (*mysql->methods->read_query_result)(mysql))
{ {
set_stmt_errmsg(stmt, net->last_error, net->last_errno, net->sqlstate); set_stmt_errmsg(stmt, net->last_error, net->last_errno, net->sqlstate);
......
...@@ -155,8 +155,16 @@ static bool send_prep_stmt(Prepared_statement *stmt, uint columns) ...@@ -155,8 +155,16 @@ static bool send_prep_stmt(Prepared_statement *stmt, uint columns)
int4store(buff+1, stmt->id); int4store(buff+1, stmt->id);
int2store(buff+5, columns); int2store(buff+5, columns);
int2store(buff+7, stmt->param_count); int2store(buff+7, stmt->param_count);
/* TODO: send types of placeholders here */ /*
return (my_net_write(net, buff, sizeof(buff)) || net_flush(net)); Send types and names of placeholders to the client
XXX: fix this nasty upcast from List<Item_param> to List<Item>
*/
return my_net_write(net, buff, sizeof(buff)) ||
(stmt->param_count &&
stmt->thd->protocol_simple.send_fields((List<Item> *)
&stmt->lex->param_list, 0)) ||
net_flush(net);
return 0;
} }
#else #else
static bool send_prep_stmt(Prepared_statement *stmt, static bool send_prep_stmt(Prepared_statement *stmt,
...@@ -1113,9 +1121,12 @@ static void reset_stmt_for_execute(Prepared_statement *stmt) ...@@ -1113,9 +1121,12 @@ static void reset_stmt_for_execute(Prepared_statement *stmt)
void mysql_stmt_execute(THD *thd, char *packet, uint packet_length) void mysql_stmt_execute(THD *thd, char *packet, uint packet_length)
{ {
ulong stmt_id= uint4korr(packet); ulong stmt_id= uint4korr(packet);
uchar *packet_end= (uchar *) packet + packet_length - 1;
Prepared_statement *stmt; Prepared_statement *stmt;
DBUG_ENTER("mysql_stmt_execute"); DBUG_ENTER("mysql_stmt_execute");
packet+= 9; /* stmt_id + 5 bytes of flags */
if (!(stmt= find_prepared_statement(thd, stmt_id, "execute", SEND_ERROR))) if (!(stmt= find_prepared_statement(thd, stmt_id, "execute", SEND_ERROR)))
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
...@@ -1135,8 +1146,6 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length) ...@@ -1135,8 +1146,6 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length)
#ifndef EMBEDDED_LIBRARY #ifndef EMBEDDED_LIBRARY
if (stmt->param_count) if (stmt->param_count)
{ {
uchar *packet_end= (uchar *) packet + packet_length - 1;
packet+= 4;
uchar *null_array= (uchar *) packet; uchar *null_array= (uchar *) packet;
if (setup_conversion_functions(stmt, (uchar **) &packet, packet_end) || if (setup_conversion_functions(stmt, (uchar **) &packet, packet_end) ||
stmt->set_params(stmt, null_array, (uchar *) packet, packet_end)) stmt->set_params(stmt, null_array, (uchar *) packet, packet_end))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment