86
86
return _verbose_name[verbose];
89
drizzle_st *drizzle_create(drizzle_st *drizzle)
89
drizzle_st *drizzle_create()
91
91
#if defined(_WIN32)
92
92
/* if it is MS windows, invoke WSAStartup */
101
101
sigaction(SIGPIPE, &act, NULL);
104
drizzle_st *drizzle= new (std::nothrow) drizzle_st;
104
106
if (drizzle == NULL)
106
drizzle= new (std::nothrow) drizzle_st;
112
drizzle->options.is_allocated= true;
115
111
/* @todo remove this default free flag with new API. */
143
drizzle_st *drizzle_clone(drizzle_st *drizzle, const drizzle_st *from)
139
drizzle_st *drizzle_clone(const drizzle_st *source)
145
drizzle= drizzle_create(drizzle);
141
drizzle_st *drizzle= drizzle_create();
146
142
if (drizzle == NULL)
151
bool cache_state= drizzle->options.is_allocated;
152
drizzle->options= from->options;
153
drizzle->options.is_allocated= cache_state;
155
for (drizzle_con_st* con= from->con_list; con != NULL; con= con->next)
147
for (drizzle_con_st* con= source->con_list; con != NULL; con= con->next)
157
if (drizzle_con_clone(drizzle, NULL, con) == NULL)
149
if (drizzle_con_clone(drizzle, con) == NULL)
159
151
drizzle_free(drizzle);
199
188
return drizzle->last_error;
191
drizzle_return_t drizzle_set_option(drizzle_st *drizzle, drizzle_options_t arg, bool set)
195
case DRIZZLE_NON_BLOCKING:
196
drizzle->options.is_non_blocking= set;
197
return DRIZZLE_RETURN_OK;
199
case DRIZZLE_FREE_OBJECTS:
200
return DRIZZLE_RETURN_OK;
202
case DRIZZLE_ASSERT_DANGLING:
203
return DRIZZLE_RETURN_OK;
209
return DRIZZLE_RETURN_INVALID_ARGUMENT;
202
212
int drizzle_errno(const drizzle_st *drizzle)
204
214
return drizzle->last_errno;
214
224
return drizzle->sqlstate;
217
int drizzle_options(const drizzle_st *)
222
void drizzle_set_options(drizzle_st *, int)
226
void drizzle_add_options(drizzle_st *, int)
230
227
void *drizzle_context(const drizzle_st *drizzle)
232
229
return drizzle->context;
278
275
drizzle->event_watch_context= context;
281
drizzle_con_st *drizzle_con_create(drizzle_st *drizzle, drizzle_con_st *con)
278
drizzle_con_st *drizzle_con_create(drizzle_st *drizzle)
285
drizzle_con_st *con= new (std::nothrow) drizzle_con_st;
285
con= new (std::nothrow) drizzle_con_st;
286
con->options= DRIZZLE_CON_ALLOCATED;
293
292
if (drizzle->con_list != NULL)
294
294
drizzle->con_list->prev= con;
296
297
con->next= drizzle->con_list;
349
drizzle_con_st *drizzle_con_clone(drizzle_st *drizzle, drizzle_con_st *con,
350
const drizzle_con_st *from)
350
drizzle_con_st *drizzle_con_clone(drizzle_st *drizzle, drizzle_con_st *source)
352
con= drizzle_con_create(drizzle, con);
352
drizzle_con_st *con= drizzle_con_create(drizzle);
358
358
/* Clear "operational" options such as IO status. */
359
con->options|= (from->options & ~(DRIZZLE_CON_ALLOCATED|DRIZZLE_CON_READY|
359
con->options|= (source->options & ~(DRIZZLE_CON_ALLOCATED|DRIZZLE_CON_READY|
360
360
DRIZZLE_CON_NO_RESULT_READ|DRIZZLE_CON_IO_READY|
361
361
DRIZZLE_CON_LISTEN));
362
con->backlog= from->backlog;
363
strcpy(con->schema, from->schema);
364
strcpy(con->password, from->password);
365
strcpy(con->user, from->user);
362
con->backlog= source->backlog;
363
strcpy(con->schema, source->schema);
364
strcpy(con->password, source->password);
365
strcpy(con->user, source->user);
367
switch (from->socket_type)
367
switch (source->socket_type)
369
369
case DRIZZLE_CON_SOCKET_TCP:
370
drizzle_con_set_tcp(con, from->socket.tcp.host, from->socket.tcp.port);
370
drizzle_con_set_tcp(con, source->socket.tcp.host, source->socket.tcp.port);
373
373
case DRIZZLE_CON_SOCKET_UDS:
374
drizzle_con_set_uds(con, from->socket.uds.sockaddr.sun_path);
374
drizzle_con_set_uds(con, source->socket.uds.sockaddr.sun_path);
552
549
* Client Definitions
555
drizzle_con_st *drizzle_con_add_tcp(drizzle_st *drizzle, drizzle_con_st *con,
552
drizzle_con_st *drizzle_con_add_tcp(drizzle_st *drizzle,
556
553
const char *host, in_port_t port,
557
554
const char *user, const char *password,
559
556
drizzle_con_options_t options)
561
con= drizzle_con_create(drizzle, con);
558
drizzle_con_st *con= drizzle_con_create(drizzle);
575
drizzle_con_st *drizzle_con_add_uds(drizzle_st *drizzle, drizzle_con_st *con,
572
drizzle_con_st *drizzle_con_add_uds(drizzle_st *drizzle,
576
573
const char *uds, const char *user,
577
574
const char *password, const char *db,
578
575
drizzle_con_options_t options)
580
con= drizzle_con_create(drizzle, con);
577
drizzle_con_st *con= drizzle_con_create(drizzle);
598
595
drizzle_con_st *drizzle_con_add_tcp_listen(drizzle_st *drizzle,
600
596
const char *host, in_port_t port,
602
598
drizzle_con_options_t options)
604
con= drizzle_con_create(drizzle, con);
600
drizzle_con_st *con= drizzle_con_create(drizzle);
617
613
drizzle_con_st *drizzle_con_add_uds_listen(drizzle_st *drizzle,
619
614
const char *uds, int backlog,
620
615
drizzle_con_options_t options)
622
con= drizzle_con_create(drizzle, con);
617
drizzle_con_st *con= drizzle_con_create(drizzle);
635
drizzle_con_st *drizzle_con_accept(drizzle_st *drizzle, drizzle_con_st *con,
630
drizzle_con_st *drizzle_con_accept(drizzle_st *drizzle,
636
631
drizzle_return_t *ret_ptr)
633
drizzle_return_t unused;
640
641
if (drizzle_con_st* ready= drizzle_con_ready_listen(drizzle))
642
643
int fd= accept(ready->fd, NULL, NULL);
644
con= drizzle_con_create(drizzle, con);
645
drizzle_con_st *con= drizzle_con_create(drizzle);
647
648
(void)closesocket(fd);
672
673
for (drizzle_con_st* ready= drizzle->con_list; ready != NULL; ready= ready->next)
674
675
if (ready->options & DRIZZLE_CON_LISTEN)
675
677
drizzle_con_set_events(ready, POLLIN);
678
681
*ret_ptr= drizzle_con_wait(drizzle);
679
682
if (*ret_ptr != DRIZZLE_RETURN_OK)