1 | /* |
2 | Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. |
3 | |
4 | The MySQL Connector/C is licensed under the terms of the GPLv2 |
5 | <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most |
6 | MySQL Connectors. There are special exceptions to the terms and |
7 | conditions of the GPLv2 as it is applied to this software, see the |
8 | FLOSS License Exception |
9 | <http://www.mysql.com/about/legal/licensing/foss-exception.html>. |
10 | |
11 | This program is free software; you can redistribute it and/or modify |
12 | it under the terms of the GNU General Public License as published |
13 | by the Free Software Foundation; version 2 of the License. |
14 | |
15 | This program is distributed in the hope that it will be useful, but |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
18 | for more details. |
19 | |
20 | You should have received a copy of the GNU General Public License along |
21 | with this program; if not, write to the Free Software Foundation, Inc., |
22 | 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
23 | */ |
24 | #include "my_test.h" |
25 | |
26 | /* Bug#15752 "Lost connection to MySQL server when calling a SP from C API" */ |
27 | |
28 | static int test_bug15752(MYSQL *mysql) |
29 | { |
30 | int rc, i; |
31 | const int ITERATION_COUNT= 100; |
32 | const char *query= "CALL p1()" ; |
33 | |
34 | |
35 | rc= mysql_query(mysql, "drop procedure if exists p1" ); |
36 | check_mysql_rc(rc, mysql); |
37 | rc= mysql_query(mysql, "create procedure p1() select 1" ); |
38 | check_mysql_rc(rc, mysql); |
39 | |
40 | rc= mysql_real_query(mysql, SL(query)); |
41 | check_mysql_rc(rc, mysql); |
42 | mysql_free_result(mysql_store_result(mysql)); |
43 | |
44 | rc= mysql_real_query(mysql, SL(query)); |
45 | FAIL_UNLESS(rc && mysql_errno(mysql) == CR_COMMANDS_OUT_OF_SYNC, "Error expected" ); |
46 | |
47 | rc= mysql_next_result(mysql); |
48 | check_mysql_rc(rc, mysql); |
49 | |
50 | mysql_free_result(mysql_store_result(mysql)); |
51 | |
52 | rc= mysql_next_result(mysql); |
53 | FAIL_IF(rc != -1, "rc != -1" ); |
54 | |
55 | for (i = 0; i < ITERATION_COUNT; i++) |
56 | { |
57 | rc= mysql_real_query(mysql, SL(query)); |
58 | check_mysql_rc(rc, mysql); |
59 | mysql_free_result(mysql_store_result(mysql)); |
60 | rc= mysql_next_result(mysql); |
61 | check_mysql_rc(rc, mysql); |
62 | mysql_free_result(mysql_store_result(mysql)); |
63 | rc= mysql_next_result(mysql); |
64 | FAIL_IF(rc != -1, "rc != -1" ); |
65 | |
66 | } |
67 | rc= mysql_query(mysql, "drop procedure p1" ); |
68 | check_mysql_rc(rc, mysql); |
69 | |
70 | return OK; |
71 | } |
72 | |
73 | |
74 | |
75 | |
76 | struct my_tests_st my_tests[] = { |
77 | {"test_bug15752" , test_bug15752, TEST_CONNECTION_NEW, 0, NULL , NULL}, |
78 | {NULL, NULL, 0, 0, NULL, NULL} |
79 | }; |
80 | |
81 | int main(int argc, char **argv) |
82 | { |
83 | if (argc > 1) |
84 | get_options(argc, argv); |
85 | |
86 | get_envvars(); |
87 | |
88 | run_tests(my_tests); |
89 | |
90 | return(exit_status()); |
91 | } |
92 | |