mysql_client_api.h
11.1 KB
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
/*
Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
The MySQL Connector/C++ is licensed under the terms of the GPLv2
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
MySQL Connectors. There are special exceptions to the terms and
conditions of the GPLv2 as it is applied to this software, see the
FLOSS License Exception
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
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; version 2 of the License.
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.,
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _MYSQL_LIBMYSQL_API_H_
#define _MYSQL_LIBMYSQL_API_H_
#include "mysql_private_iface.h"
#include <boost/shared_ptr.hpp>
namespace sql
{
class SQLString;
namespace mysql
{
namespace NativeAPI
{
typedef my_ulonglong(STDCALL* ptr2mysql_affected_rows)(MYSQL*);
typedef my_bool(STDCALL* ptr2mysql_autocommit)(MYSQL*, my_bool);
typedef void (STDCALL* ptr2mysql_close)(MYSQL* mysql);
typedef my_bool(STDCALL* ptr2mysql_commit)(MYSQL* mysql);
typedef void (STDCALL* ptr2mysql_data_seek)(MYSQL_RES*, my_ulonglong);
typedef void (STDCALL* ptr2mysql_debug)(const char* debug);
typedef unsigned int (STDCALL* ptr2mysql_errno)(MYSQL* mysql);
typedef const char* (STDCALL* ptr2mysql_error)(MYSQL* mysql);
typedef MYSQL_FIELD* (STDCALL* ptr2mysql_fetch_field)(MYSQL_RES*);
typedef MYSQL_FIELD* (STDCALL* ptr2mysql_fetch_field_direct)(MYSQL_RES*, unsigned int);
typedef unsigned long* (STDCALL* ptr2mysql_fetch_lengths)(MYSQL_RES*);
typedef MYSQL_ROW(STDCALL* ptr2mysql_fetch_row)(MYSQL_RES*);
typedef unsigned int (STDCALL* ptr2mysql_field_count)(MYSQL*);
typedef void (STDCALL* ptr2mysql_free_result)(MYSQL_RES*);
typedef unsigned long(STDCALL* ptr2mysql_get_client_version)();
typedef const char* (STDCALL* ptr2mysql_get_server_info)(MYSQL*);
typedef unsigned long(STDCALL* ptr2mysql_get_server_version)(MYSQL*);
typedef MYSQL* (STDCALL* ptr2mysql_init)(MYSQL* mysql);
typedef int (STDCALL* ptr2mysql_library_init)(int, char**, char**);
typedef void (STDCALL* ptr2mysql_library_end)(void);
typedef my_bool(STDCALL* ptr2mysql_more_results)(MYSQL*);
typedef int (STDCALL* ptr2mysql_next_result)(MYSQL*);
typedef unsigned int (STDCALL* ptr2mysql_num_fields)(MYSQL_RES*);
typedef my_ulonglong(STDCALL* ptr2mysql_num_rows)(MYSQL_RES*);
typedef int (STDCALL* ptr2mysql_options)(MYSQL*, enum mysql_option, const void*);
typedef int (STDCALL* ptr2mysql_query)(MYSQL*, const char*);
typedef int (STDCALL* ptr2mysql_ping)(MYSQL*);
typedef MYSQL* (STDCALL* ptr2mysql_real_connect)(MYSQL*, const char*, const char*, const char* , const char*, unsigned int, const char*, unsigned long);
typedef unsigned long(STDCALL* ptr2mysql_real_escape_string)(MYSQL* mysql, char*, const char*, unsigned long);
typedef int (STDCALL* ptr2mysql_real_query)(MYSQL*, const char*, unsigned long);
typedef my_bool(STDCALL* ptr2mysql_rollback)(MYSQL* mysql);
typedef const char* (STDCALL* ptr2mysql_sqlstate)(MYSQL* mysql);
typedef my_bool(STDCALL* ptr2mysql_ssl_set)(MYSQL*, const char*, const char*, const char*, const char*, const char*);
typedef MYSQL_RES* (STDCALL* ptr2mysql_store_result)(MYSQL*);
typedef MYSQL_RES* (STDCALL* ptr2mysql_use_result)(MYSQL*);
/* Prepared Statement stmt_* functions */
typedef my_ulonglong(STDCALL* ptr2mysql_stmt_affected_rows)(MYSQL_STMT*);
typedef my_bool(STDCALL* ptr2mysql_stmt_attr_set)(MYSQL_STMT*, enum enum_stmt_attr_type, const void*);
typedef my_bool(STDCALL* ptr2mysql_stmt_bind_param)(MYSQL_STMT*, MYSQL_BIND*);
typedef my_bool(STDCALL* ptr2mysql_stmt_bind_result)(MYSQL_STMT*, MYSQL_BIND*);
typedef my_bool(STDCALL* ptr2mysql_stmt_close)(MYSQL_STMT*);
typedef void (STDCALL* ptr2mysql_stmt_data_seek)(MYSQL_STMT*, my_ulonglong);
typedef unsigned int (STDCALL* ptr2mysql_stmt_errno)(MYSQL_STMT*);
typedef const char* (STDCALL* ptr2mysql_stmt_error)(MYSQL_STMT*);
typedef int (STDCALL* ptr2mysql_stmt_execute)(MYSQL_STMT*);
typedef int (STDCALL* ptr2mysql_stmt_fetch)(MYSQL_STMT*);
typedef unsigned int (STDCALL* ptr2mysql_stmt_field_count)(MYSQL_STMT*);
typedef MYSQL_STMT* (STDCALL* ptr2mysql_stmt_init)(MYSQL*);
typedef my_ulonglong(STDCALL* ptr2mysql_stmt_num_rows)(MYSQL_STMT*);
typedef unsigned long(STDCALL* ptr2mysql_stmt_param_count)(MYSQL_STMT*);
typedef int (STDCALL* ptr2mysql_stmt_prepare)(MYSQL_STMT*, const char*, unsigned long);
typedef MYSQL_RES* (STDCALL* ptr2mysql_stmt_result_metadata)(MYSQL_STMT*);
typedef my_bool(STDCALL* ptr2mysql_stmt_send_long_data)(MYSQL_STMT*, unsigned int, const char*, unsigned long);
typedef const char* (STDCALL* ptr2mysql_stmt_sqlstate)(MYSQL_STMT*);
typedef int (STDCALL* ptr2mysql_stmt_store_result)(MYSQL_STMT*);
typedef void (STDCALL* ptr2mysql_thread_init)();
typedef void (STDCALL* ptr2mysql_thread_end)();
/*
* Interface MySQL C-API wrapper class should implement.
* At the moment we must have at least 2 implementation - for static and dynamic
* mysql client library linking
*/
class IMySQLCAPI
{
public:
virtual my_ulonglong affected_rows(MYSQL*) = 0;
virtual my_bool autocommit(MYSQL*, my_bool) = 0;
virtual void close(MYSQL* mysql) = 0;
virtual my_bool commit(MYSQL* mysql) = 0;
virtual void data_seek(MYSQL_RES*, my_ulonglong) = 0;
virtual void debug(const char*) = 0;
virtual unsigned int mysql_errno(MYSQL* mysql) = 0;
virtual const char* error(MYSQL* mysql) = 0;
virtual MYSQL_FIELD* fetch_field(MYSQL_RES*) = 0;
virtual MYSQL_FIELD* fetch_field_direct(MYSQL_RES*, unsigned int) = 0;
virtual unsigned long* fetch_lengths(MYSQL_RES*) = 0;
virtual MYSQL_ROW fetch_row(MYSQL_RES*) = 0;
virtual unsigned int field_count(MYSQL*) = 0;
virtual void free_result(MYSQL_RES*) = 0;
virtual unsigned long get_client_version() = 0;
virtual const char* get_server_info(MYSQL*) = 0;
virtual unsigned long get_server_version(MYSQL*) = 0;
virtual MYSQL* init(MYSQL* mysql) = 0;
virtual int library_init(int argc, char** argv, char** groups) = 0;
virtual void library_end() = 0;
virtual my_bool more_results(MYSQL*) = 0;
virtual int next_result(MYSQL*) = 0;
virtual unsigned int num_fields(MYSQL_RES*) = 0;
virtual my_ulonglong num_rows(MYSQL_RES*) = 0;
virtual int options(MYSQL*, enum mysql_option option , const void* arg) = 0;
virtual int ping(MYSQL*) = 0;
virtual int query(MYSQL*, const char*) = 0;
virtual MYSQL* real_connect(MYSQL* mysql,
const char* host,
const char* user,
const char* passwd,
const char* db,
unsigned int port,
const char* unix_socket,
unsigned long client_flag) = 0;
virtual unsigned long real_escape_string(MYSQL* mysql, char* to, const char* from, unsigned long length) = 0;
virtual int real_query(MYSQL*, const char*, unsigned long) = 0;
virtual my_bool rollback(MYSQL*) = 0;
virtual const char* sqlstate(MYSQL*) = 0;
virtual my_bool ssl_set(MYSQL* mysql,
const char* key,
const char* cert,
const char* ca,
const char* capath,
const char* cipher) = 0;
virtual MYSQL_RES* store_result(MYSQL*) = 0;
virtual MYSQL_RES* use_result(MYSQL*) = 0;
/* Methods - wrappers of prepared statement stmt_* functions */
virtual my_ulonglong stmt_affected_rows(MYSQL_STMT*) = 0;
virtual my_bool stmt_attr_set(MYSQL_STMT* stmt, enum enum_stmt_attr_type option , const void* arg) = 0;
virtual my_bool stmt_bind_param(MYSQL_STMT*, MYSQL_BIND*) = 0;
virtual my_bool stmt_bind_result(MYSQL_STMT*, MYSQL_BIND*) = 0;
virtual my_bool stmt_close(MYSQL_STMT*) = 0;
virtual void stmt_data_seek(MYSQL_STMT*, my_ulonglong) = 0;
virtual unsigned int stmt_errno(MYSQL_STMT*) = 0;
virtual const char* stmt_error(MYSQL_STMT*) = 0;
virtual int stmt_execute(MYSQL_STMT*) = 0;
virtual int stmt_fetch(MYSQL_STMT*) = 0;
virtual unsigned int stmt_field_count(MYSQL_STMT*) = 0;
virtual MYSQL_STMT* stmt_init(MYSQL*) = 0;
virtual my_ulonglong stmt_num_rows(MYSQL_STMT*) = 0;
virtual unsigned long stmt_param_count(MYSQL_STMT*) = 0;
virtual int stmt_prepare(MYSQL_STMT*, const char*, unsigned long) = 0;
virtual MYSQL_RES* stmt_result_metadata(MYSQL_STMT*) = 0;
virtual my_bool stmt_send_long_data(MYSQL_STMT* stmt , unsigned int par_number, const char* data, unsigned long len) = 0;
virtual const char* stmt_sqlstate(MYSQL_STMT*) = 0;
virtual int stmt_store_result(MYSQL_STMT*) = 0;
virtual void thread_end() = 0;
virtual void thread_init() = 0;
};
boost::shared_ptr<IMySQLCAPI> getCApiHandle(const sql::SQLString& name);
} /* namespace NativeAPI */
} /* namespace mysql */
} /* namespace sql*/
#endif
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/