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
Very simple test of COM_MULTI
This commit is contained in:
@@ -6,25 +6,56 @@
|
|||||||
static int com_multi_1(MYSQL *mysql)
|
static int com_multi_1(MYSQL *mysql)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
MYSQL_RES *res;
|
||||||
my_bool is_multi= 1;
|
my_bool is_multi= 1;
|
||||||
|
|
||||||
|
/* TEST a simple query before COM_MULTI */
|
||||||
|
|
||||||
|
rc= mysql_query(mysql, "select 1");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
FAIL_UNLESS(res, "1 simple query no result");
|
||||||
|
res= mysql_store_result(mysql);
|
||||||
|
|
||||||
|
mysql_free_result(res);
|
||||||
|
|
||||||
|
/* TEST COM_MULTI */
|
||||||
|
|
||||||
if (mysql_options(mysql, MARIADB_OPT_COM_MULTI, &is_multi))
|
if (mysql_options(mysql, MARIADB_OPT_COM_MULTI, &is_multi))
|
||||||
{
|
{
|
||||||
diag("COM_MULT not supported");
|
diag("COM_MULT not supported");
|
||||||
return SKIP;
|
return SKIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc= mysql_query(mysql, "SET @a:=1");
|
rc= mysql_query(mysql, "select 1");
|
||||||
check_mysql_rc(rc, mysql);
|
|
||||||
|
|
||||||
rc= mysql_query(mysql, "SET @b:=2");
|
rc= mysql_query(mysql, "select 2");
|
||||||
check_mysql_rc(rc, mysql);
|
|
||||||
|
|
||||||
rc= mysql_query(mysql, "select @a,@b");
|
|
||||||
check_mysql_rc(rc, mysql);
|
|
||||||
|
|
||||||
rc= mariadb_flush_multi_command(mysql);
|
rc= mariadb_flush_multi_command(mysql);
|
||||||
check_mysql_rc(rc, mysql);
|
check_mysql_rc(rc, mysql);
|
||||||
|
/* 1 SELECT result */
|
||||||
|
res= mysql_store_result(mysql);
|
||||||
|
FAIL_UNLESS(res, "1 of 2 simple query in batch no result");
|
||||||
|
mysql_free_result(res);
|
||||||
|
/* 2 SELECT result */
|
||||||
|
rc= mysql_next_result(mysql);
|
||||||
|
FAIL_UNLESS(rc == 0, "no second result in the batch");
|
||||||
|
res= mysql_store_result(mysql);
|
||||||
|
FAIL_UNLESS(res, "2 of 2 simple query in batch no result");
|
||||||
|
mysql_free_result(res);
|
||||||
|
/* WHOLE batch result (OK) */
|
||||||
|
rc= mysql_next_result(mysql);
|
||||||
|
res= mysql_store_result(mysql);
|
||||||
|
FAIL_UNLESS(res == NULL, "rows instead of batch OK");
|
||||||
|
rc= mysql_next_result(mysql);
|
||||||
|
FAIL_UNLESS(rc == -1, "more then 2 results");
|
||||||
|
|
||||||
|
/* TEST a simple query after COM_MULTI */
|
||||||
|
|
||||||
|
rc= mysql_query(mysql, "select 1");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
res= mysql_store_result(mysql);
|
||||||
|
FAIL_UNLESS(res, "2 simple query no result");
|
||||||
|
mysql_free_result(res);
|
||||||
|
|
||||||
/* question: how will result sets look like ? */
|
/* question: how will result sets look like ? */
|
||||||
diag("error: %s", mysql_error(mysql));
|
diag("error: %s", mysql_error(mysql));
|
||||||
|
Reference in New Issue
Block a user