280
const char *drizzle_con_schema(const drizzle_con_st *con)
278
290
const char *drizzle_con_db(const drizzle_con_st *con)
292
return drizzle_con_schema(con);
283
void drizzle_con_set_db(drizzle_con_st *con, const char *db)
295
void drizzle_con_set_schema(drizzle_con_st *con, const char *schema)
289
strncpy(con->db, db, DRIZZLE_MAX_DB_SIZE);
290
con->db[DRIZZLE_MAX_DB_SIZE - 1]= 0;
308
strncpy(con->schema, schema, DRIZZLE_MAX_DB_SIZE);
309
con->schema[DRIZZLE_MAX_DB_SIZE - 1]= 0;
313
void drizzle_con_set_db(drizzle_con_st *con, const char *schema)
315
drizzle_con_set_schema(con, schema);
294
318
void *drizzle_con_context(const drizzle_con_st *con)
296
325
return con->context;
299
328
void drizzle_con_set_context(drizzle_con_st *con, void *context)
301
335
con->context= context;
304
338
void drizzle_con_set_context_free_fn(drizzle_con_st *con,
305
339
drizzle_con_context_free_fn *function)
307
346
con->context_free_fn= function;
310
349
uint8_t drizzle_con_protocol_version(const drizzle_con_st *con)
312
356
return con->protocol_version;
315
359
const char *drizzle_con_server_version(const drizzle_con_st *con)
317
366
return con->server_version;
320
369
uint32_t drizzle_con_server_version_number(const drizzle_con_st *con)
376
const char *current= con->server_version;
327
const char *current= con->server_version;
329
major= (uint32_t)strtoul(current, &end, 10);
331
minor= (uint32_t)strtoul(current, &end, 10);
333
version= (uint32_t)strtoul(current, &end, 10);
379
uint32_t major= (uint32_t)strtoul(current, &end, 10);
382
uint32_t minor= (uint32_t)strtoul(current, &end, 10);
385
uint32_t version= (uint32_t)strtoul(current, &end, 10);
335
387
return (major * 10000) + (minor * 100) + version;
338
390
uint32_t drizzle_con_thread_id(const drizzle_con_st *con)
340
397
return con->thread_id;
343
400
const uint8_t *drizzle_con_scramble(const drizzle_con_st *con)
345
407
return con->scramble;
348
410
int drizzle_con_capabilities(const drizzle_con_st *con)
350
417
return con->capabilities;
353
420
drizzle_charset_t drizzle_con_charset(const drizzle_con_st *con)
424
return drizzle_charset_t();
355
427
return con->charset;
358
430
drizzle_con_status_t drizzle_con_status(const drizzle_con_st *con)
434
return drizzle_con_status_t();
360
437
return con->status;
363
440
uint32_t drizzle_con_max_packet_size(const drizzle_con_st *con)
365
447
return con->max_packet_size;
439
533
drizzle_result_st *drizzle_shutdown(drizzle_con_st *con,
440
drizzle_result_st *result, uint32_t level,
534
drizzle_result_st *result, uint32_t,
441
535
drizzle_return_t *ret_ptr)
444
537
return drizzle_con_shutdown(con, result, ret_ptr);
484
580
ret_ptr= &unused;
487
if (!(con->options & DRIZZLE_CON_READY))
583
if ((con->options & DRIZZLE_CON_READY) == 0)
489
585
if (con->options & DRIZZLE_CON_RAW_PACKET)
491
drizzle_set_error(con->drizzle, "drizzle_command_write",
492
"connection not ready");
587
drizzle_set_error(con->drizzle, "drizzle_command_write", "connection not ready");
493
588
*ret_ptr= DRIZZLE_RETURN_NOT_READY;
497
592
*ret_ptr= drizzle_con_connect(con);
498
593
if (*ret_ptr != DRIZZLE_RETURN_OK)
576
680
int drizzle_con_backlog(const drizzle_con_st *con)
578
687
return con->backlog;
581
690
void drizzle_con_set_backlog(drizzle_con_st *con, int backlog)
583
697
con->backlog= backlog;
586
void drizzle_con_set_protocol_version(drizzle_con_st *con,
587
uint8_t protocol_version)
700
void drizzle_con_set_protocol_version(drizzle_con_st *con, uint8_t protocol_version)
589
707
con->protocol_version= protocol_version;
592
710
void drizzle_con_set_server_version(drizzle_con_st *con,
593
711
const char *server_version)
595
718
if (server_version == NULL)
596
720
con->server_version[0]= 0;
599
724
strncpy(con->server_version, server_version,
621
758
void drizzle_con_set_capabilities(drizzle_con_st *con,
622
759
int capabilities)
624
766
con->capabilities= capabilities;
627
769
void drizzle_con_set_charset(drizzle_con_st *con, drizzle_charset_t charset)
629
776
con->charset= charset;
632
779
void drizzle_con_set_status(drizzle_con_st *con, drizzle_con_status_t status)
634
786
con->status= status;
637
789
void drizzle_con_set_max_packet_size(drizzle_con_st *con,
638
790
uint32_t max_packet_size)
640
797
con->max_packet_size= max_packet_size;
643
800
void drizzle_con_copy_handshake(drizzle_con_st *con, drizzle_con_st *from)
645
807
drizzle_con_set_auth(con, from->user, NULL);
646
808
drizzle_con_set_scramble(con, from->scramble);
647
drizzle_con_set_db(con, from->db);
809
drizzle_con_set_db(con, from->schema);
648
810
drizzle_con_set_protocol_version(con, from->protocol_version);
649
811
drizzle_con_set_server_version(con, from->server_version);
650
812
drizzle_con_set_thread_id(con, from->thread_id);
705
897
if (con->command_buffer == NULL)
707
con->command_buffer= new uint8_t[(*total) + 1];
899
con->command_buffer= new (std::nothrow) uint8_t[(*total) + 1];
901
if (con->command_buffer == NULL)
904
*ret_ptr= DRIZZLE_RETURN_MEMORY;
710
909
memcpy(con->command_buffer + offset, command_data, size);
786
992
if (tcp->port != 0)
787
994
snprintf(port, NI_MAXSERV, "%u", tcp->port);
788
996
else if (con->options & DRIZZLE_CON_MYSQL)
789
998
snprintf(port, NI_MAXSERV, "%u", DRIZZLE_DEFAULT_TCP_PORT_MYSQL);
791
1002
snprintf(port, NI_MAXSERV, "%u", DRIZZLE_DEFAULT_TCP_PORT);
792
1004
port[NI_MAXSERV-1]= 0;
794
1006
memset(&ai, 0, sizeof(ai));
1163
1383
ret= drizzle_con_set_events(con, POLLOUT);
1164
1384
if (ret != DRIZZLE_RETURN_OK)
1167
if (con->drizzle->options & DRIZZLE_NON_BLOCKING)
1389
if (con->drizzle->options.is_non_blocking)
1168
1391
return DRIZZLE_RETURN_IO_WAIT;
1170
1394
ret= drizzle_con_wait(con->drizzle);
1171
1395
if (ret != DRIZZLE_RETURN_OK)
1176
1402
else if (errno == EINTR)
1178
1406
else if (errno == EPIPE || errno == ECONNRESET)
1180
1408
drizzle_set_error(con->drizzle, "drizzle_state_write",