diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2018-04-23 12:09:10 +0200 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2018-04-25 08:23:28 +0200 |
commit | 43c5dd02509267c003afe6379161e356dbecad17 (patch) | |
tree | f4ccd8bd2e5b33b27d39925868dca4badb3b38ee /tests | |
parent | 9477a2a9ba17c0db362e2bb39d5048e369096f39 (diff) | |
download | mariadb-git-43c5dd02509267c003afe6379161e356dbecad17.tar.gz |
MDEV-15079: Parameter array operation inserts wrong values in autoincrement field if indicator was specified
test added (bug is fixed)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/mysql_client_test.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 5a275c8fcbf..97ffa5bc8ac 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -20236,6 +20236,59 @@ static void test_proxy_header() test_proxy_header_ignore(); } + +static void test_bulk_autoinc() +{ + int rc; + MYSQL_STMT *stmt; + MYSQL_BIND bind[1]; + MYSQL_ROW row; + char indicator[]= {0, STMT_INDICATOR_NULL, 0/*STMT_INDICATOR_IGNORE*/}; + my_bool error[1]; + int i, id[]= {2, 3, 777}, count= sizeof(id)/sizeof(id[0]); + MYSQL_RES *result; + + rc= mysql_query(mysql, "DROP TABLE IF EXISTS ai_field_value"); + myquery(rc); + rc= mysql_query(mysql, "CREATE TABLE ai_field_value (id int not null primary key auto_increment)"); + myquery(rc); + stmt= mysql_stmt_init(mysql); + rc= mysql_stmt_prepare(stmt, "INSERT INTO ai_field_value(id) values(?)", -1); + check_execute(stmt, rc); + + memset(bind, 0, sizeof(bind)); + bind[0].buffer_type = MYSQL_TYPE_LONG; + bind[0].buffer = (void *)id; + bind[0].buffer_length = 0; + bind[0].is_null = NULL; + bind[0].length = NULL; + bind[0].error = error; + bind[0].u.indicator= indicator; + + mysql_stmt_attr_set(stmt, STMT_ATTR_ARRAY_SIZE, (void*)&count); + rc= mysql_stmt_bind_param(stmt, bind); + check_execute(stmt, rc); + + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + + mysql_stmt_close(stmt); + + rc= mysql_query(mysql, "SELECT id FROM ai_field_value"); + myquery(rc); + + result= mysql_store_result(mysql); + mytest(result); + + i= 0; + while ((row= mysql_fetch_row(result))) + { + DIE_IF(atoi(row[0]) != id[i++]); + } + rc= mysql_query(mysql, "DROP TABLE ai_field_value"); + myquery(rc); +} + #endif static struct my_tests_st my_tests[]= { @@ -20523,6 +20576,7 @@ static struct my_tests_st my_tests[]= { { "test_mdev14454", test_mdev14454 }, #ifndef EMBEDDED_LIBRARY { "test_proxy_header", test_proxy_header}, + { "test_bulk_autoinc", test_bulk_autoinc}, #endif { 0, 0 } }; |