summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authormonty@mysql.com <>2005-04-30 09:37:07 +0300
committermonty@mysql.com <>2005-04-30 09:37:07 +0300
commite16985ba15e6552324855e20661acd5841c16910 (patch)
tree4b0e9327011970dae1ac5bb2c57b1881fe289695 /tests
parentc0e8a8d6251eac0bad2201004ea9f542bfef5f4f (diff)
parent6040b0abf64ea66f9394b038eba18f4a33d26e42 (diff)
downloadmariadb-git-e16985ba15e6552324855e20661acd5841c16910.tar.gz
Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/home/my/mysql-5.0
Diffstat (limited to 'tests')
-rw-r--r--tests/mysql_client_test.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index 309f7573151..d484c9af7ee 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -12855,6 +12855,59 @@ static void test_bug9159()
myquery(rc);
}
+
+/* Crash when opening a cursor to a query with DISTICNT and no key */
+
+static void test_bug9520()
+{
+ MYSQL_STMT *stmt;
+ MYSQL_BIND bind[1];
+ char a[6];
+ ulong a_len;
+ int rc, row_count= 0;
+
+ myheader("test_bug9520");
+
+ mysql_query(mysql, "drop table if exists t1");
+ mysql_query(mysql, "create table t1 (a char(5), b char(5), c char(5),"
+ " primary key (a, b, c))");
+ rc= mysql_query(mysql, "insert into t1 values ('x', 'y', 'z'), "
+ " ('a', 'b', 'c'), ('k', 'l', 'm')");
+ myquery(rc);
+
+ stmt= open_cursor("select distinct b from t1");
+
+ /*
+ Not crashes with:
+ stmt= open_cursor("select distinct a from t1");
+ */
+
+ rc= mysql_stmt_execute(stmt);
+ check_execute(stmt, rc);
+
+ bzero(bind, sizeof(bind));
+ bind[0].buffer_type= MYSQL_TYPE_STRING;
+ bind[0].buffer= (char*) a;
+ bind[0].buffer_length= sizeof(a);
+ bind[0].length= &a_len;
+
+ mysql_stmt_bind_result(stmt, bind);
+
+ while (!(rc= mysql_stmt_fetch(stmt)))
+ row_count++;
+
+ DIE_UNLESS(rc == MYSQL_NO_DATA);
+
+ printf("Fetched %d rows\n", row_count);
+ DBUG_ASSERT(row_count == 3);
+
+ mysql_stmt_close(stmt);
+
+ rc= mysql_query(mysql, "drop table t1");
+ myquery(rc);
+}
+
+
/*
Read and parse arguments and MySQL options from my.cnf
*/
@@ -13080,6 +13133,7 @@ static struct my_tests_st my_tests[]= {
{ "test_bug8722", test_bug8722 },
{ "test_bug8880", test_bug8880 },
{ "test_bug9159", test_bug9159 },
+ { "test_bug9520", test_bug9520 },
{ 0, 0 }
};