1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

A fix and a test case for Bug#9643 " CURSOR_TYPE_SCROLLABLE dos not work"

- check on the client the unsupported feature and return 
an error message if it's been requested.
Additionally added API support for STMT_ATTR_PREFETCH_ROWS.
Post-review fixes.
This commit is contained in:
konstantin@mysql.com
2005-05-16 18:27:21 +04:00
parent 9c6ba43eb1
commit 38d68559bf
5 changed files with 108 additions and 9 deletions

View File

@ -13075,6 +13075,68 @@ static void test_bug9478()
}
/*
Error message is returned for unsupported features.
Test also cursors with non-default PREFETCH_ROWS
*/
static void test_bug9643()
{
MYSQL_STMT *stmt;
MYSQL_BIND bind[1];
int32 a;
int rc;
const char *stmt_text;
int num_rows= 0;
ulong type;
ulong prefetch_rows= 5;
myheader("test_bug9643");
mysql_query(mysql, "drop table if exists t1");
mysql_query(mysql, "create table t1 (id integer not null primary key)");
rc= mysql_query(mysql, "insert into t1 (id) values "
" (1), (2), (3), (4), (5), (6), (7), (8), (9)");
myquery(rc);
stmt= mysql_stmt_init(mysql);
/* Not implemented in 5.0 */
type= (ulong) CURSOR_TYPE_SCROLLABLE;
rc= mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (void*) &type);
DIE_UNLESS(rc);
if (! opt_silent)
printf("Got error (as expected): %s\n", mysql_stmt_error(stmt));
type= (ulong) CURSOR_TYPE_READ_ONLY;
rc= mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (void*) &type);
check_execute(stmt, rc);
rc= mysql_stmt_attr_set(stmt, STMT_ATTR_PREFETCH_ROWS,
(void*) &prefetch_rows);
check_execute(stmt, rc);
stmt_text= "select * 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_LONG;
bind[0].buffer= (void*) &a;
bind[0].buffer_length= sizeof(a);
mysql_stmt_bind_result(stmt, bind);
rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc);
while ((rc= mysql_stmt_fetch(stmt)) == 0)
++num_rows;
DIE_UNLESS(num_rows == 9);
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
*/
@ -13306,6 +13368,7 @@ static struct my_tests_st my_tests[]= {
{ "test_bug9159", test_bug9159 },
{ "test_bug9520", test_bug9520 },
{ "test_bug9478", test_bug9478 },
{ "test_bug9643", test_bug9643 },
{ 0, 0 }
};