Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
mxq
Public
Notifications
You must be signed in to change notification settings
Fork
3
Star
3
Code
Issues
20
Pull requests
3
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
e6ed782
helper
manpages
mysql
web
.gitignore
.vimrc
Doxyfile
LICENSE
Makefile
README.md
keywordset.c
keywordset.h
mx_flock.c
mx_flock.h
mx_getopt.c
mx_getopt.h
mx_log.c
mx_log.h
mx_mysql.c
mx_mysql.h
mx_proc.c
mx_proc.h
mx_util.c
mx_util.h
mxq.h
mxq_daemon.c
mxq_daemon.h
mxq_group.c
mxq_group.h
mxq_job.c
mxq_job.h
mxq_log.c
mxq_reaper.c
mxqadmin.c
mxqd.c
mxqd.h
mxqd_control.c
mxqd_control.h
mxqdctl-hostconfig.sh
mxqdump.c
mxqkill.c
mxqps.c
mxqset.c
mxqsub.c
os-release
parser.y
ppidcache.c
ppidcache.h
test_keywordset.c
test_mx_log.c
test_mx_mysql.c
test_mx_util.c
test_mxqd_control.c
test_parser.c
xmalloc.h
Breadcrumbs
mxq
/
mx_mysql.h
Blame
Blame
Latest commit
History
History
152 lines (110 loc) · 4.9 KB
Breadcrumbs
mxq
/
mx_mysql.h
Top
File metadata and controls
Code
Blame
152 lines (110 loc) · 4.9 KB
Raw
#ifndef __MX_MYSQL_H__ #define __MX_MYSQL_H__ 1 #include <sys/resource.h> #include <mysql.h> #include "mx_util.h" #ifdef MX_NDEBUG_MYSQL # include <assert.h> # define mx_mysql_assert_return_minus_errno(test, eno) \ assert(test) # define mx_mysql_assert_return_NULL(test, eno) \ assert(test) #else # define mx_mysql_assert_return_minus_errno(test, eno) \ mx_assert_return_minus_errno(test, eno) # define mx_mysql_assert_return_NULL(test, eno) \ mx_assert_return_NULL(test, eno) #endif #define mx_mysql_assert_usage_ok(res) \ do { \ if ((res) < 0) { \ assert((res) == -errno); \ assert(errno != EINVAL); \ assert(errno != EBADF); \ assert(errno != EUCLEAN); \ } \ } while (0) struct mx_mysql { MYSQL *mysql; const char *func; char *default_file; char *default_group; bool reconnect; unsigned int saved_errno; const char *error; const char *sqlstate; }; struct mx_mysql_bind_data { char flags; char **string_ptr; unsigned long length; bool is_null; bool is_error; }; enum mx_mysql_bind_type { MX_MYSQL_BIND_TYPE_UNKNOWN, MX_MYSQL_BIND_TYPE_PARAM, MX_MYSQL_BIND_TYPE_RESULT }; struct mx_mysql_bind { enum mx_mysql_bind_type type; unsigned long count; MYSQL_BIND *bind; struct mx_mysql_bind_data *data; }; struct mx_mysql_stmt { struct mx_mysql *mysql; char *statement; MYSQL_STMT *stmt; const char *func; unsigned long field_count; unsigned long param_count; struct mx_mysql_bind result; struct mx_mysql_bind param; }; #ifndef MX_MYSQL_FAIL_WAIT_DEFAULT # ifdef MX_CALLOC_FAIL_WAIT_DEFAULT # define MX_MYSQL_FAIL_WAIT_DEFAULT MX_CALLOC_FAIL_WAIT_DEFAULT # else # define MX_MYSQL_FAIL_WAIT_DEFAULT 5 # endif #endif #define mx_mysql_bind_var(b, i, t, p) mx_mysql_bind_##t((b), (i), (p)) #define mx_mysql_statement_param_bind(s, i, t, p) mx_mysql_bind_var(&((s)->param), (i), t, (p)) #define mx_mysql_statement_result_bind(s, i, t, p) mx_mysql_bind_var(&((s)->result), (i), t, (p)) int mx_mysql_initialize(struct mx_mysql **mysql); int mx_mysql_option_set_default_file(struct mx_mysql *mysql, char *fname); int mx_mysql_option_set_default_group(struct mx_mysql *mysql, char *group); int mx_mysql_option_set_reconnect(struct mx_mysql *mysql, int reconnect); int mx_mysql_connect(struct mx_mysql **mysql); int mx_mysql_connect_forever_sec(struct mx_mysql **mysql, unsigned int seconds); #define mx_mysql_connect_forever(m) mx_mysql_connect_forever_sec((m), MX_MYSQL_FAIL_WAIT_DEFAULT) int mx_mysql_disconnect(struct mx_mysql *mysql); int mx_mysql_finish(struct mx_mysql **mysql); #define mx_mysql_do_statement_noresult(m, q, p) \ mx_mysql_do_statement(m, q, p, NULL, NULL, NULL, 0) #define mx_mysql_do_statement_noresult_retry_on_fail(m, q, p) \ mx_mysql_do_statement_retry_on_fail(m, q, p, NULL, NULL, NULL, 0) int mx_mysql_do_statement(struct mx_mysql *mysql, char *query, struct mx_mysql_bind *param, struct mx_mysql_bind *result, void *from, void **to, size_t size); int mx_mysql_do_statement_retry_on_fail(struct mx_mysql *mysql, char *query, struct mx_mysql_bind *param, struct mx_mysql_bind *result, void *from, void **to, size_t size); struct mx_mysql_stmt *mx_mysql_statement_prepare(struct mx_mysql *mysql, char *statement); int mx_mysql_statement_execute(struct mx_mysql_stmt *stmt, unsigned long long *count); int mx_mysql_statement_insert_id(struct mx_mysql_stmt *stmt, unsigned long long int *id); int mx_mysql_statement_fetch(struct mx_mysql_stmt *stmt); int mx_mysql_statement_field_count(struct mx_mysql_stmt *stmt); int mx_mysql_statement_param_count(struct mx_mysql_stmt *stmt); int mx_mysql_statement_close(struct mx_mysql_stmt **stmt); int mx_mysql_statement_close_no_bind_cleanup(struct mx_mysql_stmt **stmt); #define mx_mysql_bind_init_param(b, c) mx_mysql_bind_init((b), (c), MX_MYSQL_BIND_TYPE_PARAM) #define mx_mysql_bind_init_result(b, c) mx_mysql_bind_init((b), (c), MX_MYSQL_BIND_TYPE_RESULT) int mx_mysql_bind_init(struct mx_mysql_bind *bind, unsigned long count, enum mx_mysql_bind_type type); int mx_mysql_bind_string(struct mx_mysql_bind *b, unsigned int index, char **value); int mx_mysql_bind_int8(struct mx_mysql_bind *b, unsigned int index, int8_t *value); int mx_mysql_bind_int16(struct mx_mysql_bind *b, unsigned int index, int16_t *value); int mx_mysql_bind_int32(struct mx_mysql_bind *b, unsigned int index, int32_t *value); int mx_mysql_bind_int64(struct mx_mysql_bind *b, unsigned int index, int64_t *value); int mx_mysql_bind_uint8(struct mx_mysql_bind *b, unsigned int index, uint8_t *value); int mx_mysql_bind_uint16(struct mx_mysql_bind *b, unsigned int index, uint16_t *value); int mx_mysql_bind_uint32(struct mx_mysql_bind *b, unsigned int index, uint32_t *value); int mx_mysql_bind_uint64(struct mx_mysql_bind *b, unsigned int index, uint64_t *value); #endif
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
You can’t perform that action at this time.