1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems, Inc.
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#ifndef LIBDRIZZLECLIENT_DRIZZLE_H
21
#define LIBDRIZZLECLIENT_DRIZZLE_H
23
#include <drizzled/common.h>
24
#include "drizzle_field.h"
26
#include "drizzle_res.h"
35
struct st_drizzle_methods;
39
DRIZZLE_STATUS_READY,DRIZZLE_STATUS_GET_RESULT,DRIZZLE_STATUS_USE_RESULT
42
typedef struct st_drizzle
44
NET net; /* Communication parameters */
45
unsigned char *connector_fd; /* ConnectorFd for SSL */
46
char *host,*user,*passwd,*unix_socket,*server_version,*host_info;
48
DRIZZLE_FIELD *fields;
49
uint64_t affected_rows;
50
uint64_t insert_id; /* id if insert on table with NEXTNR */
51
uint64_t extra_info; /* Not used */
52
uint32_t thread_id; /* Id for connection in server */
53
uint32_t packet_length;
55
uint32_t client_flag,server_capabilities;
56
uint32_t protocol_version;
58
uint32_t server_status;
59
uint32_t server_language;
60
uint32_t warning_count;
61
struct st_drizzleclient_options options;
62
enum drizzle_status status;
63
bool free_me; /* If free in drizzleclient_close */
64
bool reconnect; /* set to 1 if automatic reconnect */
66
/* session-wide random string */
67
char scramble[SCRAMBLE_LENGTH+1];
69
void *unused2, *unused3, *unused4, *unused5;
71
const struct st_drizzle_methods *methods;
74
Points to boolean flag in DRIZZLE_RES or DRIZZLE_STMT. We set this flag
75
from drizzle_stmt_close if close had to cancel result set of this object.
77
bool *unbuffered_fetch_owner;
78
/* needed for embedded server - no net buffer to store the 'info' */
83
DRIZZLE * drizzleclient_create(DRIZZLE *drizzle);
84
DRIZZLE * drizzleclient_connect(DRIZZLE *drizzle, const char *host,
89
const char *unix_socket,
92
int32_t drizzleclient_select_db(DRIZZLE *drizzle, const char *db);
93
int32_t drizzleclient_send_query(DRIZZLE *drizzle, const char *q, uint32_t length);
94
int32_t drizzleclient_real_query(DRIZZLE *drizzle, const char *q, uint32_t length);
96
DRIZZLE_RES * drizzleclient_store_result(DRIZZLE *drizzle);
98
uint32_t drizzleclient_errno(const DRIZZLE *drizzle);
99
const char * drizzleclient_error(const DRIZZLE *drizzle);
100
const char * drizzle_character_set_name(const DRIZZLE *drizzle);
102
bool drizzleclient_change_user(DRIZZLE *drizzle, const char *user,
103
const char *passwd, const char *db);
105
/* local infile support */
107
#define LOCAL_INFILE_ERROR_LEN 512
110
drizzleclient_set_local_infile_handler(DRIZZLE *drizzle,
111
int (*local_infile_init)(void **, const char *, void *),
112
int (*local_infile_read)(void *, char *, unsigned int),
113
void (*local_infile_end)(void *),int (*local_infile_error)
114
(void *, char*, unsigned int), void *);
117
drizzleclient_set_local_infile_default(DRIZZLE *drizzle);
119
int32_t drizzle_dump_debug_info(DRIZZLE *drizzle);
120
int32_t drizzleclient_refresh(DRIZZLE *drizzle, uint32_t refresh_options);
121
const char * drizzle_stat(DRIZZLE *drizzle);
123
uint32_t drizzleclient_get_server_version(const DRIZZLE *drizzle);
124
DRIZZLE_RES * drizzleclient_list_processes(DRIZZLE *drizzle);
125
int32_t drizzleclient_options(DRIZZLE *drizzle, enum drizzle_option option,
128
void drizzleclient_close(DRIZZLE *drizzle);
129
bool drizzleclient_reconnect(DRIZZLE *drizzle);
130
void drizzleclient_disconnect(DRIZZLE *drizzle);
133
drizzleclient_cli_advanced_command(DRIZZLE *drizzle, enum enum_server_command command,
134
const unsigned char *header, uint32_t header_length,
135
const unsigned char *arg, uint32_t arg_length,
137
uint32_t drizzleclient_cli_safe_read(DRIZZLE *drizzle);
138
DRIZZLE_FIELD * drizzleclient_cli_list_fields(DRIZZLE *drizzle);
139
DRIZZLE_DATA * drizzleclient_cli_read_rows(DRIZZLE *drizzle,DRIZZLE_FIELD *drizzle_fields,
140
unsigned int fields);
141
int drizzleclient_cli_unbuffered_fetch(DRIZZLE *drizzle, char **row);
142
const char * drizzleclient_cli_read_statistics(DRIZZLE *drizzle);
144
typedef bool (*safe_read_error_hook_func)(NET *net);
145
extern safe_read_error_hook_func safe_read_error_hook;
151
#endif /* LIBDRIZZLECLIENT_DRIZZLE_H */