@ -61,6 +61,7 @@ extern "C" {
# include "../storage/innobase/include/dict0boot.h"
# include "../storage/innobase/include/ha_prototypes.h"
# include "../storage/innobase/include/ut0mem.h"
# include "../storage/innobase/include/ibuf0ibuf.h"
}
# include "ha_innodb.h"
@ -141,6 +142,7 @@ static char* innobase_data_home_dir = NULL;
static char * innobase_data_file_path = NULL ;
static char * innobase_log_group_home_dir = NULL ;
static char * innobase_file_format_name = NULL ;
static char * innobase_change_buffering = NULL ;
/* Note: This variable can be set to on/off and any of the supported
file formats in the configuration file , but can only be set to any
@ -185,6 +187,12 @@ static hash_table_t* innobase_open_tables;
bool nw_panic = FALSE ;
# endif
/** Allowed values of innodb_change_buffering */
static const char * innobase_change_buffering_values [ IBUF_USE_INSERT + 1 ] = {
" none " , /* IBUF_USE_NONE */
" inserts " /* IBUF_USE_INSERT */
} ;
static INNOBASE_SHARE * get_share ( const char * table_name ) ;
static void free_share ( INNOBASE_SHARE * share ) ;
static int innobase_close_connection ( handlerton * hton , THD * thd ) ;
@ -2069,6 +2077,10 @@ innobase_init(
}
}
ut_a ( ( ulint ) ibuf_use < UT_ARR_SIZE ( innobase_change_buffering_values ) ) ;
innobase_change_buffering = ( char * )
innobase_change_buffering_values [ ibuf_use ] ;
/* --------------------------------------------------*/
srv_file_flush_method_str = innobase_unix_file_flush_method ;
@ -9350,6 +9362,72 @@ innodb_file_format_check_update(
}
}
/*****************************************************************
Check if it is a valid value of innodb_change_buffering . This function is
registered as a callback with MySQL . */
static
int
innodb_change_buffering_validate (
/*=============================*/
/* out: 0 for valid
innodb_change_buffering */
THD * thd , /* in: thread handle */
struct st_mysql_sys_var * var , /* in: pointer to system
variable */
void * save , /* out: immediate result
for update function */
struct st_mysql_value * value ) /* in: incoming string */
{
const char * change_buffering_input ;
char buff [ STRING_BUFFER_USUAL_SIZE ] ;
int len = sizeof ( buff ) ;
ut_a ( save ! = NULL ) ;
ut_a ( value ! = NULL ) ;
change_buffering_input = value - > val_str ( value , buff , & len ) ;
if ( change_buffering_input ! = NULL ) {
ulint use ;
for ( use = 0 ; use < UT_ARR_SIZE ( innobase_change_buffering_values ) ;
use + + ) {
if ( ! innobase_strcasecmp (
change_buffering_input ,
innobase_change_buffering_values [ use ] ) ) {
* ( ibuf_use_t * ) save = ( ibuf_use_t ) use ;
return ( 0 ) ;
}
}
}
return ( 1 ) ;
}
/********************************************************************
Update the system variable innodb_change_buffering using the " saved "
value . This function is registered as a callback with MySQL . */
static
void
innodb_change_buffering_update (
/*===========================*/
THD * thd , /* in: thread handle */
struct st_mysql_sys_var * var , /* in: pointer to
system variable */
void * var_ptr , /* out: where the
formal string goes */
const void * save ) /* in: immediate result
from check function */
{
ut_a ( var_ptr ! = NULL ) ;
ut_a ( save ! = NULL ) ;
ut_a ( ( * ( ibuf_use_t * ) save ) < = IBUF_USE_INSERT ) ;
ibuf_use = * ( const ibuf_use_t * ) save ;
* ( const char * * ) var_ptr = innobase_change_buffering_values [ ibuf_use ] ;
}
static int show_innodb_vars ( THD * thd , SHOW_VAR * var , char * buff )
{
innodb_export_status ( ) ;
@ -9587,6 +9665,13 @@ static MYSQL_SYSVAR_BOOL(use_sys_malloc, srv_use_sys_malloc,
" Use OS memory allocator instead of InnoDB's internal memory allocator " ,
NULL , NULL , FALSE ) ;
static MYSQL_SYSVAR_STR ( change_buffering , innobase_change_buffering ,
PLUGIN_VAR_RQCMDARG ,
" Buffer changes to reduce random access: "
" OFF, ON, inserting, deleting, changing, or purging. " ,
innodb_change_buffering_validate ,
innodb_change_buffering_update , NULL ) ;
static struct st_mysql_sys_var * innobase_system_variables [ ] = {
MYSQL_SYSVAR ( additional_mem_pool_size ) ,
MYSQL_SYSVAR ( autoextend_increment ) ,
@ -9634,6 +9719,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR ( autoinc_lock_mode ) ,
MYSQL_SYSVAR ( version ) ,
MYSQL_SYSVAR ( use_sys_malloc ) ,
MYSQL_SYSVAR ( change_buffering ) ,
NULL
} ;