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
Removed com_multi for mariadb_stmt_execute_direct
added support for pre 10.2-servers in mariadb_stmt_execute_direct
This commit is contained in:
@@ -136,7 +136,7 @@ static int bulk2(MYSQL *mysql)
|
||||
rc= mysql_query(mysql, "DROP TABLE IF EXISTS bulk2");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_query(mysql, "CREATE TABLE bulk2 (a int default 4, b default 2)");
|
||||
rc= mysql_query(mysql, "CREATE TABLE bulk2 (a int default 4, b int default 2)");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_stmt_prepare(stmt, "INSERT INTO bulk2 VALUES (?,1)", -1);
|
||||
|
@@ -17,6 +17,14 @@ static int execute_direct(MYSQL *mysql)
|
||||
rc= mariadb_stmt_execute_direct(stmt, "DROP TABLE IF EXISTS t1", -1);
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
rc= mariadb_stmt_execute_direct(stmt, "SELECT 1", -1);
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
while (!mysql_stmt_fetch(stmt));
|
||||
|
||||
rc= mariadb_stmt_execute_direct(stmt, "SELECT 1", -1);
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
rc= mariadb_stmt_execute_direct(stmt, "CREATE TABLE t1 (a int)", -1);
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
@@ -60,38 +68,36 @@ static int execute_direct_example(MYSQL *mysql)
|
||||
MYSQL_BIND bind[2];
|
||||
int intval= 1;
|
||||
int param_count= 2;
|
||||
const char *strval= "execute_direct_example";
|
||||
int rc;
|
||||
const char *strval= "execute_direct_example1";
|
||||
|
||||
/* Direct execution without parameters */
|
||||
if (mariadb_stmt_execute_direct(stmt, "DROP TABLE IF EXISTS execute_direct", -1))
|
||||
goto error;
|
||||
if (mariadb_stmt_execute_direct(stmt, "CREATE TABLE execute_direct (a int, b varchar(20))", -1))
|
||||
goto error;
|
||||
|
||||
rc= mariadb_stmt_execute_direct(stmt, "DROP TABLE IF EXISTS execute_direct", -1);
|
||||
check_stmt_rc(rc, stmt);
|
||||
rc= mariadb_stmt_execute_direct(stmt, "CREATE TABLE execute_direct (a int, b varchar(20))", -1);
|
||||
rc= mysql_stmt_close(stmt);
|
||||
stmt= mysql_stmt_init(mysql);
|
||||
check_stmt_rc(rc, stmt);
|
||||
memset(bind, 0, sizeof(MYSQL_BIND) * 2);
|
||||
bind[0].buffer_type= MYSQL_TYPE_SHORT;
|
||||
bind[0].buffer= &intval;
|
||||
bind[1].buffer_type= MYSQL_TYPE_STRING;
|
||||
bind[1].buffer= (char *)strval;
|
||||
bind[1].buffer_length= (ulong)strlen(strval);
|
||||
bind[1].buffer_length= strlen(strval);
|
||||
|
||||
/* set number of parameters */
|
||||
if (mysql_stmt_attr_set(stmt, STMT_ATTR_PREBIND_PARAMS, ¶m_count))
|
||||
goto error;
|
||||
rc= mysql_stmt_attr_set(stmt, STMT_ATTR_PREBIND_PARAMS, ¶m_count);
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
/* bind parameters */
|
||||
if (mysql_stmt_bind_param(stmt, bind))
|
||||
goto error;
|
||||
rc= mysql_stmt_bind_param(stmt, bind);
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
if (mariadb_stmt_execute_direct(stmt, "INSERT INTO execute_direct VALUES (?,?)", -1))
|
||||
goto error;
|
||||
rc= mariadb_stmt_execute_direct(stmt, "INSERT INTO execute_direct VALUES (?,?)", -1);
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
mysql_stmt_close(stmt);
|
||||
return OK;
|
||||
error:
|
||||
printf("Error: %s\n", mysql_stmt_error(stmt));
|
||||
mysql_stmt_close(stmt);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
struct my_tests_st my_tests[] = {
|
||||
|
@@ -4487,7 +4487,6 @@ static int test_conc205(MYSQL *mysql)
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
struct my_tests_st my_tests[] = {
|
||||
{"test_conc205", test_conc205, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
{"test_conc198", test_conc198, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
|
Reference in New Issue
Block a user