summaryrefslogtreecommitdiff
path: root/tests/mysql_client_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/mysql_client_test.c')
-rw-r--r--tests/mysql_client_test.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index 002076afd90..b6ca4996c70 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -13146,6 +13146,67 @@ static void test_bug9643()
}
/*
+ Check that proper cleanups are done for prepared statement when
+ fetching thorugh a cursor.
+*/
+
+static void test_bug10729()
+{
+ MYSQL_STMT *stmt;
+ MYSQL_BIND bind[1];
+ char a[21];
+ int rc;
+ const char *stmt_text;
+ int i= 0;
+ char *name_array[3]= { "aaa", "bbb", "ccc" };
+ ulong type;
+
+ myheader("test_bug10729");
+
+ mysql_query(mysql, "drop table if exists t1");
+ mysql_query(mysql, "create table t1 (id integer not null primary key,"
+ "name VARCHAR(20) NOT NULL)");
+ rc= mysql_query(mysql, "insert into t1 (id, name) values "
+ "(1, 'aaa'), (2, 'bbb'), (3, 'ccc')");
+ myquery(rc);
+
+ stmt= mysql_stmt_init(mysql);
+
+ type= (ulong) CURSOR_TYPE_READ_ONLY;
+ rc= mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (void*) &type);
+ check_execute(stmt, rc);
+ stmt_text= "select name from t1";
+ rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
+ check_execute(stmt, rc);
+
+ bzero(bind, sizeof(bind));
+ bind[0].buffer_type= MYSQL_TYPE_STRING;
+ bind[0].buffer= (void*) a;
+ bind[0].buffer_length= sizeof(a);
+ mysql_stmt_bind_result(stmt, bind);
+
+ for (i= 0; i < 3; i++)
+ {
+ int row_no= 0;
+ rc= mysql_stmt_execute(stmt);
+ check_execute(stmt, rc);
+ while ((rc= mysql_stmt_fetch(stmt)) == 0)
+ {
+ DIE_UNLESS(strcmp(a, name_array[row_no]) == 0);
+ if (!opt_silent)
+ printf("%d: %s\n", row_no, a);
+ ++row_no;
+ }
+ DIE_UNLESS(rc == MYSQL_NO_DATA);
+ }
+ rc= mysql_stmt_close(stmt);
+ DIE_UNLESS(rc == 0);
+
+ rc= mysql_query(mysql, "drop table t1");
+ myquery(rc);
+}
+
+/*
Read and parse arguments and MySQL options from my.cnf
*/
@@ -13377,6 +13438,7 @@ static struct my_tests_st my_tests[]= {
{ "test_bug9520", test_bug9520 },
{ "test_bug9478", test_bug9478 },
{ "test_bug9643", test_bug9643 },
+ { "test_bug10729", test_bug10729 },
{ 0, 0 }
};