1 /*
2 Copyright (c) 2016 MariaDB Corporation AB
3 
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published
6 by the Free Software Foundation; version 2 of the License.
7 
8 This program is distributed in the hope that it will be useful, but
9 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 for more details.
12 
13 You should have received a copy of the GNU General Public License along
14 with this program; if not, write to the Free Software Foundation, Inc.,
15 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
16 */
17 
18 
19 /**
20   Some basic tests of the client API.
21 */
22 
23 #include "my_test.h"
24 #include "ma_common.h"
25 
perf1(MYSQL * mysql)26 static int perf1(MYSQL *mysql)
27 {
28   int rc;
29   MYSQL_STMT *stmt;
30   const char *stmtstr= "SELECT s.emp_no, s.salary, e.emp_no, e.first_name, e.last_name, e.gender FROM salaries s, employees e WHERE s.emp_no = e.emp_no";
31 
32   rc= mysql_select_db(mysql, "employees");
33   if (rc)
34   {
35     diag("Employees database not installed");
36     return SKIP;
37   }
38 
39   stmt= mysql_stmt_init(mysql);
40 
41   diag("prepare");
42   rc= mysql_stmt_prepare(stmt, SL(stmtstr));
43   check_stmt_rc(rc, stmt);
44 
45   diag("execute");
46   rc= mysql_stmt_execute(stmt);
47   check_stmt_rc(rc, stmt);
48 
49   diag("store");
50   rc= mysql_stmt_store_result(stmt);
51   check_stmt_rc(rc, stmt);
52 
53   diag("fetch");
54   while (!mysql_stmt_fetch(stmt));
55 
56   mysql_stmt_close(stmt);
57   return OK;
58 }
59 
60 struct my_tests_st my_tests[] = {
61   {"perf1", perf1, TEST_CONNECTION_NEW, 0,  NULL,  NULL},
62   {NULL, NULL, 0, 0, NULL, NULL}
63 };
64 
65 
main(int argc,char ** argv)66 int main(int argc, char **argv)
67 {
68   if (argc > 1)
69     get_options(argc, argv);
70 
71   get_envvars();
72 
73   run_tests(my_tests);
74 
75   return(exit_status());
76 }
77