[Commits] Rev 2840: Merge in file:///home/igor/maria/maria-5.3/

Igor Babaev igor at askmonty.org
Tue Nov 2 19:12:23 EET 2010


At file:///home/igor/maria/maria-5.3/

------------------------------------------------------------
revno: 2840 [merge]
revision-id: igor at askmonty.org-20101102171221-sn0rb0sbcpj7qiec
parent: igor at askmonty.org-20101102170746-7w3mrm72taqr3n6a
parent: sergii at pisem.net-20101102094855-olecla7ivuuqndkg
committer: Igor Babaev <igor at askmonty.org>
branch nick: maria-5.3
timestamp: Tue 2010-11-02 10:12:21 -0700
message:
  Merge
modified:
  client/mysqltest.cc            sp1f-mysqltest.c-20001010065317-ix4zw26srlev7yugcz455ux22zwyynyf
  include/keycache.h             sp1f-keycache.h-20031120200620-epdbaok2tbq7pk52iejznbrk32ulro77
  include/queues.h               sp1f-queues.h-19700101030959-el3gv7sl7r742qwyw3h45iatpt5jhvmg
  libmysqld/CMakeLists.txt       sp1f-cmakelists.txt-20060403082523-x3vxka3k56u2wpzwcrlpykznlz2akpxd
  mysql-test/r/key_cache.result  sp1f-key_cache.result-20030706160952-w2k4i7umxfnkjp2xhhkmacoikxgxrpw5
  mysql-test/r/ps_ddl.result     sp1f-ps_ddl.result-20071215004622-7wxecn5bjzrz7scbog54tuaaobpayisn
  mysql-test/suite/rpl/t/rpl_loaddata_symlink.test rpl_loaddata_symlink-20091112200628-bv7esgx1vr7rhcky-1
  mysql-test/suite/vcol/inc/vcol_supported_sql_funcs_main.inc vcol_supported_sql_f-20091016212105-1lx2muao9vwbl1c1-17
  mysql-test/suite/vcol/r/vcol_supported_sql_funcs_innodb.result vcol_supported_sql_f-20091016212105-1lx2muao9vwbl1c1-43
  mysql-test/suite/vcol/r/vcol_supported_sql_funcs_myisam.result vcol_supported_sql_f-20091016212105-1lx2muao9vwbl1c1-44
  mysql-test/t/ps_ddl.test       sp1f-ps_ddl.test-20071215004622-2fkvss6xi7zvoksbhhmbwak3gs54jnbo
  mysys/mf_keycache.c            sp1f-mf_keycache.c-19700101030959-wtigyxt4n6zscc6ezr56wziqguyc5bds
  mysys/queues.c                 sp1f-queues.c-19700101030959-bjjdzyy3wthy2aput3e5iz5hervutig2
  mysys/thr_alarm.c              sp1f-thr_alarm.c-19700101030959-cnwj4a73onkvqv7ope5kvwdna7acjl6b
  sql/item_subselect.cc          sp1f-item_subselect.cc-20020512204640-qep43aqhsfrwkqmrobni6czc3fqj36oo
  sql/mysql_priv.h               sp1f-mysql_priv.h-19700101030959-4fl65tqpop5zfgxaxkqotu2fa2ree5ci
  sql/mysqld.cc                  sp1f-mysqld.cc-19700101030959-zpswdvekpvixxzxf7gdtofzel7nywtfj
  sql/sql_class.cc               sp1f-sql_class.cc-19700101030959-rpotnweaff2pikkozh3butrf7mv3oero
  sql/sql_expression_cache.cc    sql_expression_cache-20100710101008-oqtsrd0hav47cxxm-1
  sql/sql_show.cc                sp1f-sql_show.cc-19700101030959-umlljfnpplg452h7reeyqr4xnbmlkvfj
  sql/sql_test.cc                sp1f-sql_test.cc-19700101030959-7fpt436b3qzk75qpy7rqpho7nkesvwuz
  sql/table.cc                   sp1f-table.cc-19700101030959-nsxtem2adyqzwe6nz4cgrpcmts3o54v7
  storage/myisam/mi_test2.c      sp1f-mi_test2.c-19700101030959-34mdjpexgbjcbyn6x5ofspj4t2edh3nw
-------------- next part --------------
=== modified file 'client/mysqltest.cc'
--- a/client/mysqltest.cc	2010-10-25 13:21:16 +0000
+++ b/client/mysqltest.cc	2010-10-29 21:18:02 +0000
@@ -610,14 +610,14 @@
     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 @@
         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 @@
         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 @@
       }
     }
 
-    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 @@
 
 #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;
 

=== modified file 'include/keycache.h'
--- a/include/keycache.h	2010-04-06 02:08:10 +0000
+++ b/include/keycache.h	2010-10-29 21:18:02 +0000
@@ -46,6 +46,7 @@
   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 @@
   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 @@
   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 @@
   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 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);

=== modified file 'include/queues.h'
--- a/include/queues.h	2010-07-16 07:33:01 +0000
+++ b/include/queues.h	2010-11-02 09:03:33 +0000
@@ -51,7 +51,6 @@
 #define queue_top(queue) ((queue)->root[1])
 #define queue_element(queue,index) ((queue)->root[index])
 #define queue_end(queue) ((queue)->root[(queue)->elements])
-#define queue_replace(queue, idx) _downheap(queue, idx, (queue)->root[idx])
 #define queue_replace_top(queue) _downheap(queue, 1, (queue)->root[1])
 #define queue_set_cmp_arg(queue, set_arg) (queue)->first_cmp_arg= set_arg
 #define queue_set_max_at_top(queue, set_arg) \
@@ -72,6 +71,8 @@
 void queue_insert(QUEUE *queue,uchar *element);
 int queue_insert_safe(QUEUE *queue, uchar *element);
 uchar *queue_remove(QUEUE *queue,uint idx);
+void queue_replace(QUEUE *queue,uint idx);
+
 #define queue_remove_all(queue) { (queue)->elements= 0; }
 #define queue_is_full(queue) (queue->elements == queue->max_elements)
 void _downheap(QUEUE *queue, uint idx, uchar *element);

=== modified file 'libmysqld/CMakeLists.txt'
--- a/libmysqld/CMakeLists.txt	2010-10-10 14:18:11 +0000
+++ b/libmysqld/CMakeLists.txt	2010-11-02 09:47:36 +0000
@@ -144,7 +144,8 @@
            ../sql/multi_range_read.cc
            ../sql/opt_index_cond_pushdown.cc
            ../sql/opt_subselect.cc
-	   ../sql/create_options.cc
+           ../sql/create_options.cc
+           ../sql/sql_expression_cache.cc
            ${GEN_SOURCES}
            ${LIB_SOURCES})
 

=== modified file 'mysql-test/r/key_cache.result'
--- a/mysql-test/r/key_cache.result	2010-06-26 10:05:41 +0000
+++ b/mysql-test/r/key_cache.result	2010-11-02 09:12:29 +0000
@@ -412,6 +412,7 @@
 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 @@
 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 @@
 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

=== modified file 'mysql-test/r/ps_ddl.result'
--- a/mysql-test/r/ps_ddl.result	2010-01-16 07:44:24 +0000
+++ b/mysql-test/r/ps_ddl.result	2010-10-27 08:41:45 +0000
@@ -4,6 +4,7 @@
 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;

=== modified file 'mysql-test/suite/rpl/t/rpl_loaddata_symlink.test'
--- a/mysql-test/suite/rpl/t/rpl_loaddata_symlink.test	2010-02-05 06:49:01 +0000
+++ b/mysql-test/suite/rpl/t/rpl_loaddata_symlink.test	2010-10-26 14:58:52 +0000
@@ -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/not_windows.inc
 --source include/master-slave.inc
---source include/not_windows.inc
 --source include/have_binlog_format_statement.inc
 
 create table t1(a int not null auto_increment, b int, primary key(a) );

=== modified file 'mysql-test/suite/vcol/inc/vcol_supported_sql_funcs_main.inc'
--- a/mysql-test/suite/vcol/inc/vcol_supported_sql_funcs_main.inc	2010-03-19 06:23:32 +0000
+++ b/mysql-test/suite/vcol/inc/vcol_supported_sql_funcs_main.inc	2010-10-30 17:54:38 +0000
@@ -407,7 +407,7 @@
 --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;

=== modified file 'mysql-test/suite/vcol/r/vcol_supported_sql_funcs_innodb.result'
--- a/mysql-test/suite/vcol/r/vcol_supported_sql_funcs_innodb.result	2010-03-19 06:23:32 +0000
+++ b/mysql-test/suite/vcol/r/vcol_supported_sql_funcs_innodb.result	2010-10-30 17:54:38 +0000
@@ -968,12 +968,12 @@
 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);

=== modified file 'mysql-test/suite/vcol/r/vcol_supported_sql_funcs_myisam.result'
--- a/mysql-test/suite/vcol/r/vcol_supported_sql_funcs_myisam.result	2010-03-19 06:23:32 +0000
+++ b/mysql-test/suite/vcol/r/vcol_supported_sql_funcs_myisam.result	2010-10-30 17:54:38 +0000
@@ -968,12 +968,12 @@
 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);

=== modified file 'mysql-test/t/ps_ddl.test'
--- a/mysql-test/t/ps_ddl.test	2010-01-16 07:44:24 +0000
+++ b/mysql-test/t/ps_ddl.test	2010-10-27 08:41:45 +0000
@@ -58,6 +58,10 @@
 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

=== modified file 'mysys/mf_keycache.c'
--- a/mysys/mf_keycache.c	2010-07-24 06:10:03 +0000
+++ b/mysys/mf_keycache.c	2010-10-29 21:18:02 +0000
@@ -4906,6 +4906,7 @@
   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 @@
 
 
 /* 
-  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 @@
   (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 @@
     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 @@
   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 @@
   (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 @@
                                            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 @@
                                             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 @@
   }
 }
 
-
-/*
-  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
 

=== modified file 'mysys/queues.c'
--- a/mysys/queues.c	2010-07-16 07:33:01 +0000
+++ b/mysys/queues.c	2010-11-02 09:03:33 +0000
@@ -280,6 +280,9 @@
     queue	Queue to use
     idx         Index of element to change
     element     Element to store at 'idx'
+
+  NOTE
+    This only works if element is >= all elements <= start_idx
 */
 
 void _downheap(register QUEUE *queue, uint start_idx, uchar *element)
@@ -353,3 +356,22 @@
   for (i= queue->elements >> 1; i > 0; i--)
     _downheap(queue, i, queue_element(queue, i));
 }
+
+
+/*
+  Change element at fixed position
+
+  SYNOPSIS
+    queue_replace()
+    queue	Queue to use
+    idx         Index of element to change
+    element     Element to store at 'idx'
+*/
+
+void queue_replace(QUEUE *queue, uint idx)
+{
+  uchar *element= queue->root[idx];
+  DBUG_ASSERT(idx >= 1 && idx <= queue->elements);
+  queue_remove(queue, idx);
+  queue_insert(queue, element);
+}

=== modified file 'mysys/thr_alarm.c'
--- a/mysys/thr_alarm.c	2010-10-10 14:18:11 +0000
+++ b/mysys/thr_alarm.c	2010-11-02 09:03:33 +0000
@@ -465,6 +465,8 @@
 void thr_alarm_kill(my_thread_id thread_id)
 {
   uint i;
+  DBUG_ENTER("thr_alarm_kill");
+
   if (alarm_aborted)
     return;
   pthread_mutex_lock(&LOCK_alarm);
@@ -475,6 +477,7 @@
     ALARM *element= (ALARM*) queue_element(&alarm_queue,i);
     if (element->thread_id == thread_id)
     {
+      DBUG_PRINT("info", ("found thread; Killing it"));
       element->expire_time= 0;
       queue_replace(&alarm_queue, i);
       reschedule_alarms();
@@ -482,6 +485,7 @@
     }
   }
   pthread_mutex_unlock(&LOCK_alarm);
+  DBUG_VOID_RETURN;
 }
 
 

=== modified file 'sql/item_subselect.cc'
--- a/sql/item_subselect.cc	2010-10-27 13:28:19 +0000
+++ b/sql/item_subselect.cc	2010-11-02 09:03:33 +0000
@@ -4827,7 +4827,8 @@
   DBUG_ASSERT(cur_keyid == keys_count);
 
   /* Populate the indexes with data from the temporary table. */
-  tmp_table->file->ha_rnd_init(1);
+  if (tmp_table->file->ha_rnd_init_with_error(1))
+    return TRUE;
   tmp_table->file->extra_opt(HA_EXTRA_CACHE,
                              current_thd->variables.read_buff_size);
   tmp_table->null_row= 0;
@@ -5008,7 +5009,11 @@
   DBUG_ASSERT(!pq.elements);
 
   /* All data accesses during execution are via handler::ha_rnd_pos() */
-  tmp_table->file->ha_rnd_init(0);
+  if (tmp_table->file->ha_rnd_init_with_error(0))
+  {
+    res= FALSE;
+    goto end;
+  }
 
   /* Check if there is a match for the columns of the only non-NULL key. */
   if (non_null_key && !non_null_key->lookup())
@@ -5175,7 +5180,12 @@
   int error;
   bool res;
 
-  tmp_table->file->ha_rnd_init(1);
+  if (tmp_table->file->ha_rnd_init_with_error(1))
+  {
+    res= FALSE;
+    goto end;
+  }
+
   tmp_table->file->extra_opt(HA_EXTRA_CACHE,
                              current_thd->variables.read_buff_size);
   /*

=== modified file 'sql/mysql_priv.h'
--- a/sql/mysql_priv.h	2010-10-10 14:18:11 +0000
+++ b/sql/mysql_priv.h	2010-11-02 09:12:29 +0000
@@ -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
 

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2010-10-28 17:04:23 +0000
+++ b/sql/mysqld.cc	2010-11-02 09:12:29 +0000
@@ -7988,6 +7988,46 @@
 
 #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 @@
   {"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},

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2010-10-10 14:18:11 +0000
+++ b/sql/sql_class.cc	2010-11-02 09:03:33 +0000
@@ -3017,7 +3017,7 @@
 
   col_stat= (Column_statistics*) table->in_use->alloc(table->s->fields *
                                                       sizeof(Column_statistics));
-  if (!stat)
+  if (!col_stat)
     return TRUE;
 
   reset();

=== modified file 'sql/sql_expression_cache.cc'
--- a/sql/sql_expression_cache.cc	2010-10-27 03:03:59 +0000
+++ b/sql/sql_expression_cache.cc	2010-11-02 09:47:36 +0000
@@ -114,10 +114,8 @@
   field_counter=1;
 
   if (cache_table->alloc_keys(1) ||
-      (cache_table->add_tmp_key(0, items.elements - 1,
-                                &field_enumerator,
-                                (uchar*)&field_counter,
-                                TRUE) < 0) ||
+      cache_table->add_tmp_key(0, items.elements - 1, &field_enumerator,
+                                (uchar*)&field_counter, TRUE) ||
       ref.tmp_table_index_lookup_init(table_thd, cache_table->key_info, it,
                                       TRUE))
   {

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2010-10-28 17:04:23 +0000
+++ b/sql/sql_show.cc	2010-11-02 09:48:55 +0000
@@ -2292,34 +2292,6 @@
 
 
 
-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 @@
           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
@@ -4103,7 +4065,7 @@
   }
   else
   {
-    char option_buff[350],*ptr;
+    char option_buff[350];
     String str(option_buff,sizeof(option_buff), system_charset_info);
     TABLE *show_table= tables->table;
     TABLE_SHARE *share= show_table->s;

=== modified file 'sql/sql_test.cc'
--- a/sql/sql_test.cc	2010-10-10 14:38:17 +0000
+++ b/sql/sql_test.cc	2010-11-02 09:12:29 +0000
@@ -500,6 +500,9 @@
   }
   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 @@
 	   (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;
 }

=== modified file 'sql/table.cc'
--- a/sql/table.cc	2010-10-10 14:18:11 +0000
+++ b/sql/table.cc	2010-11-02 09:12:29 +0000
@@ -2066,6 +2066,7 @@
   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 @@
   /* 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 @@
                                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 @@
 #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);

=== modified file 'storage/myisam/mi_test2.c'
--- a/storage/myisam/mi_test2.c	2010-09-11 18:43:48 +0000
+++ b/storage/myisam/mi_test2.c	2010-10-29 18:29:43 +0000
@@ -812,6 +812,8 @@
   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 @@
       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 @@
 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)



More information about the commits mailing list