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
Fix for CONC-504: reset stmt->result.rows when executing mysql_stmt_next_result
While in text protocol the number of rows is resetted in mysql_store/use_result in binary protocol we need to explicitly reset it when switching to next result set.
This commit is contained in:
@@ -2374,6 +2374,7 @@ int STDCALL mysql_stmt_next_result(MYSQL_STMT *stmt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
stmt->field_count= stmt->mysql->field_count;
|
stmt->field_count= stmt->mysql->field_count;
|
||||||
|
stmt->result.rows= 0;
|
||||||
|
|
||||||
return(rc);
|
return(rc);
|
||||||
}
|
}
|
||||||
|
@@ -5232,7 +5232,50 @@ static int test_returning(MYSQL *mysql)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int test_conc504(MYSQL *mysql)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
MYSQL_STMT *stmt= mysql_stmt_init(mysql);
|
||||||
|
const char *sp= "CREATE PROCEDURE p1()\n" \
|
||||||
|
"BEGIN\n"\
|
||||||
|
" SELECT 1;\n"\
|
||||||
|
" SELECT 2;\n"\
|
||||||
|
" SELECT 3;\n"\
|
||||||
|
"END";
|
||||||
|
|
||||||
|
rc= mysql_query(mysql, "DROP PROCEDURE IF EXISTS p1");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
|
||||||
|
rc= mysql_query(mysql, sp);
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
|
||||||
|
rc= mysql_stmt_prepare(stmt, SL("CALL p1()"));
|
||||||
|
check_stmt_rc(rc, stmt);
|
||||||
|
|
||||||
|
rc= mysql_stmt_execute(stmt);
|
||||||
|
check_stmt_rc(rc, stmt);
|
||||||
|
|
||||||
|
mysql_stmt_store_result(stmt);
|
||||||
|
FAIL_IF(mysql_stmt_num_rows(stmt) != 1, "Expected 1 row");
|
||||||
|
|
||||||
|
mysql_stmt_next_result(stmt);
|
||||||
|
mysql_stmt_store_result(stmt);
|
||||||
|
FAIL_IF(mysql_stmt_num_rows(stmt) != 1, "Expected 1 row");
|
||||||
|
|
||||||
|
mysql_stmt_next_result(stmt);
|
||||||
|
mysql_stmt_store_result(stmt);
|
||||||
|
FAIL_IF(mysql_stmt_num_rows(stmt) != 1, "Expected 1 row");
|
||||||
|
|
||||||
|
mysql_stmt_close(stmt);
|
||||||
|
|
||||||
|
rc= mysql_query(mysql, "DROP PROCEDURE p1");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
struct my_tests_st my_tests[] = {
|
struct my_tests_st my_tests[] = {
|
||||||
|
{"test_conc504", test_conc504, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
{"test_returning", test_returning, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
{"test_returning", test_returning, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
{"test_mdev_21920", test_mdev_21920, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
{"test_mdev_21920", test_mdev_21920, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
{"test_maxparam", test_maxparam, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
{"test_maxparam", test_maxparam, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
||||||
|
Reference in New Issue
Block a user