~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzle-2.0/libdrizzle/structs.h

Merged embedded-innodb-index-lookup into embedded-innodb-delete-row.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Drizzle Client & Protocol Library
3
 
 *
4
 
 * Copyright (C) 2008 Eric Day (eday@oddments.org)
5
 
 * All rights reserved.
6
 
 *
7
 
 * Redistribution and use in source and binary forms, with or without
8
 
 * modification, are permitted provided that the following conditions are
9
 
 * met:
10
 
 *
11
 
 *     * Redistributions of source code must retain the above copyright
12
 
 * notice, this list of conditions and the following disclaimer.
13
 
 *
14
 
 *     * Redistributions in binary form must reproduce the above
15
 
 * copyright notice, this list of conditions and the following disclaimer
16
 
 * in the documentation and/or other materials provided with the
17
 
 * distribution.
18
 
 *
19
 
 *     * The names of its contributors may not be used to endorse or
20
 
 * promote products derived from this software without specific prior
21
 
 * written permission.
22
 
 *
23
 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
 
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
 
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
 
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27
 
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
 
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
 
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30
 
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31
 
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
 
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
 
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
 
 *
35
 
 */
36
 
 
37
 
/**
38
 
 * @file
39
 
 * @brief Struct Definitions
40
 
 */
41
 
 
42
 
#ifndef __DRIZZLE_STRUCTS_H
43
 
#define __DRIZZLE_STRUCTS_H
44
 
 
45
 
#include <sys/types.h>
46
 
 
47
 
#ifndef NI_MAXHOST
48
 
# define NI_MAXHOST 1025
49
 
#endif
50
 
 
51
 
#ifdef __cplusplus
52
 
extern "C" {
53
 
#endif
54
 
 
55
 
#ifndef __cplusplus
56
 
struct drizzle_st;
57
 
struct drizzle_con_tcp_st;
58
 
struct drizzle_con_uds_st;
59
 
struct drizzle_con_st;
60
 
struct drizzle_query_st;
61
 
struct drizzle_result_st;
62
 
struct drizzle_column_st;
63
 
#else
64
 
 
65
 
 
66
 
/**
67
 
 * @ingroup drizzle
68
 
 */
69
 
class drizzle_st
70
 
{
71
 
public:
72
 
  uint16_t error_code;
73
 
  int options;
74
 
  drizzle_verbose_t verbose;
75
 
  uint32_t con_count;
76
 
  uint32_t pfds_size;
77
 
  uint32_t query_count;
78
 
  uint32_t query_new;
79
 
  uint32_t query_running;
80
 
  int last_errno;
81
 
  int timeout;
82
 
  drizzle_con_st *con_list;
83
 
  void *context;
84
 
  drizzle_context_free_fn *context_free_fn;
85
 
  drizzle_event_watch_fn *event_watch_fn;
86
 
  void *event_watch_context;
87
 
  drizzle_log_fn *log_fn;
88
 
  void *log_context;
89
 
  struct pollfd *pfds;
90
 
  drizzle_query_st *query_list;
91
 
  char sqlstate[DRIZZLE_MAX_SQLSTATE_SIZE + 1];
92
 
  char last_error[DRIZZLE_MAX_ERROR_SIZE];
93
 
 
94
 
  drizzle_st() :
95
 
    error_code(0),
96
 
    options(DRIZZLE_NONE),
97
 
    verbose(DRIZZLE_VERBOSE_ERROR),
98
 
    con_count(0),
99
 
    pfds_size(0),
100
 
    query_count(0),
101
 
    query_new(0),
102
 
    query_running(0),
103
 
    last_errno(0),
104
 
    timeout(-1),
105
 
    con_list(NULL),
106
 
    context(NULL),
107
 
    context_free_fn(NULL),
108
 
    event_watch_fn(NULL),
109
 
    event_watch_context(NULL),
110
 
    log_fn(NULL),
111
 
    log_context(NULL),
112
 
    pfds(NULL),
113
 
    query_list(NULL)
114
 
  { }
115
 
};
116
 
 
117
 
/**
118
 
 * @ingroup drizzle_con
119
 
 */
120
 
class drizzle_con_tcp_st
121
 
{
122
 
public:
123
 
  in_port_t port;
124
 
  struct addrinfo *addrinfo;
125
 
  char *host;
126
 
  char host_buffer[NI_MAXHOST];
127
 
};
128
 
 
129
 
/**
130
 
 * @ingroup drizzle_con
131
 
 */
132
 
class drizzle_con_uds_st
133
 
{
134
 
public:
135
 
  struct addrinfo addrinfo;
136
 
  struct sockaddr_un sockaddr;
137
 
};
138
 
 
139
 
/**
140
 
 * @ingroup drizzle_con
141
 
 */
142
 
class drizzle_con_st
143
 
{
144
 
public:
145
 
  uint8_t packet_number;
146
 
  uint8_t protocol_version;
147
 
  uint8_t state_current;
148
 
  short events;
149
 
  short revents;
150
 
  int capabilities;
151
 
  drizzle_charset_t charset;
152
 
  drizzle_command_t command;
153
 
  int options;
154
 
  drizzle_con_socket_t socket_type;
155
 
  drizzle_con_status_t status;
156
 
  uint32_t max_packet_size;
157
 
  uint32_t result_count;
158
 
  uint32_t thread_id;
159
 
  int backlog;
160
 
  int fd;
161
 
  size_t buffer_size;
162
 
  size_t command_offset;
163
 
  size_t command_size;
164
 
  size_t command_total;
165
 
  size_t packet_size;
166
 
  struct addrinfo *addrinfo_next;
167
 
  uint8_t *buffer_ptr;
168
 
  uint8_t *command_buffer;
169
 
  uint8_t *command_data;
170
 
  void *context;
171
 
  drizzle_con_context_free_fn *context_free_fn;
172
 
  drizzle_st *drizzle;
173
 
  drizzle_con_st *next;
174
 
  drizzle_con_st *prev;
175
 
  drizzle_query_st *query;
176
 
  drizzle_result_st *result;
177
 
  drizzle_result_st *result_list;
178
 
  uint8_t *scramble;
179
 
  union
180
 
  {
181
 
    drizzle_con_tcp_st tcp;
182
 
    drizzle_con_uds_st uds;
183
 
  } socket;
184
 
  uint8_t buffer[DRIZZLE_MAX_BUFFER_SIZE];
185
 
  char db[DRIZZLE_MAX_DB_SIZE];
186
 
  char password[DRIZZLE_MAX_PASSWORD_SIZE];
187
 
  uint8_t scramble_buffer[DRIZZLE_MAX_SCRAMBLE_SIZE];
188
 
  char server_version[DRIZZLE_MAX_SERVER_VERSION_SIZE];
189
 
  char server_extra[DRIZZLE_MAX_SERVER_EXTRA_SIZE];
190
 
  drizzle_state_fn *state_stack[DRIZZLE_STATE_STACK_SIZE];
191
 
  char user[DRIZZLE_MAX_USER_SIZE];
192
 
 
193
 
  drizzle_con_st() :
194
 
    packet_number(0),
195
 
    protocol_version(0),
196
 
    state_current(0),
197
 
    events(0),
198
 
    revents(0),
199
 
    capabilities(DRIZZLE_CAPABILITIES_NONE),
200
 
    options(DRIZZLE_CON_NONE),
201
 
    max_packet_size(0),
202
 
    result_count(0),
203
 
    thread_id(0),
204
 
    backlog(0),
205
 
    fd(0),
206
 
    buffer_size(0),
207
 
    command_offset(0),
208
 
    command_size(0),
209
 
    command_total(0),
210
 
    packet_size(0),
211
 
    addrinfo_next(NULL),
212
 
    buffer_ptr(NULL),
213
 
    command_buffer(NULL),
214
 
    command_data(NULL),
215
 
    context(NULL),
216
 
    context_free_fn(NULL),
217
 
    drizzle(NULL),
218
 
    next(NULL),
219
 
    prev(NULL),
220
 
    query(NULL),
221
 
    result(NULL),
222
 
    result_list(NULL),
223
 
    scramble(NULL)
224
 
  { }
225
 
};
226
 
 
227
 
/**
228
 
 * @ingroup drizzle_query
229
 
 */
230
 
class drizzle_query_st
231
 
{
232
 
public:
233
 
  drizzle_st *drizzle;
234
 
  drizzle_query_st *next;
235
 
  drizzle_query_st *prev;
236
 
  int options;
237
 
  drizzle_query_state_t state;
238
 
  drizzle_con_st *con;
239
 
  drizzle_result_st *result;
240
 
  const char *string;
241
 
  size_t size;
242
 
  void *context;
243
 
  drizzle_query_context_free_fn *context_free_fn;
244
 
 
245
 
  drizzle_query_st() :
246
 
    drizzle(NULL),
247
 
    next(NULL),
248
 
    prev(NULL),
249
 
    options(0),
250
 
    con(NULL),
251
 
    result(NULL),
252
 
    string(NULL),
253
 
    size(0),
254
 
    context(NULL),
255
 
    context_free_fn(NULL)
256
 
  { }
257
 
};
258
 
 
259
 
/**
260
 
 * @ingroup drizzle_result
261
 
 */
262
 
class drizzle_result_st
263
 
{
264
 
public:
265
 
  drizzle_con_st *con;
266
 
  drizzle_result_st *next;
267
 
  drizzle_result_st *prev;
268
 
  int options;
269
 
 
270
 
  char info[DRIZZLE_MAX_INFO_SIZE];
271
 
  uint16_t error_code;
272
 
  char sqlstate[DRIZZLE_MAX_SQLSTATE_SIZE + 1];
273
 
  uint64_t insert_id;
274
 
  uint16_t warning_count;
275
 
  uint64_t affected_rows;
276
 
 
277
 
  uint16_t column_count;
278
 
  uint16_t column_current;
279
 
  drizzle_column_st *column_list;
280
 
  drizzle_column_st *column;
281
 
  drizzle_column_st *column_buffer;
282
 
 
283
 
  uint64_t row_count;
284
 
  uint64_t row_current;
285
 
 
286
 
  uint16_t field_current;
287
 
  size_t field_total;
288
 
  size_t field_offset;
289
 
  size_t field_size;
290
 
  drizzle_field_t field;
291
 
  drizzle_field_t field_buffer;
292
 
 
293
 
  uint64_t row_list_size;
294
 
  drizzle_row_t row;
295
 
  drizzle_row_list_t *row_list;
296
 
  size_t *field_sizes;
297
 
  drizzle_field_sizes_list_t *field_sizes_list;
298
 
 
299
 
  drizzle_result_st() :
300
 
    con(NULL),
301
 
    next(NULL),
302
 
    prev(NULL),
303
 
    options(DRIZZLE_RESULT_NONE),
304
 
    error_code(0),
305
 
    insert_id(0),
306
 
    warning_count(0),
307
 
    affected_rows(0),
308
 
    column_count(0),
309
 
    column_current(0),
310
 
    column_list(NULL),
311
 
    column(NULL),
312
 
    column_buffer(NULL),
313
 
    row_count(0),
314
 
    row_current(0),
315
 
    field_current(0),
316
 
    field_total(0),
317
 
    field_offset(0),
318
 
    field_size(0),
319
 
    row_list_size(0),
320
 
    row_list(NULL),
321
 
    field_sizes(NULL),
322
 
    field_sizes_list(NULL)
323
 
  { }
324
 
};
325
 
 
326
 
/**
327
 
 * @ingroup drizzle_column
328
 
 */
329
 
class drizzle_column_st
330
 
{
331
 
public:
332
 
  drizzle_result_st *result;
333
 
  drizzle_column_st *next;
334
 
  drizzle_column_st *prev;
335
 
  int options;
336
 
  char catalog[DRIZZLE_MAX_CATALOG_SIZE];
337
 
  char db[DRIZZLE_MAX_DB_SIZE];
338
 
  char table[DRIZZLE_MAX_TABLE_SIZE];
339
 
  char orig_table[DRIZZLE_MAX_TABLE_SIZE];
340
 
  char name[DRIZZLE_MAX_COLUMN_NAME_SIZE];
341
 
  char orig_name[DRIZZLE_MAX_COLUMN_NAME_SIZE];
342
 
  drizzle_charset_t charset;
343
 
  uint32_t size;
344
 
  size_t max_size;
345
 
  drizzle_column_type_t type;
346
 
  int flags;
347
 
  uint8_t decimals;
348
 
  uint8_t default_value[DRIZZLE_MAX_DEFAULT_VALUE_SIZE];
349
 
  size_t default_value_size;
350
 
 
351
 
  drizzle_column_st() :
352
 
    result(NULL),
353
 
    next(NULL),
354
 
    prev(NULL),
355
 
    options(0),
356
 
    size(0),
357
 
    max_size(0),
358
 
    flags(DRIZZLE_COLUMN_FLAGS_NONE),
359
 
    decimals(0),
360
 
    default_value_size(0)
361
 
  { }
362
 
};
363
 
#endif
364
 
 
365
 
#ifdef __cplusplus
366
 
}
367
 
#endif
368
 
 
369
 
#endif /* __DRIZZLE_STRUCTS_H */