1
0
mirror of https://github.com/mariadb-corporation/mariadb-connector-c.git synced 2025-08-07 02:42:49 +03:00

Fix for CONC-97 and CONC-98:

- Check if the connection is valid before resetting statement
  - Fix windows compile error (mingw)
This commit is contained in:
holzboote@googlemail.com
2014-06-10 09:48:05 +02:00
parent 72b1570d7c
commit e038a7fae0
3 changed files with 29 additions and 2 deletions

View File

@@ -1662,7 +1662,7 @@ static my_bool madb_reset_stmt(MYSQL_STMT *stmt, unsigned int flags)
if (flags & MADB_RESET_SERVER)
{
/* reset statement on server side */
if (stmt->mysql->status == MYSQL_STATUS_READY)
if (stmt->mysql && stmt->mysql->status == MYSQL_STATUS_READY)
{
unsigned char cmd_buf[STMT_ID_LENGTH];
int4store(cmd_buf, stmt->stmt_id);
@@ -1698,6 +1698,14 @@ my_bool STDCALL mysql_stmt_reset(MYSQL_STMT *stmt)
DBUG_ENTER("mysql_stmt_reset");
if (!mysql)
{
/* connection could be invalid, e.g. after mysql_stmt_close or failed reconnect
attempt (see bug CONC-97) */
SET_CLIENT_STMT_ERROR(stmt, CR_SERVER_LOST, SQLSTATE_UNKNOWN, 0);
DBUG_RETURN(1);
}
if (stmt->state >= MYSQL_STMT_USER_FETCHING &&
stmt->fetch_row_func == stmt_unbuffered_fetch)
flags|= MADB_RESET_BUFFER;

View File

@@ -41,7 +41,7 @@
*/
#define WIN_SET_NONBLOCKING(mysql) { \
my_bool old_mode; \
if ((mysql)->net.vio) vio_blocking((mysql)->net.vio, FALSE, &old_mode); \
if ((mysql)->net.vio) vio_blocking((mysql)->net.vio, FALSE); \
}
#else
#define WIN_SET_NONBLOCKING(mysql)

View File

@@ -25,6 +25,24 @@ with this program; if not, write to the Free Software Foundation, Inc.,
/* Utility function to verify the field members */
static int test_conc97(MYSQL *mysql)
{
MYSQL_STMT *stmt= mysql_stmt_init(mysql);
int rc;
mysql_close(mysql);
rc= mysql_stmt_reset(stmt);
FAIL_IF(!rc, "Error expected while resetting stmt");
rc= mysql_stmt_close(stmt);
check_stmt_rc(rc, stmt);
mysql= mysql_init(NULL);
return OK;
}
static int test_conc83(MYSQL *mysql)
{
MYSQL_STMT *stmt;
@@ -4844,6 +4862,7 @@ int test_notrunc(MYSQL *mysql)
}
struct my_tests_st my_tests[] = {
{"test_conc97", test_conc97, TEST_CONNECTION_NEW, 0, NULL, NULL},
{"test_conc83", test_conc83, TEST_CONNECTION_NEW, 0, NULL, NULL},
{"test_conc60", test_conc60, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
{"test_notrunc", test_notrunc, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},