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
Coverity fixes and travis integration
This commit is contained in:
@@ -88,12 +88,18 @@ void stmt_set_error(MYSQL_STMT *stmt,
|
||||
...)
|
||||
{
|
||||
va_list ap;
|
||||
const char *error= NULL;
|
||||
|
||||
if (error_nr >= CR_MIN_ERROR && error_nr <= CR_MYSQL_LAST_ERROR)
|
||||
error= ER(error_nr);
|
||||
else if (error_nr >= CER_MIN_ERROR && error_nr <= CR_MARIADB_LAST_ERROR)
|
||||
error= CER(error_nr);
|
||||
|
||||
stmt->last_errno= error_nr;
|
||||
ma_strmake(stmt->sqlstate, sqlstate, SQLSTATE_LENGTH);
|
||||
va_start(ap, format);
|
||||
vsnprintf(stmt->last_error, MYSQL_ERRMSG_SIZE,
|
||||
format ? format : ER(error_nr), ap);
|
||||
format ? format : error ? error : "", ap);
|
||||
va_end(ap);
|
||||
return;
|
||||
}
|
||||
@@ -869,7 +875,7 @@ unsigned char* mysql_stmt_execute_generate_bulk_request(MYSQL_STMT *stmt, size_t
|
||||
if (!stmt->param_count)
|
||||
{
|
||||
stmt_set_error(stmt, CR_BULK_WITHOUT_PARAMETERS, "IM001",
|
||||
CER(CR_BULK_WITHOUT_PARAMETERS), "Bulk operation");
|
||||
CER(CR_BULK_WITHOUT_PARAMETERS));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1328,15 +1334,18 @@ static my_bool net_stmt_close(MYSQL_STMT *stmt, my_bool remove)
|
||||
|
||||
my_bool STDCALL mysql_stmt_close(MYSQL_STMT *stmt)
|
||||
{
|
||||
my_bool rc;
|
||||
if (stmt && stmt->mysql && stmt->mysql->net.pvio)
|
||||
mysql_stmt_internal_reset(stmt, 1);
|
||||
my_bool rc= 1;
|
||||
|
||||
rc= net_stmt_close(stmt, 1);
|
||||
if (stmt)
|
||||
{
|
||||
if (stmt->mysql && stmt->mysql->net.pvio)
|
||||
mysql_stmt_internal_reset(stmt, 1);
|
||||
|
||||
free(stmt->extension);
|
||||
free(stmt);
|
||||
rc= net_stmt_close(stmt, 1);
|
||||
|
||||
free(stmt->extension);
|
||||
free(stmt);
|
||||
}
|
||||
return(rc);
|
||||
}
|
||||
|
||||
@@ -1898,7 +1907,8 @@ int stmt_read_execute_response(MYSQL_STMT *stmt)
|
||||
*/
|
||||
|
||||
/* preferred is buffered read */
|
||||
mysql_stmt_store_result(stmt);
|
||||
if (mysql_stmt_store_result(stmt))
|
||||
return 1;
|
||||
stmt->mysql->status= MYSQL_STATUS_STMT_RESULT;
|
||||
} else
|
||||
{
|
||||
@@ -2313,17 +2323,23 @@ int STDCALL mariadb_stmt_execute_direct(MYSQL_STMT *stmt,
|
||||
const char *stmt_str,
|
||||
size_t length)
|
||||
{
|
||||
MYSQL *mysql= stmt->mysql;
|
||||
my_bool emulate_cmd= !(!(stmt->mysql->server_capabilities & CLIENT_MYSQL) &&
|
||||
(stmt->mysql->extension->mariadb_server_capabilities &
|
||||
(MARIADB_CLIENT_STMT_BULK_OPERATIONS >> 32))) || mysql->net.compress;
|
||||
MYSQL *mysql;
|
||||
my_bool emulate_cmd;
|
||||
|
||||
if (!stmt)
|
||||
return 1;
|
||||
|
||||
mysql= stmt->mysql;
|
||||
if (!mysql)
|
||||
{
|
||||
SET_CLIENT_STMT_ERROR(stmt, CR_SERVER_LOST, SQLSTATE_UNKNOWN, 0);
|
||||
goto fail;
|
||||
return 1;
|
||||
}
|
||||
|
||||
emulate_cmd= !(!(stmt->mysql->server_capabilities & CLIENT_MYSQL) &&
|
||||
(stmt->mysql->extension->mariadb_server_capabilities &
|
||||
(MARIADB_CLIENT_STMT_BULK_OPERATIONS >> 32))) || mysql->net.compress;
|
||||
|
||||
/* Server versions < 10.2 don't support execute_direct, so we need to
|
||||
emulate it */
|
||||
if (emulate_cmd)
|
||||
@@ -2331,7 +2347,6 @@ int STDCALL mariadb_stmt_execute_direct(MYSQL_STMT *stmt,
|
||||
int rc;
|
||||
|
||||
/* avoid sending close + prepare in 2 packets */
|
||||
|
||||
if ((rc= mysql_stmt_prepare(stmt, stmt_str, (unsigned long)length)))
|
||||
return rc;
|
||||
return mysql_stmt_execute(stmt);
|
||||
@@ -2340,13 +2355,7 @@ int STDCALL mariadb_stmt_execute_direct(MYSQL_STMT *stmt,
|
||||
if (ma_multi_command(mysql, COM_MULTI_ENABLED))
|
||||
{
|
||||
SET_CLIENT_STMT_ERROR(stmt, CR_COMMANDS_OUT_OF_SYNC, SQLSTATE_UNKNOWN, 0);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!stmt->mysql)
|
||||
{
|
||||
SET_CLIENT_STMT_ERROR(stmt, CR_SERVER_LOST, SQLSTATE_UNKNOWN, 0);
|
||||
return(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (length == (size_t) -1)
|
||||
@@ -2430,8 +2439,10 @@ int STDCALL mariadb_stmt_execute_direct(MYSQL_STMT *stmt,
|
||||
/* read execute response packet */
|
||||
return stmt_read_execute_response(stmt);
|
||||
fail:
|
||||
SET_CLIENT_STMT_ERROR(stmt, mysql->net.last_errno, mysql->net.sqlstate,
|
||||
mysql->net.last_error);
|
||||
/* check if we need to set error message */
|
||||
if (!mysql_stmt_errno(stmt))
|
||||
SET_CLIENT_STMT_ERROR(stmt, mysql->net.last_errno, mysql->net.sqlstate,
|
||||
mysql->net.last_error);
|
||||
do {
|
||||
stmt->mysql->methods->db_stmt_flush_unbuffered(stmt);
|
||||
} while(mysql_stmt_more_results(stmt));
|
||||
|
Reference in New Issue
Block a user