433
433
const char *err_sqlstate, string *ds);
434
434
void handle_no_error(struct st_command*);
436
#ifdef EMBEDDED_LIBRARY
438
/* attributes of the query thread */
439
pthread_attr_t cn_thd_attrib;
442
send_one_query executes query in separate thread, which is
443
necessary in embedded library to run 'send' in proper way.
444
This implementation doesn't handle errors returned
445
by drizzle_send_query. It's technically possible, though
446
I don't see where it is needed.
448
pthread_handler_t send_one_query(void *arg)
450
struct st_connection *cn= (struct st_connection*)arg;
452
drizzle_thread_init();
453
VOID(drizzle_send_query(&cn->drizzle, cn->cur_query, cn->cur_query_len));
455
drizzle_thread_end();
456
pthread_mutex_lock(&cn->mutex);
458
VOID(pthread_cond_signal(&cn->cond));
459
pthread_mutex_unlock(&cn->mutex);
464
static int do_send_query(struct st_connection *cn, const char *q, int q_len,
469
if (flags & QUERY_REAP_FLAG)
470
return drizzle_send_query(&cn->drizzle, q, q_len);
472
if (pthread_mutex_init(&cn->mutex, NULL) ||
473
pthread_cond_init(&cn->cond, NULL))
474
die("Error in the thread library");
477
cn->cur_query_len= q_len;
479
if (pthread_create(&tid, &cn_thd_attrib, send_one_query, (void*)cn))
480
die("Cannot start new thread for query");
485
static void wait_query_thread_end(struct st_connection *con)
487
if (!con->query_done)
489
pthread_mutex_lock(&con->mutex);
490
while (!con->query_done)
491
pthread_cond_wait(&con->cond, &con->mutex);
492
pthread_mutex_unlock(&con->mutex);
496
#else /*EMBEDDED_LIBRARY*/
498
437
#define do_send_query(cn,q,q_len,flags) drizzle_send_query(&cn->drizzle, q, q_len)
500
#endif /*EMBEDDED_LIBRARY*/
502
439
void do_eval(string *query_eval, const char *query,
503
440
const char *query_end, bool pass_through_escape_chars)