Commit 94fb9e14 authored by unknown's avatar unknown

make maria more pluggable


mysql-test/r/maria.result:
  test for maria variables
mysql-test/t/maria.test:
  test for maria variables
BitKeeper/etc/ignore:
  Added sql/link_sources ylwrap libmysql_r/link_sources to the ignore list
sql/sql_delete.cc:
  fix incorrect check
storage/maria/ha_maria.cc:
  maria status and pagecache variables
parent e593209e
......@@ -3060,3 +3060,6 @@ libmysql_r/client_settings.h
libmysqld/scheduler.cc
libmysqld/sql_connect.cc
libmysqld/sql_tablespace.cc
sql/link_sources
ylwrap
libmysql_r/link_sources
......@@ -1973,3 +1973,23 @@ check table t1 extended;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
show variables like 'maria%';
Variable_name Value
maria_block_size 8192
maria_checkpoint_frequency 30
maria_max_sort_file_size 9223372036854775807
maria_pagecache_age_threshold 300
maria_pagecache_buffer_size 8388572
maria_pagecache_division_limit 100
maria_repair_threads 1
maria_sort_buffer_size 8388608
maria_stats_method nulls_unequal
show status like 'maria%';
Variable_name Value
Maria_pagecache_blocks_not_flushed #
Maria_pagecache_blocks_unused #
Maria_pagecache_blocks_used #
Maria_pagecache_read_requests #
Maria_pagecache_reads #
Maria_pagecache_write_requests #
Maria_pagecache_writes #
......@@ -1262,6 +1262,10 @@ update t1 set s1=2 where seq=1;
check table t1 extended;
drop table t1;
show variables like 'maria%';
--replace_column 2 #
show status like 'maria%';
# End of 5.2 tests
--disable_result_log
......
......@@ -28,10 +28,6 @@
#include <myisampack.h>
#include <errno.h>
#ifdef WITH_MARIA_STORAGE_ENGINE
#include <maria.h>
#endif
#ifdef WITH_PARTITION_STORAGE_ENGINE
#include "ha_partition.h"
#endif
......@@ -2772,97 +2768,6 @@ int ha_change_key_cache(KEY_CACHE *old_key_cache,
}
/*****************************************************************************
pagecache handling.
This code is only relevant for maria tables
pagecache->cache may be 0 only in the case where a key cache is not
initialized or when we where not able to init the key cache in a previous
call to ha_init_pagecache() (probably out of memory)
*****************************************************************************/
#ifdef WITH_MARIA_STORAGE_ENGINE
/* Init a pagecache if it has not been initied before */
int ha_init_pagecache(const char *name, PAGECACHE *pagecache)
{
DBUG_ENTER("ha_init_pagecache");
if (!pagecache->inited)
{
pthread_mutex_lock(&LOCK_global_system_variables);
long tmp_buff_size= (long) pagecache->param_buff_size;
uint division_limit= pagecache->param_division_limit;
uint age_threshold= pagecache->param_age_threshold;
pthread_mutex_unlock(&LOCK_global_system_variables);
DBUG_RETURN(!init_pagecache(pagecache,
tmp_buff_size, division_limit, age_threshold,
MARIA_KEY_BLOCK_LENGTH));
}
DBUG_RETURN(0);
}
/* Resize key cache */
/*
TODO: uncomment when resize will be implemented
int ha_resize_pagecache(PAGECACHE *pagecache)
{
DBUG_ENTER("ha_resize_pagecache");
if (pagecache->inited)
{
pthread_mutex_lock(&LOCK_global_system_variables);
long tmp_buff_size= (long) pagecache->param_buff_size;
long tmp_block_size= (long) pagecache->param_block_size;
uint division_limit= pagecache->param_division_limit;
uint age_threshold= pagecache->param_age_threshold;
pthread_mutex_unlock(&LOCK_global_system_variables);
DBUG_RETURN(!resize_pagecache(pagecache, tmp_block_size,
tmp_buff_size,
division_limit, age_threshold));
}
DBUG_RETURN(0);
}
*/
/* Change parameters for key cache (like size) */
int ha_change_pagecache_param(PAGECACHE *pagecache)
{
if (pagecache->inited)
{
pthread_mutex_lock(&LOCK_global_system_variables);
uint division_limit= pagecache->param_division_limit;
uint age_threshold= pagecache->param_age_threshold;
pthread_mutex_unlock(&LOCK_global_system_variables);
change_pagecache_param(pagecache, division_limit, age_threshold);
}
return 0;
}
/* Free memory allocated by a key cache */
int ha_end_pagecache(PAGECACHE *pagecache)
{
end_pagecache(pagecache, 1); // Can never fail
return 0;
}
/* Move all tables from one key cache to another one */
int ha_change_pagecache(PAGECACHE *old_pagecache,
PAGECACHE *new_pagecache)
{
maria_change_pagecache(old_pagecache, new_pagecache);
return 0;
}
#endif /* WITH_MARIA_STORAGE_ENGINE */
/** @brief
Try to discover one table from handler(s)
......
......@@ -23,9 +23,6 @@
#include <my_handler.h>
#include <ft_global.h>
#include <keycache.h>
#ifdef WITH_MARIA_STORAGE_ENGINE
#include "../storage/maria/ma_pagecache.h"
#endif
#ifndef NO_HASH
#define NO_HASH /* Not yet implemented */
......@@ -276,7 +273,6 @@ enum legacy_db_type
DB_TYPE_TABLE_FUNCTION,
DB_TYPE_MEMCACHE,
DB_TYPE_FALCON,
DB_TYPE_MARIA,
DB_TYPE_FIRST_DYNAMIC=42,
DB_TYPE_DEFAULT=127 // Must be last
};
......@@ -898,9 +894,6 @@ typedef struct st_ha_check_opt
uint flags; /* isam layer flags (e.g. for myisamchk) */
uint sql_flags; /* sql layer flags - for something myisamchk cannot do */
KEY_CACHE *key_cache; /* new key cache when changing key cache */
#ifdef WITH_MARIA_STORAGE_ENGINE
PAGECACHE *pagecache; /* new pagecache when changing pagecache */
#endif
void init();
} HA_CHECK_OPT;
......@@ -1894,17 +1887,6 @@ int ha_resize_key_cache(KEY_CACHE *key_cache);
int ha_change_key_cache_param(KEY_CACHE *key_cache);
int ha_change_key_cache(KEY_CACHE *old_key_cache, KEY_CACHE *new_key_cache);
int ha_end_key_cache(KEY_CACHE *key_cache);
#ifdef WITH_MARIA_STORAGE_ENGINE
/* pagecache */
int ha_init_pagecache(const char *name, PAGECACHE *pagecache);
/*
TODO: uncomment when resizing will be implemented
int ha_resize_pagecache(PAGECACHE *pagecache);
*/
int ha_change_pagecache_param(PAGECACHE *pagecache);
int ha_change_pagecache(PAGECACHE *old_pagecache, PAGECACHE *new_pagecache);
int ha_end_pagecache(PAGECACHE *pagecache);
#endif
/* report to InnoDB that control passes to the client */
int ha_release_temporary_latches(THD *thd);
......
......@@ -1853,9 +1853,6 @@ extern pthread_cond_t COND_global_read_lock;
extern pthread_attr_t connection_attrib;
extern I_List<THD> threads;
extern I_List<NAMED_LIST> key_caches;
#ifdef WITH_MARIA_STORAGE_ENGINE
extern I_List<NAMED_LIST> pagecaches;
#endif /* WITH_MARIA_STORAGE_ENGINE */
extern MY_BITMAP temp_pool;
extern String my_empty_string;
extern const String my_null_string;
......@@ -1869,6 +1866,9 @@ extern struct system_variables max_system_variables;
extern struct system_status_var global_status_var;
extern struct rand_struct sql_rand;
extern handlerton *maria_hton; /* @todo remove, make it static in ha_maria.cc
currently it's needed for sql_delete.cc */
extern const char *opt_date_time_formats[];
extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[];
......
......@@ -28,9 +28,6 @@
#include "events.h"
#include "../storage/myisam/ha_myisam.h"
#ifdef WITH_MARIA_STORAGE_ENGINE
#include "../storage/maria/ha_maria.h"
#endif
#include "rpl_injector.h"
......@@ -528,9 +525,6 @@ FILE *stderror_file=0;
I_List<THD> threads;
I_List<NAMED_LIST> key_caches;
#ifdef WITH_MARIA_STORAGE_ENGINE
I_List<NAMED_LIST> pagecaches;
#endif /* WITH_MARIA_STORAGE_ENGINE */
Rpl_filter* rpl_filter;
Rpl_filter* binlog_filter;
......@@ -1214,13 +1208,7 @@ void clean_up(bool print_message)
tc_log->close();
xid_cache_free();
delete_elements(&key_caches, (void (*)(const char*, uchar*)) free_key_cache);
#ifdef WITH_MARIA_STORAGE_ENGINE
delete_elements(&pagecaches, (void (*)(const char*, uchar*)) free_pagecache);
#endif /* WITH_MARIA_STORAGE_ENGINE */
multi_keycache_free();
#ifdef WITH_MARIA_STORAGE_ENGINE
multi_pagecache_free();
#endif
free_status_vars();
end_thr_alarm(1); /* Free allocated memory */
my_free_open_file_info();
......@@ -2209,10 +2197,6 @@ the problem, but since we have already crashed, something is definitely wrong\n\
and this may fail.\n\n");
fprintf(stderr, "key_buffer_size=%lu\n",
(ulong) dflt_key_cache->key_cache_mem_size);
#ifdef WITH_MARIA_STORAGE_ENGINE
fprintf(stderr, "page_buffer_size=%lu\n",
(ulong) maria_pagecache->mem_size);
#endif /* WITH_MARIA_STORAGE_ENGINE */
fprintf(stderr, "read_buffer_size=%ld\n", (long) global_system_variables.read_buff_size);
fprintf(stderr, "max_used_connections=%lu\n", max_used_connections);
fprintf(stderr, "max_threads=%u\n", thread_scheduler.max_threads);
......@@ -2220,9 +2204,6 @@ and this may fail.\n\n");
fprintf(stderr, "It is possible that mysqld could use up to \n\
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = %lu K\n\
bytes of memory\n", ((ulong) dflt_key_cache->key_cache_mem_size +
#ifdef WITH_MARIA_STORAGE_ENGINE
(ulong) maria_pagecache->mem_size +
#endif /* WITH_MARIA_STORAGE_ENGINE */
(global_system_variables.read_buff_size +
global_system_variables.sortbuff_size) *
thread_scheduler.max_threads +
......@@ -3419,14 +3400,6 @@ server.");
/* call ha_init_key_cache() on all key caches to init them */
process_key_caches(&ha_init_key_cache);
/*
Maria's pagecache needs to be ready before Maria engine (Recovery uses
pagecache, and Checkpoint may happen at startup). Maria engine is taken up
in plugin_init().
*/
#ifdef WITH_MARIA_STORAGE_ENGINE
process_pagecaches(&ha_init_pagecache);
#endif /* WITH_MARIA_STORAGE_ENGINE */
/* Allow storage engine to give real error messages */
if (ha_init_errors())
......@@ -6214,24 +6187,6 @@ The minimum value for this variable is 4096.",
(uchar**) &global_system_variables.optimizer_search_depth,
(uchar**) &max_system_variables.optimizer_search_depth,
0, GET_ULONG, OPT_ARG, MAX_TABLES+1, 0, MAX_TABLES+2, 0, 1, 0},
#ifdef WITH_MARIA_STORAGE_ENGINE
{"pagecache_age_threshold", OPT_PAGECACHE_AGE_THRESHOLD,
"This characterizes the number of hits a hot block has to be untouched until it is considered aged enough to be downgraded to a warm block. This specifies the percentage ratio of that number of hits to the total number of blocks in key cache",
(uchar**) &maria_pagecache_var.param_age_threshold,
(uchar**) 0, 0, (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG,
300, 100, ~0L, 0, 100, 0},
{"pagecache_buffer_size", OPT_PAGECACHE_BUFFER_SIZE,
"The size of the buffer used for index blocks for Maria tables. Increase this to get better index handling (for all reads and multiple writes) to as much as you can afford; 64M on a 256M machine that mainly runs MySQL is quite common.",
(uchar**) &maria_pagecache_var.param_buff_size,
(uchar**) 0, 0, (GET_ULL | GET_ASK_ADDR), REQUIRED_ARG,
KEY_CACHE_SIZE, MALLOC_OVERHEAD, ~(ulong) 0, MALLOC_OVERHEAD, IO_SIZE, 0},
{"pagecache_division_limit", OPT_PAGECACHE_DIVISION_LIMIT,
"The minimum percentage of warm blocks in key cache",
(uchar**) &maria_pagecache_var.param_division_limit,
(uchar**) 0,
0, (GET_ULONG | GET_ASK_ADDR) , REQUIRED_ARG, 100,
1, 100, 0, 1, 0},
#endif /* WITH_MARIA_STORAGE_ENGINE */
{"plugin_dir", OPT_PLUGIN_DIR,
"Directory for plugins.",
(uchar**) &opt_plugin_dir_ptr, (uchar**) &opt_plugin_dir_ptr, 0,
......@@ -7160,22 +7115,12 @@ static void mysql_init_variables(void)
threads.empty();
thread_cache.empty();
key_caches.empty();
#ifdef WITH_MARIA_STORAGE_ENGINE
pagecaches.empty();
#endif /* WITH_MARIA_STORAGE_ENGINE */
if (!(dflt_key_cache= get_or_create_key_cache(default_key_cache_base.str,
default_key_cache_base.length)))
exit(1);
/* set key_cache_hash.default_value = dflt_key_cache */
multi_keycache_init();
#ifdef WITH_MARIA_STORAGE_ENGINE
if (!(maria_pagecache= get_or_create_pagecache(maria_pagecache_base.str,
maria_pagecache_base.length)))
exit(1);
/* set pagecache_hash.default_value = maria_pagecache */
multi_pagecache_init();
#endif
/* Set directory paths */
strmake(language, LANGUAGE, sizeof(language)-1);
......@@ -7841,24 +7786,6 @@ mysql_getopt_value(const char *keyname, uint key_length,
return (uchar**) &key_cache->param_age_threshold;
}
}
#ifdef WITH_MARIA_STORAGE_ENGINE
case OPT_PAGECACHE_BUFFER_SIZE:
case OPT_PAGECACHE_DIVISION_LIMIT:
case OPT_PAGECACHE_AGE_THRESHOLD:
{
PAGECACHE *pagecache;
if (!(pagecache= get_or_create_pagecache(keyname, key_length)))
exit(1);
switch (option->id) {
case OPT_PAGECACHE_BUFFER_SIZE:
return (uchar**) &pagecache->param_buff_size;
case OPT_PAGECACHE_DIVISION_LIMIT:
return (uchar**) &pagecache->param_division_limit;
case OPT_PAGECACHE_AGE_THRESHOLD:
return (uchar**) &pagecache->param_age_threshold;
}
}
#endif
}
return option->value;
}
......@@ -8262,9 +8189,6 @@ void refresh_status(THD *thd)
/* Reset the counters of all key caches (default and named). */
process_key_caches(reset_key_cache_counters);
#ifdef WITH_MARIA_STORAGE_ENGINE
process_pagecaches(reset_pagecache_counters);
#endif /* WITH_MARIA_STORAGE_ENGINE */
pthread_mutex_unlock(&LOCK_status);
/*
......
......@@ -54,9 +54,6 @@
#include <thr_alarm.h>
#include <myisam.h>
#include <my_dir.h>
#ifdef WITH_MARIA_STORAGE_ENGINE
#include <maria.h>
#endif
#include "events.h"
......@@ -124,9 +121,6 @@ static void fix_thd_mem_root(THD *thd, enum_var_type type);
static void fix_trans_mem_root(THD *thd, enum_var_type type);
static void fix_server_id(THD *thd, enum_var_type type);
static KEY_CACHE *create_key_cache(const char *name, uint length);
#ifdef WITH_MARIA_STORAGE_ENGINE
static PAGECACHE *create_pagecache(const char *name, uint length);
#endif /* WITH_MARIA_STORAGE_ENGINE */
void fix_sql_mode_var(THD *thd, enum_var_type type);
static uchar *get_error_count(THD *thd);
static uchar *get_warning_count(THD *thd);
......@@ -244,14 +238,6 @@ static sys_var_key_cache_long sys_key_cache_division_limit(&vars, "key_cache_div
static sys_var_key_cache_long sys_key_cache_age_threshold(&vars, "key_cache_age_threshold",
offsetof(KEY_CACHE,
param_age_threshold));
#ifdef WITH_MARIA_STORAGE_ENGINE
sys_var_pagecache_long sys_pagecache_division_limit("pagecache_division_limit",
offsetof(PAGECACHE,
param_division_limit));
sys_var_pagecache_long sys_pagecache_age_threshold("pagecache_age_threshold",
offsetof(KEY_CACHE,
param_age_threshold));
#endif /* WITH_MARIA_STORAGE_ENGINE */
static sys_var_bool_ptr sys_local_infile(&vars, "local_infile",
&opt_local_infile);
static sys_var_trust_routine_creators
......@@ -1919,10 +1905,6 @@ LEX_STRING default_key_cache_base= {(char *) "default", 7 };
static KEY_CACHE zero_key_cache;
#ifdef WITH_MARIA_STORAGE_ENGINE
LEX_STRING maria_pagecache_base= {(char *) "default", 7 };
static PAGECACHE zero_pagecache;
#endif /* WITH_MARIA_STORAGE_ENGINE */
KEY_CACHE *get_key_cache(LEX_STRING *cache_name)
{
......@@ -1933,17 +1915,6 @@ KEY_CACHE *get_key_cache(LEX_STRING *cache_name)
cache_name->str, cache_name->length, 0));
}
#ifdef WITH_MARIA_STORAGE_ENGINE
PAGECACHE *get_pagecache(LEX_STRING *cache_name)
{
safe_mutex_assert_owner(&LOCK_global_system_variables);
if (!cache_name || ! cache_name->length)
cache_name= &default_key_cache_base;
return ((PAGECACHE*) find_named(&pagecaches,
cache_name->str, cache_name->length, 0));
}
#endif /* WITH_MARIA_STORAGE_ENGINE */
uchar *sys_var_key_cache_param::value_ptr(THD *thd, enum_var_type type,
LEX_STRING *base)
{
......@@ -1954,18 +1925,6 @@ uchar *sys_var_key_cache_param::value_ptr(THD *thd, enum_var_type type,
}
#ifdef WITH_MARIA_STORAGE_ENGINE
uchar *sys_var_pagecache_param::value_ptr(THD *thd, enum_var_type type,
LEX_STRING *base)
{
PAGECACHE *pagecache= get_pagecache(base);
if (!pagecache)
pagecache= &zero_pagecache;
return (uchar*) pagecache + offset ;
}
#endif /* WITH_MARIA_STORAGE_ENGINE */
bool sys_var_key_buffer_size::update(THD *thd, set_var *var)
{
ulonglong tmp= var->save_result.ulonglong_value;
......@@ -2102,60 +2061,6 @@ bool sys_var_key_cache_long::update(THD *thd, set_var *var)
}
#ifdef WITH_MARIA_STORAGE_ENGINE
bool sys_var_pagecache_long::update(THD *thd, set_var *var)
{
ulong tmp= (ulong) var->value->val_int();
LEX_STRING *base_name= &var->base;
bool error= 0;
if (!base_name->length)
base_name= &maria_pagecache_base;
pthread_mutex_lock(&LOCK_global_system_variables);
PAGECACHE *pagecache= get_pagecache(base_name);
if (!pagecache && !(pagecache= create_pagecache(base_name->str,
base_name->length)))
{
error= 1;
goto end;
}
/*
Abort if some other thread is changing the key cache
TODO: This should be changed so that we wait until the previous
assignment is done and then do the new assign
*/
if (pagecache->in_init)
goto end;
*((ulong*) (((char*) pagecache) + offset))=
(ulong) getopt_ull_limit_value(tmp, option_limits);
/*
Don't create a new key cache if it didn't exist
(pagecaches are created only when the user sets block_size)
*/
pagecache->in_init= 1;
pthread_mutex_unlock(&LOCK_global_system_variables);
/*
TODO: uncomment whan it will be implemented
error= (bool) (ha_resize_pagecache(pagecache));
*/
pthread_mutex_lock(&LOCK_global_system_variables);
pagecache->in_init= 0;
end:
pthread_mutex_unlock(&LOCK_global_system_variables);
return error;
}
#endif /* WITH_MARIA_STORAGE_ENGINE */
bool sys_var_log_state::update(THD *thd, set_var *var)
{
bool res;
......@@ -3694,78 +3599,6 @@ bool process_key_caches(process_key_cache_t func)
}
#ifdef WITH_MARIA_STORAGE_ENGINE
static PAGECACHE *create_pagecache(const char *name, uint length)
{
PAGECACHE *pagecache;
DBUG_ENTER("create_pagecache");
DBUG_PRINT("enter",("name: %.*s", length, name));
if ((pagecache= (PAGECACHE*) my_malloc(sizeof(PAGECACHE),
MYF(MY_ZEROFILL | MY_WME))))
{
if (!new NAMED_LIST(&pagecaches, name, length, (uchar*) pagecache))
{
my_free((char*) pagecache, MYF(0));
pagecache= 0;
}
else
{
/*
Set default values for a key cache
The values in maria_pagecache_var is set by my_getopt() at startup
We don't set 'buff_size' as this is used to enable the key cache
*/
pagecache->param_buff_size= (maria_pagecache_var.param_buff_size ?
maria_pagecache_var.param_buff_size:
KEY_CACHE_SIZE);
pagecache->param_division_limit= maria_pagecache_var.param_division_limit;
pagecache->param_age_threshold= maria_pagecache_var.param_age_threshold;
}
}
DBUG_RETURN(pagecache);
}
PAGECACHE *get_or_create_pagecache(const char *name, uint length)
{
LEX_STRING pagecache_name;
PAGECACHE *pagecache;
pagecache_name.str= (char *) name;
pagecache_name.length= length;
pthread_mutex_lock(&LOCK_global_system_variables);
if (!(pagecache= get_pagecache(&pagecache_name)))
pagecache= create_pagecache(name, length);
pthread_mutex_unlock(&LOCK_global_system_variables);
return pagecache;
}
void free_pagecache(const char *name, PAGECACHE *pagecache)
{
ha_end_pagecache(pagecache);
my_free((char*) pagecache, MYF(0));
}
bool process_pagecaches(int (* func) (const char *name, PAGECACHE *))
{
I_List_iterator<NAMED_LIST> it(pagecaches);
NAMED_LIST *element;
while ((element= it++))
{
PAGECACHE *pagecache= (PAGECACHE *) element->data;
func(element->name, pagecache);
}
return 0;
}
#endif /* WITH_MARIA_STORAGE_ENGINE */
void sys_var_trust_routine_creators::warn_deprecated(THD *thd)
{
WARN_DEPRECATED(thd, "5.2", "log_bin_trust_routine_creators",
......
......@@ -734,33 +734,6 @@ class sys_var_key_cache_long :public sys_var_key_cache_param
};
#ifdef WITH_MARIA_STORAGE_ENGINE
class sys_var_pagecache_param :public sys_var
{
protected:
size_t offset;
public:
sys_var_pagecache_param(const char *name_arg, size_t offset_arg)
:sys_var(name_arg), offset(offset_arg)
{}
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
bool check_default(enum_var_type type) { return 1; }
bool is_struct() { return 1; }
};
class sys_var_pagecache_long :public sys_var_pagecache_param
{
public:
sys_var_pagecache_long(const char *name_arg, size_t offset_arg)
:sys_var_pagecache_param(name_arg, offset_arg)
{}
bool update(THD *thd, set_var *var);
SHOW_TYPE type() { return SHOW_LONG; }
};
#endif /* WITH_MARIA_STORAGE_ENGINE */
class sys_var_thd_date_time_format :public sys_var_thd
{
DATE_TIME_FORMAT *SV::*offset;
......@@ -1185,10 +1158,6 @@ class NAMED_LIST :public ilink
my_free((uchar*) name, MYF(0));
}
friend bool process_key_caches(process_key_cache_t func);
#ifdef WITH_MARIA_STORAGE_ENGINE
friend bool process_pagecaches(int (* func) (const char *name,
PAGECACHE *));
#endif /* WITH_MARIA_STORAGE_ENGINE */
friend void delete_elements(I_List<NAMED_LIST> *list,
void (*free_element)(const char*, uchar*));
};
......@@ -1198,9 +1167,6 @@ class NAMED_LIST :public ilink
extern sys_var_thd_bool sys_old_alter_table;
extern sys_var_thd_bool sys_old_passwords;
extern LEX_STRING default_key_cache_base;
#ifdef WITH_MARIA_STORAGE_ENGINE
extern LEX_STRING maria_pagecache_base;
#endif /* WITH_MARIA_STORAGE_ENGINE */
/* For sql_yacc */
struct sys_var_with_base
......@@ -1242,8 +1208,3 @@ void free_key_cache(const char *name, KEY_CACHE *key_cache);
bool process_key_caches(process_key_cache_t func);
void delete_elements(I_List<NAMED_LIST> *list,
void (*free_element)(const char*, uchar*));
#ifdef WITH_MARIA_STORAGE_ENGINE
PAGECACHE *get_or_create_pagecache(const char *name, uint length);
void free_pagecache(const char *name, PAGECACHE *pagecache);
bool process_pagecaches(int (* func) (const char *name, PAGECACHE *));
#endif /* WITH_MARIA_STORAGE_ENGINE */
......@@ -939,7 +939,7 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
is correctly created as non-transactional but then, when truncated, is
recreated as transactional.
*/
if (table_type->db_type == DB_TYPE_MARIA)
if (table_type == maria_hton)
create_info.transactional= HA_CHOICE_NO;
#endif
close_temporary_table(thd, table, 0, 0); // Don't free share
......
......@@ -44,6 +44,9 @@ C_MODE_END
#define trans_register_ha(A, B, C) do { /* nothing */ } while(0)
#endif
ulong pagecache_division_limit, pagecache_age_threshold;
ulonglong pagecache_buffer_size;
/**
@todo For now there is no way for a user to set a different value of
maria_recover_options, i.e. auto-check-and-repair is always disabled.
......@@ -54,7 +57,7 @@ C_MODE_END
still corrupted.
*/
ulong maria_recover_options= HA_RECOVER_NONE;
static handlerton *maria_hton;
handlerton *maria_hton;
/* bits in maria_recover_options */
const char *maria_recover_names[]=
......@@ -100,6 +103,26 @@ static MYSQL_SYSVAR_ULONGLONG(max_sort_file_size,
"temporary file would get bigger than this.",
0, 0, MAX_FILE_SIZE, 0, MAX_FILE_SIZE, 1024*1024);
static MYSQL_SYSVAR_ULONG(pagecache_age_threshold,
pagecache_age_threshold, PLUGIN_VAR_RQCMDARG,
"This characterizes the number of hits a hot block has to be untouched "
"until it is considered aged enough to be downgraded to a warm block. "
"This specifies the percentage ratio of that number of hits to the "
"total number of blocks in the page cache.", 0, 0,
300, 100, ~0L, 100);
static MYSQL_SYSVAR_ULONGLONG(pagecache_buffer_size, pagecache_buffer_size,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"The size of the buffer used for index blocks for Maria tables. "
"Increase this to get better index handling (for all reads and multiple "
"writes) to as much as you can afford.", 0, 0,
KEY_CACHE_SIZE, MALLOC_OVERHEAD, ~(ulong) 0, IO_SIZE);
static MYSQL_SYSVAR_ULONG(pagecache_division_limit, pagecache_division_limit,
PLUGIN_VAR_RQCMDARG,
"The minimum percentage of warm blocks in key cache", 0, 0,
100, 1, 100, 1);
static MYSQL_THDVAR_ULONG(repair_threads, PLUGIN_VAR_RQCMDARG,
"Number of threads to use when repairing maria tables. The value of 1 "
"disables parallel repair.",
......@@ -1345,6 +1368,7 @@ int ha_maria::repair(THD *thd, HA_CHECK &param, bool do_optimize)
int ha_maria::assign_to_keycache(THD * thd, HA_CHECK_OPT *check_opt)
{
#if 0 && NOT_IMPLEMENTED
PAGECACHE *new_pagecache= check_opt->pagecache;
const char *errmsg= 0;
int error= HA_ADMIN_OK;
......@@ -1352,8 +1376,6 @@ int ha_maria::assign_to_keycache(THD * thd, HA_CHECK_OPT *check_opt)
TABLE_LIST *table_list= table->pos_in_table_list;
DBUG_ENTER("ha_maria::assign_to_keycache");
/* for now, it is disabled */
DBUG_RETURN(HA_ADMIN_NOT_IMPLEMENTED);
table->keys_in_use_for_query.clear_all();
......@@ -1386,6 +1408,9 @@ int ha_maria::assign_to_keycache(THD * thd, HA_CHECK_OPT *check_opt)
_ma_check_print_error(&param, errmsg);
}
DBUG_RETURN(error);
#else
return HA_ADMIN_NOT_IMPLEMENTED;
#endif
}
......@@ -2394,7 +2419,7 @@ static int ha_maria_init(void *p)
int res;
maria_hton= (handlerton *)p;
maria_hton->state= SHOW_OPTION_YES;
maria_hton->db_type= DB_TYPE_MARIA;
maria_hton->db_type= DB_TYPE_UNKNOWN;
maria_hton->create= maria_create_handler;
maria_hton->panic= maria_hton_panic;
maria_hton->commit= maria_commit;
......@@ -2404,6 +2429,9 @@ static int ha_maria_init(void *p)
bzero(maria_log_pagecache, sizeof(*maria_log_pagecache));
maria_data_root= mysql_real_data_home;
res= maria_init() || ma_control_file_create_or_open() ||
(init_pagecache(maria_pagecache,
pagecache_buffer_size, pagecache_division_limit,
pagecache_age_threshold, MARIA_KEY_BLOCK_LENGTH) == 0) ||
(init_pagecache(maria_log_pagecache,
TRANSLOG_PAGECACHE_SIZE, 0, 0,
TRANSLOG_PAGE_SIZE) == 0) ||
......@@ -2496,6 +2524,9 @@ static struct st_mysql_sys_var* system_variables[]= {
MYSQL_SYSVAR(block_size),
MYSQL_SYSVAR(checkpoint_frequency),
MYSQL_SYSVAR(max_sort_file_size),
MYSQL_SYSVAR(pagecache_age_threshold),
MYSQL_SYSVAR(pagecache_buffer_size),
MYSQL_SYSVAR(pagecache_division_limit),
MYSQL_SYSVAR(repair_threads),
MYSQL_SYSVAR(sort_buffer_size),
MYSQL_SYSVAR(stats_method),
......@@ -2523,6 +2554,16 @@ static void update_checkpoint_frequency(MYSQL_THD thd,
}
}
static SHOW_VAR status_variables[]= {
{"Maria_pagecache_blocks_not_flushed", (char*) &maria_pagecache_var.global_blocks_changed, SHOW_LONG},
{"Maria_pagecache_blocks_unused", (char*) &maria_pagecache_var.blocks_unused, SHOW_LONG},
{"Maria_pagecache_blocks_used", (char*) &maria_pagecache_var.blocks_used, SHOW_LONG},
{"Maria_pagecache_read_requests", (char*) &maria_pagecache_var.global_cache_r_requests, SHOW_LONGLONG},
{"Maria_pagecache_reads", (char*) &maria_pagecache_var.global_cache_read, SHOW_LONGLONG},
{"Maria_pagecache_write_requests", (char*) &maria_pagecache_var.global_cache_w_requests, SHOW_LONGLONG},
{"Maria_pagecache_writes", (char*) &maria_pagecache_var.global_cache_write, SHOW_LONGLONG},
{NullS, NullS, SHOW_LONG}
};
struct st_mysql_storage_engine maria_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
......@@ -2538,7 +2579,7 @@ mysql_declare_plugin(maria)
ha_maria_init, /* Plugin Init */
NULL, /* Plugin Deinit */
0x0100, /* 1.0 */
NULL, /* status variables */
status_variables, /* status variables */
system_variables, /* system variables */
NULL
}
......
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