MySQL:如何编写Information Schema Plugin(10)
#include <mysql_priv.h>
#include <mysql/plugin.h>
#include <my_global.h>
#include <mysql_version.h>
#include <my_dir.h>
/*创建一个子类,query_cache的成员queries为私有变量
class Accessible_Query_Cache : privateQuery_cache {
public:
HASH *get_queries()
{
return &this->queries; //&query_cache.queries;
}
};
bool schema_table_store_record(THD *thd,TABLE *table);
#define MAX_STATEMENT_TEXT_LENGTH 32767
#define COLUMN_STATEMENT_ID 0
#define COLUMN_SCHEMA_NAME 1
#define COLUMN_STATEMENT_TEXT 2
#define COLUMN_RESULT_BLOCKS_COUNT 3
#define COLUMN_RESULT_BLOCKS_SIZE 4
#define COLUMN_RESULT_BLOCKS_SIZE_USED 5
/* 定义表结构*/
ST_FIELD_INFOmysql_is_cached_queries_fields[]=
{
{"STATEMENT_ID", 21, MYSQL_TYPE_LONG, 0, 0, "Id"},
{"SCHEMA_NAME", 64, MYSQL_TYPE_STRING, 0, 0,"Schema"},
{"STATEMENT_TEXT", MAX_STATEMENT_TEXT_LENGTH,MYSQL_TYPE_STRING, 0, 0, "Statment text"},
{"RESULT_BLOCKS_COUNT", 21, MYSQL_TYPE_LONG, 0, 0, "CountResult Blocks"},
{"RESULT_BLOCKS_SIZE", 21, MYSQL_TYPE_LONGLONG, 0, 0,"Size Result Blocks"},
{"RESULT_BLOCKS_SIZE_USED", 21, MYSQL_TYPE_LONGLONG, 0, 0,"Size Used Result Blocks"},
{0,0, MYSQL_TYPE_STRING, 0, 0, 0}
};
/*填充数据函数*/
static intmysql_is_cached_queries_fill_table(THD *thd, TABLE_LIST *tables, COND *cond)
{
intstatus;
CHARSET_INFO *scs= system_charset_info; /* need this to store field into table */
TABLE *table= (TABLE *)tables->table;
Accessible_Query_Cache *qc;
HASH *queries;
const uchar *query_cache_block_raw;
Query_cache_block* query_cache_block;
Query_cache_query* query_cache_query;
uint result_blocks_count;
ulonglong result_blocks_size;
ulonglong result_blocks_size_used;
Query_cache_block *first_result_block;
Query_cache_block *result_block;
const char *statement_text;
size_t statement_text_length;
相关新闻>>
- 发表评论
-
- 最新评论 更多>>