You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-08 14:02:17 +03:00
Implement mysql_stmt_execute_direct without COM_MULTI.
Network roundtrip is avoided, but no other optimization done in this commit. Like, possible to accumulate send 2 command packets in single send(), and it is trivial to do, but ommited here on reasons of clarity
This commit is contained in:
@@ -1667,22 +1667,18 @@ int stmt_read_execute_response(MYSQL_STMT *stmt)
|
||||
return(0);
|
||||
}
|
||||
|
||||
int STDCALL mysql_stmt_execute(MYSQL_STMT *stmt)
|
||||
|
||||
int stmt_execute_send(MYSQL_STMT *stmt)
|
||||
{
|
||||
MYSQL *mysql= stmt->mysql;
|
||||
char *request;
|
||||
int ret;
|
||||
size_t request_len= 0;
|
||||
enum mariadb_com_multi multi= MARIADB_COM_MULTI_END;
|
||||
|
||||
if (!stmt->mysql)
|
||||
{
|
||||
SET_CLIENT_STMT_ERROR(stmt, CR_SERVER_LOST, SQLSTATE_UNKNOWN, 0);
|
||||
return(1);
|
||||
}
|
||||
|
||||
mysql_get_optionv(mysql, MARIADB_OPT_COM_MULTI, &multi);
|
||||
|
||||
if (stmt->state < MYSQL_STMT_PREPARED)
|
||||
{
|
||||
SET_CLIENT_ERROR(mysql, CR_COMMANDS_OUT_OF_SYNC, SQLSTATE_UNKNOWN, 0);
|
||||
@@ -1729,11 +1725,12 @@ int STDCALL mysql_stmt_execute(MYSQL_STMT *stmt)
|
||||
mysql->net.last_error);
|
||||
return(1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (multi == MARIADB_COM_MULTI_BEGIN)
|
||||
return(0);
|
||||
|
||||
return(stmt_read_execute_response(stmt));
|
||||
int STDCALL mysql_stmt_execute(MYSQL_STMT *stmt)
|
||||
{
|
||||
return stmt_execute_send(stmt) || stmt_read_execute_response(stmt);
|
||||
}
|
||||
|
||||
static my_bool madb_reset_stmt(MYSQL_STMT *stmt, unsigned int flags)
|
||||
@@ -2042,7 +2039,7 @@ int STDCALL mariadb_stmt_execute_direct(MYSQL_STMT *stmt,
|
||||
const char *stmt_str,
|
||||
size_t length)
|
||||
{
|
||||
enum mariadb_com_multi multi= MARIADB_COM_MULTI_BEGIN;
|
||||
|
||||
MYSQL *mysql= stmt->mysql;
|
||||
|
||||
if (!mysql)
|
||||
@@ -2051,9 +2048,6 @@ int STDCALL mariadb_stmt_execute_direct(MYSQL_STMT *stmt,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (mysql_optionsv(mysql, MARIADB_OPT_COM_MULTI, &multi))
|
||||
goto fail;
|
||||
|
||||
if (!stmt->mysql)
|
||||
{
|
||||
SET_CLIENT_STMT_ERROR(stmt, CR_SERVER_LOST, SQLSTATE_UNKNOWN, 0);
|
||||
@@ -2063,8 +2057,6 @@ int STDCALL mariadb_stmt_execute_direct(MYSQL_STMT *stmt,
|
||||
if (length == -1)
|
||||
length= strlen(stmt_str);
|
||||
|
||||
mysql_get_optionv(mysql, MARIADB_OPT_COM_MULTI, &multi);
|
||||
|
||||
/* clear flags */
|
||||
CLEAR_CLIENT_STMT_ERROR(stmt);
|
||||
CLEAR_CLIENT_ERROR(stmt->mysql);
|
||||
@@ -2096,13 +2088,10 @@ int STDCALL mariadb_stmt_execute_direct(MYSQL_STMT *stmt,
|
||||
stmt->state= MYSQL_STMT_PREPARED;
|
||||
/* Since we can't determine stmt_id here, we need to set it to -1, so server will know that the
|
||||
* execute command belongs to previous prepare */
|
||||
stmt->stmt_id= -1;
|
||||
if (mysql_stmt_execute(stmt))
|
||||
goto fail;
|
||||
|
||||
/* flush multi buffer */
|
||||
multi= MARIADB_COM_MULTI_END;
|
||||
if (mysql_optionsv(mysql, MARIADB_OPT_COM_MULTI, &multi))
|
||||
stmt->stmt_id= -1;
|
||||
ma_net_clear(&mysql->net);
|
||||
if (stmt_execute_send(stmt))
|
||||
goto fail;
|
||||
|
||||
/* read prepare response */
|
||||
|
Reference in New Issue
Block a user