41
41
#define CLIENT_NET_READ_TIMEOUT 365*24*3600 /* Timeout on read */
42
42
#define CLIENT_NET_WRITE_TIMEOUT 365*24*3600 /* Timeout on write */
43
#if !defined(DRIZZLE_SERVER) && !defined(DRIZZLE_CLIENT)
44
#define DRIZZLE_CLIENT
44
47
#include <libdrizzle/drizzle_field.h>
45
48
#include <libdrizzle/drizzle_rows.h>
46
49
#include <libdrizzle/drizzle_data.h>
47
50
#include <libdrizzle/drizzle_options.h>
52
DRIZZLE_STATUS_READY,DRIZZLE_STATUS_GET_RESULT,DRIZZLE_STATUS_USE_RESULT
55
struct st_drizzle_methods;
56
struct st_drizzle_stmt;
58
typedef struct st_drizzle
60
NET net; /* Communication parameters */
61
unsigned char *connector_fd; /* ConnectorFd for SSL */
62
char *host,*user,*passwd,*unix_socket,*server_version,*host_info;
64
DRIZZLE_FIELD *fields;
65
uint64_t affected_rows;
66
uint64_t insert_id; /* id if insert on table with NEXTNR */
67
uint64_t extra_info; /* Not used */
68
uint32_t thread_id; /* Id for connection in server */
69
uint32_t packet_length;
71
uint32_t client_flag,server_capabilities;
72
uint32_t protocol_version;
74
uint32_t server_status;
75
uint32_t server_language;
76
uint32_t warning_count;
77
struct st_drizzle_options options;
78
enum drizzle_status status;
79
bool free_me; /* If free in drizzle_close */
80
bool reconnect; /* set to 1 if automatic reconnect */
82
/* session-wide random string */
83
char scramble[SCRAMBLE_LENGTH+1];
85
void *unused2, *unused3, *unused4, *unused5;
87
const struct st_drizzle_methods *methods;
90
Points to boolean flag in DRIZZLE_RES or DRIZZLE_STMT. We set this flag
91
from drizzle_stmt_close if close had to cancel result set of this object.
93
bool *unbuffered_fetch_owner;
94
/* needed for embedded server - no net buffer to store the 'info' */
100
typedef struct st_drizzle_res {
102
DRIZZLE_FIELD *fields;
104
DRIZZLE_ROWS *data_cursor;
105
uint32_t *lengths; /* column lengths of current row */
106
DRIZZLE *handle; /* for unbuffered reads */
107
const struct st_drizzle_methods *methods;
108
DRIZZLE_ROW row; /* If unbuffered read */
109
DRIZZLE_ROW current_row; /* buffer to current row */
110
uint32_t field_count, current_field;
111
bool eof; /* Used by drizzle_fetch_row */
112
/* drizzle_stmt_close() had to cancel this result */
113
bool unbuffered_fetch_cancelled;
118
#if !defined(DRIZZLE_SERVER) && !defined(DRIZZLE_CLIENT)
119
#define DRIZZLE_CLIENT
123
typedef struct st_drizzle_parameters
125
uint32_t *p_max_allowed_packet;
126
uint32_t *p_net_buffer_length;
128
} DRIZZLE_PARAMETERS;
130
#if !defined(DRIZZLE_SERVER)
131
#define max_allowed_packet (*drizzle_get_parameters()->p_max_allowed_packet)
132
#define net_buffer_length (*drizzle_get_parameters()->p_net_buffer_length)
52
#include <libdrizzle/drizzle.h>
53
#include <libdrizzle/drizzle_parameters.h>
54
#include <libdrizzle/drizzle_methods.h>
136
57
Set up and bring down the server; to ensure that applications will
151
72
#define drizzle_library_end drizzle_server_end
153
const DRIZZLE_PARAMETERS * drizzle_get_parameters(void);
157
Functions to get information from the DRIZZLE and DRIZZLE_RES structures
158
Should definitely be used if one uses shared libraries.
161
uint64_t drizzle_num_rows(const DRIZZLE_RES *res);
162
unsigned int drizzle_num_fields(const DRIZZLE_RES *res);
163
bool drizzle_eof(const DRIZZLE_RES *res);
164
const DRIZZLE_FIELD * drizzle_fetch_field_direct(const DRIZZLE_RES *res,
165
unsigned int fieldnr);
166
const DRIZZLE_FIELD * drizzle_fetch_fields(const DRIZZLE_RES *res);
167
DRIZZLE_ROW_OFFSET drizzle_row_tell(const DRIZZLE_RES *res);
168
DRIZZLE_FIELD_OFFSET drizzle_field_tell(const DRIZZLE_RES *res);
170
uint32_t drizzle_field_count(const DRIZZLE *drizzle);
171
uint64_t drizzle_affected_rows(const DRIZZLE *drizzle);
172
uint64_t drizzle_insert_id(const DRIZZLE *drizzle);
173
uint32_t drizzle_errno(const DRIZZLE *drizzle);
174
const char * drizzle_error(const DRIZZLE *drizzle);
175
const char * drizzle_sqlstate(const DRIZZLE *drizzle);
176
uint32_t drizzle_warning_count(const DRIZZLE *drizzle);
177
const char * drizzle_info(const DRIZZLE *drizzle);
178
uint32_t drizzle_thread_id(const DRIZZLE *drizzle);
179
const char * drizzle_character_set_name(const DRIZZLE *drizzle);
180
int32_t drizzle_set_character_set(DRIZZLE *drizzle, const char *csname);
182
DRIZZLE * drizzle_create(DRIZZLE *drizzle);
183
bool drizzle_change_user(DRIZZLE *drizzle, const char *user,
184
const char *passwd, const char *db);
185
DRIZZLE * drizzle_connect(DRIZZLE *drizzle, const char *host,
190
const char *unix_socket,
191
uint32_t clientflag);
192
int32_t drizzle_select_db(DRIZZLE *drizzle, const char *db);
193
int32_t drizzle_query(DRIZZLE *drizzle, const char *q);
194
int32_t drizzle_send_query(DRIZZLE *drizzle, const char *q, uint32_t length);
195
int32_t drizzle_real_query(DRIZZLE *drizzle, const char *q, uint32_t length);
196
DRIZZLE_RES * drizzle_store_result(DRIZZLE *drizzle);
197
DRIZZLE_RES * drizzle_use_result(DRIZZLE *drizzle);
199
/* local infile support */
201
#define LOCAL_INFILE_ERROR_LEN 512
204
drizzle_set_local_infile_handler(DRIZZLE *drizzle,
205
int (*local_infile_init)(void **, const char *, void *),
206
int (*local_infile_read)(void *, char *, unsigned int),
207
void (*local_infile_end)(void *),int (*local_infile_error)
208
(void *, char*, unsigned int), void *);
211
drizzle_set_local_infile_default(DRIZZLE *drizzle);
213
int32_t drizzle_shutdown(DRIZZLE *drizzle, enum drizzle_enum_shutdown_level shutdown_level);
214
int32_t drizzle_dump_debug_info(DRIZZLE *drizzle);
215
int32_t drizzle_refresh(DRIZZLE *drizzle, uint32_t refresh_options);
216
int32_t drizzle_kill(DRIZZLE *drizzle, uint32_t pid);
217
int32_t drizzle_set_server_option(DRIZZLE *drizzle, enum enum_drizzle_set_option option);
218
int32_t drizzle_ping(DRIZZLE *drizzle);
219
const char * drizzle_stat(DRIZZLE *drizzle);
220
const char * drizzle_get_server_info(const DRIZZLE *drizzle);
221
75
const char * drizzle_get_client_info(void);
222
76
uint32_t drizzle_get_client_version(void);
223
const char * drizzle_get_host_info(const DRIZZLE *drizzle);
224
uint32_t drizzle_get_server_version(const DRIZZLE *drizzle);
225
uint32_t drizzle_get_proto_info(const DRIZZLE *drizzle);
226
DRIZZLE_RES * drizzle_list_tables(DRIZZLE *drizzle,const char *wild);
227
DRIZZLE_RES * drizzle_list_processes(DRIZZLE *drizzle);
228
int32_t drizzle_options(DRIZZLE *drizzle,enum drizzle_option option, const void *arg);
229
void drizzle_free_result(DRIZZLE_RES *result);
230
void drizzle_data_seek(DRIZZLE_RES *result, uint64_t offset);
231
DRIZZLE_ROW_OFFSET drizzle_row_seek(DRIZZLE_RES *result, DRIZZLE_ROW_OFFSET offset);
232
DRIZZLE_FIELD_OFFSET drizzle_field_seek(DRIZZLE_RES *result, DRIZZLE_FIELD_OFFSET offset);
233
DRIZZLE_ROW drizzle_fetch_row(DRIZZLE_RES *result);
234
uint32_t * drizzle_fetch_lengths(DRIZZLE_RES *result);
235
DRIZZLE_FIELD * drizzle_fetch_field(DRIZZLE_RES *result);
236
DRIZZLE_RES * drizzle_list_fields(DRIZZLE *drizzle, const char *table, const char *wild);
237
77
uint32_t drizzle_escape_string(char *to,const char *from, uint32_t from_length);
238
78
uint32_t drizzle_hex_string(char *to,const char *from, uint32_t from_length);
239
bool drizzle_read_query_result(DRIZZLE *drizzle);
243
typedef struct st_drizzle_methods
245
bool (*read_query_result)(DRIZZLE *drizzle);
246
bool (*advanced_command)(DRIZZLE *drizzle,
247
enum enum_server_command command,
248
const unsigned char *header,
249
uint32_t header_length,
250
const unsigned char *arg,
253
DRIZZLE_DATA *(*read_rows)(DRIZZLE *drizzle,DRIZZLE_FIELD *drizzle_fields, uint32_t fields);
254
DRIZZLE_RES * (*use_result)(DRIZZLE *drizzle);
255
void (*fetch_lengths)(uint32_t *to, DRIZZLE_ROW column, uint32_t field_count);
256
void (*flush_use_result)(DRIZZLE *drizzle);
257
DRIZZLE_FIELD * (*list_fields)(DRIZZLE *drizzle);
258
int32_t (*unbuffered_fetch)(DRIZZLE *drizzle, char **row);
259
const char *(*read_statistics)(DRIZZLE *drizzle);
260
bool (*next_result)(DRIZZLE *drizzle);
261
int32_t (*read_change_user_result)(DRIZZLE *drizzle);
265
bool drizzle_commit(DRIZZLE *drizzle);
266
bool drizzle_rollback(DRIZZLE *drizzle);
267
bool drizzle_autocommit(DRIZZLE *drizzle, bool auto_mode);
268
bool drizzle_more_results(const DRIZZLE *drizzle);
269
int drizzle_next_result(DRIZZLE *drizzle);
270
void drizzle_close(DRIZZLE *sock);
273
/* status return codes */
274
#define DRIZZLE_NO_DATA 100
275
#define DRIZZLE_DATA_TRUNCATED 101
278
#define drizzle_reload(drizzle) drizzle_refresh((drizzle),REFRESH_GRANT)
281
81
The following functions are mainly exported because of binlog;