diff options
author | Sergei Golubchik <sergii@pisem.net> | 2013-06-12 22:12:09 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2013-06-12 22:12:09 +0200 |
commit | 1098184c47674481a397af86054fb3fb15a89b77 (patch) | |
tree | 41ac3aed47091b28a616e356ceb73640613f0032 /tests | |
parent | c40b7694d0dbb0781ee7578b5a44f412ce8dae64 (diff) | |
download | mariadb-git-1098184c47674481a397af86054fb3fb15a89b77.tar.gz |
MDEV-4604 Wrong server status when sending out parameters
reset SERVER_MORE_RESULTS_EXISTS *after* sending the OUT packet to the client.
the next packet will be the last one.
patch by Georg Richter.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/mysql_client_test.c | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 57fde42a92e..7ec91636d26 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -18775,6 +18775,76 @@ static void test_bug11754979() DBUG_VOID_RETURN; } +static void test_ps_sp_out_params() +{ + MYSQL *my; + MYSQL_STMT *stmt; + MYSQL_BIND bind[1]; + char buffer[20]; + int status, rc; + + myheader("test_ps_sp_out_params"); + my= mysql_client_init(NULL); + + if (!mysql_real_connect(my, opt_host, opt_user, + opt_password, current_db, opt_port, + opt_unix_socket, CLIENT_MULTI_RESULTS)) + DIE("mysql_real_connect failed"); + + rc= mysql_query(my, "DROP PROCEDURE IF EXISTS p1"); + myquery(rc); + + rc= mysql_query(my, + "CREATE PROCEDURE p1(OUT out_param VARCHAR(19)) " + "BEGIN" + " SELECT 'foo' FROM DUAL;" + " SET out_param='foo';" + " SELECT 'foo' FROM DUAL;" + "END"); + myquery(rc); + + stmt= mysql_stmt_init(my); + + rc= mysql_stmt_prepare(stmt, "CALL P1(?)", 10); + DIE_UNLESS(rc==0); + + DIE_UNLESS(mysql_stmt_param_count(stmt) == 1); + + memset(bind, 0, sizeof(MYSQL_BIND)); + bind[0].buffer= buffer; + bind[0].buffer_length= sizeof(buffer); + bind[0].buffer_type= MYSQL_TYPE_STRING; + + mysql_stmt_bind_param(stmt, bind); + + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + + do { + if (mysql_stmt_field_count(stmt)) + { + /* since server sends a status packet at the end, + there must follow at least one additional packet */ + DIE_UNLESS(mysql_more_results(stmt->mysql)); + + mysql_stmt_bind_result(stmt, bind); + + rc= mysql_stmt_fetch(stmt); + DIE_UNLESS(rc== 0); + + DIE_UNLESS(strcmp(buffer, "foo") == 0); + } + status= mysql_stmt_next_result(stmt); + } while (status == 0); + + rc= mysql_stmt_reset(stmt); + DIE_UNLESS(rc== 0); + + mysql_stmt_close(stmt); + mysql_close(my); + + printf("end\n"); +} /* Bug#13001491: MYSQL_REFRESH CRASHES WHEN STORED ROUTINES ARE RUN CONCURRENTLY. @@ -19224,6 +19294,7 @@ static struct my_tests_st my_tests[]= { { "test_bug11754979", test_bug11754979 }, { "test_bug13001491", test_bug13001491 }, { "test_mdev4326", test_mdev4326 }, + { "test_ps_sp_out_params", test_ps_sp_out_params }, { 0, 0 } }; |