~jaypipes/drizzle/proto-definitions

« back to all changes in this revision

Viewing changes to libdrizzle/drizzle.h

  • Committer: Jay Pipes
  • Date: 2008-09-25 18:13:26 UTC
  • mfrom: (352.5.30 codestyle)
  • Revision ID: jay@mysql.com-20080925181326-2z7pr377hcvf28qt
Merged in trunk and added additional definition wrappers for proto buffer messages

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 _libdrizzle_drizzle_h
 
21
#define _libdrizzle_drizzle_h
 
22
 
 
23
 
 
24
#include <stdint.h>
 
25
#include <stdbool.h>
 
26
#include <libdrizzle/drizzle_com.h>
 
27
#include <libdrizzle/drizzle_field.h>
 
28
#include <libdrizzle/drizzle_options.h>
 
29
#include <libdrizzle/drizzle_res.h>
 
30
#include <libdrizzle/net_serv.h>
 
31
 
 
32
#ifdef  __cplusplus
 
33
extern "C" {
 
34
#endif
 
35
 
 
36
struct st_drizzle_methods;
 
37
 
 
38
enum drizzle_status
 
39
{
 
40
  DRIZZLE_STATUS_READY,DRIZZLE_STATUS_GET_RESULT,DRIZZLE_STATUS_USE_RESULT
 
41
};
 
42
 
 
43
typedef struct st_drizzle
 
44
{
 
45
  NET    net;      /* Communication parameters */
 
46
  unsigned char  *connector_fd;    /* ConnectorFd for SSL */
 
47
  char    *host,*user,*passwd,*unix_socket,*server_version,*host_info;
 
48
  char          *info, *db;
 
49
  DRIZZLE_FIELD  *fields;
 
50
  uint64_t affected_rows;
 
51
  uint64_t insert_id;    /* id if insert on table with NEXTNR */
 
52
  uint64_t extra_info;    /* Not used */
 
53
  uint32_t thread_id;    /* Id for connection in server */
 
54
  uint32_t packet_length;
 
55
  uint32_t  port;
 
56
  uint32_t client_flag,server_capabilities;
 
57
  uint32_t  protocol_version;
 
58
  uint32_t  field_count;
 
59
  uint32_t  server_status;
 
60
  uint32_t  server_language;
 
61
  uint32_t  warning_count;
 
62
  struct st_drizzle_options options;
 
63
  enum drizzle_status status;
 
64
  bool  free_me;    /* If free in drizzle_close */
 
65
  bool  reconnect;    /* set to 1 if automatic reconnect */
 
66
 
 
67
  /* session-wide random string */
 
68
  char          scramble[SCRAMBLE_LENGTH+1];
 
69
  bool unused1;
 
70
  void *unused2, *unused3, *unused4, *unused5;
 
71
 
 
72
  const struct st_drizzle_methods *methods;
 
73
  void *thd;
 
74
  /*
 
75
    Points to boolean flag in DRIZZLE_RES  or DRIZZLE_STMT. We set this flag
 
76
    from drizzle_stmt_close if close had to cancel result set of this object.
 
77
  */
 
78
  bool *unbuffered_fetch_owner;
 
79
  /* needed for embedded server - no net buffer to store the 'info' */
 
80
  char *info_buffer;
 
81
  void *extension;
 
82
} DRIZZLE;
 
83
 
 
84
DRIZZLE * drizzle_create(DRIZZLE *drizzle);
 
85
DRIZZLE * drizzle_connect(DRIZZLE *drizzle, const char *host,
 
86
             const char *user,
 
87
             const char *passwd,
 
88
             const char *db,
 
89
             uint32_t port,
 
90
             const char *unix_socket,
 
91
             uint32_t clientflag);
 
92
 
 
93
int32_t    drizzle_select_db(DRIZZLE *drizzle, const char *db);
 
94
int32_t    drizzle_query(DRIZZLE *drizzle, const char *q);
 
95
int32_t    drizzle_send_query(DRIZZLE *drizzle, const char *q, uint32_t length);
 
96
int32_t    drizzle_real_query(DRIZZLE *drizzle, const char *q, uint32_t length);
 
97
 
 
98
DRIZZLE_RES * drizzle_store_result(DRIZZLE *drizzle);
 
99
DRIZZLE_RES * drizzle_use_result(DRIZZLE *drizzle);
 
100
 
 
101
uint32_t drizzle_field_count(const DRIZZLE *drizzle);
 
102
uint64_t drizzle_affected_rows(const DRIZZLE *drizzle);
 
103
uint64_t drizzle_insert_id(const DRIZZLE *drizzle);
 
104
uint32_t drizzle_errno(const DRIZZLE *drizzle);
 
105
const char * drizzle_error(const DRIZZLE *drizzle);
 
106
const char * drizzle_sqlstate(const DRIZZLE *drizzle);
 
107
uint32_t drizzle_warning_count(const DRIZZLE *drizzle);
 
108
const char * drizzle_info(const DRIZZLE *drizzle);
 
109
uint32_t drizzle_thread_id(const DRIZZLE *drizzle);
 
110
const char * drizzle_character_set_name(const DRIZZLE *drizzle);
 
111
 
 
112
bool   drizzle_change_user(DRIZZLE *drizzle, const char *user,
 
113
                           const char *passwd, const char *db);
 
114
 
 
115
/* local infile support */
 
116
 
 
117
#define LOCAL_INFILE_ERROR_LEN 512
 
118
 
 
119
void
 
120
drizzle_set_local_infile_handler(DRIZZLE *drizzle,
 
121
        int (*local_infile_init)(void **, const char *, void *),
 
122
        int (*local_infile_read)(void *, char *, unsigned int),
 
123
        void (*local_infile_end)(void *),int (*local_infile_error)
 
124
        (void *, char*, unsigned int), void *);
 
125
 
 
126
void
 
127
drizzle_set_local_infile_default(DRIZZLE *drizzle);
 
128
 
 
129
int32_t    drizzle_shutdown(DRIZZLE *drizzle,
 
130
                            enum drizzle_enum_shutdown_level shutdown_level);
 
131
int32_t    drizzle_dump_debug_info(DRIZZLE *drizzle);
 
132
int32_t    drizzle_refresh(DRIZZLE *drizzle, uint32_t refresh_options);
 
133
int32_t    drizzle_kill(DRIZZLE *drizzle, uint32_t pid);
 
134
int32_t    drizzle_set_server_option(DRIZZLE *drizzle,
 
135
                                     enum enum_drizzle_set_option option);
 
136
int32_t    drizzle_ping(DRIZZLE *drizzle);
 
137
const char *  drizzle_stat(DRIZZLE *drizzle);
 
138
const char *  drizzle_get_server_info(const DRIZZLE *drizzle);
 
139
 
 
140
const char *  drizzle_get_host_info(const DRIZZLE *drizzle);
 
141
uint32_t  drizzle_get_server_version(const DRIZZLE *drizzle);
 
142
uint32_t  drizzle_get_proto_info(const DRIZZLE *drizzle);
 
143
DRIZZLE_RES *  drizzle_list_tables(DRIZZLE *drizzle,const char *wild);
 
144
DRIZZLE_RES *  drizzle_list_processes(DRIZZLE *drizzle);
 
145
int32_t    drizzle_options(DRIZZLE *drizzle, enum drizzle_option option,
 
146
                           const void *arg);
 
147
DRIZZLE_RES *     drizzle_list_fields(DRIZZLE *drizzle, const char *table,
 
148
                                      const char *wild);
 
149
bool         drizzle_read_query_result(DRIZZLE *drizzle);
 
150
 
 
151
bool drizzle_commit(DRIZZLE *drizzle);
 
152
bool drizzle_rollback(DRIZZLE *drizzle);
 
153
bool drizzle_autocommit(DRIZZLE *drizzle, bool auto_mode);
 
154
bool drizzle_more_results(const DRIZZLE *drizzle);
 
155
int drizzle_next_result(DRIZZLE *drizzle);
 
156
void drizzle_close(DRIZZLE *drizzle);
 
157
bool drizzle_reconnect(DRIZZLE *drizzle);
 
158
void drizzle_disconnect(DRIZZLE *drizzle);
 
159
 
 
160
bool
 
161
cli_advanced_command(DRIZZLE *drizzle, enum enum_server_command command,
 
162
                     const unsigned char *header, uint32_t header_length,
 
163
                     const unsigned char *arg, uint32_t arg_length,
 
164
                     bool skip_check);
 
165
uint32_t cli_safe_read(DRIZZLE *drizzle);
 
166
DRIZZLE_FIELD * cli_list_fields(DRIZZLE *drizzle);
 
167
DRIZZLE_DATA * cli_read_rows(DRIZZLE *drizzle,DRIZZLE_FIELD *drizzle_fields,
 
168
                             unsigned int fields);
 
169
int cli_unbuffered_fetch(DRIZZLE *drizzle, char **row);
 
170
const char * cli_read_statistics(DRIZZLE *drizzle);
 
171
int cli_read_change_user_result(DRIZZLE *drizzle);
 
172
 
 
173
 
 
174
#ifdef  __cplusplus
 
175
}
 
176
#endif
 
177
 
 
178
#endif /* _libdrizzle_drizzle_h */