diff options
author | unknown <konstantin@mysql.com> | 2005-05-16 18:27:21 +0400 |
---|---|---|
committer | unknown <konstantin@mysql.com> | 2005-05-16 18:27:21 +0400 |
commit | 1bb1bc69935a234fcb72088e1065712ac59f475b (patch) | |
tree | e6dfafb73cbb2de3614c02947064cf7fc10404ab /tests | |
parent | 6f4c2486439dfcbaab7e1686860385282562d442 (diff) | |
download | mariadb-git-1bb1bc69935a234fcb72088e1065712ac59f475b.tar.gz |
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.
include/errmsg.h:
Add a new error code for "Not implemented" client-side error message.
include/mysql.h:
Add a statement attribute STMT_ATTR_PREFETCH_ROWS - unsigned long
number of rows to fetch per one COM_FETCH command, used when there
is a read-only cursor.
Note, that we don't break compatibility by adding this new member
because MYSQL_STMT is always allocated inside the client library by
mysql_stmt_init.
libmysql/errmsg.c:
Text for the error message CR_NOT_IMPLEMENTED
libmysql/libmysql.c:
Implement support for STMT_ATTR_PREFETCH_ROWS
Return an error message on attempt to set an attribute of a prepared
statement which is not implemented yet. We probably should be doing
it in the server: currently the server just ignores unknown attributes.
tests/mysql_client_test.c:
A test case for Bug#9643 "CURSOR_TYPE_SCROLLABLE dos not work"
- check that an error message is returned for CURSOR_TYPE_SCROLLABLE.
Additionally, check setting of STMT_ATTR_PREFETCH_ROWS.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/mysql_client_test.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index da57fbabaf2..5d647a2f693 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -13076,6 +13076,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 } }; |