You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-07 02:42:49 +03:00
Fix for CONC-344: reset internal row counter before executing prepared statement
This commit is contained in:
@@ -1977,8 +1977,9 @@ int STDCALL mysql_stmt_execute(MYSQL_STMT *stmt)
|
|||||||
{
|
{
|
||||||
ma_free_root(&stmt->result.alloc, MYF(MY_KEEP_PREALLOC));
|
ma_free_root(&stmt->result.alloc, MYF(MY_KEEP_PREALLOC));
|
||||||
stmt->result_cursor= stmt->result.data= 0;
|
stmt->result_cursor= stmt->result.data= 0;
|
||||||
stmt->result.rows= 0;
|
|
||||||
}
|
}
|
||||||
|
/* CONC-344: set row count to zero */
|
||||||
|
stmt->result.rows= 0;
|
||||||
if (stmt->array_size > 0)
|
if (stmt->array_size > 0)
|
||||||
request= (char *)mysql_stmt_execute_generate_bulk_request(stmt, &request_len);
|
request= (char *)mysql_stmt_execute_generate_bulk_request(stmt, &request_len);
|
||||||
else
|
else
|
||||||
|
@@ -4660,7 +4660,7 @@ static int test_codbc138(MYSQL *mysql)
|
|||||||
int i= 0;
|
int i= 0;
|
||||||
|
|
||||||
struct st_time_test {
|
struct st_time_test {
|
||||||
char *statement;
|
const char *statement;
|
||||||
MYSQL_TIME tm;
|
MYSQL_TIME tm;
|
||||||
} time_test[]= {
|
} time_test[]= {
|
||||||
{"SELECT DATE_ADD('2018-02-01', INTERVAL -188 DAY)",
|
{"SELECT DATE_ADD('2018-02-01', INTERVAL -188 DAY)",
|
||||||
@@ -4752,9 +4752,36 @@ static int test_conc334(MYSQL *mysql)
|
|||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
static int test_conc344(MYSQL *mysql)
|
||||||
|
{
|
||||||
|
MYSQL_STMT *stmt= mysql_stmt_init(mysql);
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc= mysql_query(mysql, "CREATE OR REPLACE TABLE t1 (a int, b int)");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
rc= mysql_query(mysql, "INSERT INTO t1 VALUES (1,1), (2,2),(3,3),(4,4),(5,5)");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
|
||||||
|
rc= mysql_stmt_prepare(stmt, SL("SELECT * FROM t1 ORDER BY a"));
|
||||||
|
check_stmt_rc(rc, stmt);
|
||||||
|
|
||||||
|
rc= mysql_stmt_execute(stmt);
|
||||||
|
check_stmt_rc(rc, stmt);
|
||||||
|
|
||||||
|
while (!mysql_stmt_fetch(stmt));
|
||||||
|
FAIL_IF(mysql_stmt_num_rows(stmt) != 5, "expected 5 rows");
|
||||||
|
rc= mysql_stmt_execute(stmt);
|
||||||
|
check_stmt_rc(rc, stmt);
|
||||||
|
rc= mysql_stmt_fetch(stmt);
|
||||||
|
diag("num_rows: %lld", mysql_stmt_num_rows(stmt));
|
||||||
|
FAIL_IF(mysql_stmt_num_rows(stmt) != 1, "expected 1 row");
|
||||||
|
|
||||||
|
mysql_stmt_close(stmt);
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
struct my_tests_st my_tests[] = {
|
struct my_tests_st my_tests[] = {
|
||||||
|
{"test_conc344", test_conc344, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
||||||
{"test_conc334", test_conc334, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
{"test_conc334", test_conc334, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
||||||
{"test_compress", test_compress, TEST_CONNECTION_NEW, CLIENT_COMPRESS, NULL, NULL},
|
{"test_compress", test_compress, TEST_CONNECTION_NEW, CLIENT_COMPRESS, NULL, NULL},
|
||||||
{"test_codbc138", test_codbc138, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
{"test_codbc138", test_codbc138, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
|
Reference in New Issue
Block a user