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
CONC-683: Check pending results when closing statement.
Similiar to fix for CONC-667 we need to check if other statements have a pending result set before we can close a statement handle.
This commit is contained in:
@@ -123,6 +123,20 @@ void stmt_set_error(MYSQL_STMT *stmt,
|
||||
return;
|
||||
}
|
||||
|
||||
/* checks if there are any other statements which have a
|
||||
pending result set */
|
||||
static my_bool madb_have_pending_results(MYSQL_STMT *stmt)
|
||||
{
|
||||
LIST *li_stmt= stmt->mysql->stmts;
|
||||
for (;li_stmt;li_stmt= li_stmt->next)
|
||||
{
|
||||
MYSQL_STMT *s= (MYSQL_STMT *)li_stmt->data;
|
||||
if (s != stmt && s->state == MYSQL_STMT_WAITING_USE_OR_STORE)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
my_bool mthd_supported_buffer_type(enum enum_field_types type)
|
||||
{
|
||||
switch (type) {
|
||||
@@ -1489,6 +1503,12 @@ my_bool STDCALL mysql_stmt_close(MYSQL_STMT *stmt)
|
||||
{
|
||||
my_bool rc= 1;
|
||||
|
||||
if (madb_have_pending_results(stmt))
|
||||
{
|
||||
stmt_set_error(stmt, CR_COMMANDS_OUT_OF_SYNC, SQLSTATE_UNKNOWN, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (stmt)
|
||||
{
|
||||
if (stmt->mysql && stmt->mysql->net.pvio)
|
||||
@@ -2208,14 +2228,10 @@ static my_bool madb_reset_stmt(MYSQL_STMT *stmt, unsigned int flags)
|
||||
|
||||
/* CONC-667: If an other statement has a pending result set, we
|
||||
need to return an error */
|
||||
for (;li_stmt;li_stmt= li_stmt->next)
|
||||
if (madb_have_pending_results(stmt))
|
||||
{
|
||||
MYSQL_STMT *s= (MYSQL_STMT *)li_stmt->data;
|
||||
if (s != stmt && s->state == MYSQL_STMT_WAITING_USE_OR_STORE)
|
||||
{
|
||||
stmt_set_error(stmt, CR_COMMANDS_OUT_OF_SYNC, SQLSTATE_UNKNOWN, 0);
|
||||
return 1;
|
||||
}
|
||||
stmt_set_error(stmt, CR_COMMANDS_OUT_OF_SYNC, SQLSTATE_UNKNOWN, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!stmt->mysql)
|
||||
|
Reference in New Issue
Block a user