~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzleclient/drizzle.h

  • Committer: Monty Taylor
  • Date: 2009-03-02 23:14:32 UTC
  • mto: This revision was merged to the branch mainline in revision 910.
  • Revision ID: mordred@inaugust.com-20090302231432-i35xehp7uzo6hjjw
Updated build system to use new version numbering. Just remember to run ./config/autorun.sh before running make distcheck for release and all should be peachy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
5
 *
 
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.
 
9
 *
 
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.
 
14
 *
 
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
 
18
 */
 
19
 
 
20
#ifndef LIBDRIZZLECLIENT_DRIZZLE_H
 
21
#define LIBDRIZZLECLIENT_DRIZZLE_H
 
22
 
 
23
#include <drizzled/common.h>
 
24
#include "drizzle_field.h"
 
25
#include "options.h"
 
26
#include "drizzle_res.h"
 
27
#include "net_serv.h"
 
28
 
 
29
#include <stdint.h>
 
30
#if !defined(__cplusplus)
 
31
# include <stdbool.h>
 
32
#endif
 
33
 
 
34
#ifdef  __cplusplus
 
35
extern "C" {
 
36
#endif
 
37
 
 
38
struct st_drizzle_methods;
 
39
 
 
40
enum drizzle_status
 
41
{
 
42
  DRIZZLE_STATUS_READY,DRIZZLE_STATUS_GET_RESULT,DRIZZLE_STATUS_USE_RESULT
 
43
};
 
44
 
 
45
typedef struct st_drizzle
 
46
{
 
47
  NET    net;      /* Communication parameters */
 
48
  unsigned char  *connector_fd;    /* ConnectorFd for SSL */
 
49
  char    *host,*user,*passwd,*unix_socket,*server_version,*host_info;
 
50
  char          *info, *db;
 
51
  DRIZZLE_FIELD  *fields;
 
52
  uint64_t affected_rows;
 
53
  uint64_t insert_id;    /* id if insert on table with NEXTNR */
 
54
  uint64_t extra_info;    /* Not used */
 
55
  uint32_t thread_id;    /* Id for connection in server */
 
56
  uint32_t packet_length;
 
57
  uint32_t  port;
 
58
  uint32_t client_flag,server_capabilities;
 
59
  uint32_t  protocol_version;
 
60
  uint32_t  field_count;
 
61
  uint32_t  server_status;
 
62
  uint32_t  server_language;
 
63
  uint32_t  warning_count;
 
64
  struct st_drizzleclient_options options;
 
65
  enum drizzle_status status;
 
66
  bool  free_me;    /* If free in drizzleclient_close */
 
67
  bool  reconnect;    /* set to 1 if automatic reconnect */
 
68
 
 
69
  /* session-wide random string */
 
70
  char          scramble[SCRAMBLE_LENGTH+1];
 
71
  bool unused1;
 
72
  void *unused2, *unused3, *unused4, *unused5;
 
73
 
 
74
  const struct st_drizzle_methods *methods;
 
75
  void *thd;
 
76
  /*
 
77
    Points to boolean flag in DRIZZLE_RES  or DRIZZLE_STMT. We set this flag
 
78
    from drizzle_stmt_close if close had to cancel result set of this object.
 
79
  */
 
80
  bool *unbuffered_fetch_owner;
 
81
  /* needed for embedded server - no net buffer to store the 'info' */
 
82
  char *info_buffer;
 
83
  void *extension;
 
84
} DRIZZLE;
 
85
 
 
86
DRIZZLE * drizzleclient_create(DRIZZLE *drizzle);
 
87
DRIZZLE * drizzleclient_connect(DRIZZLE *drizzle, const char *host,
 
88
             const char *user,
 
89
             const char *passwd,
 
90
             const char *db,
 
91
             uint32_t port,
 
92
             const char *unix_socket,
 
93
             uint32_t clientflag);
 
94
 
 
95
int32_t    drizzleclient_select_db(DRIZZLE *drizzle, const char *db);
 
96
int32_t    drizzleclient_query(DRIZZLE *drizzle, const char *q);
 
97
int32_t    drizzleclient_send_query(DRIZZLE *drizzle, const char *q, uint32_t length);
 
98
int32_t    drizzleclient_real_query(DRIZZLE *drizzle, const char *q, uint32_t length);
 
99
 
 
100
DRIZZLE_RES * drizzleclient_store_result(DRIZZLE *drizzle);
 
101
DRIZZLE_RES * drizzleclient_use_result(DRIZZLE *drizzle);
 
102
 
 
103
uint32_t drizzleclient_field_count(const DRIZZLE *drizzle);
 
104
uint64_t drizzleclient_affected_rows(const DRIZZLE *drizzle);
 
105
uint64_t drizzleclient_insert_id(const DRIZZLE *drizzle);
 
106
uint32_t drizzleclient_errno(const DRIZZLE *drizzle);
 
107
const char * drizzleclient_error(const DRIZZLE *drizzle);
 
108
const char * drizzleclient_sqlstate(const DRIZZLE *drizzle);
 
109
uint32_t drizzleclient_warning_count(const DRIZZLE *drizzle);
 
110
const char * drizzleclient_info(const DRIZZLE *drizzle);
 
111
uint32_t drizzleclient_thread_id(const DRIZZLE *drizzle);
 
112
const char * drizzle_character_set_name(const DRIZZLE *drizzle);
 
113
 
 
114
bool   drizzleclient_change_user(DRIZZLE *drizzle, const char *user,
 
115
                           const char *passwd, const char *db);
 
116
 
 
117
/* local infile support */
 
118
 
 
119
#define LOCAL_INFILE_ERROR_LEN 512
 
120
 
 
121
void
 
122
drizzleclient_set_local_infile_handler(DRIZZLE *drizzle,
 
123
        int (*local_infile_init)(void **, const char *, void *),
 
124
        int (*local_infile_read)(void *, char *, unsigned int),
 
125
        void (*local_infile_end)(void *),int (*local_infile_error)
 
126
        (void *, char*, unsigned int), void *);
 
127
 
 
128
void
 
129
drizzleclient_set_local_infile_default(DRIZZLE *drizzle);
 
130
 
 
131
int32_t    drizzleclient_shutdown(DRIZZLE *drizzle);
 
132
int32_t    drizzle_dump_debug_info(DRIZZLE *drizzle);
 
133
int32_t    drizzleclient_refresh(DRIZZLE *drizzle, uint32_t refresh_options);
 
134
int32_t    drizzleclient_kill(DRIZZLE *drizzle, uint32_t pid);
 
135
int32_t    drizzleclient_set_server_option(DRIZZLE *drizzle,
 
136
                                     enum enum_drizzle_set_option option);
 
137
int32_t    drizzleclient_ping(DRIZZLE *drizzle);
 
138
const char *  drizzle_stat(DRIZZLE *drizzle);
 
139
const char *  drizzleclient_get_server_info(const DRIZZLE *drizzle);
 
140
 
 
141
const char *  drizzleclient_get_host_info(const DRIZZLE *drizzle);
 
142
uint32_t  drizzleclient_get_server_version(const DRIZZLE *drizzle);
 
143
uint32_t  drizzleclient_get_proto_info(const DRIZZLE *drizzle);
 
144
DRIZZLE_RES *  drizzleclient_list_tables(DRIZZLE *drizzle,const char *wild);
 
145
DRIZZLE_RES *  drizzleclient_list_processes(DRIZZLE *drizzle);
 
146
int32_t    drizzleclient_options(DRIZZLE *drizzle, enum drizzle_option option,
 
147
                           const void *arg);
 
148
DRIZZLE_RES *     drizzleclient_list_fields(DRIZZLE *drizzle, const char *table,
 
149
                                      const char *wild);
 
150
bool         drizzleclient_read_query_result(DRIZZLE *drizzle);
 
151
 
 
152
bool drizzleclient_commit(DRIZZLE *drizzle);
 
153
bool drizzleclient_rollback(DRIZZLE *drizzle);
 
154
bool drizzleclient_autocommit(DRIZZLE *drizzle, bool auto_mode);
 
155
bool drizzleclient_more_results(const DRIZZLE *drizzle);
 
156
int drizzleclient_next_result(DRIZZLE *drizzle);
 
157
void drizzleclient_close(DRIZZLE *drizzle);
 
158
bool drizzleclient_reconnect(DRIZZLE *drizzle);
 
159
void drizzleclient_disconnect(DRIZZLE *drizzle);
 
160
 
 
161
bool
 
162
drizzleclient_cli_advanced_command(DRIZZLE *drizzle, enum enum_server_command command,
 
163
                     const unsigned char *header, uint32_t header_length,
 
164
                     const unsigned char *arg, uint32_t arg_length,
 
165
                     bool skip_check);
 
166
uint32_t drizzleclient_cli_safe_read(DRIZZLE *drizzle);
 
167
DRIZZLE_FIELD * drizzleclient_cli_list_fields(DRIZZLE *drizzle);
 
168
DRIZZLE_DATA * drizzleclient_cli_read_rows(DRIZZLE *drizzle,DRIZZLE_FIELD *drizzle_fields,
 
169
                             unsigned int fields);
 
170
int drizzleclient_cli_unbuffered_fetch(DRIZZLE *drizzle, char **row);
 
171
const char * drizzleclient_cli_read_statistics(DRIZZLE *drizzle);
 
172
int drizzleclient_cli_read_change_user_result(DRIZZLE *drizzle);
 
173
 
 
174
typedef bool (*safe_read_error_hook_func)(NET *net);
 
175
extern safe_read_error_hook_func safe_read_error_hook;
 
176
 
 
177
#ifdef  __cplusplus
 
178
}
 
179
#endif
 
180
 
 
181
#endif /* LIBDRIZZLECLIENT_DRIZZLE_H */