Loading Makefile.am +3 −1 Original line number Diff line number Diff line Loading @@ -125,7 +125,9 @@ test-force-pl: ./mysql-test-run.pl --force && \ ./mysql-test-run.pl --ps-protocol --force test-force-pl-mem: #used by autopush.pl to run memory based tests test-force-mem: cd mysql-test; \ ./mysql-test-run.pl --force --mem && \ ./mysql-test-run.pl --ps-protocol --force --mem client/mysqltest.c +82 −8 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ Matt Wagner <matt@mysql.com> Monty Jani Holyfoot */ #define MTEST_VERSION "3.0" Loading Loading @@ -182,6 +183,18 @@ DYNAMIC_ARRAY q_lines; #include "sslopt-vars.h" struct connection { MYSQL mysql; char *name; const char *cur_query; int cur_query_len; pthread_mutex_t mutex; pthread_cond_t cond; int query_done; }; struct { int read_lines,current_line; Loading Loading @@ -459,7 +472,6 @@ void mysql_disable_rpl_parse(MYSQL* mysql __attribute__((unused))) {} int mysql_rpl_parse_enabled(MYSQL* mysql __attribute__((unused))) { return 1; } my_bool mysql_rpl_probe(MYSQL *mysql __attribute__((unused))) { return 1; } #endif void replace_dynstr_append_mem(DYNAMIC_STRING *ds, const char *val, int len); void replace_dynstr_append(DYNAMIC_STRING *ds, const char *val); Loading @@ -471,6 +483,56 @@ void handle_error(struct st_command*, void handle_no_error(struct st_command*); #ifdef EMBEDDED_LIBRARY /* send_one_query executes query in separate thread what is necessary in embedded library to run 'send' in proper way. This implementation doesn't handle errors returned by mysql_send_query. It's technically possible, though i don't see where it is needed. */ pthread_handler_decl(send_one_query, arg) { struct connection *cn= (struct connection*)arg; mysql_thread_init(); VOID(mysql_send_query(&cn->mysql, cn->cur_query, cn->cur_query_len)); mysql_thread_end(); pthread_mutex_lock(&cn->mutex); cn->query_done= 1; VOID(pthread_cond_signal(&cn->cond)); pthread_mutex_unlock(&cn->mutex); pthread_exit(0); return 0; } static int do_send_query(struct connection *cn, const char *q, int q_len, int flags) { pthread_t tid; if (flags & QUERY_REAP_FLAG) return mysql_send_query(&cn->mysql, q, q_len); if (pthread_mutex_init(&cn->mutex, NULL) || pthread_cond_init(&cn->cond, NULL)) die("Error in the thread library"); cn->cur_query= q; cn->cur_query_len= q_len; cn->query_done= 0; if (pthread_create(&tid, NULL, send_one_query, (void*)cn)) die("Cannot start new thread for query"); return 0; } #else /*EMBEDDED_LIBRARY*/ #define do_send_query(cn,q,q_len,flags) mysql_send_query(&cn->mysql, q, q_len) #endif /*EMBEDDED_LIBRARY*/ void do_eval(DYNAMIC_STRING *query_eval, const char *query, const char *query_end, my_bool pass_through_escape_chars) Loading Loading @@ -4492,7 +4554,6 @@ int append_warnings(DYNAMIC_STRING *ds, MYSQL* mysql) } /* Run query using MySQL C API Loading @@ -4509,10 +4570,11 @@ int append_warnings(DYNAMIC_STRING *ds, MYSQL* mysql) error - function will not return */ void run_query_normal(MYSQL *mysql, struct st_command *command, void run_query_normal(struct connection *cn, *mysql, struct st_command *command, int flags, char *query, int query_len, DYNAMIC_STRING *ds, DYNAMIC_STRING *ds_warnings) { MYSQL *mysql= &cn->mysql; MYSQL_RES *res= 0; int err= 0, counter= 0; DBUG_ENTER("run_query_normal"); Loading @@ -4524,14 +4586,26 @@ void run_query_normal(MYSQL *mysql, struct st_command *command, /* Send the query */ if (mysql_send_query(mysql, query, query_len)) if (do_send_query(cn, query, query_len, flags)) { handle_error(command, mysql_errno(mysql), mysql_error(mysql), mysql_sqlstate(mysql), ds); goto end; } } #ifdef EMBEDDED_LIBRARY /* Here we handle 'reap' command, so we need to check if the query's thread was finished and probably wait */ else if (flags & QUERY_REAP) { pthread_mutex_lock(&cn->mutex); while (!cn->query_done) pthread_cond_wait(&cn->cond, &cn->mutex); pthread_mutex_unlock(&cn->mutex); } #endif /*EMBEDDED_LIBRARY*/ if (!(flags & QUERY_REAP_FLAG)) DBUG_VOID_RETURN; Loading Loading @@ -5641,7 +5715,7 @@ int main(int argc, char **argv) strmake(command->require_file, save_file, sizeof(save_file)); save_file[0]= 0; } run_query(&cur_con->mysql, command, QUERY_REAP_FLAG|QUERY_SEND_FLAG); run_query(cur_con, command, QUERY_REAP_FLAG|QUERY_SEND_FLAG); display_result_vertically= old_display_result_vertically; command->last_argument= command->end; command_executed++; Loading Loading @@ -5672,7 +5746,7 @@ int main(int argc, char **argv) strmake(command->require_file, save_file, sizeof(save_file)); save_file[0]= 0; } run_query(&cur_con->mysql, command, flags); run_query(cur, command, flags); command_executed++; command->last_argument= command->end; break; Loading @@ -5698,7 +5772,7 @@ int main(int argc, char **argv) the query and read the result some time later when reap instruction is given on this connection. */ run_query(&cur_con->mysql, command, QUERY_SEND_FLAG); run_query(cur_con, command, QUERY_SEND_FLAG); command_executed++; command->last_argument= command->end; break; Loading include/mysql.h +0 −6 Original line number Diff line number Diff line Loading @@ -281,12 +281,6 @@ typedef struct st_mysql from mysql_stmt_close if close had to cancel result set of this object. */ my_bool *unbuffered_fetch_owner; /* In embedded server it points to the statement that is processed in the current query. We store some results directly in statement fields then. */ struct st_mysql_stmt *current_stmt; } MYSQL; typedef struct st_mysql_res { Loading libmysql/libmysql.c +0 −7 Original line number Diff line number Diff line Loading @@ -4395,13 +4395,6 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt) set_stmt_error(stmt, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate); DBUG_RETURN(1); } if (result->data) { free_root(&result->alloc, MYF(MY_KEEP_PREALLOC)); result->data= NULL; result->rows= 0; stmt->data_cursor= NULL; } if (stmt->update_max_length && !stmt->bind_result_done) { Loading libmysqld/lib_sql.cc +5 −5 Original line number Diff line number Diff line Loading @@ -94,7 +94,7 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command, mysql->affected_rows= ~(my_ulonglong) 0; mysql->field_count= 0; net->last_errno= 0; mysql->current_stmt= stmt; thd->current_stmt= stmt; thd->store_globals(); // Fix if more than one connect /* Loading Loading @@ -644,7 +644,7 @@ bool Protocol::send_fields(List<Item> *list, uint flag) DBUG_RETURN(0); field_count= list->elements; field_alloc= mysql->current_stmt ? &mysql->current_stmt->mem_root : field_alloc= thd->current_stmt ? &thd->current_stmt->mem_root : &mysql->field_alloc; if (!(client_field= mysql->fields= (MYSQL_FIELD *)alloc_root(field_alloc, Loading Loading @@ -751,8 +751,8 @@ bool Protocol_prep::write() { MYSQL *mysql= thd->mysql; if (mysql->current_stmt) data= &mysql->current_stmt->result; if (thd->current_stmt) data= &thd->current_stmt->result; else { if (!(data= (MYSQL_DATA*) my_malloc(sizeof(MYSQL_DATA), Loading Loading
Makefile.am +3 −1 Original line number Diff line number Diff line Loading @@ -125,7 +125,9 @@ test-force-pl: ./mysql-test-run.pl --force && \ ./mysql-test-run.pl --ps-protocol --force test-force-pl-mem: #used by autopush.pl to run memory based tests test-force-mem: cd mysql-test; \ ./mysql-test-run.pl --force --mem && \ ./mysql-test-run.pl --ps-protocol --force --mem
client/mysqltest.c +82 −8 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ Matt Wagner <matt@mysql.com> Monty Jani Holyfoot */ #define MTEST_VERSION "3.0" Loading Loading @@ -182,6 +183,18 @@ DYNAMIC_ARRAY q_lines; #include "sslopt-vars.h" struct connection { MYSQL mysql; char *name; const char *cur_query; int cur_query_len; pthread_mutex_t mutex; pthread_cond_t cond; int query_done; }; struct { int read_lines,current_line; Loading Loading @@ -459,7 +472,6 @@ void mysql_disable_rpl_parse(MYSQL* mysql __attribute__((unused))) {} int mysql_rpl_parse_enabled(MYSQL* mysql __attribute__((unused))) { return 1; } my_bool mysql_rpl_probe(MYSQL *mysql __attribute__((unused))) { return 1; } #endif void replace_dynstr_append_mem(DYNAMIC_STRING *ds, const char *val, int len); void replace_dynstr_append(DYNAMIC_STRING *ds, const char *val); Loading @@ -471,6 +483,56 @@ void handle_error(struct st_command*, void handle_no_error(struct st_command*); #ifdef EMBEDDED_LIBRARY /* send_one_query executes query in separate thread what is necessary in embedded library to run 'send' in proper way. This implementation doesn't handle errors returned by mysql_send_query. It's technically possible, though i don't see where it is needed. */ pthread_handler_decl(send_one_query, arg) { struct connection *cn= (struct connection*)arg; mysql_thread_init(); VOID(mysql_send_query(&cn->mysql, cn->cur_query, cn->cur_query_len)); mysql_thread_end(); pthread_mutex_lock(&cn->mutex); cn->query_done= 1; VOID(pthread_cond_signal(&cn->cond)); pthread_mutex_unlock(&cn->mutex); pthread_exit(0); return 0; } static int do_send_query(struct connection *cn, const char *q, int q_len, int flags) { pthread_t tid; if (flags & QUERY_REAP_FLAG) return mysql_send_query(&cn->mysql, q, q_len); if (pthread_mutex_init(&cn->mutex, NULL) || pthread_cond_init(&cn->cond, NULL)) die("Error in the thread library"); cn->cur_query= q; cn->cur_query_len= q_len; cn->query_done= 0; if (pthread_create(&tid, NULL, send_one_query, (void*)cn)) die("Cannot start new thread for query"); return 0; } #else /*EMBEDDED_LIBRARY*/ #define do_send_query(cn,q,q_len,flags) mysql_send_query(&cn->mysql, q, q_len) #endif /*EMBEDDED_LIBRARY*/ void do_eval(DYNAMIC_STRING *query_eval, const char *query, const char *query_end, my_bool pass_through_escape_chars) Loading Loading @@ -4492,7 +4554,6 @@ int append_warnings(DYNAMIC_STRING *ds, MYSQL* mysql) } /* Run query using MySQL C API Loading @@ -4509,10 +4570,11 @@ int append_warnings(DYNAMIC_STRING *ds, MYSQL* mysql) error - function will not return */ void run_query_normal(MYSQL *mysql, struct st_command *command, void run_query_normal(struct connection *cn, *mysql, struct st_command *command, int flags, char *query, int query_len, DYNAMIC_STRING *ds, DYNAMIC_STRING *ds_warnings) { MYSQL *mysql= &cn->mysql; MYSQL_RES *res= 0; int err= 0, counter= 0; DBUG_ENTER("run_query_normal"); Loading @@ -4524,14 +4586,26 @@ void run_query_normal(MYSQL *mysql, struct st_command *command, /* Send the query */ if (mysql_send_query(mysql, query, query_len)) if (do_send_query(cn, query, query_len, flags)) { handle_error(command, mysql_errno(mysql), mysql_error(mysql), mysql_sqlstate(mysql), ds); goto end; } } #ifdef EMBEDDED_LIBRARY /* Here we handle 'reap' command, so we need to check if the query's thread was finished and probably wait */ else if (flags & QUERY_REAP) { pthread_mutex_lock(&cn->mutex); while (!cn->query_done) pthread_cond_wait(&cn->cond, &cn->mutex); pthread_mutex_unlock(&cn->mutex); } #endif /*EMBEDDED_LIBRARY*/ if (!(flags & QUERY_REAP_FLAG)) DBUG_VOID_RETURN; Loading Loading @@ -5641,7 +5715,7 @@ int main(int argc, char **argv) strmake(command->require_file, save_file, sizeof(save_file)); save_file[0]= 0; } run_query(&cur_con->mysql, command, QUERY_REAP_FLAG|QUERY_SEND_FLAG); run_query(cur_con, command, QUERY_REAP_FLAG|QUERY_SEND_FLAG); display_result_vertically= old_display_result_vertically; command->last_argument= command->end; command_executed++; Loading Loading @@ -5672,7 +5746,7 @@ int main(int argc, char **argv) strmake(command->require_file, save_file, sizeof(save_file)); save_file[0]= 0; } run_query(&cur_con->mysql, command, flags); run_query(cur, command, flags); command_executed++; command->last_argument= command->end; break; Loading @@ -5698,7 +5772,7 @@ int main(int argc, char **argv) the query and read the result some time later when reap instruction is given on this connection. */ run_query(&cur_con->mysql, command, QUERY_SEND_FLAG); run_query(cur_con, command, QUERY_SEND_FLAG); command_executed++; command->last_argument= command->end; break; Loading
include/mysql.h +0 −6 Original line number Diff line number Diff line Loading @@ -281,12 +281,6 @@ typedef struct st_mysql from mysql_stmt_close if close had to cancel result set of this object. */ my_bool *unbuffered_fetch_owner; /* In embedded server it points to the statement that is processed in the current query. We store some results directly in statement fields then. */ struct st_mysql_stmt *current_stmt; } MYSQL; typedef struct st_mysql_res { Loading
libmysql/libmysql.c +0 −7 Original line number Diff line number Diff line Loading @@ -4395,13 +4395,6 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt) set_stmt_error(stmt, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate); DBUG_RETURN(1); } if (result->data) { free_root(&result->alloc, MYF(MY_KEEP_PREALLOC)); result->data= NULL; result->rows= 0; stmt->data_cursor= NULL; } if (stmt->update_max_length && !stmt->bind_result_done) { Loading
libmysqld/lib_sql.cc +5 −5 Original line number Diff line number Diff line Loading @@ -94,7 +94,7 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command, mysql->affected_rows= ~(my_ulonglong) 0; mysql->field_count= 0; net->last_errno= 0; mysql->current_stmt= stmt; thd->current_stmt= stmt; thd->store_globals(); // Fix if more than one connect /* Loading Loading @@ -644,7 +644,7 @@ bool Protocol::send_fields(List<Item> *list, uint flag) DBUG_RETURN(0); field_count= list->elements; field_alloc= mysql->current_stmt ? &mysql->current_stmt->mem_root : field_alloc= thd->current_stmt ? &thd->current_stmt->mem_root : &mysql->field_alloc; if (!(client_field= mysql->fields= (MYSQL_FIELD *)alloc_root(field_alloc, Loading Loading @@ -751,8 +751,8 @@ bool Protocol_prep::write() { MYSQL *mysql= thd->mysql; if (mysql->current_stmt) data= &mysql->current_stmt->result; if (thd->current_stmt) data= &thd->current_stmt->result; else { if (!(data= (MYSQL_DATA*) my_malloc(sizeof(MYSQL_DATA), Loading