forked from hholzgra/connector-c-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mysql_dump_debug_info.c
63 lines (50 loc) · 1.84 KB
/
mysql_dump_debug_info.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* Copyright (C) 2005, 2006 Hartmut Holzgraefe
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* MySQL C client API example: mysql_dump_debug_info()
*
* see also http://mysql.com/mysql_dump_debug_info
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <mysql.h>
int main(int argc, char **argv)
{
MYSQL *mysql = NULL;
mysql = mysql_init(mysql);
if (!mysql) {
puts("Init faild, out of memory?");
return EXIT_FAILURE;
}
if (!mysql_real_connect(mysql, /* MYSQL structure to use */
MYSQL_HOST, /* server hostname or IP address */
MYSQL_USER, /* mysql user */
MYSQL_PWD, /* password */
NULL, /* default database to use, NULL for none */
0, /* port number, 0 for default */
NULL, /* socket file or named pipe name */
CLIENT_FOUND_ROWS /* connection flags */ )) {
puts("Connect failed\n");
} else {
if (mysql_dump_debug_info(mysql)) {
printf("Debug dump error: %s\n", mysql_error(mysql));
} else {
puts("Debug Dump OK, check server error log for output\n");
}
}
mysql_close(mysql);
return EXIT_SUCCESS;
}