Commit 87432c7c authored by unknown's avatar unknown

WL 2059 Engine-specific status variables framework and WL 1922

InnoDB status variables


innobase/buf/buf0buf.c:
  Added function to get the number of latched pages
innobase/buf/buf0flu.c:
  Added support for dblwr_pages_written, dblwr_writes and
  buffer_pool_pages_flushed status variables
innobase/buf/buf0lru.c:
  Added support for _buffer_pool_wait_free status variable
innobase/buf/buf0rea.c:
  Added support for buffer_pool_read_ahead_rnd, buffer_pool_read_ahead_seq
  and srv_buf_pool_reads status variables
innobase/fil/fil0fil.c:
  Added support for os_log_fsyncs, data_read, and data_written
innobase/include/buf0buf.h:
  Functions and variables needed for new status variables declared
innobase/include/buf0flu.ic:
  Added support for buffer_pool_write_requests status variable
innobase/include/fil0fil.h:
  Variable declared
innobase/include/os0file.h:
  Declared several variabled
innobase/include/srv0srv.h:
  Declared all new variables needed for InnoDB status variables
innobase/log/log0log.c:
  Added support for various log-related status variables
innobase/os/os0file.c:
  Added support for pending_writes, pending_reads status variables
innobase/srv/srv0srv.c:
  Added internal counters and function to accumulate information for
  InnoDB status variables
mysql-test/r/innodb.result:
  result fot the test
mysql-test/t/innodb.test:
  We have tests only for few variables, as we cannot predict value for
  most of the added variables. It depends on the system load, OS, HDD
  e.t.c Thus, we cannot test them with mysql-test.
sql/ha_innodb.cc:
  Added an array for InnoDB status variables. This is part of the
  WL2059 Engine-specific status variables framework
sql/ha_innodb.h:
  Declared status variables array and the function to refresh statistics
sql/handler.cc:
  Added function to get statistics
sql/handler.h:
  Declared function to update handlers statistics
sql/mysql_priv.h:
  declared opt_innodb to see it from handlers
sql/mysqld.cc:
  Don't include Innodb_*  status variables into "show status" if we
  are compiling without InnoDB
sql/sql_show.cc:
  mysqld_show modified and split into two parts to support enclosed
  arrays in the show_var_st structure. This is a part of
  WL2059 Engine-specific status variables framework.
sql/structs.h:
  Added new value to mark enclosed array in the status variables array
parent 00113f4a
...@@ -2136,6 +2136,30 @@ buf_print(void) ...@@ -2136,6 +2136,30 @@ buf_print(void)
ut_a(buf_validate()); ut_a(buf_validate());
} }
/*************************************************************************
Returns the number of latched pages in the buffer pool. */
ulint
buf_get_latched_pages_number(void)
{
buf_block_t* block;
ulint i;
ulint fixed_pages_number = 0;
mutex_enter(&(buf_pool->mutex));
for (i = 0; i < buf_pool->curr_size; i++) {
block = buf_pool_get_nth_block(buf_pool, i);
if ((block->buf_fix_count != 0) || (block->io_fix != 0))
fixed_pages_number++;
}
mutex_exit(&(buf_pool->mutex));
return fixed_pages_number;
}
/************************************************************************* /*************************************************************************
Returns the number of pending buf pool ios. */ Returns the number of pending buf pool ios. */
......
...@@ -273,6 +273,10 @@ buf_flush_buffered_writes(void) ...@@ -273,6 +273,10 @@ buf_flush_buffered_writes(void)
} }
} }
/* increment the doublewrite flushed pages counter */
srv_dblwr_pages_written+= trx_doublewrite->first_free;
srv_dblwr_writes++;
if (trx_doublewrite->first_free > TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) { if (trx_doublewrite->first_free > TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) {
len = TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE; len = TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE;
} else { } else {
...@@ -901,6 +905,9 @@ buf_flush_batch( ...@@ -901,6 +905,9 @@ buf_flush_batch(
(ulong) page_count); (ulong) page_count);
} }
if (page_count != ULINT_UNDEFINED)
srv_buf_pool_flushed+= page_count;
return(page_count); return(page_count);
} }
......
...@@ -432,6 +432,7 @@ buf_LRU_get_free_block(void) ...@@ -432,6 +432,7 @@ buf_LRU_get_free_block(void)
/* No free block was found: try to flush the LRU list */ /* No free block was found: try to flush the LRU list */
buf_flush_free_margin(); buf_flush_free_margin();
++srv_buf_pool_wait_free;
os_aio_simulated_wake_handler_threads(); os_aio_simulated_wake_handler_threads();
......
...@@ -20,6 +20,10 @@ Created 11/5/1995 Heikki Tuuri ...@@ -20,6 +20,10 @@ Created 11/5/1995 Heikki Tuuri
#include "os0file.h" #include "os0file.h"
#include "srv0start.h" #include "srv0start.h"
extern ulint srv_read_ahead_rnd;
extern ulint srv_read_ahead_seq;
extern ulint srv_buf_pool_reads;
/* The size in blocks of the area where the random read-ahead algorithm counts /* The size in blocks of the area where the random read-ahead algorithm counts
the accessed pages when deciding whether to read-ahead */ the accessed pages when deciding whether to read-ahead */
#define BUF_READ_AHEAD_RANDOM_AREA BUF_READ_AHEAD_AREA #define BUF_READ_AHEAD_RANDOM_AREA BUF_READ_AHEAD_AREA
...@@ -291,6 +295,7 @@ buf_read_ahead_random( ...@@ -291,6 +295,7 @@ buf_read_ahead_random(
(ulong) count); (ulong) count);
} }
++srv_read_ahead_rnd;
return(count); return(count);
} }
...@@ -323,6 +328,7 @@ buf_read_page( ...@@ -323,6 +328,7 @@ buf_read_page(
count2 = buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space, count2 = buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space,
tablespace_version, offset); tablespace_version, offset);
srv_buf_pool_reads+= count2;
if (err == DB_TABLESPACE_DELETED) { if (err == DB_TABLESPACE_DELETED) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
...@@ -575,6 +581,7 @@ buf_read_ahead_linear( ...@@ -575,6 +581,7 @@ buf_read_ahead_linear(
(ulong) space, (ulong) offset, (ulong) count); (ulong) space, (ulong) offset, (ulong) count);
} }
++srv_read_ahead_seq;
return(count); return(count);
} }
......
...@@ -88,6 +88,9 @@ but in the MySQL Embedded Server Library and ibbackup it is not the default ...@@ -88,6 +88,9 @@ but in the MySQL Embedded Server Library and ibbackup it is not the default
directory, and we must set the base file path explicitly */ directory, and we must set the base file path explicitly */
const char* fil_path_to_mysql_datadir = "."; const char* fil_path_to_mysql_datadir = ".";
/* The number of fsyncs done to the log */
ulint fil_n_log_flushes = 0;
ulint fil_n_pending_log_flushes = 0; ulint fil_n_pending_log_flushes = 0;
ulint fil_n_pending_tablespace_flushes = 0; ulint fil_n_pending_tablespace_flushes = 0;
...@@ -3671,6 +3674,12 @@ fil_io( ...@@ -3671,6 +3674,12 @@ fil_io(
mode = OS_AIO_NORMAL; mode = OS_AIO_NORMAL;
} }
if (type == OS_FILE_READ) {
srv_data_read+= len;
} else if (type == OS_FILE_WRITE) {
srv_data_written+= len;
}
/* Reserve the fil_system mutex and make sure that we can open at /* Reserve the fil_system mutex and make sure that we can open at
least one file while holding it, if the file is not already open */ least one file while holding it, if the file is not already open */
...@@ -3956,6 +3965,7 @@ fil_flush( ...@@ -3956,6 +3965,7 @@ fil_flush(
fil_n_pending_tablespace_flushes++; fil_n_pending_tablespace_flushes++;
} else { } else {
fil_n_pending_log_flushes++; fil_n_pending_log_flushes++;
fil_n_log_flushes++;
} }
#ifdef __WIN__ #ifdef __WIN__
if (node->is_raw_disk) { if (node->is_raw_disk) {
......
...@@ -58,6 +58,8 @@ extern buf_pool_t* buf_pool; /* The buffer pool of the database */ ...@@ -58,6 +58,8 @@ extern buf_pool_t* buf_pool; /* The buffer pool of the database */
extern ibool buf_debug_prints;/* If this is set TRUE, the program extern ibool buf_debug_prints;/* If this is set TRUE, the program
prints info whenever read or flush prints info whenever read or flush
occurs */ occurs */
extern ulint srv_buf_pool_write_requests; /* variable to count write request
issued */
/************************************************************************ /************************************************************************
Creates the buffer pool. */ Creates the buffer pool. */
...@@ -497,6 +499,12 @@ void ...@@ -497,6 +499,12 @@ void
buf_print(void); buf_print(void);
/*============*/ /*============*/
/************************************************************************* /*************************************************************************
Returns the number of latched pages in the buffer pool. */
ulint
buf_get_latched_pages_number(void);
/*==============================*/
/*************************************************************************
Returns the number of pending buf pool ios. */ Returns the number of pending buf pool ios. */
ulint ulint
......
...@@ -61,6 +61,8 @@ buf_flush_note_modification( ...@@ -61,6 +61,8 @@ buf_flush_note_modification(
ut_ad(ut_dulint_cmp(block->oldest_modification, ut_ad(ut_dulint_cmp(block->oldest_modification,
mtr->start_lsn) <= 0); mtr->start_lsn) <= 0);
} }
++srv_buf_pool_write_requests;
} }
/************************************************************************ /************************************************************************
......
...@@ -89,6 +89,8 @@ extern fil_addr_t fil_addr_null; ...@@ -89,6 +89,8 @@ extern fil_addr_t fil_addr_null;
#define FIL_TABLESPACE 501 #define FIL_TABLESPACE 501
#define FIL_LOG 502 #define FIL_LOG 502
extern ulint fil_n_log_flushes;
extern ulint fil_n_pending_log_flushes; extern ulint fil_n_pending_log_flushes;
extern ulint fil_n_pending_tablespace_flushes; extern ulint fil_n_pending_tablespace_flushes;
......
...@@ -24,6 +24,9 @@ extern ibool os_aio_print_debug; ...@@ -24,6 +24,9 @@ extern ibool os_aio_print_debug;
extern ulint os_file_n_pending_preads; extern ulint os_file_n_pending_preads;
extern ulint os_file_n_pending_pwrites; extern ulint os_file_n_pending_pwrites;
extern ulint os_n_pending_reads;
extern ulint os_n_pending_writes;
#ifdef __WIN__ #ifdef __WIN__
/* We define always WIN_ASYNC_IO, and check at run-time whether /* We define always WIN_ASYNC_IO, and check at run-time whether
......
...@@ -184,6 +184,63 @@ i/o handler thread */ ...@@ -184,6 +184,63 @@ i/o handler thread */
extern const char* srv_io_thread_op_info[]; extern const char* srv_io_thread_op_info[];
extern const char* srv_io_thread_function[]; extern const char* srv_io_thread_function[];
/* the number of the log write requests done */
extern ulint srv_log_write_requests;
/* the number of physical writes to the log performed */
extern ulint srv_log_writes;
/* amount of data written to the log files in bytes */
extern ulint srv_os_log_written;
/* amount of writes being done to the log files */
extern ulint srv_os_log_pending_writes;
/* we increase this counter, when there we don't have enough space in the
log buffer and have to flush it */
extern ulint srv_log_waits;
/* variable that counts amount of data read in total (in bytes) */
extern ulint srv_data_read;
/* here we count the amount of data written in total (in bytes) */
extern ulint srv_data_written;
/* this variable counts the amount of times, when the doublewrite buffer
was flushed */
extern ulint srv_dblwr_writes;
/* here we store the number of pages that have been flushed to the
doublewrite buffer */
extern ulint srv_dblwr_pages_written;
/* in this variable we store the number of write requests issued */
extern ulint srv_buf_pool_write_requests;
/* here we store the number of times when we had to wait for a free page
in the buffer pool. It happens when the buffer pool is full and we need
to make a flush, in order to be able to read or create a page. */
extern ulint srv_buf_pool_wait_free;
/* variable to count the number of pages that were written from the
buffer pool to disk */
extern ulint srv_buf_pool_flushed;
/* variable to count the number of buffer pool reads that led to the
reading of a disk page */
extern ulint srv_buf_pool_reads;
/* variable to count the number of sequential read-aheads were done */
extern ulint srv_read_ahead_seq;
/* variable to count the number of random read-aheads were done */
extern ulint srv_read_ahead_rnd;
/* In this structure we store status variables to be passed to MySQL */
typedef struct export_var_struct export_struc;
extern export_struc export_vars;
typedef struct srv_sys_struct srv_sys_t; typedef struct srv_sys_struct srv_sys_t;
/* The server system */ /* The server system */
...@@ -400,7 +457,12 @@ void ...@@ -400,7 +457,12 @@ void
srv_printf_innodb_monitor( srv_printf_innodb_monitor(
/*======================*/ /*======================*/
FILE* file); /* in: output stream */ FILE* file); /* in: output stream */
/************************************************************************
Function to pass InnoDB status variables to MySQL */
void
srv_export_innodb_status(void);
/*=====================*/
/* Types for the threads existing in the system. Threads of types 4 - 9 /* Types for the threads existing in the system. Threads of types 4 - 9
are called utility threads. Note that utility threads are mainly disk are called utility threads. Note that utility threads are mainly disk
...@@ -426,6 +488,48 @@ typedef struct srv_slot_struct srv_slot_t; ...@@ -426,6 +488,48 @@ typedef struct srv_slot_struct srv_slot_t;
/* Thread table is an array of slots */ /* Thread table is an array of slots */
typedef srv_slot_t srv_table_t; typedef srv_slot_t srv_table_t;
/* In this structure we store status variables to be passed to MySQL */
struct export_var_struct{
ulint innodb_data_pending_reads;
ulint innodb_data_pending_writes;
ulint innodb_data_pending_fsyncs;
ulint innodb_data_fsyncs;
ulint innodb_data_read;
ulint innodb_data_writes;
ulint innodb_data_written;
ulint innodb_data_reads;
ulint innodb_buffer_pool_pages_total;
ulint innodb_buffer_pool_pages_data;
ulint innodb_buffer_pool_pages_dirty;
ulint innodb_buffer_pool_pages_misc;
ulint innodb_buffer_pool_pages_free;
ulint innodb_buffer_pool_pages_latched;
ulint innodb_buffer_pool_read_requests;
ulint innodb_buffer_pool_reads;
ulint innodb_buffer_pool_wait_free;
ulint innodb_buffer_pool_pages_flushed;
ulint innodb_buffer_pool_write_requests;
ulint innodb_buffer_pool_read_ahead_seq;
ulint innodb_buffer_pool_read_ahead_rnd;
ulint innodb_dblwr_pages_written;
ulint innodb_dblwr_writes;
ulint innodb_log_waits;
ulint innodb_log_write_requests;
ulint innodb_log_writes;
ulint innodb_os_log_written;
ulint innodb_os_log_fsyncs;
ulint innodb_os_log_pending_writes;
ulint innodb_os_log_pending_fsyncs;
ulint innodb_page_size;
ulint innodb_pages_created;
ulint innodb_pages_read;
ulint innodb_pages_written;
ulint innodb_rows_read;
ulint innodb_rows_inserted;
ulint innodb_rows_updated;
ulint innodb_rows_deleted;
};
/* The server system struct */ /* The server system struct */
struct srv_sys_struct{ struct srv_sys_struct{
os_event_t operational; /* created threads must wait for the os_event_t operational; /* created threads must wait for the
......
...@@ -190,6 +190,8 @@ log_reserve_and_open( ...@@ -190,6 +190,8 @@ log_reserve_and_open(
log_buffer_flush_to_disk(); log_buffer_flush_to_disk();
srv_log_waits++;
ut_ad(++count < 50); ut_ad(++count < 50);
goto loop; goto loop;
...@@ -292,6 +294,8 @@ log_write_low( ...@@ -292,6 +294,8 @@ log_write_low(
if (str_len > 0) { if (str_len > 0) {
goto part_loop; goto part_loop;
} }
srv_log_write_requests++;
} }
/**************************************************************** /****************************************************************
...@@ -1112,11 +1116,15 @@ log_group_file_header_flush( ...@@ -1112,11 +1116,15 @@ log_group_file_header_flush(
if (log_do_write) { if (log_do_write) {
log_sys->n_log_ios++; log_sys->n_log_ios++;
srv_os_log_pending_writes++;
fil_io(OS_FILE_WRITE | OS_FILE_LOG, TRUE, group->space_id, fil_io(OS_FILE_WRITE | OS_FILE_LOG, TRUE, group->space_id,
dest_offset / UNIV_PAGE_SIZE, dest_offset / UNIV_PAGE_SIZE,
dest_offset % UNIV_PAGE_SIZE, dest_offset % UNIV_PAGE_SIZE,
OS_FILE_LOG_BLOCK_SIZE, OS_FILE_LOG_BLOCK_SIZE,
buf, group); buf, group);
srv_os_log_pending_writes--;
} }
} }
...@@ -1181,6 +1189,8 @@ log_group_write_buf( ...@@ -1181,6 +1189,8 @@ log_group_write_buf(
log_group_file_header_flush(group, log_group_file_header_flush(group,
next_offset / group->file_size, start_lsn); next_offset / group->file_size, start_lsn);
srv_os_log_written+= OS_FILE_LOG_BLOCK_SIZE;
srv_log_writes++;
} }
if ((next_offset % group->file_size) + len > group->file_size) { if ((next_offset % group->file_size) + len > group->file_size) {
...@@ -1225,9 +1235,16 @@ log_group_write_buf( ...@@ -1225,9 +1235,16 @@ log_group_write_buf(
if (log_do_write) { if (log_do_write) {
log_sys->n_log_ios++; log_sys->n_log_ios++;
srv_os_log_pending_writes++;
fil_io(OS_FILE_WRITE | OS_FILE_LOG, TRUE, group->space_id, fil_io(OS_FILE_WRITE | OS_FILE_LOG, TRUE, group->space_id,
next_offset / UNIV_PAGE_SIZE, next_offset / UNIV_PAGE_SIZE,
next_offset % UNIV_PAGE_SIZE, write_len, buf, group); next_offset % UNIV_PAGE_SIZE, write_len, buf, group);
srv_os_log_pending_writes--;
srv_os_log_written+= write_len;
srv_log_writes++;
} }
if (write_len < len) { if (write_len < len) {
......
...@@ -155,6 +155,10 @@ os_mutex_t os_file_count_mutex; ...@@ -155,6 +155,10 @@ os_mutex_t os_file_count_mutex;
ulint os_file_n_pending_preads = 0; ulint os_file_n_pending_preads = 0;
ulint os_file_n_pending_pwrites = 0; ulint os_file_n_pending_pwrites = 0;
/* These are not protected by any mutex */
ulint os_n_pending_writes = 0;
ulint os_n_pending_reads = 0;
/*************************************************************************** /***************************************************************************
Gets the operating system version. Currently works only on Windows. */ Gets the operating system version. Currently works only on Windows. */
...@@ -1987,8 +1991,12 @@ os_file_read( ...@@ -1987,8 +1991,12 @@ os_file_read(
goto error_handling; goto error_handling;
} }
os_n_pending_reads++;
ret = ReadFile(file, buf, n, &len, NULL); ret = ReadFile(file, buf, n, &len, NULL);
os_n_pending_reads--;
os_mutex_exit(os_file_seek_mutexes[i]); os_mutex_exit(os_file_seek_mutexes[i]);
if (ret && len == n) { if (ret && len == n) {
...@@ -2001,8 +2009,12 @@ os_file_read( ...@@ -2001,8 +2009,12 @@ os_file_read(
os_bytes_read_since_printout += n; os_bytes_read_since_printout += n;
try_again: try_again:
os_n_pending_reads++;
ret = os_file_pread(file, buf, n, offset, offset_high); ret = os_file_pread(file, buf, n, offset, offset_high);
os_n_pending_reads--;
if ((ulint)ret == n) { if ((ulint)ret == n) {
return(TRUE); return(TRUE);
...@@ -2090,8 +2102,12 @@ os_file_read_no_error_handling( ...@@ -2090,8 +2102,12 @@ os_file_read_no_error_handling(
goto error_handling; goto error_handling;
} }
os_n_pending_reads++;
ret = ReadFile(file, buf, n, &len, NULL); ret = ReadFile(file, buf, n, &len, NULL);
os_n_pending_reads--;
os_mutex_exit(os_file_seek_mutexes[i]); os_mutex_exit(os_file_seek_mutexes[i]);
if (ret && len == n) { if (ret && len == n) {
...@@ -2104,8 +2120,12 @@ os_file_read_no_error_handling( ...@@ -2104,8 +2120,12 @@ os_file_read_no_error_handling(
os_bytes_read_since_printout += n; os_bytes_read_since_printout += n;
try_again: try_again:
os_n_pending_reads++;
ret = os_file_pread(file, buf, n, offset, offset_high); ret = os_file_pread(file, buf, n, offset, offset_high);
os_n_pending_reads--;
if ((ulint)ret == n) { if ((ulint)ret == n) {
return(TRUE); return(TRUE);
...@@ -2187,7 +2207,11 @@ os_file_write( ...@@ -2187,7 +2207,11 @@ os_file_write(
return(FALSE); return(FALSE);
} }
os_n_pending_writes++;
ret = WriteFile(file, buf, n, &len, NULL); ret = WriteFile(file, buf, n, &len, NULL);
os_n_pending_writes--;
/* Always do fsync to reduce the probability that when the OS crashes, /* Always do fsync to reduce the probability that when the OS crashes,
a database page is only partially physically written to disk. */ a database page is only partially physically written to disk. */
...@@ -2248,8 +2272,12 @@ os_file_write( ...@@ -2248,8 +2272,12 @@ os_file_write(
#else #else
ssize_t ret; ssize_t ret;
os_n_pending_writes++;
ret = os_file_pwrite(file, buf, n, offset, offset_high); ret = os_file_pwrite(file, buf, n, offset, offset_high);
os_n_pending_writes--;
if ((ulint)ret == n) { if ((ulint)ret == n) {
return(TRUE); return(TRUE);
......
...@@ -186,6 +186,61 @@ that during a time of heavy update/insert activity. */ ...@@ -186,6 +186,61 @@ that during a time of heavy update/insert activity. */
ulint srv_max_buf_pool_modified_pct = 90; ulint srv_max_buf_pool_modified_pct = 90;
/* variable counts amount of data read in total (in bytes) */
ulint srv_data_read = 0;
/* here we count the amount of data written in total (in bytes) */
ulint srv_data_written = 0;
/* the number of the log write requests done */
ulint srv_log_write_requests = 0;
/* the number of physical writes to the log performed */
ulint srv_log_writes = 0;
/* amount of data written to the log files in bytes */
ulint srv_os_log_written = 0;
/* amount of writes being done to the log files */
ulint srv_os_log_pending_writes = 0;
/* we increase this counter, when there we don't have enough space in the
log buffer and have to flush it */
ulint srv_log_waits = 0;
/* this variable counts the amount of times, when the doublewrite buffer
was flushed */
ulint srv_dblwr_writes = 0;
/* here we store the number of pages that have been flushed to the
doublewrite buffer */
ulint srv_dblwr_pages_written = 0;
/* in this variable we store the number of write requests issued */
ulint srv_buf_pool_write_requests = 0;
/* here we store the number of times when we had to wait for a free page
in the buffer pool. It happens when the buffer pool is full and we need
to make a flush, in order to be able to read or create a page. */
ulint srv_buf_pool_wait_free = 0;
/* variable to count the number of pages that were written from buffer
pool to the disk */
ulint srv_buf_pool_flushed = 0;
/* variable to count the number of buffer pool reads that led to the
reading of a disk page */
ulint srv_buf_pool_reads = 0;
/* variable to count the number of sequential read-aheads */
ulint srv_read_ahead_seq = 0;
/* variable to count the number of random read-aheads */
ulint srv_read_ahead_rnd = 0;
/* structure to pass status variables to MySQL */
export_struc export_vars;
/* If the following is != 0 we do not allow inserts etc. This protects /* If the following is != 0 we do not allow inserts etc. This protects
the user from forgetting the innodb_force_recovery keyword to my.cnf */ the user from forgetting the innodb_force_recovery keyword to my.cnf */
...@@ -1619,6 +1674,57 @@ srv_printf_innodb_monitor( ...@@ -1619,6 +1674,57 @@ srv_printf_innodb_monitor(
fflush(file); fflush(file);
} }
/**********************************************************************
Function to pass InnoDB status variables to MySQL */
void
srv_export_innodb_status(void)
{
mutex_enter(&srv_innodb_monitor_mutex);
export_vars.innodb_data_pending_reads= os_n_pending_reads;
export_vars.innodb_data_pending_writes= os_n_pending_writes;
export_vars.innodb_data_pending_fsyncs=
fil_n_pending_log_flushes + fil_n_pending_tablespace_flushes;
export_vars.innodb_data_fsyncs= os_n_fsyncs;
export_vars.innodb_data_read= srv_data_read;
export_vars.innodb_data_reads= os_n_file_reads;
export_vars.innodb_data_writes= os_n_file_writes;
export_vars.innodb_data_written= srv_data_written;
export_vars.innodb_buffer_pool_read_requests= buf_pool->n_page_gets;
export_vars.innodb_buffer_pool_write_requests= srv_buf_pool_write_requests;
export_vars.innodb_buffer_pool_wait_free= srv_buf_pool_wait_free;
export_vars.innodb_buffer_pool_pages_flushed= srv_buf_pool_flushed;
export_vars.innodb_buffer_pool_reads= srv_buf_pool_reads;
export_vars.innodb_buffer_pool_read_ahead_rnd= srv_read_ahead_rnd;
export_vars.innodb_buffer_pool_read_ahead_seq= srv_read_ahead_seq;
export_vars.innodb_buffer_pool_pages_data= UT_LIST_GET_LEN(buf_pool->LRU);
export_vars.innodb_buffer_pool_pages_dirty= UT_LIST_GET_LEN(buf_pool->flush_list);
export_vars.innodb_buffer_pool_pages_free= UT_LIST_GET_LEN(buf_pool->free);
export_vars.innodb_buffer_pool_pages_latched= buf_get_latched_pages_number();
export_vars.innodb_buffer_pool_pages_total= buf_pool->curr_size;
export_vars.innodb_buffer_pool_pages_misc= buf_pool->max_size -
UT_LIST_GET_LEN(buf_pool->LRU) - UT_LIST_GET_LEN(buf_pool->free);
export_vars.innodb_page_size= UNIV_PAGE_SIZE;
export_vars.innodb_log_waits= srv_log_waits;
export_vars.innodb_os_log_written= srv_os_log_written;
export_vars.innodb_os_log_fsyncs= fil_n_log_flushes;
export_vars.innodb_os_log_pending_fsyncs= fil_n_pending_log_flushes;
export_vars.innodb_os_log_pending_writes= srv_os_log_pending_writes;
export_vars.innodb_log_write_requests= srv_log_write_requests;
export_vars.innodb_log_writes= srv_log_writes;
export_vars.innodb_dblwr_pages_written= srv_dblwr_pages_written;
export_vars.innodb_dblwr_writes= srv_dblwr_writes;
export_vars.innodb_pages_created= buf_pool->n_pages_created;
export_vars.innodb_pages_read= buf_pool->n_pages_read;
export_vars.innodb_pages_written= buf_pool->n_pages_written;
export_vars.innodb_rows_read= srv_n_rows_read;
export_vars.innodb_rows_inserted= srv_n_rows_inserted;
export_vars.innodb_rows_updated= srv_n_rows_updated;
export_vars.innodb_rows_deleted= srv_n_rows_deleted;
mutex_exit(&srv_innodb_monitor_mutex);
}
/************************************************************************* /*************************************************************************
A thread which wakes up threads whose lock wait may have lasted too long. A thread which wakes up threads whose lock wait may have lasted too long.
This also prints the info output by various InnoDB monitors. */ This also prints the info output by various InnoDB monitors. */
......
...@@ -1664,3 +1664,21 @@ select count(*) from t1 where x = 18446744073709551601; ...@@ -1664,3 +1664,21 @@ select count(*) from t1 where x = 18446744073709551601;
count(*) count(*)
1 1
drop table t1; drop table t1;
show status like "Innodb_buffer_pool_pages_total";
Variable_name Value
Innodb_buffer_pool_pages_total 512
show status like "Innodb_page_size";
Variable_name Value
Innodb_page_size 16384
show status like "Innodb_rows_deleted";
Variable_name Value
Innodb_rows_deleted 2078
show status like "Innodb_rows_inserted";
Variable_name Value
Innodb_rows_inserted 31706
show status like "Innodb_rows_read";
Variable_name Value
Innodb_rows_read 80161
show status like "Innodb_rows_updated";
Variable_name Value
Innodb_rows_updated 29530
...@@ -1180,3 +1180,11 @@ select count(*) from t1 where x = 18446744073709551601; ...@@ -1180,3 +1180,11 @@ select count(*) from t1 where x = 18446744073709551601;
drop table t1; drop table t1;
# Test for testable InnoDB status variables. This test
# uses previous ones(pages_created, rows_deleted, ...).
show status like "Innodb_buffer_pool_pages_total";
show status like "Innodb_page_size";
show status like "Innodb_rows_deleted";
show status like "Innodb_rows_inserted";
show status like "Innodb_rows_read";
show status like "Innodb_rows_updated";
...@@ -149,6 +149,85 @@ static mysql_byte* innobase_get_key(INNOBASE_SHARE *share,uint *length, ...@@ -149,6 +149,85 @@ static mysql_byte* innobase_get_key(INNOBASE_SHARE *share,uint *length,
static INNOBASE_SHARE *get_share(const char *table_name); static INNOBASE_SHARE *get_share(const char *table_name);
static void free_share(INNOBASE_SHARE *share); static void free_share(INNOBASE_SHARE *share);
struct show_var_st innodb_status_variables[]= {
{"buffer_pool_pages_data",
(char*) &export_vars.innodb_buffer_pool_pages_data, SHOW_LONG},
{"buffer_pool_pages_dirty",
(char*) &export_vars.innodb_buffer_pool_pages_dirty, SHOW_LONG},
{"buffer_pool_pages_flushed",
(char*) &export_vars.innodb_buffer_pool_pages_flushed, SHOW_LONG},
{"buffer_pool_pages_free",
(char*) &export_vars.innodb_buffer_pool_pages_free, SHOW_LONG},
{"buffer_pool_pages_latched",
(char*) &export_vars.innodb_buffer_pool_pages_latched, SHOW_LONG},
{"buffer_pool_pages_misc",
(char*) &export_vars.innodb_buffer_pool_pages_misc, SHOW_LONG},
{"buffer_pool_pages_total",
(char*) &export_vars.innodb_buffer_pool_pages_total, SHOW_LONG},
{"buffer_pool_read_ahead_rnd",
(char*) &export_vars.innodb_buffer_pool_read_ahead_rnd, SHOW_LONG},
{"buffer_pool_read_ahead_seq",
(char*) &export_vars.innodb_buffer_pool_read_ahead_seq, SHOW_LONG},
{"buffer_pool_read_requests",
(char*) &export_vars.innodb_buffer_pool_read_requests, SHOW_LONG},
{"buffer_pool_reads",
(char*) &export_vars.innodb_buffer_pool_reads, SHOW_LONG},
{"buffer_pool_wait_free",
(char*) &export_vars.innodb_buffer_pool_wait_free, SHOW_LONG},
{"buffer_pool_write_requests",
(char*) &export_vars.innodb_buffer_pool_write_requests, SHOW_LONG},
{"data_fsyncs",
(char*) &export_vars.innodb_data_fsyncs, SHOW_LONG},
{"data_pending_fsyncs",
(char*) &export_vars.innodb_data_pending_fsyncs, SHOW_LONG},
{"data_pending_reads",
(char*) &export_vars.innodb_data_pending_reads, SHOW_LONG},
{"data_pending_writes",
(char*) &export_vars.innodb_data_pending_writes, SHOW_LONG},
{"data_read",
(char*) &export_vars.innodb_data_read, SHOW_LONG},
{"data_reads",
(char*) &export_vars.innodb_data_reads, SHOW_LONG},
{"data_writes",
(char*) &export_vars.innodb_data_writes, SHOW_LONG},
{"data_written",
(char*) &export_vars.innodb_data_written, SHOW_LONG},
{"dblwr_pages_written",
(char*) &export_vars.innodb_dblwr_pages_written, SHOW_LONG},
{"dblwr_writes",
(char*) &export_vars.innodb_dblwr_writes, SHOW_LONG},
{"log_waits",
(char*) &export_vars.innodb_log_waits, SHOW_LONG},
{"log_write_requests",
(char*) &export_vars.innodb_log_write_requests, SHOW_LONG},
{"log_writes",
(char*) &export_vars.innodb_log_writes, SHOW_LONG},
{"os_log_fsyncs",
(char*) &export_vars.innodb_os_log_fsyncs, SHOW_LONG},
{"os_log_pending_fsyncs",
(char*) &export_vars.innodb_os_log_pending_fsyncs, SHOW_LONG},
{"os_log_pending_writes",
(char*) &export_vars.innodb_os_log_pending_writes, SHOW_LONG},
{"os_log_written",
(char*) &export_vars.innodb_os_log_written, SHOW_LONG},
{"page_size",
(char*) &export_vars.innodb_page_size, SHOW_LONG},
{"pages_created",
(char*) &export_vars.innodb_pages_created, SHOW_LONG},
{"pages_read",
(char*) &export_vars.innodb_pages_read, SHOW_LONG},
{"pages_written",
(char*) &export_vars.innodb_pages_written, SHOW_LONG},
{"rows_deleted",
(char*) &export_vars.innodb_rows_deleted, SHOW_LONG},
{"rows_inserted",
(char*) &export_vars.innodb_rows_inserted, SHOW_LONG},
{"rows_read",
(char*) &export_vars.innodb_rows_read, SHOW_LONG},
{"rows_updated",
(char*) &export_vars.innodb_rows_updated, SHOW_LONG},
{NullS, NullS, SHOW_LONG}};
/* General functions */ /* General functions */
/********************************************************************** /**********************************************************************
...@@ -5123,6 +5202,17 @@ ha_innobase::external_lock( ...@@ -5123,6 +5202,17 @@ ha_innobase::external_lock(
DBUG_RETURN(0); DBUG_RETURN(0);
} }
/****************************************************************************
Here we export InnoDB status variables to MySQL. */
void
innodb_export_status(void)
/*======================*/
{
srv_export_innodb_status();
}
/**************************************************************************** /****************************************************************************
Implements the SHOW INNODB STATUS command. Sends the output of the InnoDB Implements the SHOW INNODB STATUS command. Sends the output of the InnoDB
Monitor to the client. */ Monitor to the client. */
......
...@@ -176,6 +176,7 @@ class ha_innobase: public handler ...@@ -176,6 +176,7 @@ class ha_innobase: public handler
int cmp_ref(const byte *ref1, const byte *ref2); int cmp_ref(const byte *ref1, const byte *ref2);
}; };
extern struct show_var_st innodb_status_variables[];
extern uint innobase_init_flags, innobase_lock_type; extern uint innobase_init_flags, innobase_lock_type;
extern uint innobase_flush_log_at_trx_commit; extern uint innobase_flush_log_at_trx_commit;
extern ulong innobase_cache_size; extern ulong innobase_cache_size;
...@@ -235,6 +236,7 @@ int innobase_savepoint( ...@@ -235,6 +236,7 @@ int innobase_savepoint(
int innobase_close_connection(THD *thd); int innobase_close_connection(THD *thd);
int innobase_drop_database(char *path); int innobase_drop_database(char *path);
bool innodb_show_status(THD* thd); bool innodb_show_status(THD* thd);
void innodb_export_status(void);
my_bool innobase_query_caching_of_table_permitted(THD* thd, char* full_name, my_bool innobase_query_caching_of_table_permitted(THD* thd, char* full_name,
uint full_name_len); uint full_name_len);
......
...@@ -468,6 +468,21 @@ int ha_release_temporary_latches(THD *thd) ...@@ -468,6 +468,21 @@ int ha_release_temporary_latches(THD *thd)
return 0; return 0;
} }
/*
Export statistics for different engines. Currently we use it only for
InnoDB.
*/
int ha_update_statistics()
{
#ifdef HAVE_INNOBASE_DB
if (opt_innodb)
innodb_export_status();
#endif
return 0;
}
int ha_commit_trans(THD *thd, THD_TRANS* trans) int ha_commit_trans(THD *thd, THD_TRANS* trans)
{ {
int error=0; int error=0;
......
...@@ -581,6 +581,7 @@ int ha_report_binlog_offset_and_commit(THD *thd, char *log_file_name, ...@@ -581,6 +581,7 @@ int ha_report_binlog_offset_and_commit(THD *thd, char *log_file_name,
my_off_t end_offset); my_off_t end_offset);
int ha_commit_complete(THD *thd); int ha_commit_complete(THD *thd);
int ha_release_temporary_latches(THD *thd); int ha_release_temporary_latches(THD *thd);
int ha_update_statistics();
int ha_commit_trans(THD *thd, THD_TRANS *trans); int ha_commit_trans(THD *thd, THD_TRANS *trans);
int ha_rollback_trans(THD *thd, THD_TRANS *trans); int ha_rollback_trans(THD *thd, THD_TRANS *trans);
int ha_rollback_to_savepoint(THD *thd, char *savepoint_name); int ha_rollback_to_savepoint(THD *thd, char *savepoint_name);
......
...@@ -990,7 +990,7 @@ extern ulong rpl_recovery_rank, thread_cache_size; ...@@ -990,7 +990,7 @@ extern ulong rpl_recovery_rank, thread_cache_size;
extern ulong back_log; extern ulong back_log;
extern ulong specialflag, current_pid; extern ulong specialflag, current_pid;
extern ulong expire_logs_days, sync_binlog_period, sync_binlog_counter; extern ulong expire_logs_days, sync_binlog_period, sync_binlog_counter;
extern my_bool relay_log_purge, opt_innodb_safe_binlog; extern my_bool relay_log_purge, opt_innodb_safe_binlog, opt_innodb;
extern uint test_flags,select_errors,ha_open_options; extern uint test_flags,select_errors,ha_open_options;
extern uint protocol_version, mysqld_port, dropping_tables; extern uint protocol_version, mysqld_port, dropping_tables;
extern uint delay_key_write_options, lower_case_table_names; extern uint delay_key_write_options, lower_case_table_names;
......
...@@ -5402,6 +5402,9 @@ struct show_var_st status_vars[]= { ...@@ -5402,6 +5402,9 @@ struct show_var_st status_vars[]= {
SHOW_LONG_STATUS}, SHOW_LONG_STATUS},
{"Handler_write", (char*) offsetof(STATUS_VAR, ha_write_count), {"Handler_write", (char*) offsetof(STATUS_VAR, ha_write_count),
SHOW_LONG_STATUS}, SHOW_LONG_STATUS},
#ifdef HAVE_INNOBASE_DB
{"Innodb_", (char*) &innodb_status_variables, SHOW_VARS},
#endif /*HAVE_INNOBASE_DB*/
{"Key_blocks_not_flushed", (char*) &dflt_key_cache_var.global_blocks_changed, {"Key_blocks_not_flushed", (char*) &dflt_key_cache_var.global_blocks_changed,
SHOW_KEY_CACHE_LONG}, SHOW_KEY_CACHE_LONG},
{"Key_blocks_unused", (char*) &dflt_key_cache_var.blocks_unused, {"Key_blocks_unused", (char*) &dflt_key_cache_var.blocks_unused,
......
...@@ -1394,311 +1394,348 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose) ...@@ -1394,311 +1394,348 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
Status functions Status functions
*****************************************************************************/ *****************************************************************************/
bool mysqld_show(THD *thd, const char *wild, show_var_st *variables,
enum enum_var_type value_type, static bool show_status_array(THD *thd, const char *wild,
pthread_mutex_t *mutex, show_var_st *variables,
struct system_status_var *status_var) enum enum_var_type value_type,
struct system_status_var *status_var,
const char *prefix)
{ {
char buff[1024]; char buff[1024], *prefix_end;
List<Item> field_list; /* the variable name should not be longer then 80 characters */
char name_buffer[80];
int len;
Protocol *protocol= thd->protocol; Protocol *protocol= thd->protocol;
LEX_STRING null_lex_str; LEX_STRING null_lex_str;
DBUG_ENTER("mysqld_show"); DBUG_ENTER("show_status_array");
field_list.push_back(new Item_empty_string("Variable_name",30));
field_list.push_back(new Item_empty_string("Value",256));
if (protocol->send_fields(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(TRUE); /* purecov: inspected */
null_lex_str.str= 0; // For sys_var->value_ptr() null_lex_str.str= 0; // For sys_var->value_ptr()
null_lex_str.length= 0; null_lex_str.length= 0;
pthread_mutex_lock(mutex); prefix_end=strnmov(name_buffer, prefix, sizeof(name_buffer)-1);
len=name_buffer + sizeof(name_buffer) - prefix_end;
for (; variables->name; variables++) for (; variables->name; variables++)
{ {
if (!(wild && wild[0] && wild_case_compare(system_charset_info, strnmov(prefix_end, variables->name, len);
variables->name,wild))) name_buffer[sizeof(name_buffer)-1]=0; /* Safety */
SHOW_TYPE show_type=variables->type;
if (show_type == SHOW_VARS)
{
show_status_array(thd, wild, (show_var_st *) variables->value,
value_type, status_var, variables->name);
}
else
{ {
protocol->prepare_for_resend(); if (!(wild && wild[0] && wild_case_compare(system_charset_info,
protocol->store(variables->name, system_charset_info); name_buffer, wild)))
SHOW_TYPE show_type=variables->type;
char *value=variables->value;
const char *pos, *end;
long nr;
if (show_type == SHOW_SYS)
{ {
show_type= ((sys_var*) value)->type(); char *value=variables->value;
value= (char*) ((sys_var*) value)->value_ptr(thd, value_type, const char *pos, *end;
&null_lex_str); long nr;
}
pos= end= buff; protocol->prepare_for_resend();
switch (show_type) { protocol->store(name_buffer, system_charset_info);
case SHOW_LONG_STATUS:
case SHOW_LONG_CONST_STATUS: if (show_type == SHOW_SYS)
value= ((char *) status_var + (ulong) value); {
/* fall through */ show_type= ((sys_var*) value)->type();
case SHOW_LONG: value= (char*) ((sys_var*) value)->value_ptr(thd, value_type,
case SHOW_LONG_CONST: &null_lex_str);
end= int10_to_str(*(long*) value, buff, 10); }
break;
case SHOW_LONGLONG: pos= end= buff;
end= longlong10_to_str(*(longlong*) value, buff, 10); switch (show_type) {
break; case SHOW_LONG_STATUS:
case SHOW_HA_ROWS: case SHOW_LONG_CONST_STATUS:
end= longlong10_to_str((longlong) *(ha_rows*) value, buff, 10); value= ((char *) status_var + (ulong) value);
break; /* fall through */
case SHOW_BOOL: case SHOW_LONG:
end= strmov(buff, *(bool*) value ? "ON" : "OFF"); case SHOW_LONG_CONST:
break; end= int10_to_str(*(long*) value, buff, 10);
case SHOW_MY_BOOL: break;
end= strmov(buff, *(my_bool*) value ? "ON" : "OFF"); case SHOW_LONGLONG:
break; end= longlong10_to_str(*(longlong*) value, buff, 10);
case SHOW_INT_CONST: break;
case SHOW_INT: case SHOW_HA_ROWS:
end= int10_to_str((long) *(uint32*) value, buff, 10); end= longlong10_to_str((longlong) *(ha_rows*) value, buff, 10);
break; break;
case SHOW_HAVE: case SHOW_BOOL:
{ end= strmov(buff, *(bool*) value ? "ON" : "OFF");
SHOW_COMP_OPTION tmp= *(SHOW_COMP_OPTION*) value; break;
pos= show_comp_option_name[(int) tmp]; case SHOW_MY_BOOL:
end= strend(pos); end= strmov(buff, *(my_bool*) value ? "ON" : "OFF");
break; break;
} case SHOW_INT_CONST:
case SHOW_CHAR: case SHOW_INT:
{ end= int10_to_str((long) *(uint32*) value, buff, 10);
if (!(pos= value)) break;
pos= ""; case SHOW_HAVE:
end= strend(pos); {
break; SHOW_COMP_OPTION tmp= *(SHOW_COMP_OPTION*) value;
} pos= show_comp_option_name[(int) tmp];
case SHOW_STARTTIME: end= strend(pos);
nr= (long) (thd->query_start() - start_time); break;
end= int10_to_str(nr, buff, 10); }
break; case SHOW_CHAR:
case SHOW_QUESTION: {
end= int10_to_str((long) thd->query_id, buff, 10); if (!(pos= value))
break; pos= "";
end= strend(pos);
break;
}
case SHOW_STARTTIME:
nr= (long) (thd->query_start() - start_time);
end= int10_to_str(nr, buff, 10);
break;
case SHOW_QUESTION:
end= int10_to_str((long) thd->query_id, buff, 10);
break;
#ifdef HAVE_REPLICATION #ifdef HAVE_REPLICATION
case SHOW_RPL_STATUS: case SHOW_RPL_STATUS:
end= strmov(buff, rpl_status_type[(int)rpl_status]); end= strmov(buff, rpl_status_type[(int)rpl_status]);
break; break;
case SHOW_SLAVE_RUNNING: case SHOW_SLAVE_RUNNING:
{ {
pthread_mutex_lock(&LOCK_active_mi); pthread_mutex_lock(&LOCK_active_mi);
end= strmov(buff, (active_mi->slave_running && end= strmov(buff, (active_mi->slave_running &&
active_mi->rli.slave_running) ? "ON" : "OFF"); active_mi->rli.slave_running) ? "ON" : "OFF");
pthread_mutex_unlock(&LOCK_active_mi); pthread_mutex_unlock(&LOCK_active_mi);
break; break;
} }
#endif /* HAVE_REPLICATION */ #endif /* HAVE_REPLICATION */
case SHOW_OPENTABLES: case SHOW_OPENTABLES:
end= int10_to_str((long) cached_tables(), buff, 10); end= int10_to_str((long) cached_tables(), buff, 10);
break; break;
case SHOW_CHAR_PTR: case SHOW_CHAR_PTR:
{ {
if (!(pos= *(char**) value)) if (!(pos= *(char**) value))
pos= ""; pos= "";
end= strend(pos); end= strend(pos);
break; break;
} }
case SHOW_DOUBLE: case SHOW_DOUBLE:
{ {
end= buff + sprintf(buff, "%f", *(double*) value); end= buff + sprintf(buff, "%f", *(double*) value);
break; break;
} }
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
/* First group - functions relying on CTX */ /* First group - functions relying on CTX */
case SHOW_SSL_CTX_SESS_ACCEPT: case SHOW_SSL_CTX_SESS_ACCEPT:
end= int10_to_str((long) (!ssl_acceptor_fd ? 0 : end= int10_to_str((long) (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_accept(ssl_acceptor_fd-> SSL_CTX_sess_accept(ssl_acceptor_fd->
ssl_context)), ssl_context)),
buff, 10); buff, 10);
break; break;
case SHOW_SSL_CTX_SESS_ACCEPT_GOOD: case SHOW_SSL_CTX_SESS_ACCEPT_GOOD:
end= int10_to_str((long) (!ssl_acceptor_fd ? 0 : end= int10_to_str((long) (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_accept_good(ssl_acceptor_fd-> SSL_CTX_sess_accept_good(ssl_acceptor_fd->
ssl_context)), ssl_context)),
buff, 10); buff, 10);
break; break;
case SHOW_SSL_CTX_SESS_CONNECT_GOOD: case SHOW_SSL_CTX_SESS_CONNECT_GOOD:
end= int10_to_str((long) (!ssl_acceptor_fd ? 0 : end= int10_to_str((long) (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_connect_good(ssl_acceptor_fd-> SSL_CTX_sess_connect_good(ssl_acceptor_fd->
ssl_context)), ssl_context)),
buff, 10); buff, 10);
break; break;
case SHOW_SSL_CTX_SESS_ACCEPT_RENEGOTIATE: case SHOW_SSL_CTX_SESS_ACCEPT_RENEGOTIATE:
end= int10_to_str((long) (!ssl_acceptor_fd ? 0 : end= int10_to_str((long) (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_accept_renegotiate(ssl_acceptor_fd->ssl_context)), SSL_CTX_sess_accept_renegotiate(ssl_acceptor_fd->ssl_context)),
buff, 10); buff, 10);
break; break;
case SHOW_SSL_CTX_SESS_CONNECT_RENEGOTIATE: case SHOW_SSL_CTX_SESS_CONNECT_RENEGOTIATE:
end= int10_to_str((long) (!ssl_acceptor_fd ? 0 : end= int10_to_str((long) (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_connect_renegotiate(ssl_acceptor_fd-> ssl_context)), SSL_CTX_sess_connect_renegotiate(ssl_acceptor_fd-> ssl_context)),
buff, 10); buff, 10);
break; break;
case SHOW_SSL_CTX_SESS_CB_HITS: case SHOW_SSL_CTX_SESS_CB_HITS:
end= int10_to_str((long) (!ssl_acceptor_fd ? 0 : end= int10_to_str((long) (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_cb_hits(ssl_acceptor_fd-> SSL_CTX_sess_cb_hits(ssl_acceptor_fd->
ssl_context)), ssl_context)),
buff, 10); buff, 10);
break; break;
case SHOW_SSL_CTX_SESS_HITS: case SHOW_SSL_CTX_SESS_HITS:
end= int10_to_str((long) (!ssl_acceptor_fd ? 0 : end= int10_to_str((long) (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_hits(ssl_acceptor_fd-> SSL_CTX_sess_hits(ssl_acceptor_fd->
ssl_context)), ssl_context)),
buff, 10); buff, 10);
break; break;
case SHOW_SSL_CTX_SESS_CACHE_FULL: case SHOW_SSL_CTX_SESS_CACHE_FULL:
end= int10_to_str((long) (!ssl_acceptor_fd ? 0 : end= int10_to_str((long) (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_cache_full(ssl_acceptor_fd-> SSL_CTX_sess_cache_full(ssl_acceptor_fd->
ssl_context)), ssl_context)),
buff, 10); buff, 10);
break; break;
case SHOW_SSL_CTX_SESS_MISSES: case SHOW_SSL_CTX_SESS_MISSES:
end= int10_to_str((long) (!ssl_acceptor_fd ? 0 : end= int10_to_str((long) (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_misses(ssl_acceptor_fd-> SSL_CTX_sess_misses(ssl_acceptor_fd->
ssl_context)), ssl_context)),
buff, 10); buff, 10);
break; break;
case SHOW_SSL_CTX_SESS_TIMEOUTS: case SHOW_SSL_CTX_SESS_TIMEOUTS:
end= int10_to_str((long) (!ssl_acceptor_fd ? 0 : end= int10_to_str((long) (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_timeouts(ssl_acceptor_fd->ssl_context)), SSL_CTX_sess_timeouts(ssl_acceptor_fd->ssl_context)),
buff,10); buff,10);
break; break;
case SHOW_SSL_CTX_SESS_NUMBER: case SHOW_SSL_CTX_SESS_NUMBER:
end= int10_to_str((long) (!ssl_acceptor_fd ? 0 : end= int10_to_str((long) (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_number(ssl_acceptor_fd->ssl_context)), SSL_CTX_sess_number(ssl_acceptor_fd->ssl_context)),
buff,10); buff,10);
break; break;
case SHOW_SSL_CTX_SESS_CONNECT: case SHOW_SSL_CTX_SESS_CONNECT:
end= int10_to_str((long) (!ssl_acceptor_fd ? 0 : end= int10_to_str((long) (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_connect(ssl_acceptor_fd->ssl_context)), SSL_CTX_sess_connect(ssl_acceptor_fd->ssl_context)),
buff,10); buff,10);
break; break;
case SHOW_SSL_CTX_SESS_GET_CACHE_SIZE: case SHOW_SSL_CTX_SESS_GET_CACHE_SIZE:
end= int10_to_str((long) (!ssl_acceptor_fd ? 0 : end= int10_to_str((long) (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_get_cache_size(ssl_acceptor_fd->ssl_context)), SSL_CTX_sess_get_cache_size(ssl_acceptor_fd->ssl_context)),
buff,10); buff,10);
break; break;
case SHOW_SSL_CTX_GET_VERIFY_MODE: case SHOW_SSL_CTX_GET_VERIFY_MODE:
end= int10_to_str((long) (!ssl_acceptor_fd ? 0 : end= int10_to_str((long) (!ssl_acceptor_fd ? 0 :
SSL_CTX_get_verify_mode(ssl_acceptor_fd->ssl_context)), SSL_CTX_get_verify_mode(ssl_acceptor_fd->ssl_context)),
buff,10); buff,10);
break; break;
case SHOW_SSL_CTX_GET_VERIFY_DEPTH: case SHOW_SSL_CTX_GET_VERIFY_DEPTH:
end= int10_to_str((long) (!ssl_acceptor_fd ? 0 : end= int10_to_str((long) (!ssl_acceptor_fd ? 0 :
SSL_CTX_get_verify_depth(ssl_acceptor_fd->ssl_context)), SSL_CTX_get_verify_depth(ssl_acceptor_fd->ssl_context)),
buff,10); buff,10);
break; break;
case SHOW_SSL_CTX_GET_SESSION_CACHE_MODE: case SHOW_SSL_CTX_GET_SESSION_CACHE_MODE:
if (!ssl_acceptor_fd) if (!ssl_acceptor_fd)
{ {
pos= "NONE"; pos= "NONE";
end= pos+4; end= pos+4;
break; break;
} }
switch (SSL_CTX_get_session_cache_mode(ssl_acceptor_fd->ssl_context)) switch (SSL_CTX_get_session_cache_mode(ssl_acceptor_fd->ssl_context))
{ {
case SSL_SESS_CACHE_OFF: case SSL_SESS_CACHE_OFF:
pos= "OFF"; pos= "OFF";
break; break;
case SSL_SESS_CACHE_CLIENT: case SSL_SESS_CACHE_CLIENT:
pos= "CLIENT"; pos= "CLIENT";
break; break;
case SSL_SESS_CACHE_SERVER: case SSL_SESS_CACHE_SERVER:
pos= "SERVER"; pos= "SERVER";
break; break;
case SSL_SESS_CACHE_BOTH: case SSL_SESS_CACHE_BOTH:
pos= "BOTH"; pos= "BOTH";
break; break;
case SSL_SESS_CACHE_NO_AUTO_CLEAR: case SSL_SESS_CACHE_NO_AUTO_CLEAR:
pos= "NO_AUTO_CLEAR"; pos= "NO_AUTO_CLEAR";
break; break;
case SSL_SESS_CACHE_NO_INTERNAL_LOOKUP: case SSL_SESS_CACHE_NO_INTERNAL_LOOKUP:
pos= "NO_INTERNAL_LOOKUP"; pos= "NO_INTERNAL_LOOKUP";
break; break;
default: default:
pos= "Unknown"; pos= "Unknown";
break; break;
} }
end= strend(pos); end= strend(pos);
break; break;
/* First group - functions relying on SSL */ /* First group - functions relying on SSL */
case SHOW_SSL_GET_VERSION: case SHOW_SSL_GET_VERSION:
pos= (thd->net.vio->ssl_arg ? pos= (thd->net.vio->ssl_arg ?
SSL_get_version((SSL*) thd->net.vio->ssl_arg) : ""); SSL_get_version((SSL*) thd->net.vio->ssl_arg) : "");
end= strend(pos); end= strend(pos);
break; break;
case SHOW_SSL_SESSION_REUSED: case SHOW_SSL_SESSION_REUSED:
end= int10_to_str((long) (thd->net.vio->ssl_arg ? end= int10_to_str((long) (thd->net.vio->ssl_arg ?
SSL_session_reused((SSL*) thd->net.vio-> SSL_session_reused((SSL*) thd->net.vio->
ssl_arg) : ssl_arg) :
0), 0),
buff, 10); buff, 10);
break; break;
case SHOW_SSL_GET_DEFAULT_TIMEOUT: case SHOW_SSL_GET_DEFAULT_TIMEOUT:
end= int10_to_str((long) (thd->net.vio->ssl_arg ? end= int10_to_str((long) (thd->net.vio->ssl_arg ?
SSL_get_default_timeout((SSL*) thd->net.vio-> SSL_get_default_timeout((SSL*) thd->net.vio->
ssl_arg) : ssl_arg) :
0), 0),
buff, 10); buff, 10);
break; break;
case SHOW_SSL_GET_VERIFY_MODE: case SHOW_SSL_GET_VERIFY_MODE:
end= int10_to_str((long) (thd->net.vio->ssl_arg ? end= int10_to_str((long) (thd->net.vio->ssl_arg ?
SSL_get_verify_mode((SSL*) thd->net.vio-> SSL_get_verify_mode((SSL*) thd->net.vio->
ssl_arg): ssl_arg):
0), 0),
buff, 10); buff, 10);
break; break;
case SHOW_SSL_GET_VERIFY_DEPTH: case SHOW_SSL_GET_VERIFY_DEPTH:
end= int10_to_str((long) (thd->net.vio->ssl_arg ? end= int10_to_str((long) (thd->net.vio->ssl_arg ?
SSL_get_verify_depth((SSL*) thd->net.vio-> SSL_get_verify_depth((SSL*) thd->net.vio->
ssl_arg): ssl_arg):
0), 0),
buff, 10); buff, 10);
break; break;
case SHOW_SSL_GET_CIPHER: case SHOW_SSL_GET_CIPHER:
pos= (thd->net.vio->ssl_arg ? pos= (thd->net.vio->ssl_arg ?
SSL_get_cipher((SSL*) thd->net.vio->ssl_arg) : "" ); SSL_get_cipher((SSL*) thd->net.vio->ssl_arg) : "" );
end= strend(pos); end= strend(pos);
break; break;
case SHOW_SSL_GET_CIPHER_LIST: case SHOW_SSL_GET_CIPHER_LIST:
if (thd->net.vio->ssl_arg) if (thd->net.vio->ssl_arg)
{ {
char *to= buff; char *to= buff;
for (int i=0 ; i++ ;) for (int i=0 ; i++ ;)
{ {
const char *p= SSL_get_cipher_list((SSL*) thd->net.vio->ssl_arg,i); const char *p= SSL_get_cipher_list((SSL*) thd->net.vio->ssl_arg,i);
if (p == NULL) if (p == NULL)
break; break;
to= strmov(to, p); to= strmov(to, p);
*to++= ':'; *to++= ':';
} }
if (to != buff) if (to != buff)
to--; // Remove last ':' to--; // Remove last ':'
end= to; end= to;
} }
break; break;
#endif /* HAVE_OPENSSL */ #endif /* HAVE_OPENSSL */
case SHOW_KEY_CACHE_LONG: case SHOW_KEY_CACHE_LONG:
case SHOW_KEY_CACHE_CONST_LONG: case SHOW_KEY_CACHE_CONST_LONG:
value= (value-(char*) &dflt_key_cache_var)+ (char*) sql_key_cache; value= (value-(char*) &dflt_key_cache_var)+ (char*) sql_key_cache;
end= int10_to_str(*(long*) value, buff, 10); end= int10_to_str(*(long*) value, buff, 10);
break; break;
case SHOW_UNDEF: // Show never happen case SHOW_UNDEF: // Show never happen
case SHOW_SYS: case SHOW_SYS:
break; // Return empty string break; // Return empty string
default: default:
break; break;
}
if (protocol->store(pos, (uint32) (end - pos), system_charset_info) ||
protocol->write())
DBUG_RETURN(TRUE); /* purecov: inspected */
} }
if (protocol->store(pos, (uint32) (end - pos), system_charset_info) ||
protocol->write())
goto err; /* purecov: inspected */
} }
} }
DBUG_RETURN(FALSE);
}
bool mysqld_show(THD *thd, const char *wild, show_var_st *variables,
enum enum_var_type value_type,
pthread_mutex_t *mutex,
struct system_status_var *status_var)
{
List<Item> field_list;
Protocol *protocol= thd->protocol;
DBUG_ENTER("mysqld_show");
ha_update_statistics(); /* Export engines statistics */
field_list.push_back(new Item_empty_string("Variable_name",30));
field_list.push_back(new Item_empty_string("Value",256));
if (protocol->send_fields(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(TRUE); /* purecov: inspected */
pthread_mutex_lock(mutex);
if (show_status_array(thd, wild, variables, value_type, status_var, ""))
goto err;
pthread_mutex_unlock(mutex); pthread_mutex_unlock(mutex);
send_eof(thd); send_eof(thd);
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
......
...@@ -161,6 +161,7 @@ enum SHOW_TYPE ...@@ -161,6 +161,7 @@ enum SHOW_TYPE
SHOW_LONG, SHOW_LONGLONG, SHOW_INT, SHOW_CHAR, SHOW_CHAR_PTR, SHOW_DOUBLE, SHOW_LONG, SHOW_LONGLONG, SHOW_INT, SHOW_CHAR, SHOW_CHAR_PTR, SHOW_DOUBLE,
SHOW_BOOL, SHOW_MY_BOOL, SHOW_OPENTABLES, SHOW_STARTTIME, SHOW_QUESTION, SHOW_BOOL, SHOW_MY_BOOL, SHOW_OPENTABLES, SHOW_STARTTIME, SHOW_QUESTION,
SHOW_LONG_CONST, SHOW_INT_CONST, SHOW_HAVE, SHOW_SYS, SHOW_HA_ROWS, SHOW_LONG_CONST, SHOW_INT_CONST, SHOW_HAVE, SHOW_SYS, SHOW_HA_ROWS,
SHOW_VARS,
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
SHOW_SSL_CTX_SESS_ACCEPT, SHOW_SSL_CTX_SESS_ACCEPT_GOOD, SHOW_SSL_CTX_SESS_ACCEPT, SHOW_SSL_CTX_SESS_ACCEPT_GOOD,
SHOW_SSL_GET_VERSION, SHOW_SSL_CTX_GET_SESSION_CACHE_MODE, SHOW_SSL_GET_VERSION, SHOW_SSL_CTX_GET_SESSION_CACHE_MODE,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment