summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2010-11-02 10:12:29 +0100
committerSergei Golubchik <sergii@pisem.net>2010-11-02 10:12:29 +0100
commit74711a46153088e5e9159977b42ba7615a3af2df (patch)
tree16b52e05f461a0f9392f4c2bfaeacb3dadfeb126
parent8e7ebfbce89a472b3c5a6c30e6de101e567a8218 (diff)
parent5789f96c624d00aeef137602ab0c4828620748e8 (diff)
downloadmariadb-git-74711a46153088e5e9159977b42ba7615a3af2df.tar.gz
merge w/ 5.2
-rw-r--r--client/mysqltest.cc15
-rw-r--r--include/keycache.h13
-rw-r--r--mysql-test/r/key_cache.result3
-rw-r--r--mysql-test/r/ps_ddl.result1
-rw-r--r--mysql-test/suite/rpl/t/rpl_loaddata_symlink.test2
-rw-r--r--mysql-test/suite/vcol/inc/vcol_supported_sql_funcs_main.inc2
-rw-r--r--mysql-test/suite/vcol/r/vcol_supported_sql_funcs_innodb.result4
-rw-r--r--mysql-test/suite/vcol/r/vcol_supported_sql_funcs_myisam.result4
-rw-r--r--mysql-test/t/ps_ddl.test4
-rw-r--r--mysys/mf_keycache.c161
-rw-r--r--sql/mysql_priv.h3
-rw-r--r--sql/mysqld.cc48
-rw-r--r--sql/sql_show.cc38
-rw-r--r--sql/sql_test.cc14
-rw-r--r--sql/table.cc5
-rw-r--r--storage/myisam/mi_test2.c15
16 files changed, 92 insertions, 240 deletions
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index 5162d58d02d..635d013eae8 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -610,14 +610,14 @@ public:
lines++;
int show_offset= 0;
- char buf[256];
+ char buf[256+1]; /* + zero termination for DBUG_PRINT */
size_t bytes;
bool found_bof= false;
/* Search backward in file until "lines" newline has been found */
while (lines && !found_bof)
{
- show_offset-= sizeof(buf);
+ show_offset-= sizeof(buf)-1;
while(fseek(m_file, show_offset, SEEK_END) != 0 && show_offset < 0)
{
found_bof= true;
@@ -625,7 +625,7 @@ public:
show_offset++;
}
- if ((bytes= fread(buf, 1, sizeof(buf), m_file)) <= 0)
+ if ((bytes= fread(buf, 1, sizeof(buf)-1, m_file)) <= 0)
{
// ferror=0 will happen here if no queries executed yet
if (ferror(m_file))
@@ -635,6 +635,7 @@ public:
DBUG_VOID_RETURN;
}
+ IF_DBUG(buf[bytes]= '\0';)
DBUG_PRINT("info", ("Read %lu bytes from file, buf: %s",
(unsigned long)bytes, buf));
@@ -679,8 +680,8 @@ public:
}
}
- while ((bytes= fread(buf, 1, sizeof(buf), m_file)) > 0)
- if (fwrite(buf, 1, bytes, stderr))
+ while ((bytes= fread(buf, 1, sizeof(buf)-1, m_file)) > 0)
+ if (bytes != fwrite(buf, 1, bytes, stderr))
die("Failed to write to '%s', errno: %d",
m_file_name, errno);
@@ -723,6 +724,10 @@ void handle_no_error(struct st_command*);
#ifdef EMBEDDED_LIBRARY
+/* workaround for MySQL BUG#57491 */
+#undef MY_WME
+#define MY_WME 0
+
/* attributes of the query thread */
pthread_attr_t cn_thd_attrib;
diff --git a/include/keycache.h b/include/keycache.h
index 25a204cede2..acb85522c0e 100644
--- a/include/keycache.h
+++ b/include/keycache.h
@@ -46,6 +46,7 @@ typedef struct st_key_cache_statistics
ulonglong blocks_used; /* maximum number of used blocks/buffers */
ulonglong blocks_unused; /* number of currently unused blocks */
ulonglong blocks_changed; /* number of currently dirty blocks */
+ ulonglong blocks_warm; /* number of blocks in warm sub-chain */
ulonglong read_requests; /* number of read requests (read hits) */
ulonglong reads; /* number of actual reads from files into buffers */
ulonglong write_requests; /* number of write requests (write hits) */
@@ -107,9 +108,6 @@ 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
@@ -134,7 +132,6 @@ typedef struct st_key_cache_funcs
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;
@@ -153,13 +150,6 @@ typedef struct st_key_cache
my_bool in_init; /* Set to 1 in MySQL during init/resize */
uint partitions; /* actual number of partitions */
size_t key_cache_mem_size; /* specified size of the cache memory */
- ulong blocks_used; /* maximum number of concurrently used blocks */
- ulong blocks_unused; /* number of currently unused blocks */
- ulong global_blocks_changed; /* number of currently dirty blocks */
- ulonglong global_cache_w_requests;/* number of write requests (write hits) */
- ulonglong global_cache_write; /* number of writes from cache to files */
- ulonglong global_cache_r_requests;/* number of read requests (read hits) */
- ulonglong global_cache_read; /* number of reads from files to cache */
} KEY_CACHE;
@@ -193,7 +183,6 @@ extern void end_key_cache(KEY_CACHE *keycache, my_bool cleanup);
extern void get_key_cache_statistics(KEY_CACHE *keycache,
uint partition_no,
KEY_CACHE_STATISTICS *key_cache_stats);
-extern ulonglong get_key_cache_stat_value(KEY_CACHE *keycache, uint var_no);
/* Functions to handle multiple key caches */
extern my_bool multi_keycache_init(void);
diff --git a/mysql-test/r/key_cache.result b/mysql-test/r/key_cache.result
index a87ade614b8..c432732b1f9 100644
--- a/mysql-test/r/key_cache.result
+++ b/mysql-test/r/key_cache.result
@@ -412,6 +412,7 @@ Variable_name Value
Key_blocks_not_flushed 0
Key_blocks_unused KEY_BLOCKS_UNUSED
Key_blocks_used 4
+Key_blocks_warm 0
Key_read_requests 22
Key_reads 0
Key_write_requests 26
@@ -459,6 +460,7 @@ Variable_name Value
Key_blocks_not_flushed 0
Key_blocks_unused KEY_BLOCKS_UNUSED
Key_blocks_used 4
+Key_blocks_warm 0
Key_read_requests 22
Key_reads 0
Key_write_requests 26
@@ -501,6 +503,7 @@ Variable_name Value
Key_blocks_not_flushed 0
Key_blocks_unused KEY_BLOCKS_UNUSED
Key_blocks_used 4
+Key_blocks_warm 0
Key_read_requests 22
Key_reads 0
Key_write_requests 26
diff --git a/mysql-test/r/ps_ddl.result b/mysql-test/r/ps_ddl.result
index 375f31ef9c4..a5e71e114ca 100644
--- a/mysql-test/r/ps_ddl.result
+++ b/mysql-test/r/ps_ddl.result
@@ -4,6 +4,7 @@ drop procedure if exists p_verify_reprepare_count;
drop procedure if exists p1;
drop function if exists f1;
drop view if exists v1, v2;
+TRUNCATE TABLE mysql.general_log;
create procedure p_verify_reprepare_count(expected int)
begin
declare old_reprepare_count int default @reprepare_count;
diff --git a/mysql-test/suite/rpl/t/rpl_loaddata_symlink.test b/mysql-test/suite/rpl/t/rpl_loaddata_symlink.test
index 63e65834e5b..69b481bddd1 100644
--- a/mysql-test/suite/rpl/t/rpl_loaddata_symlink.test
+++ b/mysql-test/suite/rpl/t/rpl_loaddata_symlink.test
@@ -3,8 +3,8 @@
# This test verifies if loading data infile will work fine
# if the path of the load data file is a symbolic link.
#
---source include/master-slave.inc
--source include/not_windows.inc
+--source include/master-slave.inc
--source include/have_binlog_format_statement.inc
create table t1(a int not null auto_increment, b int, primary key(a) );
diff --git a/mysql-test/suite/vcol/inc/vcol_supported_sql_funcs_main.inc b/mysql-test/suite/vcol/inc/vcol_supported_sql_funcs_main.inc
index daf59c38a7e..4f6b960f9d0 100644
--- a/mysql-test/suite/vcol/inc/vcol_supported_sql_funcs_main.inc
+++ b/mysql-test/suite/vcol/inc/vcol_supported_sql_funcs_main.inc
@@ -407,7 +407,7 @@ let $rows = 1;
--source suite/vcol/inc/vcol_supported_sql_funcs.inc
--echo # LIKE
-let $cols = a varchar(10), b bool as (a like 'H%o');
+let $cols = a varchar(10), b bool as (a like 'H%!o' escape '!');
let $values1 = 'Hello',default;
let $values2 = 'MySQL',default;
let $rows = 2;
diff --git a/mysql-test/suite/vcol/r/vcol_supported_sql_funcs_innodb.result b/mysql-test/suite/vcol/r/vcol_supported_sql_funcs_innodb.result
index 2bc652a7da2..83f755a2e7f 100644
--- a/mysql-test/suite/vcol/r/vcol_supported_sql_funcs_innodb.result
+++ b/mysql-test/suite/vcol/r/vcol_supported_sql_funcs_innodb.result
@@ -968,12 +968,12 @@ drop table t1;
set sql_warnings = 0;
# LIKE
set sql_warnings = 1;
-create table t1 (a varchar(10), b bool as (a like 'H%o'));
+create table t1 (a varchar(10), b bool as (a like 'H%!o' escape '!'));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varchar(10) DEFAULT NULL,
- `b` tinyint(1) AS (a like 'H%o') VIRTUAL
+ `b` tinyint(1) AS (a like 'H%!o' escape '!') VIRTUAL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
insert into t1 values ('Hello',default);
insert into t1 values ('MySQL',default);
diff --git a/mysql-test/suite/vcol/r/vcol_supported_sql_funcs_myisam.result b/mysql-test/suite/vcol/r/vcol_supported_sql_funcs_myisam.result
index a94e220180c..844aae38af2 100644
--- a/mysql-test/suite/vcol/r/vcol_supported_sql_funcs_myisam.result
+++ b/mysql-test/suite/vcol/r/vcol_supported_sql_funcs_myisam.result
@@ -968,12 +968,12 @@ drop table t1;
set sql_warnings = 0;
# LIKE
set sql_warnings = 1;
-create table t1 (a varchar(10), b bool as (a like 'H%o'));
+create table t1 (a varchar(10), b bool as (a like 'H%!o' escape '!'));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varchar(10) DEFAULT NULL,
- `b` tinyint(1) AS (a like 'H%o') VIRTUAL
+ `b` tinyint(1) AS (a like 'H%!o' escape '!') VIRTUAL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
insert into t1 values ('Hello',default);
insert into t1 values ('MySQL',default);
diff --git a/mysql-test/t/ps_ddl.test b/mysql-test/t/ps_ddl.test
index 1543c757908..10a96285451 100644
--- a/mysql-test/t/ps_ddl.test
+++ b/mysql-test/t/ps_ddl.test
@@ -58,6 +58,10 @@ drop function if exists f1;
drop view if exists v1, v2;
--enable_warnings
+# Avoid selecting from a huge table possibly left over from previous tests,
+# as this really hurts --valgrind testing.
+TRUNCATE TABLE mysql.general_log;
+
delimiter |;
create procedure p_verify_reprepare_count(expected int)
begin
diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c
index 08c160910c7..00e5f0874a2 100644
--- a/mysys/mf_keycache.c
+++ b/mysys/mf_keycache.c
@@ -4906,6 +4906,7 @@ void get_simple_key_cache_statistics(SIMPLE_KEY_CACHE_CB *keycache,
keycache_stats->blocks_used= keycache->blocks_used;
keycache_stats->blocks_unused= keycache->blocks_unused;
keycache_stats->blocks_changed= keycache->global_blocks_changed;
+ keycache_stats->blocks_warm= keycache->warm_blocks;
keycache_stats->read_requests= keycache->global_cache_r_requests;
keycache_stats->reads= keycache->global_cache_read;
keycache_stats->write_requests= keycache->global_cache_w_requests;
@@ -4915,61 +4916,6 @@ void get_simple_key_cache_statistics(SIMPLE_KEY_CACHE_CB *keycache,
/*
- Offsets of the statistical values in the control block for a simple key cache
- The first NO_LONG_KEY_CACHE_STAT_VARIABLES=3 are of the ulong type while the
- remaining are of the ulonglong type.
- */
-static size_t simple_key_cache_stat_var_offsets[]=
-{
- offsetof(SIMPLE_KEY_CACHE_CB, blocks_used),
- offsetof(SIMPLE_KEY_CACHE_CB, blocks_unused),
- offsetof(SIMPLE_KEY_CACHE_CB, global_blocks_changed),
- offsetof(SIMPLE_KEY_CACHE_CB, global_cache_w_requests),
- offsetof(SIMPLE_KEY_CACHE_CB, global_cache_write),
- offsetof(SIMPLE_KEY_CACHE_CB, global_cache_r_requests),
- offsetof(SIMPLE_KEY_CACHE_CB, global_cache_read)
-};
-
-
-/*
- Get the value of a statistical variable for a simple key cache
-
- SYNOPSIS
- get_simple_key_cache_stat_value()
- keycache pointer to the control block of a simple key cache
- var_no the ordered number of a statistical variable
-
- DESCRIPTION
- This function is the implementation of the get_simple_key_cache_stat_value
- interface function that is employed by simple (non-partitioned) key caches.
- The function takes the parameter keycache as a pointer to the
- control block structure of the type SIMPLE_KEY_CACHE_CB for a simple key
- cache. This function returns the value of the statistical variable var_no
- for this key cache. The variables are numbered starting from 0 to 6.
-
- RETURN
- The value of the specified statistical variable
-
-*/
-
-static
-ulonglong get_simple_key_cache_stat_value(SIMPLE_KEY_CACHE_CB *keycache,
- uint var_no)
-{
- size_t var_ofs= simple_key_cache_stat_var_offsets[var_no];
- ulonglong res= 0;
- DBUG_ENTER("get_simple_key_cache_stat_value");
-
- if (var_no < 3)
- res= (ulonglong) (*(long *) ((char *) keycache + var_ofs));
- else
- res= *(ulonglong *) ((char *) keycache + var_ofs);
-
- DBUG_RETURN(res);
-}
-
-
-/*
The array of pointer to the key cache interface functions used for simple
key caches. Any simple key cache objects including those incorporated into
partitioned keys caches exploit this array.
@@ -4990,7 +4936,6 @@ static KEY_CACHE_FUNCS simple_key_cache_funcs =
(RESET_KEY_CACHE_COUNTERS) reset_simple_key_cache_counters,
(END_KEY_CACHE) end_simple_key_cache,
(GET_KEY_CACHE_STATISTICS) get_simple_key_cache_statistics,
- (GET_KEY_CACHE_STAT_VALUE) get_simple_key_cache_stat_value
};
@@ -5853,6 +5798,7 @@ get_partitioned_key_cache_statistics(PARTITIONED_KEY_CACHE_CB *keycache,
keycache_stats->blocks_used+= partition->blocks_used;
keycache_stats->blocks_unused+= partition->blocks_unused;
keycache_stats->blocks_changed+= partition->global_blocks_changed;
+ keycache_stats->blocks_warm+= partition->warm_blocks;
keycache_stats->read_requests+= partition->global_cache_r_requests;
keycache_stats->reads+= partition->global_cache_read;
keycache_stats->write_requests+= partition->global_cache_w_requests;
@@ -5861,61 +5807,6 @@ get_partitioned_key_cache_statistics(PARTITIONED_KEY_CACHE_CB *keycache,
DBUG_VOID_RETURN;
}
-/*
- Get the value of a statistical variable for a partitioned key cache
-
- SYNOPSIS
- get_partitioned_key_cache_stat_value()
- keycache pointer to the control block of a partitioned key cache
- var_no the ordered number of a statistical variable
-
- DESCRIPTION
- This function is the implementation of the get_key_cache_stat_value
- interface function that is employed by partitioned key caches.
- The function takes the parameter keycache as a pointer to the
- control block structure of the type PARTITIONED_KEY_CACHE_CB for a
- partitioned key cache.
- This function returns the value of the statistical variable var_no
- for this key cache. The variables are numbered starting from 0 to 6.
- The returned value is calculated as the sum of the values of the
- statistical variable with number var_no for all simple key caches that
- comprise the partitioned key cache.
-
- RETURN
- The value of the specified statistical variable
-*/
-
-static
-ulonglong
-get_partitioned_key_cache_stat_value(PARTITIONED_KEY_CACHE_CB *keycache,
- uint var_no)
-{
- uint i;
- uint partitions= keycache->partitions;
- size_t var_ofs= simple_key_cache_stat_var_offsets[var_no];
- ulonglong res= 0;
- DBUG_ENTER("get_partitioned_key_cache_stat_value");
-
- if (var_no < NUM_LONG_KEY_CACHE_STAT_VARIABLES)
- {
- for (i = 0; i < partitions; i++)
- {
- SIMPLE_KEY_CACHE_CB *partition= keycache->partition_array[i];
- res+= (ulonglong) (*(long *) ((char *) partition + var_ofs));
- }
- }
- else
- {
- for (i = 0; i < partitions; i++)
- {
- SIMPLE_KEY_CACHE_CB *partition= keycache->partition_array[i];
- res+= *(ulonglong *) ((char *) partition + var_ofs);
- }
- }
- DBUG_RETURN(res);
-}
-
-
/*
The array of pointers to the key cache interface functions used by
partitioned key caches. Any partitioned key cache object caches exploits
@@ -5938,7 +5829,6 @@ static KEY_CACHE_FUNCS partitioned_key_cache_funcs =
(RESET_KEY_CACHE_COUNTERS) reset_partitioned_key_cache_counters,
(END_KEY_CACHE) end_partitioned_key_cache,
(GET_KEY_CACHE_STATISTICS) get_partitioned_key_cache_statistics,
- (GET_KEY_CACHE_STAT_VALUE) get_partitioned_key_cache_stat_value
};
@@ -6246,8 +6136,6 @@ uchar *key_cache_read(KEY_CACHE *keycache,
block_length, return_buffer);
/* We can't use mutex here as the key cache may not be initialized */
- keycache->global_cache_r_requests++;
- keycache->global_cache_read++;
if (my_pread(file, (uchar*) buff, length, filepos, MYF(MY_NABP)))
return (uchar *) 0;
@@ -6356,8 +6244,6 @@ int key_cache_write(KEY_CACHE *keycache,
block_length, force_write);
/* We can't use mutex here as the key cache may not be initialized */
- keycache->global_cache_w_requests++;
- keycache->global_cache_write++;
if (my_pwrite(file, buff, length, filepos, MYF(MY_NABP | MY_WAIT_IF_FULL)))
return 1;
@@ -6474,49 +6360,6 @@ void get_key_cache_statistics(KEY_CACHE *keycache, uint partition_no,
}
}
-
-/*
- Get the value of a statistical variable for a key cache
-
- SYNOPSIS
- get_key_cache_stat_value()
- keycache pointer to the key cache to get statistics for
- var_no the ordered number of a statistical variable
-
- DESCRIPTION
- This function returns the value of the statistical variable var_no for
- the key cache keycache. The variables are numbered starting from 0 to 6.
-
- RETURN
- The value of the specified statistical variable.
-
- NOTES
- Currently for any key cache the function can return values for the
- following 7 statistical variables:
-
- Name Number
-
- blocks_used 0
- blocks_unused 1
- blocks_changed 2
- read_requests 3
- reads 4
- write_requests 5
- writes 6
-*/
-
-ulonglong get_key_cache_stat_value(KEY_CACHE *keycache, uint var_no)
-{
- if (keycache->key_cache_inited)
- {
- return keycache->interface_funcs->get_stat_val(keycache->keycache_cb,
- var_no);
- }
- else
- return 0;
-}
-
-
/*
Repartition a key cache
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 84c07dbf2b3..255e22005d3 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -33,8 +33,7 @@
that is defined in mysql/plugin.h
it has to be before mysql/plugin.h is included.
*/
-#define SHOW_always_last SHOW_KEY_CACHE_LONG, \
- SHOW_KEY_CACHE_LONGLONG, SHOW_LONG_STATUS, SHOW_DOUBLE_STATUS, \
+#define SHOW_always_last SHOW_LONG_STATUS, SHOW_DOUBLE_STATUS, \
SHOW_HAVE, SHOW_MY_BOOL, SHOW_HA_ROWS, SHOW_SYS, \
SHOW_LONG_NOFLUSH, SHOW_LONGLONG_STATUS
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 763515c9e9c..f8da9432732 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -7988,6 +7988,46 @@ static int show_ssl_get_cipher_list(THD *thd, SHOW_VAR *var, char *buff)
#endif /* HAVE_OPENSSL */
+static int show_default_keycache(THD *thd, SHOW_VAR *var, char *buff)
+{
+ struct st_data {
+ KEY_CACHE_STATISTICS stats;
+ SHOW_VAR var[8];
+ } *data;
+ SHOW_VAR *v;
+
+ data=(st_data *)buff;
+ v= data->var;
+
+ var->type= SHOW_ARRAY;
+ var->value= (char*)v;
+
+ get_key_cache_statistics(dflt_key_cache, 0, &data->stats);
+
+#define set_one_keycache_var(X,Y) \
+ v->name= X; \
+ v->type= SHOW_LONGLONG; \
+ v->value= (char*)&data->stats.Y; \
+ v++;
+
+ set_one_keycache_var("blocks_not_flushed", blocks_changed);
+ set_one_keycache_var("blocks_unused", blocks_unused);
+ set_one_keycache_var("blocks_used", blocks_used);
+ set_one_keycache_var("blocks_warm", blocks_warm);
+ set_one_keycache_var("read_requests", read_requests);
+ set_one_keycache_var("reads", reads);
+ set_one_keycache_var("write_requests", write_requests);
+ set_one_keycache_var("writes", writes);
+
+ v->name= 0;
+
+ DBUG_ASSERT((char*)(v+1) <= buff + SHOW_VAR_FUNC_BUFF_SIZE);
+
+#undef set_one_keycache_var
+
+ return 0;
+}
+
/*
Variables shown by SHOW STATUS in alphabetical order
@@ -8030,13 +8070,7 @@ SHOW_VAR status_vars[]= {
{"Handler_savepoint_rollback",(char*) offsetof(STATUS_VAR, ha_savepoint_rollback_count), SHOW_LONG_STATUS},
{"Handler_update", (char*) offsetof(STATUS_VAR, ha_update_count), SHOW_LONG_STATUS},
{"Handler_write", (char*) offsetof(STATUS_VAR, ha_write_count), SHOW_LONG_STATUS},
- {"Key_blocks_not_flushed", (char*) offsetof(KEY_CACHE, global_blocks_changed), SHOW_KEY_CACHE_LONG},
- {"Key_blocks_unused", (char*) offsetof(KEY_CACHE, blocks_unused), SHOW_KEY_CACHE_LONG},
- {"Key_blocks_used", (char*) offsetof(KEY_CACHE, blocks_used), SHOW_KEY_CACHE_LONG},
- {"Key_read_requests", (char*) offsetof(KEY_CACHE, global_cache_r_requests), SHOW_KEY_CACHE_LONGLONG},
- {"Key_reads", (char*) offsetof(KEY_CACHE, global_cache_read), SHOW_KEY_CACHE_LONGLONG},
- {"Key_write_requests", (char*) offsetof(KEY_CACHE, global_cache_w_requests), SHOW_KEY_CACHE_LONGLONG},
- {"Key_writes", (char*) offsetof(KEY_CACHE, global_cache_write), SHOW_KEY_CACHE_LONGLONG},
+ {"Key", (char*) &show_default_keycache, SHOW_FUNC},
{"Last_query_cost", (char*) offsetof(STATUS_VAR, last_query_cost), SHOW_DOUBLE_STATUS},
{"Max_used_connections", (char*) &max_used_connections, SHOW_LONG},
{"Not_flushed_delayed_rows", (char*) &delayed_rows_in_use, SHOW_LONG_NOFLUSH},
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index e05ea4a5dcd..0bd3367de86 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -2292,34 +2292,6 @@ void remove_status_vars(SHOW_VAR *list)
-static void update_key_cache_stat_var(KEY_CACHE *key_cache, size_t ofs)
-{
- uint var_no;
- if (ofs == offsetof(KEY_CACHE, blocks_used) ||
- ofs == offsetof(KEY_CACHE, blocks_unused) ||
- ofs == offsetof(KEY_CACHE, global_blocks_changed))
- {
- var_no= (ofs-offsetof(KEY_CACHE, blocks_used))/sizeof(ulong);
- *(ulong *)((char *) key_cache + ofs)=
- (ulong) get_key_cache_stat_value(key_cache, var_no);
- return;
- }
-
- if (ofs == offsetof(KEY_CACHE, global_cache_r_requests) ||
- ofs == offsetof(KEY_CACHE, global_cache_read) ||
- ofs == offsetof(KEY_CACHE, global_cache_w_requests) ||
- ofs == offsetof(KEY_CACHE, global_cache_write))
- {
- var_no= NUM_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);
- return;
- }
-}
-
-
static bool show_status_array(THD *thd, const char *wild,
SHOW_VAR *variables,
enum enum_var_type value_type,
@@ -2451,16 +2423,6 @@ static bool show_status_array(THD *thd, const char *wild,
end= strend(pos);
break;
}
- case SHOW_KEY_CACHE_LONG:
- update_key_cache_stat_var(dflt_key_cache, (size_t) value);
- value= (char*) dflt_key_cache + (ulong)value;
- end= int10_to_str(*(long*) value, buff, 10);
- break;
- case SHOW_KEY_CACHE_LONGLONG:
- update_key_cache_stat_var(dflt_key_cache, (size_t) value);
- value= (char*) dflt_key_cache + (ulong)value;
- end= longlong10_to_str(*(longlong*) value, buff, 10);
- break;
case SHOW_UNDEF:
break; // Return empty string
case SHOW_SYS: // Cannot happen
diff --git a/sql/sql_test.cc b/sql/sql_test.cc
index 76cb7cec3c7..401a413b2dc 100644
--- a/sql/sql_test.cc
+++ b/sql/sql_test.cc
@@ -500,6 +500,9 @@ static int print_key_cache_status(const char *name, KEY_CACHE *key_cache)
}
else
{
+ KEY_CACHE_STATISTICS stats;
+ get_key_cache_statistics(key_cache, 0, &stats);
+
printf("%s\n\
Buffer_size: %10lu\n\
Block_size: %10lu\n\
@@ -516,11 +519,12 @@ reads: %10s\n\n",
(ulong) key_cache->param_buff_size, key_cache->param_block_size,
key_cache->param_division_limit, key_cache->param_age_threshold,
key_cache->param_partitions,
- key_cache->blocks_used,key_cache->global_blocks_changed,
- llstr(key_cache->global_cache_w_requests,llbuff1),
- llstr(key_cache->global_cache_write,llbuff2),
- llstr(key_cache->global_cache_r_requests,llbuff3),
- llstr(key_cache->global_cache_read,llbuff4));
+ (ulong)stats.blocks_used,
+ (ulong)stats.blocks_changed,
+ llstr(stats.write_requests,llbuff1),
+ llstr(stats.writes,llbuff2),
+ llstr(stats.read_requests,llbuff3),
+ llstr(stats.reads,llbuff4));
}
return 0;
}
diff --git a/sql/table.cc b/sql/table.cc
index 302c5090925..1711fe8c426 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -2066,6 +2066,7 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias,
bool error_reported= FALSE;
uchar *record, *bitmaps;
Field **field_ptr, **vfield_ptr;
+ bool save_view_prepare_mode= thd->lex->view_prepare_mode;
DBUG_ENTER("open_table_from_share");
DBUG_PRINT("enter",("name: '%s.%s' form: 0x%lx", share->db.str,
share->table_name.str, (long) outparam));
@@ -2073,6 +2074,8 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias,
/* Parsing of partitioning information from .frm needs thd->lex set up. */
DBUG_ASSERT(thd->lex->is_lex_started);
+ thd->lex->view_prepare_mode= FALSE; // not a view
+
error= 1;
bzero((char*) outparam, sizeof(*outparam));
outparam->in_use= thd;
@@ -2404,6 +2407,7 @@ partititon_err:
HA_HAS_OWN_BINLOGGING);
thd->status_var.opened_tables++;
+ thd->lex->view_prepare_mode= save_view_prepare_mode;
DBUG_RETURN (0);
err:
@@ -2416,6 +2420,7 @@ partititon_err:
#endif
outparam->file= 0; // For easier error checking
outparam->db_stat=0;
+ thd->lex->view_prepare_mode= save_view_prepare_mode;
free_root(&outparam->mem_root, MYF(0)); // Safe to call on bzero'd root
my_free((char*) outparam->alias, MYF(MY_ALLOW_ZERO_PTR));
DBUG_RETURN (error);
diff --git a/storage/myisam/mi_test2.c b/storage/myisam/mi_test2.c
index 527c5e03a27..c463f0e3daa 100644
--- a/storage/myisam/mi_test2.c
+++ b/storage/myisam/mi_test2.c
@@ -812,6 +812,8 @@ end:
mi_panic(HA_PANIC_CLOSE); /* Should close log */
if (!silent)
{
+ KEY_CACHE_STATISTICS stats;
+
printf("\nFollowing test have been made:\n");
printf("Write records: %d\nUpdate records: %d\nSame-key-read: %d\nDelete records: %d\n", write_count,update,dupp_keys,opt_delete);
if (rec_pointer_size)
@@ -834,6 +836,7 @@ end:
puts("Locking used");
if (use_blob)
puts("blobs used");
+ get_key_cache_statistics(dflt_key_cache, 0, &stats);
printf("key cache status: \n\
blocks used:%10lu\n\
not flushed:%10lu\n\
@@ -841,12 +844,12 @@ w_requests: %10lu\n\
writes: %10lu\n\
r_requests: %10lu\n\
reads: %10lu\n",
- dflt_key_cache->blocks_used,
- dflt_key_cache->global_blocks_changed,
- (ulong) dflt_key_cache->global_cache_w_requests,
- (ulong) dflt_key_cache->global_cache_write,
- (ulong) dflt_key_cache->global_cache_r_requests,
- (ulong) dflt_key_cache->global_cache_read);
+ (ulong) stats.blocks_used,
+ (ulong) stats.blocks_changed,
+ (ulong) stats.write_requests,
+ (ulong) stats.writes,
+ (ulong) stats.read_requests,
+ (ulong) stats.reads);
}
end_key_cache(dflt_key_cache,1);
if (blob_buffer)