diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 51d6d669d36..e63a583a0dd 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -1846,6 +1846,16 @@ my_bool cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt) field_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 (!(mysql->server_status & SERVER_STATUS_AUTOCOMMIT)) @@ -2322,15 +2332,17 @@ static my_bool execute(MYSQL_STMT * stmt, char *packet, ulong length) { MYSQL *mysql= stmt->mysql; NET *net= &mysql->net; - char buff[MYSQL_STMT_HEADER]; + char buff[4 /* size of stmt id */ + + 5 /* execution flags */]; DBUG_ENTER("execute"); DBUG_PRINT("enter",("packet: %s, length :%d",packet ? packet :" ", length)); mysql->last_used_con= mysql; int4store(buff, stmt->stmt_id); /* Send stmt id to server */ - if (cli_advanced_command(mysql, COM_EXECUTE, buff, - MYSQL_STMT_HEADER, packet, - length, 1) || + buff[4]= (char) 0; /* no flags */ + int4store(buff+5, 1); /* iteration count */ + if (cli_advanced_command(mysql, COM_EXECUTE, buff, sizeof(buff), + packet, length, 1) || (*mysql->methods->read_query_result)(mysql)) { set_stmt_errmsg(stmt, net->last_error, net->last_errno, net->sqlstate); diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 0285c1eec2f..94fef4cafdc 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -155,8 +155,16 @@ static bool send_prep_stmt(Prepared_statement *stmt, uint columns) int4store(buff+1, stmt->id); int2store(buff+5, columns); 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 to List + */ + return my_net_write(net, buff, sizeof(buff)) || + (stmt->param_count && + stmt->thd->protocol_simple.send_fields((List *) + &stmt->lex->param_list, 0)) || + net_flush(net); + return 0; } #else static bool send_prep_stmt(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) { ulong stmt_id= uint4korr(packet); + uchar *packet_end= (uchar *) packet + packet_length - 1; Prepared_statement *stmt; DBUG_ENTER("mysql_stmt_execute"); + + packet+= 9; /* stmt_id + 5 bytes of flags */ if (!(stmt= find_prepared_statement(thd, stmt_id, "execute", SEND_ERROR))) DBUG_VOID_RETURN; @@ -1135,8 +1146,6 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length) #ifndef EMBEDDED_LIBRARY if (stmt->param_count) { - uchar *packet_end= (uchar *) packet + packet_length - 1; - packet+= 4; uchar *null_array= (uchar *) packet; if (setup_conversion_functions(stmt, (uchar **) &packet, packet_end) || stmt->set_params(stmt, null_array, (uchar *) packet, packet_end))