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 test for MDEV-15133
This commit is contained in:
@@ -853,8 +853,141 @@ static int bulk_skip_row(MYSQL *mysql)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int bulk_null_null(MYSQL *mysql)
|
||||||
|
{
|
||||||
|
struct st_bulk4 {
|
||||||
|
char char_value[20];
|
||||||
|
char indicator1;
|
||||||
|
int int_value;
|
||||||
|
char indicator2;
|
||||||
|
double double_value;
|
||||||
|
char indicator3;
|
||||||
|
char time_value[20];
|
||||||
|
char indicator4;
|
||||||
|
char decimal_value[4];
|
||||||
|
char indicator5;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct st_bulk4 val[]= {{"3", STMT_INDICATOR_NTS,
|
||||||
|
3, STMT_INDICATOR_NONE,
|
||||||
|
3.0, STMT_INDICATOR_NONE,
|
||||||
|
"00:00:00", STMT_INDICATOR_NTS,
|
||||||
|
"3.0", STMT_INDICATOR_NTS},
|
||||||
|
{"3", STMT_INDICATOR_NULL,
|
||||||
|
3, STMT_INDICATOR_NULL,
|
||||||
|
3.0, STMT_INDICATOR_NULL,
|
||||||
|
"00:00:00", STMT_INDICATOR_NULL,
|
||||||
|
"3.0", STMT_INDICATOR_NULL},
|
||||||
|
{"3", STMT_INDICATOR_NTS,
|
||||||
|
3, STMT_INDICATOR_NONE,
|
||||||
|
3.0, STMT_INDICATOR_NONE,
|
||||||
|
"00:00:00", STMT_INDICATOR_NTS,
|
||||||
|
"3.0", STMT_INDICATOR_NTS}};
|
||||||
|
int rc;
|
||||||
|
MYSQL_BIND bind[5];
|
||||||
|
MYSQL_RES *res;
|
||||||
|
MYSQL_STMT *stmt= mysql_stmt_init(mysql);
|
||||||
|
size_t row_size= sizeof(struct st_bulk4);
|
||||||
|
int array_size= 3;
|
||||||
|
unsigned long server_version= mysql_get_server_version(mysql);
|
||||||
|
unsigned long lengths[3]= {-1, -1, -1};
|
||||||
|
|
||||||
|
if (!bulk_enabled)
|
||||||
|
return SKIP;
|
||||||
|
|
||||||
|
if (server_version > 100300 &&
|
||||||
|
server_version < 100305)
|
||||||
|
return SKIP;
|
||||||
|
|
||||||
|
rc= mysql_query(mysql, "DROP TABLE IF EXISTS bulk_null");
|
||||||
|
check_mysql_rc(rc,mysql);
|
||||||
|
rc= mysql_query(mysql, "CREATE TABLE bulk_null "
|
||||||
|
"(s varchar(20), "
|
||||||
|
" i int, "
|
||||||
|
" d double, "
|
||||||
|
" t time, "
|
||||||
|
" c decimal(3,1))");
|
||||||
|
check_mysql_rc(rc,mysql);
|
||||||
|
|
||||||
|
rc= mysql_stmt_prepare(stmt, "INSERT INTO bulk_null VALUES (?,?,?,?,?)", -1);
|
||||||
|
check_stmt_rc(rc, stmt);
|
||||||
|
|
||||||
|
memset(bind, 0, sizeof(MYSQL_BIND)*2);
|
||||||
|
|
||||||
|
rc= mysql_stmt_attr_set(stmt, STMT_ATTR_ARRAY_SIZE, &array_size);
|
||||||
|
check_stmt_rc(rc, stmt);
|
||||||
|
rc= mysql_stmt_attr_set(stmt, STMT_ATTR_ROW_SIZE, &row_size);
|
||||||
|
check_stmt_rc(rc, stmt);
|
||||||
|
|
||||||
|
bind[0].buffer_type= MYSQL_TYPE_STRING;
|
||||||
|
bind[0].u.indicator= &val[0].indicator1;
|
||||||
|
bind[0].buffer= &val[0].char_value;
|
||||||
|
bind[0].length= lengths;
|
||||||
|
bind[1].buffer_type= MYSQL_TYPE_LONG;
|
||||||
|
bind[1].buffer= &val[0].int_value;
|
||||||
|
bind[1].u.indicator= &val[0].indicator2;
|
||||||
|
bind[2].buffer_type= MYSQL_TYPE_DOUBLE;
|
||||||
|
bind[2].buffer= &val[0].double_value;
|
||||||
|
bind[2].u.indicator= &val[0].indicator3;
|
||||||
|
bind[3].buffer_type= MYSQL_TYPE_STRING;
|
||||||
|
bind[3].u.indicator= &val[0].indicator4;
|
||||||
|
bind[3].buffer= &val[0].time_value;
|
||||||
|
bind[3].length= lengths;
|
||||||
|
bind[4].buffer_type= MYSQL_TYPE_NEWDECIMAL;
|
||||||
|
bind[4].u.indicator= &val[0].indicator5;
|
||||||
|
bind[4].buffer= &val[0].decimal_value;
|
||||||
|
bind[4].length= lengths;
|
||||||
|
|
||||||
|
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 bulk_null WHERE s='3'");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
res= mysql_store_result(mysql);
|
||||||
|
rc= (int)mysql_num_rows(res);
|
||||||
|
mysql_free_result(res);
|
||||||
|
FAIL_IF(rc != 2, "expected 2 rows");
|
||||||
|
|
||||||
|
rc= mysql_query(mysql, "SELECT * FROM bulk_null WHERE i=3");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
res= mysql_store_result(mysql);
|
||||||
|
rc= (int)mysql_num_rows(res);
|
||||||
|
mysql_free_result(res);
|
||||||
|
FAIL_IF(rc != 2, "expected 2 rows");
|
||||||
|
|
||||||
|
rc= mysql_query(mysql, "SELECT * FROM bulk_null WHERE d=3.0");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
res= mysql_store_result(mysql);
|
||||||
|
rc= (int)mysql_num_rows(res);
|
||||||
|
mysql_free_result(res);
|
||||||
|
FAIL_IF(rc != 2, "expected 2 rows");
|
||||||
|
|
||||||
|
rc= mysql_query(mysql, "SELECT * FROM bulk_null WHERE t='00:00:00'");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
res= mysql_store_result(mysql);
|
||||||
|
rc= (int)mysql_num_rows(res);
|
||||||
|
mysql_free_result(res);
|
||||||
|
FAIL_IF(rc != 2, "expected 2 rows");
|
||||||
|
|
||||||
|
rc= mysql_query(mysql, "SELECT * FROM bulk_null WHERE c=3.0");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
res= mysql_store_result(mysql);
|
||||||
|
rc= (int)mysql_num_rows(res);
|
||||||
|
mysql_free_result(res);
|
||||||
|
FAIL_IF(rc != 2, "expected 2 rows");
|
||||||
|
|
||||||
|
rc= mysql_query(mysql, "DROP TABLE bulk_null");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
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},
|
||||||
|
{"bulk_null_null", bulk_null_null, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
||||||
{"test_char_conv1", test_char_conv1, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
{"test_char_conv1", test_char_conv1, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
||||||
{"test_char_conv2", test_char_conv2, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
{"test_char_conv2", test_char_conv2, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
||||||
{"test_conc243", test_conc243, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
{"test_conc243", test_conc243, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
@@ -870,7 +1003,6 @@ struct my_tests_st my_tests[] = {
|
|||||||
{NULL, NULL, 0, 0, NULL, NULL}
|
{NULL, NULL, 0, 0, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
if (argc > 1)
|
if (argc > 1)
|
||||||
|
Reference in New Issue
Block a user