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
Added support for STMT_INDICATE_IGNORE indicator - please note that the counter part for indicator type ignore is not pushed in server repo yet.
This commit is contained in:
@@ -740,8 +740,7 @@ unsigned char* mysql_stmt_execute_generate_request(MYSQL_STMT *stmt, size_t *req
|
|||||||
else
|
else
|
||||||
indicator= ma_get_indicator(stmt, i, j);
|
indicator= ma_get_indicator(stmt, i, j);
|
||||||
/* check if we need to send data */
|
/* check if we need to send data */
|
||||||
if (indicator == STMT_INDICATOR_NULL ||
|
if (indicator > 0)
|
||||||
indicator == STMT_INDICATOR_DEFAULT)
|
|
||||||
has_data= FALSE;
|
has_data= FALSE;
|
||||||
size= 1;
|
size= 1;
|
||||||
}
|
}
|
||||||
@@ -801,7 +800,7 @@ unsigned char* mysql_stmt_execute_generate_request(MYSQL_STMT *stmt, size_t *req
|
|||||||
p= start + offset;
|
p= start + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (indicator != STMT_INDICATOR_DEFAULT &&
|
if ((indicator != STMT_INDICATOR_DEFAULT && indicator != STMT_INDICATOR_IGNORE) &&
|
||||||
((stmt->params[i].is_null && *stmt->params[i].is_null) ||
|
((stmt->params[i].is_null && *stmt->params[i].is_null) ||
|
||||||
stmt->params[i].buffer_type == MYSQL_TYPE_NULL ||
|
stmt->params[i].buffer_type == MYSQL_TYPE_NULL ||
|
||||||
!stmt->params[i].buffer))
|
!stmt->params[i].buffer))
|
||||||
|
@@ -335,11 +335,126 @@ static int bulk_null(MYSQL *mysql)
|
|||||||
|
|
||||||
mysql_stmt_close(stmt);
|
mysql_stmt_close(stmt);
|
||||||
return OK;
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int bulk5(MYSQL *mysql)
|
||||||
|
{
|
||||||
|
MYSQL_STMT *stmt= mysql_stmt_init(mysql);
|
||||||
|
MYSQL_BIND bind[3];
|
||||||
|
MYSQL_RES *res;
|
||||||
|
unsigned long rows;
|
||||||
|
unsigned int array_size= 5;
|
||||||
|
int rc;
|
||||||
|
int intval[]= {12,13,14,15,16};
|
||||||
|
int id[]= {1,2,3,4,5};
|
||||||
|
|
||||||
|
rc= mysql_query(mysql, "DROP TABLE IF EXISTS bulk5");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
|
||||||
|
rc= mysql_query(mysql, "CREATE TABLE bulk5 (a int, b int)");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
|
||||||
|
rc= mysql_query(mysql, "INSERT INTO bulk5 VALUES (1,1), (2,2), (3,3), (4,4), (5,5)");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
|
||||||
|
|
||||||
|
memset(bind, 0, sizeof(MYSQL_BIND) * 3);
|
||||||
|
|
||||||
|
rc= mysql_stmt_prepare(stmt, "UPDATE bulk5 SET a=? WHERE a=?", -1);
|
||||||
|
check_stmt_rc(rc, stmt);
|
||||||
|
|
||||||
|
bind[0].buffer_type= MYSQL_TYPE_LONG;
|
||||||
|
bind[0].buffer= &intval;
|
||||||
|
bind[1].buffer_type= MYSQL_TYPE_LONG;
|
||||||
|
bind[1].buffer= &id;
|
||||||
|
|
||||||
|
rc= mysql_stmt_attr_set(stmt, STMT_ATTR_ARRAY_SIZE, &array_size);
|
||||||
|
check_stmt_rc(rc, stmt);
|
||||||
|
|
||||||
|
rc= mysql_stmt_bind_param(stmt, bind);
|
||||||
|
check_stmt_rc(rc, stmt);
|
||||||
|
|
||||||
|
rc= mysql_stmt_execute(stmt);
|
||||||
|
check_stmt_rc(rc, stmt);
|
||||||
|
|
||||||
|
mysql_stmt_close(stmt);
|
||||||
|
|
||||||
|
rc= mysql_query(mysql, "SELECT * FROM bulk5 WHERE a=b+11");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
|
||||||
|
res= mysql_store_result(mysql);
|
||||||
|
rows= mysql_num_rows(res);
|
||||||
|
mysql_free_result(res);
|
||||||
|
|
||||||
|
FAIL_IF(rows != 5, "expected 5 rows");
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int bulk6(MYSQL *mysql)
|
||||||
|
{
|
||||||
|
MYSQL_STMT *stmt= mysql_stmt_init(mysql);
|
||||||
|
MYSQL_BIND bind[3];
|
||||||
|
MYSQL_RES *res;
|
||||||
|
unsigned long rows;
|
||||||
|
unsigned int array_size= 5;
|
||||||
|
int rc;
|
||||||
|
int intval[]= {12,13,14,15,16};
|
||||||
|
int id[]= {1,2,3,4,5};
|
||||||
|
char indicator[5];
|
||||||
|
|
||||||
|
memset(indicator, STMT_INDICATOR_IGNORE, 5);
|
||||||
|
|
||||||
|
rc= mysql_query(mysql, "DROP TABLE IF EXISTS bulk5");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
|
||||||
|
rc= mysql_query(mysql, "CREATE TABLE bulk5 (a int, b int default 4)");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
|
||||||
|
rc= mysql_query(mysql, "INSERT INTO bulk5 VALUES (1,1), (2,2), (3,3), (4,4), (5,5)");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
|
||||||
|
|
||||||
|
memset(bind, 0, sizeof(MYSQL_BIND) * 3);
|
||||||
|
|
||||||
|
rc= mysql_stmt_prepare(stmt, "UPDATE bulk5 SET a=?, b=? WHERE a=?", -1);
|
||||||
|
check_stmt_rc(rc, stmt);
|
||||||
|
|
||||||
|
bind[0].buffer_type= MYSQL_TYPE_LONG;
|
||||||
|
bind[0].buffer= &intval;
|
||||||
|
bind[1].buffer_type= MYSQL_TYPE_LONG;
|
||||||
|
bind[1].buffer= &intval;
|
||||||
|
bind[1].u.indicator= indicator;
|
||||||
|
bind[2].buffer_type= MYSQL_TYPE_LONG;
|
||||||
|
bind[2].buffer= &id;
|
||||||
|
|
||||||
|
rc= mysql_stmt_attr_set(stmt, STMT_ATTR_ARRAY_SIZE, &array_size);
|
||||||
|
check_stmt_rc(rc, stmt);
|
||||||
|
|
||||||
|
rc= mysql_stmt_bind_param(stmt, bind);
|
||||||
|
check_stmt_rc(rc, stmt);
|
||||||
|
|
||||||
|
rc= mysql_stmt_execute(stmt);
|
||||||
|
check_stmt_rc(rc, stmt);
|
||||||
|
|
||||||
|
mysql_stmt_close(stmt);
|
||||||
|
|
||||||
|
rc= mysql_query(mysql, "SELECT * FROM bulk5 WHERE a=b+11");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
|
||||||
|
res= mysql_store_result(mysql);
|
||||||
|
rows= mysql_num_rows(res);
|
||||||
|
mysql_free_result(res);
|
||||||
|
|
||||||
|
FAIL_IF(rows != 5, "expected 5 rows");
|
||||||
|
|
||||||
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct my_tests_st my_tests[] = {
|
struct my_tests_st my_tests[] = {
|
||||||
{"check_bulk", check_bulk, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
{"check_bulk", check_bulk, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
|
{"bulk5", bulk5, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
|
{"bulk6", bulk6, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
{"bulk1", bulk1, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
{"bulk1", bulk1, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
{"bulk2", bulk2, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
{"bulk2", bulk2, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
{"bulk3", bulk3, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
{"bulk3", bulk3, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
|
Reference in New Issue
Block a user