[Commits] bf34851c549: MDEV-15079: Parameter array operation inserts wrong values in autoincrement field if indicator was specified

Oleksandr Byelkin sanja at mariadb.com
Mon Apr 23 13:09:10 EEST 2018


revision-id: bf34851c549859551549baee2e3e93abef3c39fb (mariadb-10.3.6-36-gbf34851c549)
parent(s): c6ba758d1d41c11466b8f9b61b4546efc95aa689
author: Oleksandr Byelkin
committer: Oleksandr Byelkin
timestamp: 2018-04-23 12:09:10 +0200
message:

MDEV-15079: Parameter array operation inserts wrong values in autoincrement field if indicator was specified

test added (bug is fixed)

---
 tests/mysql_client_test.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index 5a275c8fcbf..3188ea882bb 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -20227,6 +20227,59 @@ static void 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);
+}
+
+
 static void test_proxy_header()
 {
   test_proxy_header_tcp("192.0.2.1",3333);
@@ -20524,6 +20577,7 @@ static struct my_tests_st my_tests[]= {
 #ifndef EMBEDDED_LIBRARY
   { "test_proxy_header", test_proxy_header},
 #endif
+  { "test_bulk_autoinc", test_bulk_autoinc},
   { 0, 0 }
 };
 


More information about the commits mailing list