Skip to content
This repository has been archived by the owner on May 8, 2019. It is now read-only.

Commit

Permalink
Added test for MDEV-15133
Browse files Browse the repository at this point in the history
  • Loading branch information
9EOR9 committed Feb 16, 2018
1 parent eefaadf commit da9ed3c
Showing 1 changed file with 133 additions and 1 deletion.
134 changes: 133 additions & 1 deletion unittest/libmariadb/bulk1.c
Original file line number Diff line number Diff line change
Expand Up @@ -853,8 +853,141 @@ static int bulk_skip_row(MYSQL *mysql)
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[] = {
{"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_conv2", test_char_conv2, TEST_CONNECTION_NEW, 0, NULL, NULL},
{"test_conc243", test_conc243, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
Expand All @@ -870,7 +1003,6 @@ struct my_tests_st my_tests[] = {
{NULL, NULL, 0, 0, NULL, NULL}
};


int main(int argc, char **argv)
{
if (argc > 1)
Expand Down

0 comments on commit da9ed3c

Please sign in to comment.