summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2010-11-23 23:39:59 +0200
committerMichael Widenius <monty@askmonty.org>2010-11-23 23:39:59 +0200
commitb52020221e8b4e58d1bc6dd5a5a6f065a6a3a083 (patch)
tree6068b9d90b4127b1c3608e29913fa82bf1a1f20e /tests
parent7840965db9460e2117c163f3db83aaa247c65203 (diff)
parent498ee6bd19eabc85dcbd9abebc9cf6aeb79d1985 (diff)
downloadmariadb-git-b52020221e8b4e58d1bc6dd5a5a6f065a6a3a083.tar.gz
Merge with MySQL 5.1.52
Diffstat (limited to 'tests')
-rw-r--r--tests/mysql_client_test.c102
1 files changed, 102 insertions, 0 deletions
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index 0b8781210e5..b1b10225940 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -18340,6 +18340,107 @@ static void test_bug54041()
}
+/**
+ Bug#47485: mysql_store_result returns a result set for a prepared statement
+*/
+static void test_bug47485()
+{
+ MYSQL_STMT *stmt;
+ MYSQL_RES *res;
+ MYSQL_BIND bind[2];
+ int rc;
+ const char* sql_select = "SELECT 1, 'a'";
+ int int_data;
+ char str_data[16];
+ my_bool is_null[2];
+ my_bool error[2];
+ unsigned long length[2];
+
+ DBUG_ENTER("test_bug47485");
+ myheader("test_bug47485");
+
+ stmt= mysql_stmt_init(mysql);
+ check_stmt(stmt);
+ rc= mysql_stmt_prepare(stmt, sql_select, strlen(sql_select));
+ check_execute(stmt, rc);
+
+ rc= mysql_stmt_execute(stmt);
+ check_execute(stmt, rc);
+
+ res = mysql_store_result(mysql);
+ DIE_UNLESS(res == NULL);
+
+ mysql_stmt_reset(stmt);
+
+ rc= mysql_stmt_execute(stmt);
+ check_execute(stmt, rc);
+
+ res = mysql_use_result(mysql);
+ DIE_UNLESS(res == NULL);
+
+ mysql_stmt_reset(stmt);
+
+ memset(bind, 0, sizeof(bind));
+ bind[0].buffer_type= MYSQL_TYPE_LONG;
+ bind[0].buffer= (char *)&int_data;
+ bind[0].is_null= &is_null[0];
+ bind[0].length= &length[0];
+ bind[0].error= &error[0];
+
+ bind[1].buffer_type= MYSQL_TYPE_STRING;
+ bind[1].buffer= (char *)str_data;
+ bind[1].buffer_length= sizeof(str_data);
+ bind[1].is_null= &is_null[1];
+ bind[1].length= &length[1];
+ bind[1].error= &error[1];
+
+ rc= mysql_stmt_bind_result(stmt, bind);
+ check_execute(stmt, rc);
+
+ rc= mysql_stmt_execute(stmt);
+ check_execute(stmt, rc);
+
+ rc= mysql_stmt_store_result(stmt);
+ check_execute(stmt, rc);
+
+ while (!(rc= mysql_stmt_fetch(stmt)))
+ ;
+
+ DIE_UNLESS(rc == MYSQL_NO_DATA);
+
+ mysql_stmt_reset(stmt);
+
+ memset(bind, 0, sizeof(bind));
+ bind[0].buffer_type= MYSQL_TYPE_LONG;
+ bind[0].buffer= (char *)&int_data;
+ bind[0].is_null= &is_null[0];
+ bind[0].length= &length[0];
+ bind[0].error= &error[0];
+
+ bind[1].buffer_type= MYSQL_TYPE_STRING;
+ bind[1].buffer= (char *)str_data;
+ bind[1].buffer_length= sizeof(str_data);
+ bind[1].is_null= &is_null[1];
+ bind[1].length= &length[1];
+ bind[1].error= &error[1];
+
+ rc= mysql_stmt_bind_result(stmt, bind);
+ check_execute(stmt, rc);
+
+ rc= mysql_stmt_execute(stmt);
+ check_execute(stmt, rc);
+
+ while (!(rc= mysql_stmt_fetch(stmt)))
+ ;
+
+ DIE_UNLESS(rc == MYSQL_NO_DATA);
+
+ mysql_stmt_close(stmt);
+
+ DBUG_VOID_RETURN;
+}
+
+
/*
Read and parse arguments and MySQL options from my.cnf
*/
@@ -18663,6 +18764,7 @@ static struct my_tests_st my_tests[]= {
{ "test_bug44495", test_bug44495 },
{ "test_bug42373", test_bug42373 },
{ "test_bug54041", test_bug54041 },
+ { "test_bug47485", test_bug47485 },
{ 0, 0 }
};