diff options
-rw-r--r-- | include/mysql.h | 1 | ||||
-rw-r--r-- | libmysql/client_settings.h | 1 | ||||
-rw-r--r-- | libmysql/libmysql.c | 17 | ||||
-rw-r--r-- | libmysqld/lib_sql.cc | 12 | ||||
-rw-r--r-- | sql-common/client.c | 3 | ||||
-rw-r--r-- | sql/sql_parse.cc | 10 |
6 files changed, 33 insertions, 11 deletions
diff --git a/include/mysql.h b/include/mysql.h index 95f480b41c1..9a8d2b07220 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -565,6 +565,7 @@ typedef struct st_mysql_methods MYSQL_DATA *(STDCALL *read_binary_rows)(MYSQL_STMT *stmt); int (STDCALL *unbuffered_fetch)(MYSQL *mysql, char **row); void (STDCALL *free_embedded_thd)(MYSQL *mysql); + const char *(STDCALL *read_statistic)(MYSQL *mysql); #endif } MYSQL_METHODS; diff --git a/libmysql/client_settings.h b/libmysql/client_settings.h index d0432503ee9..b9c47c1dd55 100644 --- a/libmysql/client_settings.h +++ b/libmysql/client_settings.h @@ -57,3 +57,4 @@ MYSQL_DATA *cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, int STDCALL cli_stmt_execute(MYSQL_STMT *stmt); MYSQL_DATA *cli_read_binary_rows(MYSQL_STMT *stmt); int STDCALL cli_unbuffered_fetch(MYSQL *mysql, char **row); +const char * STDCALL cli_read_statistic(MYSQL *mysql); diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 3efce367cae..0e937a6e0c9 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -1102,12 +1102,8 @@ mysql_dump_debug_info(MYSQL *mysql) DBUG_RETURN(simple_command(mysql,COM_DEBUG,0,0,0)); } -const char * STDCALL -mysql_stat(MYSQL *mysql) +const char * STDCALL cli_read_statistic(MYSQL *mysql) { - DBUG_ENTER("mysql_stat"); - if (simple_command(mysql,COM_STATISTICS,0,0,0)) - return mysql->net.last_error; mysql->net.read_pos[mysql->packet_length]=0; /* End of stat string */ if (!mysql->net.read_pos[0]) { @@ -1116,7 +1112,16 @@ mysql_stat(MYSQL *mysql) strmov(mysql->net.last_error, ER(mysql->net.last_errno)); return mysql->net.last_error; } - DBUG_RETURN((char*) mysql->net.read_pos); + return (char*) mysql->net.read_pos; +} + +const char * STDCALL +mysql_stat(MYSQL *mysql) +{ + DBUG_ENTER("mysql_stat"); + if (simple_command(mysql,COM_STATISTICS,0,0,0)) + return mysql->net.last_error; + DBUG_RETURN((*mysql->methods->read_statistic)(mysql)); } diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index ddfd05d64b6..e70f34397d6 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -217,9 +217,16 @@ static void STDCALL emb_free_embedded_thd(MYSQL *mysql) THD *thd= (THD*)mysql->thd; if (thd->data) free_rows(thd->data); + thread_count--; delete thd; } +static const char * STDCALL emb_read_statistic(MYSQL *mysql) +{ + THD *thd= (THD*)mysql->thd; + return thd->net.last_error; +} + MYSQL_METHODS embedded_methods= { emb_mysql_read_query_result, @@ -232,7 +239,8 @@ MYSQL_METHODS embedded_methods= emb_stmt_execute, emb_read_binary_rows, emb_unbuffered_fetch, - emb_free_embedded_thd + emb_free_embedded_thd, + emb_read_statistic }; C_MODE_END @@ -431,6 +439,7 @@ void init_embedded_mysql(MYSQL *mysql, int client_flag, char *db) { THD *thd = (THD *)mysql->thd; thd->mysql= mysql; + mysql->server_version= server_version; } void *create_embedded_thd(int client_flag, char *db) @@ -465,6 +474,7 @@ void *create_embedded_thd(int client_flag, char *db) thd->data= 0; + thread_count++; return thd; } diff --git a/sql-common/client.c b/sql-common/client.c index 77aa733fe0c..cedfac67328 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -1410,7 +1410,8 @@ static MYSQL_METHODS client_methods= cli_stmt_execute, cli_read_binary_rows, cli_unbuffered_fetch, - NULL + NULL, + cli_read_statistic #endif }; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index b0dd2437fd7..978099ae04a 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1473,12 +1473,15 @@ bool dispatch_command(enum enum_server_command command, THD *thd, error=TRUE; break; #endif -#ifndef EMBEDDED_LIBRARY case COM_STATISTICS: { mysql_log.write(thd,command,NullS); statistic_increment(com_stat[SQLCOM_SHOW_STATUS],&LOCK_status); +#ifndef EMBEDDED_LIBRARY char buff[200]; +#else + char *buff= thd->net.last_error; +#endif ulong uptime = (ulong) (thd->start_time - start_time); sprintf((char*) buff, "Uptime: %ld Threads: %d Questions: %lu Slow queries: %ld Opens: %ld Flush tables: %ld Open tables: %u Queries per second avg: %.3f", @@ -1491,12 +1494,13 @@ bool dispatch_command(enum enum_server_command command, THD *thd, sprintf(strend(buff), " Memory in use: %ldK Max memory used: %ldK", (sf_malloc_cur_memory+1023L)/1024L, (sf_malloc_max_memory+1023L)/1024L); - #endif +#endif +#ifndef EMBEDDED_LIBRARY VOID(my_net_write(net, buff,(uint) strlen(buff))); VOID(net_flush(net)); +#endif break; } -#endif case COM_PING: statistic_increment(com_other,&LOCK_status); send_ok(thd); // Tell client we are alive |