diff options
author | konstantin@mysql.com <> | 2005-07-01 15:47:45 +0400 |
---|---|---|
committer | konstantin@mysql.com <> | 2005-07-01 15:47:45 +0400 |
commit | 0efa6f86be8e7e29be6a85d0935ffbae69df7057 (patch) | |
tree | e1393e450cf0ca1709997362f5ef64d6b49532d2 /tests | |
parent | ba2a0328d145f0527a6b7867a8379074e7b17ef7 (diff) | |
download | mariadb-git-0efa6f86be8e7e29be6a85d0935ffbae69df7057.tar.gz |
A fix and a test case for Bug#11172 "mysql_stmt_attr_set
CURSOR_TYPE_READ_ONLY date/datetime filter server crash".
The fix adds support for Item_change_list in cursors (proper rollback
of the modified item tree).
Diffstat (limited to 'tests')
-rw-r--r-- | tests/mysql_client_test.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index fa70168d0ef..e57d00e5a91 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -13477,6 +13477,74 @@ static void test_bug10794() } +/* Bug#11172: cursors, crash on a fetch from a datetime column */ + +static void test_bug11172() +{ + MYSQL_STMT *stmt; + MYSQL_BIND bind_in[1], bind_out[2]; + MYSQL_TIME hired; + int rc; + const char *stmt_text; + int i= 0, id; + ulong type; + + myheader("test_bug11172"); + + mysql_query(mysql, "drop table if exists t1"); + mysql_query(mysql, "create table t1 (id integer not null primary key," + "hired date not null)"); + rc= mysql_query(mysql, + "insert into t1 (id, hired) values (1, '1933-08-24'), " + "(2, '1965-01-01'), (3, '1949-08-17'), (4, '1945-07-07'), " + "(5, '1941-05-15'), (6, '1978-09-15'), (7, '1936-03-28')"); + myquery(rc); + stmt= mysql_stmt_init(mysql); + stmt_text= "SELECT id, hired FROM t1 WHERE hired=?"; + rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + check_execute(stmt, rc); + + type= (ulong) CURSOR_TYPE_READ_ONLY; + mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (const void*) &type); + + bzero(bind_in, sizeof(bind_in)); + bzero(bind_out, sizeof(bind_out)); + bzero(&hired, sizeof(hired)); + hired.year= 1965; + hired.month= 1; + hired.day= 1; + bind_in[0].buffer_type= MYSQL_TYPE_DATE; + bind_in[0].buffer= (void*) &hired; + bind_in[0].buffer_length= sizeof(hired); + bind_out[0].buffer_type= MYSQL_TYPE_LONG; + bind_out[0].buffer= (void*) &id; + bind_out[1]= bind_in[0]; + + for (i= 0; i < 3; i++) + { + rc= mysql_stmt_bind_param(stmt, bind_in); + check_execute(stmt, rc); + rc= mysql_stmt_bind_result(stmt, bind_out); + check_execute(stmt, rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + while ((rc= mysql_stmt_fetch(stmt)) == 0) + { + if (!opt_silent) + printf("fetched data %d:%d-%d-%d\n", id, + hired.year, hired.month, hired.day); + } + DIE_UNLESS(rc == MYSQL_NO_DATA); + mysql_stmt_free_result(stmt) || mysql_stmt_reset(stmt); + } + mysql_stmt_close(stmt); + mysql_rollback(mysql); + mysql_rollback(mysql); + + rc= mysql_query(mysql, "drop table t1"); + myquery(rc); +} + /* Read and parse arguments and MySQL options from my.cnf */ @@ -13714,6 +13782,7 @@ static struct my_tests_st my_tests[]= { { "test_bug9992", test_bug9992 }, { "test_bug10736", test_bug10736 }, { "test_bug10794", test_bug10794 }, + { "test_bug11172", test_bug11172 }, { 0, 0 } }; |