mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Post-review fixes.
This commit is contained in:
@ -37,7 +37,6 @@ C_MODE_START
|
||||
|
||||
#define MAX_KEY_CACHE_PARTITIONS 64
|
||||
|
||||
|
||||
/* The structure to get statistical data about a key cache */
|
||||
|
||||
typedef struct st_key_cache_statistics
|
||||
@ -53,6 +52,8 @@ typedef struct st_key_cache_statistics
|
||||
ulonglong writes; /* number of actual writes from buffers into files */
|
||||
} KEY_CACHE_STATISTICS;
|
||||
|
||||
#define NO_LONG_KEY_CACHE_STAT_VARIABLES 3
|
||||
|
||||
/* The type of a key cache object */
|
||||
typedef enum key_cache_type
|
||||
{
|
||||
@ -61,6 +62,55 @@ typedef enum key_cache_type
|
||||
} KEY_CACHE_TYPE;
|
||||
|
||||
|
||||
typedef
|
||||
int (*INIT_KEY_CACHE)
|
||||
(void *, uint key_cache_block_size,
|
||||
size_t use_mem, uint division_limit, uint age_threshold);
|
||||
typedef
|
||||
int (*RESIZE_KEY_CACHE)
|
||||
(void *, uint key_cache_block_size,
|
||||
size_t use_mem, uint division_limit, uint age_threshold);
|
||||
typedef
|
||||
void (*CHANGE_KEY_CACHE_PARAM)
|
||||
(void *keycache_cb,
|
||||
uint division_limit, uint age_threshold);
|
||||
typedef
|
||||
uchar* (*KEY_CACHE_READ)
|
||||
(void *keycache_cb,
|
||||
File file, my_off_t filepos, int level,
|
||||
uchar *buff, uint length,
|
||||
uint block_length, int return_buffer);
|
||||
typedef
|
||||
int (*KEY_CACHE_INSERT)
|
||||
(void *keycache_cb,
|
||||
File file, my_off_t filepos, int level,
|
||||
uchar *buff, uint length);
|
||||
typedef
|
||||
int (*KEY_CACHE_WRITE)
|
||||
(void *keycache_cb,
|
||||
File file, void *file_extra,
|
||||
my_off_t filepos, int level,
|
||||
uchar *buff, uint length,
|
||||
uint block_length, int force_write);
|
||||
typedef
|
||||
int (*FLUSH_KEY_BLOCKS)
|
||||
(void *keycache_cb,
|
||||
int file, void *file_extra,
|
||||
enum flush_type type);
|
||||
typedef
|
||||
int (*RESET_KEY_CACHE_COUNTERS)
|
||||
(const char *name, void *keycache_cb);
|
||||
typedef
|
||||
void (*END_KEY_CACHE)
|
||||
(void *keycache_cb, my_bool cleanup);
|
||||
typedef
|
||||
void (*GET_KEY_CACHE_STATISTICS)
|
||||
(void *keycache_cb, uint partition_no,
|
||||
KEY_CACHE_STATISTICS *key_cache_stats);
|
||||
typedef
|
||||
ulonglong (*GET_KEY_CACHE_STAT_VALUE)
|
||||
(void *keycache_cb, uint var_no);
|
||||
|
||||
/*
|
||||
An object of the type KEY_CACHE_FUNCS contains pointers to all functions
|
||||
from the key cache interface.
|
||||
@ -74,32 +124,17 @@ typedef enum key_cache_type
|
||||
|
||||
typedef struct st_key_cache_funcs
|
||||
{
|
||||
int (*init) (void *, uint key_cache_block_size,
|
||||
size_t use_mem, uint division_limit, uint age_threshold);
|
||||
int (*resize) (void *, uint key_cache_block_size,
|
||||
size_t use_mem, uint division_limit, uint age_threshold);
|
||||
void (*change_param) (void *keycache_cb,
|
||||
uint division_limit, uint age_threshold);
|
||||
uchar* (*read) (void *keycache_cb,
|
||||
File file, my_off_t filepos, int level,
|
||||
uchar *buff, uint length,
|
||||
uint block_length, int return_buffer);
|
||||
int (*insert) (void *keycache_cb,
|
||||
File file, my_off_t filepos, int level,
|
||||
uchar *buff, uint length);
|
||||
int (*write) (void *keycache_cb,
|
||||
File file, void *file_extra,
|
||||
my_off_t filepos, int level,
|
||||
uchar *buff, uint length,
|
||||
uint block_length, int force_write);
|
||||
int (*flush) (void *keycache_cb,
|
||||
int file, void *file_extra,
|
||||
enum flush_type type);
|
||||
int (*reset_counters) (const char *name, void *keycache_cb);
|
||||
void (*end) (void *keycache_cb, my_bool cleanup);
|
||||
void (*get_stats) (void *keycache_cb, uint partition_no,
|
||||
KEY_CACHE_STATISTICS *key_cache_stats);
|
||||
ulonglong (*get_stat_val) (void *keycache_cb, uint var_no);
|
||||
INIT_KEY_CACHE init;
|
||||
RESIZE_KEY_CACHE resize;
|
||||
CHANGE_KEY_CACHE_PARAM change_param;
|
||||
KEY_CACHE_READ read;
|
||||
KEY_CACHE_INSERT insert;
|
||||
KEY_CACHE_WRITE write;
|
||||
FLUSH_KEY_BLOCKS flush;
|
||||
RESET_KEY_CACHE_COUNTERS reset_counters;
|
||||
END_KEY_CACHE end;
|
||||
GET_KEY_CACHE_STATISTICS get_stats;
|
||||
GET_KEY_CACHE_STAT_VALUE get_stat_val;
|
||||
} KEY_CACHE_FUNCS;
|
||||
|
||||
|
||||
|
@ -672,12 +672,12 @@ insert into t2 values (2000, 3, 'yyyy');
|
||||
select * from information_schema.key_caches where key_cache_name like "keycache2"
|
||||
and partition_number is null;
|
||||
KEY_CACHE_NAME PARTITIONS PARTITION_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
keycache2 NULL NULL 1048576 1024 0 # 0 0 0 0 0
|
||||
keycache2 NULL NULL 1048576 1024 6 # 0 6 6 3 3
|
||||
select * from information_schema.key_caches where key_cache_name like "key%"
|
||||
and partition_number is null;
|
||||
KEY_CACHE_NAME PARTITIONS PARTITION_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
keycache1 7 NULL 262143 2048 25 # 0 2082 25 1071 19
|
||||
keycache2 NULL NULL 1048576 1024 0 # 0 0 0 0 0
|
||||
keycache2 NULL NULL 1048576 1024 6 # 0 6 6 3 3
|
||||
cache index t2 in keycache1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t2 assign_to_keycache status OK
|
||||
@ -718,7 +718,7 @@ KEY_CACHE_NAME PARTITIONS PARTITION_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUS
|
||||
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
|
||||
small NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache1 7 NULL 262143 2048 # # 0 3201 43 1594 30
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3
|
||||
set global keycache1.key_cache_block_size=2*1024;
|
||||
insert into t2 values (7000, 3, 'yyyy');
|
||||
select * from information_schema.key_caches where partition_number is null;
|
||||
@ -726,66 +726,72 @@ KEY_CACHE_NAME PARTITIONS PARTITION_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUS
|
||||
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
|
||||
small NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache1 7 NULL 262143 2048 # # 0 6 6 3 3
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3
|
||||
set global keycache1.key_cache_block_size=8*1024;
|
||||
select * from information_schema.key_caches where partition_number is null;
|
||||
KEY_CACHE_NAME PARTITIONS PARTITION_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
|
||||
small NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache1 3 NULL 262143 8192 # # 0 0 0 0 0
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3
|
||||
insert into t2 values (8000, 3, 'yyyy');
|
||||
select * from information_schema.key_caches where partition_number is null;
|
||||
KEY_CACHE_NAME PARTITIONS PARTITION_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
|
||||
small NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache1 3 NULL 262143 8192 # # 0 6 5 3 3
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3
|
||||
set global keycache1.key_buffer_size=64*1024;
|
||||
select * from information_schema.key_caches where partition_number is null;
|
||||
KEY_CACHE_NAME PARTITIONS PARTITION_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
|
||||
small NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3
|
||||
set global keycache1.key_cache_block_size=2*1024;
|
||||
select * from information_schema.key_caches where partition_number is null;
|
||||
KEY_CACHE_NAME PARTITIONS PARTITION_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
|
||||
small NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache1 3 NULL 65535 2048 # # 0 0 0 0 0
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3
|
||||
set global keycache1.key_cache_block_size=8*1024;
|
||||
select * from information_schema.key_caches where partition_number is null;
|
||||
KEY_CACHE_NAME PARTITIONS PARTITION_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
|
||||
small NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3
|
||||
set global keycache1.key_buffer_size=0;
|
||||
select * from information_schema.key_caches where partition_number is null;
|
||||
KEY_CACHE_NAME PARTITIONS PARTITION_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
|
||||
small NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3
|
||||
set global keycache1.key_cache_block_size=8*1024;
|
||||
select * from information_schema.key_caches where partition_number is null;
|
||||
KEY_CACHE_NAME PARTITIONS PARTITION_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
|
||||
small NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3
|
||||
set global keycache1.key_buffer_size=0;
|
||||
select * from information_schema.key_caches where partition_number is null;
|
||||
KEY_CACHE_NAME PARTITIONS PARTITION_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
|
||||
small NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3
|
||||
set global keycache1.key_buffer_size=128*1024;
|
||||
select * from information_schema.key_caches where partition_number is null;
|
||||
KEY_CACHE_NAME PARTITIONS PARTITION_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
|
||||
small NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache1 1 NULL 131072 8192 # # 0 0 0 0 0
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3
|
||||
set global keycache1.key_cache_block_size=1024;
|
||||
select * from information_schema.key_caches where partition_number is null;
|
||||
KEY_CACHE_NAME PARTITIONS PARTITION_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
|
||||
small NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache1 7 NULL 131068 1024 # # 0 0 0 0 0
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3
|
||||
drop table t1,t2;
|
||||
set global keycache1.key_buffer_size=0;
|
||||
set global keycache2.key_buffer_size=0;
|
||||
|
@ -469,6 +469,8 @@ insert into t2 values (7000, 3, 'yyyy');
|
||||
select * from information_schema.key_caches where partition_number is null;
|
||||
|
||||
set global keycache1.key_cache_block_size=8*1024;
|
||||
--replace_column 6 # 7 #
|
||||
select * from information_schema.key_caches where partition_number is null;
|
||||
insert into t2 values (8000, 3, 'yyyy');
|
||||
--replace_column 6 # 7 #
|
||||
select * from information_schema.key_caches where partition_number is null;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -2235,8 +2235,9 @@ static void update_key_cache_stat_var(KEY_CACHE *key_cache, size_t ofs)
|
||||
case offsetof(KEY_CACHE, global_cache_read):
|
||||
case offsetof(KEY_CACHE, global_cache_w_requests):
|
||||
case offsetof(KEY_CACHE, global_cache_write):
|
||||
var_no= 3+(ofs-offsetof(KEY_CACHE, global_cache_w_requests))/
|
||||
sizeof(ulonglong);
|
||||
var_no= NO_LONG_KEY_CACHE_STAT_VARIABLES +
|
||||
(ofs-offsetof(KEY_CACHE, global_cache_w_requests))/
|
||||
sizeof(ulonglong);
|
||||
*(ulonglong *)((char *) key_cache + ofs)=
|
||||
get_key_cache_stat_value(key_cache, var_no);
|
||||
break;
|
||||
@ -6643,13 +6644,13 @@ int store_key_cache_table_record(THD *thd, TABLE *table,
|
||||
KEY_CACHE *key_cache,
|
||||
uint partitions, uint partition_no)
|
||||
{
|
||||
KEY_CACHE_STATISTICS key_cache_stats;
|
||||
KEY_CACHE_STATISTICS keycache_stats;
|
||||
uint err;
|
||||
DBUG_ENTER("store_key_cache_table_record");
|
||||
|
||||
get_key_cache_statistics(key_cache, partition_no, &key_cache_stats);
|
||||
get_key_cache_statistics(key_cache, partition_no, &keycache_stats);
|
||||
|
||||
if (key_cache_stats.mem_size == 0)
|
||||
if (!key_cache->key_cache_inited || keycache_stats.mem_size == 0)
|
||||
DBUG_RETURN(0);
|
||||
|
||||
restore_record(table, s->default_values);
|
||||
@ -6669,15 +6670,15 @@ int store_key_cache_table_record(THD *thd, TABLE *table,
|
||||
table->field[2]->set_notnull();
|
||||
table->field[2]->store((long) partition_no, TRUE);
|
||||
}
|
||||
table->field[3]->store(key_cache_stats.mem_size, TRUE);
|
||||
table->field[4]->store(key_cache_stats.block_size, TRUE);
|
||||
table->field[5]->store(key_cache_stats.blocks_used, TRUE);
|
||||
table->field[6]->store(key_cache_stats.blocks_unused, TRUE);
|
||||
table->field[7]->store(key_cache_stats.blocks_changed, TRUE);
|
||||
table->field[8]->store(key_cache_stats.read_requests, TRUE);
|
||||
table->field[9]->store(key_cache_stats.reads, TRUE);
|
||||
table->field[10]->store(key_cache_stats.write_requests, TRUE);
|
||||
table->field[11]->store(key_cache_stats.writes, TRUE);
|
||||
table->field[3]->store(keycache_stats.mem_size, TRUE);
|
||||
table->field[4]->store(keycache_stats.block_size, TRUE);
|
||||
table->field[5]->store(keycache_stats.blocks_used, TRUE);
|
||||
table->field[6]->store(keycache_stats.blocks_unused, TRUE);
|
||||
table->field[7]->store(keycache_stats.blocks_changed, TRUE);
|
||||
table->field[8]->store(keycache_stats.read_requests, TRUE);
|
||||
table->field[9]->store(keycache_stats.reads, TRUE);
|
||||
table->field[10]->store(keycache_stats.write_requests, TRUE);
|
||||
table->field[11]->store(keycache_stats.writes, TRUE);
|
||||
|
||||
err= schema_table_store_record(thd, table);
|
||||
DBUG_RETURN(err);
|
||||
|
Reference in New Issue
Block a user