diff options
-rw-r--r-- | include/mysql.h | 1 | ||||
-rw-r--r-- | libmysql/client_settings.h | 1 | ||||
-rw-r--r-- | libmysql/libmysql.c | 25 | ||||
-rw-r--r-- | libmysqld/lib_sql.cc | 20 | ||||
-rw-r--r-- | sql/sql_class.h | 2 | ||||
-rw-r--r-- | sql/sql_parse.cc | 13 |
6 files changed, 50 insertions, 12 deletions
diff --git a/include/mysql.h b/include/mysql.h index d1b467f9649..3679b65ba4a 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -575,6 +575,7 @@ typedef struct st_mysql_methods int (*unbuffered_fetch)(MYSQL *mysql, char **row); void (*free_embedded_thd)(MYSQL *mysql); const char *(*read_statistic)(MYSQL *mysql); + int (*next_result)(MYSQL *mysql); #endif } MYSQL_METHODS; diff --git a/libmysql/client_settings.h b/libmysql/client_settings.h index b1a85f567f9..6a7da0bcc81 100644 --- a/libmysql/client_settings.h +++ b/libmysql/client_settings.h @@ -58,6 +58,7 @@ int cli_stmt_execute(MYSQL_STMT *stmt); MYSQL_DATA * cli_read_binary_rows(MYSQL_STMT *stmt); int cli_unbuffered_fetch(MYSQL *mysql, char **row); const char * cli_read_statistic(MYSQL *mysql); +int cli_next_result(MYSQL *mysql); #ifdef EMBEDDED_LIBRARY int init_embedded_server(int argc, char **argv, char **groups); diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 977657f8998..a3e88ccd03d 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -3511,6 +3511,21 @@ my_bool STDCALL mysql_more_results(MYSQL *mysql) Reads and returns the next query results */ +int cli_next_result(MYSQL *mysql) +{ + DBUG_ENTER("cli_next_result"); + + mysql->net.last_error[0]= 0; + mysql->net.last_errno= 0; + strmov(mysql->net.sqlstate, not_error_sqlstate); + mysql->affected_rows= ~(my_ulonglong) 0; + + if (mysql->last_used_con->server_status & SERVER_MORE_RESULTS_EXISTS) + DBUG_RETURN((*mysql->methods->read_query_result)(mysql)); + + DBUG_RETURN(-1); /* No more results */ +} + int STDCALL mysql_next_result(MYSQL *mysql) { DBUG_ENTER("mysql_next_result"); @@ -3523,15 +3538,7 @@ int STDCALL mysql_next_result(MYSQL *mysql) DBUG_RETURN(1); } - mysql->net.last_error[0]= 0; - mysql->net.last_errno= 0; - strmov(mysql->net.sqlstate, not_error_sqlstate); - mysql->affected_rows= ~(my_ulonglong) 0; - - if (mysql->last_used_con->server_status & SERVER_MORE_RESULTS_EXISTS) - DBUG_RETURN((*mysql->methods->read_query_result)(mysql)); - - DBUG_RETURN(-1); /* No more results */ + DBUG_RETURN((*mysql->methods->next_result)(mysql)); } diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index e36e878d4b1..81235ce0c22 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -245,6 +245,18 @@ static MYSQL_RES * emb_mysql_store_result(MYSQL *mysql) return mysql_store_result(mysql); } +int emb_next_result(MYSQL *mysql) +{ + THD *thd= (THD*)mysql->thd; + DBUG_ENTER("emb_next_result"); + + if (emb_advanced_command(mysql, COM_QUERY,0,0, + thd->query_rest,thd->query_rest_length,1) + || emb_mysql_read_query_result(mysql)) + DBUG_RETURN(1); + + DBUG_RETURN(0); /* No more results */ +} MYSQL_METHODS embedded_methods= { @@ -259,7 +271,8 @@ MYSQL_METHODS embedded_methods= emb_read_binary_rows, emb_unbuffered_fetch, emb_free_embedded_thd, - emb_read_statistic + emb_read_statistic, + emb_next_result }; C_MODE_END @@ -749,6 +762,11 @@ bool Protocol::net_store_data(const char *from, uint length) return false; } +char *memdup_mysql(struct st_mysql *mysql, const char*data, int length) +{ + return memdup_root(&mysql->field_alloc, data, length); +} + #if 0 /* The same as Protocol::net_store_data but does the converstion */ diff --git a/sql/sql_class.h b/sql/sql_class.h index 7971137d848..879d75fe26a 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -565,6 +565,8 @@ public: struct st_mysql_bind *client_params; char *extra_data; ulong extra_length; + char *query_rest; + uint32 query_rest_length; #endif NET net; // client connection descriptor MEM_ROOT warn_root; // For warnings and errors diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 9d742995976..564c22dd004 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -48,6 +48,7 @@ extern "C" int gethostname(char *name, int namelen); #endif +char *memdup_mysql(struct st_mysql *mysql, const char*data, int length); static int check_for_max_user_connections(THD *thd, USER_CONN *uc); static void decrease_user_connections(USER_CONN *uc); static bool check_db_used(THD *thd,TABLE_LIST *tables); @@ -1397,11 +1398,13 @@ bool dispatch_command(enum enum_server_command command, THD *thd, char *packet= thd->lex->found_colon; /* Multiple queries exits, execute them individually + in embedded server - just store them to be executed later */ +#ifndef EMBEDDED_LIBRARY if (thd->lock || thd->open_tables || thd->derived_tables) close_thread_tables(thd); - - ulong length= thd->query_length-(ulong)(thd->lex->found_colon-thd->query); +#endif + ulong length= thd->query_length-(ulong)(packet-thd->query); /* Remove garbage at start of query */ while (my_isspace(thd->charset(), *packet) && length > 0) @@ -1414,7 +1417,13 @@ bool dispatch_command(enum enum_server_command command, THD *thd, VOID(pthread_mutex_lock(&LOCK_thread_count)); thd->query_id= query_id++; VOID(pthread_mutex_unlock(&LOCK_thread_count)); +#ifndef EMBEDDED_LIBRARY mysql_parse(thd, packet, length); +#else + thd->query_rest= (char*)memdup_mysql(thd->mysql, packet, length); + thd->query_rest_length= length; + break; +#endif /*EMBEDDED_LIBRARY*/ } if (!(specialflag & SPECIAL_NO_PRIOR)) |