mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
include/mysql.h: read_statistic added to virtual methods libmysql/client_settings.h: interface for cli_read_statistic added libmysql/libmysql.c: read_statistic and mysql_stat code changes libmysqld/lib_sql.cc: emb_read_statistic implemented server_version initialized sql-common/client.c: cli_read_statistic added to the table sql/sql_parse.cc: storage of result of COM_STATISTIC changed in embedded library
This commit is contained in:
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
};
|
||||
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user