diff options
author | unknown <andrey@lmy004.> | 2005-08-27 09:09:54 +0200 |
---|---|---|
committer | unknown <andrey@lmy004.> | 2005-08-27 09:09:54 +0200 |
commit | 5e938cfd2d22157bb8f3f65e3fefef778b19984f (patch) | |
tree | 5c0a71c0348bc34d744b3e390cf6b7b7088df41d /tests | |
parent | ef055c333d22416061d24059e276eb6c6f8ea79e (diff) | |
parent | 6d74f5b0e4c529830c6589eb0871428ebbba20b9 (diff) | |
download | mariadb-git-5e938cfd2d22157bb8f3f65e3fefef778b19984f.tar.gz |
Merge ahristov@bk-internal.mysql.com:/home/bk/mysql-5.0
into lmy004.:/work/mysql-5.0-bug11904
sql/sql_select.cc:
Auto merged
tests/mysql_client_test.c:
Auto merged
Diffstat (limited to 'tests')
-rw-r--r-- | tests/mysql_client_test.c | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 4f1e6a72b91..4bf03938f03 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -14179,6 +14179,81 @@ static void test_bug11901() myquery(rc); } +/* Bug#11904: mysql_stmt_attr_set CURSOR_TYPE_READ_ONLY grouping wrong result */ + +static void test_bug11904() +{ + MYSQL_STMT *stmt1; + int rc; + const char *stmt_text; + const ulong type= (ulong)CURSOR_TYPE_READ_ONLY; + MYSQL_BIND bind[2]; + int country_id=0; + char row_data[11]= {0}; + + myheader("test_bug11904"); + + /* create tables */ + rc= mysql_query(mysql, "DROP TABLE IF EXISTS bug11904b"); + myquery(rc); + rc= mysql_query(mysql, "CREATE TABLE bug11904b (id int, name char(10), primary key(id, name))"); + myquery(rc); + + rc= mysql_query(mysql, "INSERT INTO bug11904b VALUES (1, 'sofia'), (1,'plovdiv')," + " (1,'varna'), (2,'LA'), (2,'new york'), (3,'heidelberg')," + " (3,'berlin'), (3, 'frankfurt')"); + + myquery(rc); + mysql_commit(mysql); + /* create statement */ + stmt1= mysql_stmt_init(mysql); + mysql_stmt_attr_set(stmt1, STMT_ATTR_CURSOR_TYPE, (const void*) &type); + + stmt_text= "SELECT id, MIN(name) FROM bug11904b GROUP BY id"; + + rc= mysql_stmt_prepare(stmt1, stmt_text, strlen(stmt_text)); + check_execute(stmt1, rc); + + memset(bind, 0, sizeof(bind)); + bind[0].buffer_type= MYSQL_TYPE_LONG; + bind[0].buffer=& country_id; + bind[0].buffer_length= 0; + bind[0].length= 0; + + bind[1].buffer_type= MYSQL_TYPE_STRING; + bind[1].buffer=& row_data; + bind[1].buffer_length= sizeof(row_data) - 1; + bind[1].length= 0; + + rc= mysql_stmt_bind_result(stmt1, bind); + check_execute(stmt1, rc); + + rc= mysql_stmt_execute(stmt1); + check_execute(stmt1, rc); + + rc= mysql_stmt_fetch(stmt1); + check_execute(stmt1, rc); + DIE_UNLESS(country_id == 1); + DIE_UNLESS(memcmp(row_data, "plovdiv", 7) == 0); + + rc= mysql_stmt_fetch(stmt1); + check_execute(stmt1, rc); + DIE_UNLESS(country_id == 2); + DIE_UNLESS(memcmp(row_data, "LA", 2) == 0); + + rc= mysql_stmt_fetch(stmt1); + check_execute(stmt1, rc); + DIE_UNLESS(country_id == 3); + DIE_UNLESS(memcmp(row_data, "berlin", 6) == 0); + + rc= mysql_stmt_close(stmt1); + check_execute(stmt1, rc); + + rc= mysql_query(mysql, "drop table bug11904b"); + myquery(rc); +} + + /* Bug#12243: multiple cursors, crash in a fetch after commit. */ static void test_bug12243() @@ -14522,6 +14597,7 @@ static struct my_tests_st my_tests[]= { { "test_bug11718", test_bug11718 }, { "test_bug11909", test_bug11909 }, { "test_bug11901", test_bug11901 }, + { "test_bug11904", test_bug11904 }, { "test_bug12243", test_bug12243 }, { 0, 0 } }; |