List:Internals« Previous MessageNext Message »
From:msvensson Date:September 7 2005 7:39am
Subject:bk commit into 5.1 tree (msvensson:1.1902)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of msvensson. When msvensson does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.1902 05/09/07 09:39:38 msvensson@neptunus.(none) +9 -0
  Merge neptunus.(none):/home/msvensson/mysql/mysql-5.0
  into  neptunus.(none):/home/msvensson/mysql/mysql-5.1

  sql/sql_yacc.yy
    1.408 05/09/07 09:39:28 msvensson@neptunus.(none) +0 -0
    Auto merged

  sql/sql_parse.cc
    1.468 05/09/07 09:39:27 msvensson@neptunus.(none) +0 -0
    Auto merged

  sql/sql_cache.cc
    1.83 05/09/07 09:39:27 msvensson@neptunus.(none) +0 -0
    Auto merged

  sql/set_var.cc
    1.133 05/09/07 09:39:26 msvensson@neptunus.(none) +0 -0
    Auto merged

  sql/mysqld.cc
    1.479 05/09/07 09:39:26 msvensson@neptunus.(none) +0 -0
    Auto merged

  sql/mysql_priv.h
    1.331 05/09/07 09:39:25 msvensson@neptunus.(none) +0 -0
    Auto merged

  sql/ha_federated.cc
    1.35 05/09/07 09:39:25 msvensson@neptunus.(none) +0 -0
    Auto merged

  configure.in
    1.295 05/09/07 09:39:25 msvensson@neptunus.(none) +0 -0
    Auto merged

  client/mysqltest.c
    1.158 05/09/07 09:39:25 msvensson@neptunus.(none) +0 -0
    Auto merged

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	msvensson
# Host:	neptunus.(none)
# Root:	/home/msvensson/mysql/mysql-5.1/RESYNC

--- 1.330/sql/mysql_priv.h	2005-09-06 18:08:15 +02:00
+++ 1.331/sql/mysql_priv.h	2005-09-07 09:39:25 +02:00
@@ -552,6 +552,7 @@
 #define query_cache_store_query(A, B) query_cache.store_query(A, B)
 #define query_cache_destroy() query_cache.destroy()
 #define query_cache_result_size_limit(A) query_cache.result_size_limit(A)
+#define query_cache_init() query_cache.init()
 #define query_cache_resize(A) query_cache.resize(A)
 #define query_cache_set_min_res_unit(A) query_cache.set_min_res_unit(A)
 #define query_cache_invalidate3(A, B, C) query_cache.invalidate(A, B, C)
@@ -565,6 +566,7 @@
 #define query_cache_store_query(A, B)
 #define query_cache_destroy()
 #define query_cache_result_size_limit(A)
+#define query_cache_init()
 #define query_cache_resize(A)
 #define query_cache_set_min_res_unit(A)
 #define query_cache_invalidate3(A, B, C)

--- 1.478/sql/mysqld.cc	2005-09-06 18:08:15 +02:00
+++ 1.479/sql/mysqld.cc	2005-09-07 09:39:26 +02:00
@@ -2784,6 +2784,7 @@
 
   query_cache_result_size_limit(query_cache_limit);
   query_cache_set_min_res_unit(query_cache_min_res_unit);
+  query_cache_init();
   query_cache_resize(query_cache_size);
   randominit(&sql_rand,(ulong) start_time,(ulong) start_time/2);
   reset_floating_point_exceptions();

--- 1.82/sql/sql_cache.cc	2005-08-25 18:49:42 +02:00
+++ 1.83/sql/sql_cache.cc	2005-09-07 09:39:27 +02:00
@@ -573,13 +573,18 @@
 {
   DBUG_ENTER("query_cache_insert");
 
-#ifndef DBUG_OFF
-  // Check if we have called query_cache.wreck() (which disables the cache)
-  if (query_cache.query_cache_size == 0)
+  STRUCT_LOCK(&query_cache.structure_guard_mutex);
+  /*
+    It is very unlikely that following condition is TRUE (it is possible
+    only if other thread is resizing cache), so we check it only after guard
+    mutex lock
+  */
+  if (unlikely(query_cache.query_cache_size == 0))
+  {
+    STRUCT_UNLOCK(&query_cache.structure_guard_mutex);
     DBUG_VOID_RETURN;
-#endif
+  }
 
-  STRUCT_LOCK(&query_cache.structure_guard_mutex);
   Query_cache_block *query_block = ((Query_cache_block*)
 				    net->query_cache_query);
   if (query_block)
@@ -623,14 +628,20 @@
 {
   DBUG_ENTER("query_cache_abort");
 
-#ifndef DBUG_OFF
-  // Check if we have called query_cache.wreck() (which disables the cache)
-  if (query_cache.query_cache_size == 0)
-    DBUG_VOID_RETURN;
-#endif
   if (net->query_cache_query != 0)	// Quick check on unlocked structure
   {
     STRUCT_LOCK(&query_cache.structure_guard_mutex);
+    /*
+      It is very unlikely that following condition is TRUE (it is possible
+      only if other thread is resizing cache), so we check it only after guard
+      mutex lock
+    */
+    if (unlikely(query_cache.query_cache_size == 0))
+    {
+      STRUCT_UNLOCK(&query_cache.structure_guard_mutex);
+      DBUG_VOID_RETURN;
+    }
+
     Query_cache_block *query_block = ((Query_cache_block*)
 				       net->query_cache_query);
     if (query_block)			// Test if changed by other thread
@@ -652,11 +663,6 @@
 {
   DBUG_ENTER("query_cache_end_of_result");
 
-#ifndef DBUG_OFF
-  // Check if we have called query_cache.wreck() (which disables the cache)
-  if (query_cache.query_cache_size == 0) DBUG_VOID_RETURN;
-#endif
-
   if (thd->net.query_cache_query != 0)	// Quick check on unlocked structure
   {
 #ifdef EMBEDDED_LIBRARY
@@ -664,6 +670,17 @@
 		       emb_count_querycache_size(thd));
 #endif
     STRUCT_LOCK(&query_cache.structure_guard_mutex);
+    /*
+      It is very unlikely that following condition is TRUE (it is possible
+      only if other thread is resizing cache), so we check it only after guard
+      mutex lock
+    */
+    if (unlikely(query_cache.query_cache_size == 0))
+    {
+      STRUCT_UNLOCK(&query_cache.structure_guard_mutex);
+      DBUG_VOID_RETURN;
+    }
+
     Query_cache_block *query_block = ((Query_cache_block*)
 				      thd->net.query_cache_query);
     if (query_block)
@@ -743,9 +760,14 @@
   DBUG_ENTER("Query_cache::resize");
   DBUG_PRINT("qcache", ("from %lu to %lu",query_cache_size,
 			query_cache_size_arg));
-  free_cache(0);
+  DBUG_ASSERT(initialized);
+  STRUCT_LOCK(&structure_guard_mutex);
+  if (query_cache_size > 0)
+    free_cache();
   query_cache_size= query_cache_size_arg;
-  DBUG_RETURN(::query_cache_size= init_cache());
+  ::query_cache_size= init_cache();
+  STRUCT_UNLOCK(&structure_guard_mutex);
+  DBUG_RETURN(::query_cache_size);
 }
 
 
@@ -1438,7 +1460,7 @@
   }
   else
   {
-    free_cache(1);
+    free_cache();
     pthread_mutex_destroy(&structure_guard_mutex);
     initialized = 0;
   }
@@ -1467,8 +1489,6 @@
   int align;
 
   DBUG_ENTER("Query_cache::init_cache");
-  if (!initialized)
-    init();
   approx_additional_data_size = (sizeof(Query_cache) +
 				 sizeof(gptr)*(def_query_hash_size+
 					       def_table_hash_size));
@@ -1526,14 +1546,9 @@
     goto err;
   query_cache_size -= additional_data_size;
 
-  STRUCT_LOCK(&structure_guard_mutex);
-
-  if (!(cache = (byte *)
-	 my_malloc_lock(query_cache_size+additional_data_size, MYF(0))))
-  {
-    STRUCT_UNLOCK(&structure_guard_mutex);
+  if (!(cache= (byte *)
+        my_malloc_lock(query_cache_size+additional_data_size, MYF(0))))
     goto err;
-  }
 
   DBUG_PRINT("qcache", ("cache length %lu, min unit %lu, %u bins",
 		      query_cache_size, min_allocation_unit, mem_bin_num));
@@ -1629,7 +1644,6 @@
 
   queries_in_cache = 0;
   queries_blocks = 0;
-  STRUCT_UNLOCK(&structure_guard_mutex);
   DBUG_RETURN(query_cache_size +
 	      additional_data_size + approx_additional_data_size);
 
@@ -1645,6 +1659,7 @@
 {
   DBUG_ENTER("Query_cache::make_disabled");
   query_cache_size= 0;
+  queries_blocks= 0;
   free_memory= 0;
   bins= 0;
   steps= 0;
@@ -1656,14 +1671,11 @@
 }
 
 
-void Query_cache::free_cache(my_bool destruction)
+void Query_cache::free_cache()
 {
   DBUG_ENTER("Query_cache::free_cache");
   if (query_cache_size > 0)
   {
-    if (!destruction)
-      STRUCT_LOCK(&structure_guard_mutex);
-
     flush_cache();
 #ifndef DBUG_OFF
     if (bins[0].free_blocks == 0)
@@ -1685,8 +1697,6 @@
     make_disabled();
     hash_free(&queries);
     hash_free(&tables);
-    if (!destruction)
-      STRUCT_UNLOCK(&structure_guard_mutex);
   }
   DBUG_VOID_RETURN;
 }
@@ -2401,7 +2411,19 @@
   }
 
   if (!under_guard)
+  {
     STRUCT_LOCK(&structure_guard_mutex);
+    /*
+      It is very unlikely that following condition is TRUE (it is possible
+      only if other thread is resizing cache), so we check it only after
+      guard mutex lock
+    */
+    if (unlikely(query_cache.query_cache_size == 0))
+    {
+      STRUCT_UNLOCK(&structure_guard_mutex);
+      DBUG_RETURN(0);
+    }
+  }
 
   /* Free old queries until we have enough memory to store this block */
   Query_cache_block *block;
@@ -2947,6 +2969,17 @@
 {
   DBUG_ENTER("Query_cache::pack_cache");
   STRUCT_LOCK(&structure_guard_mutex);
+  /*
+    It is very unlikely that following condition is TRUE (it is possible
+    only if other thread is resizing cache), so we check it only after
+    guard mutex lock
+  */
+  if (unlikely(query_cache_size == 0))
+  {
+    STRUCT_UNLOCK(&structure_guard_mutex);
+    DBUG_VOID_RETURN;
+  }
+
   DBUG_EXECUTE("check_querycache",query_cache.check_integrity(1););
 
   byte *border = 0;
@@ -3256,6 +3289,7 @@
   STRUCT_LOCK(&structure_guard_mutex);
   if (queries_blocks != 0)
   {
+    DBUG_ASSERT(query_cache_size > 0);
     Query_cache_block *block = queries_blocks;
     do
     {
@@ -3552,7 +3586,19 @@
     DBUG_RETURN(0);
   }
   if (!not_locked)
+  {
     STRUCT_LOCK(&structure_guard_mutex);
+    /*
+      It is very unlikely that following condition is TRUE (it is possible
+      only if other thread is resizing cache), so we check it only after
+      guard mutex lock
+    */
+    if (unlikely(query_cache_size == 0))
+    {
+      STRUCT_UNLOCK(&query_cache.structure_guard_mutex);
+      DBUG_RETURN(0);
+    }
+  }
 
   if (hash_check(&queries))
   {

--- 1.407/sql/sql_yacc.yy	2005-09-06 09:11:51 +02:00
+++ 1.408/sql/sql_yacc.yy	2005-09-07 09:39:28 +02:00
@@ -4413,6 +4413,11 @@
 	OPTIMIZE opt_no_write_to_binlog table_or_tables
 	{
 	   LEX *lex=Lex;
+	   if (lex->sphead)
+	   {
+	     my_error(ER_SP_BADSTATEMENT, MYF(0), "OPTIMIZE TABLE");
+	     YYABORT;
+	   }
 	   lex->sql_command = SQLCOM_OPTIMIZE;
            lex->no_write_to_binlog= $2;
 	   lex->check_opt.init();

--- 1.34/sql/ha_federated.cc	2005-08-05 23:50:35 +02:00
+++ 1.35/sql/ha_federated.cc	2005-09-07 09:39:25 +02:00
@@ -1935,6 +1935,8 @@
   {
     int error_code= ER_QUERY_ON_FOREIGN_DATA_SOURCE;
     char error_buffer[FEDERATED_QUERY_BUFFER_SIZE];
+    my_sprintf(error_buffer, (error_buffer, ": %d : %s",
+              mysql_errno(mysql), mysql_error(mysql)));
     my_error(error_code, MYF(0), error_buffer);
     DBUG_RETURN(error_code);
   }
Thread
bk commit into 5.1 tree (msvensson:1.1902)msvensson7 Sep