List:Commits« Previous MessageNext Message »
From:marc.alff Date:March 21 2007 12:22am
Subject:bk commit into 5.1 tree (malff:1.2472) BUG#21554
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of marcsql. When marcsql 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@stripped, 2007-03-20 18:21:53-06:00, malff@weblab.(none) +13 -0
  Bug#21554 (sp_cache.cc: violates C++ aliasing rules)
  
  The problem reported is a compile bug,
  reported by the development GCC team with GCC 4.2.
  
  The original issue can no longer be reproduced in MySQL 5.1,
  since the configure script no longer define HAVE_ATOMIC_ADD,
  which caused the Linux atomic functions to be used (and cause a problem
  with an invalid cast).
  
  This patch implements some code cleanup for 5.1 only, which was identified
  during the investigation of this issue.
  
  With this patch, statistics maintained in THD::status_var are by definition
  owned by the running thread, and do not need to be protected against race
  conditions. These statistics are maintained by the status_var_* helpers,
  which do not require any lock.
  
  At this point, implementing thread_safe_statistics using my_atomic_add apis
  can not be implemented, since 64 bits atomic operations are not implemented.
  64 bits counters are needed to support current ulong counters on 64 bits
  platforms.

  include/my_global.h@stripped, 2007-03-20 18:21:26-06:00, malff@weblab.(none) +1 -19
    General cleanup of thread_safe_increment / statistic_increment

  include/my_pthread.h@stripped, 2007-03-20 18:21:26-06:00, malff@weblab.(none) +39 -15
    General cleanup of thread_safe_increment / statistic_increment

  sql/filesort.cc@stripped, 2007-03-20 18:21:26-06:00, malff@weblab.(none) +3 -4
    General cleanup of thread_safe_increment / statistic_increment

  sql/ha_ndbcluster.cc@stripped, 2007-03-20 18:21:26-06:00, malff@weblab.(none) +10 -15
    General cleanup of thread_safe_increment / statistic_increment

  sql/handler.cc@stripped, 2007-03-20 18:21:26-06:00, malff@weblab.(none) +10 -12
    General cleanup of thread_safe_increment / statistic_increment

  sql/sql_insert.cc@stripped, 2007-03-20 18:21:26-06:00, malff@weblab.(none) +1 -1
    General cleanup of thread_safe_increment / statistic_increment

  sql/sql_parse.cc@stripped, 2007-03-20 18:21:26-06:00, malff@weblab.(none) +16 -25
    General cleanup of thread_safe_increment / statistic_increment

  sql/sql_prepare.cc@stripped, 2007-03-20 18:21:26-06:00, malff@weblab.(none) +6 -6
    General cleanup of thread_safe_increment / statistic_increment

  sql/sql_select.cc@stripped, 2007-03-20 18:21:27-06:00, malff@weblab.(none) +7 -13
    General cleanup of thread_safe_increment / statistic_increment

  storage/federated/ha_federated.cc@stripped, 2007-03-20 18:21:27-06:00, malff@weblab.(none) +4 -7
    General cleanup of thread_safe_increment / statistic_increment

  storage/heap/ha_heap.cc@stripped, 2007-03-20 18:21:27-06:00, malff@weblab.(none) +12 -21
    General cleanup of thread_safe_increment / statistic_increment

  storage/myisam/ha_myisam.cc@stripped, 2007-03-20 18:21:27-06:00, malff@weblab.(none) +14 -25
    General cleanup of thread_safe_increment / statistic_increment

  storage/myisammrg/ha_myisammrg.cc@stripped, 2007-03-20 18:21:27-06:00, malff@weblab.(none) +13 -23
    General cleanup of thread_safe_increment / statistic_increment

# 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:	malff
# Host:	weblab.(none)
# Root:	/home/marcsql/TREE/mysql-5.1-21554

--- 1.108/include/my_pthread.h	2007-03-20 18:22:01 -06:00
+++ 1.109/include/my_pthread.h	2007-03-20 18:22:01 -06:00
@@ -697,37 +697,61 @@ extern struct st_my_thread_var *_my_thre
 extern uint my_thread_end_wait_time;
 #define my_thread_var (_my_thread_var())
 #define my_errno my_thread_var->thr_errno
+
 /*
-  Keep track of shutdown,signal, and main threads so that my_end() will not
-  report errors with them
+  thread_safe_xxx functions are for critical statistic or counters.
+  The implementation is guaranteed to be thread safe, on all platforms.
+  Note that the calling code should *not* assume the counter is protected
+  by the mutex given, as the implementation of these helpers may change
+  to use my_atomic operations instead.
 */
-	/* statistics_xxx functions are for not essential statistic */
 
-#ifndef thread_safe_increment
-#ifdef HAVE_ATOMIC_ADD
-#define thread_safe_increment(V,L) atomic_inc((atomic_t*) &V)
-#define thread_safe_decrement(V,L) atomic_dec((atomic_t*) &V)
-#define thread_safe_add(V,C,L)     atomic_add((C),(atomic_t*) &V)
-#define thread_safe_sub(V,C,L)     atomic_sub((C),(atomic_t*) &V)
+#ifndef THREAD
+#define thread_safe_increment(V,L) (V)++
+#define thread_safe_decrement(V,L) (V)--
+#define thread_safe_add(V,C,L) (V)+=(C)
+#define thread_safe_sub(V,C,L) (V)-=(C)
 #else
 #define thread_safe_increment(V,L) \
         (pthread_mutex_lock((L)), (V)++, pthread_mutex_unlock((L)))
 #define thread_safe_decrement(V,L) \
         (pthread_mutex_lock((L)), (V)--, pthread_mutex_unlock((L)))
-#define thread_safe_add(V,C,L) (pthread_mutex_lock((L)), (V)+=(C), pthread_mutex_unlock((L)))
+#define thread_safe_add(V,C,L) \
+        (pthread_mutex_lock((L)), (V)+=(C), pthread_mutex_unlock((L)))
 #define thread_safe_sub(V,C,L) \
         (pthread_mutex_lock((L)), (V)-=(C), pthread_mutex_unlock((L)))
-#endif /* HAVE_ATOMIC_ADD */
+#endif
+
+/*
+  statistics_xxx functions are for non critical statistic,
+  maintained in global variables.
+  When compiling with SAFE_STATISTICS:
+  - race conditions can not occur.
+  - some locking occurs, which may cause performance degradation.
+
+  When compiling without SAFE_STATISTICS:
+  - race conditions can occur, making the result slightly inaccurate.
+  - the lock given is not honored.
+*/
 #ifdef SAFE_STATISTICS
-#define statistic_increment(V,L)   thread_safe_increment((V),(L))
-#define statistic_decrement(V,L)   thread_safe_decrement((V),(L))
-#define statistic_add(V,C,L)       thread_safe_add((V),(C),(L))
+#define statistic_increment(V,L) thread_safe_increment((V),(L))
+#define statistic_decrement(V,L) thread_safe_decrement((V),(L))
+#define statistic_add(V,C,L)     thread_safe_add((V),(C),(L))
+#define statistic_sub(V,C,L)     thread_safe_sub((V),(C),(L))
 #else
 #define statistic_decrement(V,L) (V)--
 #define statistic_increment(V,L) (V)++
 #define statistic_add(V,C,L)     (V)+=(C)
+#define statistic_sub(V,C,L)     (V)-=(C)
 #endif /* SAFE_STATISTICS */
-#endif /* thread_safe_increment */
+
+/*
+  No locking needed, the counter is owned by the thread
+*/
+#define status_var_increment(V) (V)++
+#define status_var_decrement(V) (V)--
+#define status_var_add(V,C)     (V)+=(C)
+#define status_var_sub(V,C)     (V)-=(C)
 
 #ifdef  __cplusplus
 }

--- 1.126/sql/filesort.cc	2007-03-20 18:22:01 -06:00
+++ 1.127/sql/filesort.cc	2007-03-20 18:22:01 -06:00
@@ -171,11 +171,11 @@ ha_rows filesort(THD *thd, TABLE *table,
 
   if (select && select->quick)
   {
-    statistic_increment(thd->status_var.filesort_range_count, &LOCK_status);
+    status_var_increment(thd->status_var.filesort_range_count);
   }
   else
   {
-    statistic_increment(thd->status_var.filesort_scan_count, &LOCK_status);
+    status_var_increment(thd->status_var.filesort_scan_count);
   }
 #ifdef CAN_TRUST_RANGE
   if (select && select->quick && select->quick->records > 0L)
@@ -1120,8 +1120,7 @@ int merge_buffers(SORTPARAM *param, IO_C
   THD::killed_state not_killable;
   DBUG_ENTER("merge_buffers");
 
-  statistic_increment(current_thd->status_var.filesort_merge_passes,
-		      &LOCK_status);
+  status_var_increment(current_thd->status_var.filesort_merge_passes);
   if (param->not_killable)
   {
     killed= &not_killable;

--- 1.107/storage/heap/ha_heap.cc	2007-03-20 18:22:01 -06:00
+++ 1.108/storage/heap/ha_heap.cc	2007-03-20 18:22:01 -06:00
@@ -181,7 +181,7 @@ void ha_heap::update_key_stats()
 int ha_heap::write_row(byte * buf)
 {
   int res;
-  statistic_increment(table->in_use->status_var.ha_write_count,&LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_write_count);
   if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
     table->timestamp_field->set_time();
   if (table->next_number_field && buf == table->record[0])
@@ -205,7 +205,7 @@ int ha_heap::write_row(byte * buf)
 int ha_heap::update_row(const byte * old_data, byte * new_data)
 {
   int res;
-  statistic_increment(table->in_use->status_var.ha_update_count,&LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_update_count);
   if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
     table->timestamp_field->set_time();
   res= heap_update(file,old_data,new_data);
@@ -224,7 +224,7 @@ int ha_heap::update_row(const byte * old
 int ha_heap::delete_row(const byte * buf)
 {
   int res;
-  statistic_increment(table->in_use->status_var.ha_delete_count,&LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_delete_count);
   res= heap_delete(file,buf);
   if (!res && table->s->tmp_table == NO_TMP_TABLE && 
       ++records_changed*HEAP_STATS_UPDATE_THRESHOLD > file->s->records)
@@ -242,8 +242,7 @@ int ha_heap::index_read(byte * buf, cons
 			enum ha_rkey_function find_flag)
 {
   DBUG_ASSERT(inited==INDEX);
-  statistic_increment(table->in_use->status_var.ha_read_key_count,
-		      &LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_read_key_count);
   int error = heap_rkey(file,buf,active_index, key, key_len, find_flag);
   table->status = error ? STATUS_NOT_FOUND : 0;
   return error;
@@ -252,8 +251,7 @@ int ha_heap::index_read(byte * buf, cons
 int ha_heap::index_read_last(byte *buf, const byte *key, uint key_len)
 {
   DBUG_ASSERT(inited==INDEX);
-  statistic_increment(table->in_use->status_var.ha_read_key_count,
-		      &LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_read_key_count);
   int error= heap_rkey(file, buf, active_index, key, key_len,
 		       HA_READ_PREFIX_LAST);
   table->status= error ? STATUS_NOT_FOUND : 0;
@@ -263,8 +261,7 @@ int ha_heap::index_read_last(byte *buf, 
 int ha_heap::index_read_idx(byte * buf, uint index, const byte * key,
 			    uint key_len, enum ha_rkey_function find_flag)
 {
-  statistic_increment(table->in_use->status_var.ha_read_key_count,
-		      &LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_read_key_count);
   int error = heap_rkey(file, buf, index, key, key_len, find_flag);
   table->status = error ? STATUS_NOT_FOUND : 0;
   return error;
@@ -273,8 +270,7 @@ int ha_heap::index_read_idx(byte * buf, 
 int ha_heap::index_next(byte * buf)
 {
   DBUG_ASSERT(inited==INDEX);
-  statistic_increment(table->in_use->status_var.ha_read_next_count,
-		      &LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_read_next_count);
   int error=heap_rnext(file,buf);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -283,8 +279,7 @@ int ha_heap::index_next(byte * buf)
 int ha_heap::index_prev(byte * buf)
 {
   DBUG_ASSERT(inited==INDEX);
-  statistic_increment(table->in_use->status_var.ha_read_prev_count,
-		      &LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_read_prev_count);
   int error=heap_rprev(file,buf);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -293,8 +288,7 @@ int ha_heap::index_prev(byte * buf)
 int ha_heap::index_first(byte * buf)
 {
   DBUG_ASSERT(inited==INDEX);
-  statistic_increment(table->in_use->status_var.ha_read_first_count,
-		      &LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_read_first_count);
   int error=heap_rfirst(file, buf, active_index);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -303,8 +297,7 @@ int ha_heap::index_first(byte * buf)
 int ha_heap::index_last(byte * buf)
 {
   DBUG_ASSERT(inited==INDEX);
-  statistic_increment(table->in_use->status_var.ha_read_last_count,
-		      &LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_read_last_count);
   int error=heap_rlast(file, buf, active_index);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -317,8 +310,7 @@ int ha_heap::rnd_init(bool scan)
 
 int ha_heap::rnd_next(byte *buf)
 {
-  statistic_increment(table->in_use->status_var.ha_read_rnd_next_count,
-		      &LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_read_rnd_next_count);
   int error=heap_scan(file, buf);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -328,8 +320,7 @@ int ha_heap::rnd_pos(byte * buf, byte *p
 {
   int error;
   HEAP_PTR heap_position;
-  statistic_increment(table->in_use->status_var.ha_read_rnd_count,
-		      &LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_read_rnd_count);
   memcpy_fixed((char*) &heap_position, pos, sizeof(HEAP_PTR));
   error=heap_rrnd(file, buf, heap_position);
   table->status=error ? STATUS_NOT_FOUND: 0;

--- 1.211/storage/myisam/ha_myisam.cc	2007-03-20 18:22:01 -06:00
+++ 1.212/storage/myisam/ha_myisam.cc	2007-03-20 18:22:01 -06:00
@@ -654,7 +654,7 @@ int ha_myisam::close(void)
 
 int ha_myisam::write_row(byte * buf)
 {
-  statistic_increment(table->in_use->status_var.ha_write_count,&LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_write_count);
 
   /* If we have a timestamp column, update it to the current time */
   if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
@@ -1512,7 +1512,7 @@ bool ha_myisam::is_crashed() const
 
 int ha_myisam::update_row(const byte * old_data, byte * new_data)
 {
-  statistic_increment(table->in_use->status_var.ha_update_count,&LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_update_count);
   if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
     table->timestamp_field->set_time();
   return mi_update(file,old_data,new_data);
@@ -1520,7 +1520,7 @@ int ha_myisam::update_row(const byte * o
 
 int ha_myisam::delete_row(const byte * buf)
 {
-  statistic_increment(table->in_use->status_var.ha_delete_count,&LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_delete_count);
   return mi_delete(file,buf);
 }
 
@@ -1528,8 +1528,7 @@ int ha_myisam::index_read(byte * buf, co
 			  uint key_len, enum ha_rkey_function find_flag)
 {
   DBUG_ASSERT(inited==INDEX);
-  statistic_increment(table->in_use->status_var.ha_read_key_count,
-		      &LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_read_key_count);
   int error=mi_rkey(file,buf,active_index, key, key_len, find_flag);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -1538,8 +1537,7 @@ int ha_myisam::index_read(byte * buf, co
 int ha_myisam::index_read_idx(byte * buf, uint index, const byte * key,
 			      uint key_len, enum ha_rkey_function find_flag)
 {
-  statistic_increment(table->in_use->status_var.ha_read_key_count,
-		      &LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_read_key_count);
   int error=mi_rkey(file,buf,index, key, key_len, find_flag);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -1549,8 +1547,7 @@ int ha_myisam::index_read_last(byte * bu
 {
   DBUG_ENTER("ha_myisam::index_read_last");
   DBUG_ASSERT(inited==INDEX);
-  statistic_increment(table->in_use->status_var.ha_read_key_count,
-		      &LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_read_key_count);
   int error=mi_rkey(file,buf,active_index, key, key_len, HA_READ_PREFIX_LAST);
   table->status=error ? STATUS_NOT_FOUND: 0;
   DBUG_RETURN(error);
@@ -1559,8 +1556,7 @@ int ha_myisam::index_read_last(byte * bu
 int ha_myisam::index_next(byte * buf)
 {
   DBUG_ASSERT(inited==INDEX);
-  statistic_increment(table->in_use->status_var.ha_read_next_count,
-		      &LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_read_next_count);
   int error=mi_rnext(file,buf,active_index);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -1569,8 +1565,7 @@ int ha_myisam::index_next(byte * buf)
 int ha_myisam::index_prev(byte * buf)
 {
   DBUG_ASSERT(inited==INDEX);
-  statistic_increment(table->in_use->status_var.ha_read_prev_count,
-		      &LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_read_prev_count);
   int error=mi_rprev(file,buf, active_index);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -1579,8 +1574,7 @@ int ha_myisam::index_prev(byte * buf)
 int ha_myisam::index_first(byte * buf)
 {
   DBUG_ASSERT(inited==INDEX);
-  statistic_increment(table->in_use->status_var.ha_read_first_count,
-		      &LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_read_first_count);
   int error=mi_rfirst(file, buf, active_index);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -1589,8 +1583,7 @@ int ha_myisam::index_first(byte * buf)
 int ha_myisam::index_last(byte * buf)
 {
   DBUG_ASSERT(inited==INDEX);
-  statistic_increment(table->in_use->status_var.ha_read_last_count,
-		      &LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_read_last_count);
   int error=mi_rlast(file, buf, active_index);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -1601,8 +1594,7 @@ int ha_myisam::index_next_same(byte * bu
 			       uint length __attribute__((unused)))
 {
   DBUG_ASSERT(inited==INDEX);
-  statistic_increment(table->in_use->status_var.ha_read_next_count,
-		      &LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_read_next_count);
   int error=mi_rnext_same(file,buf);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -1618,8 +1610,7 @@ int ha_myisam::rnd_init(bool scan)
 
 int ha_myisam::rnd_next(byte *buf)
 {
-  statistic_increment(table->in_use->status_var.ha_read_rnd_next_count,
-		      &LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_read_rnd_next_count);
   int error=mi_scan(file, buf);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -1632,8 +1623,7 @@ int ha_myisam::restart_rnd_next(byte *bu
 
 int ha_myisam::rnd_pos(byte * buf, byte *pos)
 {
-  statistic_increment(table->in_use->status_var.ha_read_rnd_count,
-		      &LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_read_rnd_count);
   int error=mi_rrnd(file, buf, my_get_ptr(pos,ref_length));
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -1921,8 +1911,7 @@ int ha_myisam::ft_read(byte * buf)
   if (!ft_handler)
     return -1;
 
-  thread_safe_increment(table->in_use->status_var.ha_read_next_count,
-			&LOCK_status); // why ?
+  status_var_increment(table->in_use->status_var.ha_read_next_count);
 
   error=ft_handler->please->read_next(ft_handler,(char*) buf);
 

--- 1.117/storage/myisammrg/ha_myisammrg.cc	2007-03-20 18:22:01 -06:00
+++ 1.118/storage/myisammrg/ha_myisammrg.cc	2007-03-20 18:22:01 -06:00
@@ -148,7 +148,7 @@ int ha_myisammrg::close(void)
 
 int ha_myisammrg::write_row(byte * buf)
 {
-  statistic_increment(table->in_use->status_var.ha_write_count,&LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_write_count);
 
   if (file->merge_insert_method == MERGE_INSERT_DISABLED || !file->tables)
     return (HA_ERR_TABLE_READONLY);
@@ -166,7 +166,7 @@ int ha_myisammrg::write_row(byte * buf)
 
 int ha_myisammrg::update_row(const byte * old_data, byte * new_data)
 {
-  statistic_increment(table->in_use->status_var.ha_update_count,&LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_update_count);
   if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
     table->timestamp_field->set_time();
   return myrg_update(file,old_data,new_data);
@@ -174,15 +174,14 @@ int ha_myisammrg::update_row(const byte 
 
 int ha_myisammrg::delete_row(const byte * buf)
 {
-  statistic_increment(table->in_use->status_var.ha_delete_count,&LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_delete_count);
   return myrg_delete(file,buf);
 }
 
 int ha_myisammrg::index_read(byte * buf, const byte * key,
 			  uint key_len, enum ha_rkey_function find_flag)
 {
-  statistic_increment(table->in_use->status_var.ha_read_key_count,
-		      &LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_read_key_count);
   int error=myrg_rkey(file,buf,active_index, key, key_len, find_flag);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -191,8 +190,7 @@ int ha_myisammrg::index_read(byte * buf,
 int ha_myisammrg::index_read_idx(byte * buf, uint index, const byte * key,
 				 uint key_len, enum ha_rkey_function find_flag)
 {
-  statistic_increment(table->in_use->status_var.ha_read_key_count,
-		      &LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_read_key_count);
   int error=myrg_rkey(file,buf,index, key, key_len, find_flag);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -200,8 +198,7 @@ int ha_myisammrg::index_read_idx(byte * 
 
 int ha_myisammrg::index_read_last(byte * buf, const byte * key, uint key_len)
 {
-  statistic_increment(table->in_use->status_var.ha_read_key_count,
-		      &LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_read_key_count);
   int error=myrg_rkey(file,buf,active_index, key, key_len,
 		      HA_READ_PREFIX_LAST);
   table->status=error ? STATUS_NOT_FOUND: 0;
@@ -210,8 +207,7 @@ int ha_myisammrg::index_read_last(byte *
 
 int ha_myisammrg::index_next(byte * buf)
 {
-  statistic_increment(table->in_use->status_var.ha_read_next_count,
-		      &LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_read_next_count);
   int error=myrg_rnext(file,buf,active_index);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -219,8 +215,7 @@ int ha_myisammrg::index_next(byte * buf)
 
 int ha_myisammrg::index_prev(byte * buf)
 {
-  statistic_increment(table->in_use->status_var.ha_read_prev_count,
-		      &LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_read_prev_count);
   int error=myrg_rprev(file,buf, active_index);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -228,8 +223,7 @@ int ha_myisammrg::index_prev(byte * buf)
 
 int ha_myisammrg::index_first(byte * buf)
 {
-  statistic_increment(table->in_use->status_var.ha_read_first_count,
-		      &LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_read_first_count);
   int error=myrg_rfirst(file, buf, active_index);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -237,8 +231,7 @@ int ha_myisammrg::index_first(byte * buf
 
 int ha_myisammrg::index_last(byte * buf)
 {
-  statistic_increment(table->in_use->status_var.ha_read_last_count,
-		      &LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_read_last_count);
   int error=myrg_rlast(file, buf, active_index);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -248,8 +241,7 @@ int ha_myisammrg::index_next_same(byte *
                                   const byte *key __attribute__((unused)),
                                   uint length __attribute__((unused)))
 {
-  statistic_increment(table->in_use->status_var.ha_read_next_count,
-		      &LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_read_next_count);
   int error=myrg_rnext_same(file,buf);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -264,8 +256,7 @@ int ha_myisammrg::rnd_init(bool scan)
 
 int ha_myisammrg::rnd_next(byte *buf)
 {
-  statistic_increment(table->in_use->status_var.ha_read_rnd_next_count,
-		      &LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_read_rnd_next_count);
   int error=myrg_rrnd(file, buf, HA_OFFSET_ERROR);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -274,8 +265,7 @@ int ha_myisammrg::rnd_next(byte *buf)
 
 int ha_myisammrg::rnd_pos(byte * buf, byte *pos)
 {
-  statistic_increment(table->in_use->status_var.ha_read_rnd_count,
-		      &LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_read_rnd_count);
   int error=myrg_rrnd(file, buf, my_get_ptr(pos,ref_length));
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;

--- 1.299/sql/handler.cc	2007-03-20 18:22:01 -06:00
+++ 1.300/sql/handler.cc	2007-03-20 18:22:01 -06:00
@@ -623,7 +623,7 @@ int ha_prepare(THD *thd)
     for (; *ht; ht++)
     {
       int err;
-      statistic_increment(thd->status_var.ha_prepare_count,&LOCK_status);
+      status_var_increment(thd->status_var.ha_prepare_count);
       if ((*ht)->prepare)
       {
         if ((err= (*(*ht)->prepare)(*ht, thd, all)))
@@ -718,7 +718,7 @@ int ha_commit_trans(THD *thd, bool all)
           my_error(ER_ERROR_DURING_COMMIT, MYF(0), err);
           error= 1;
         }
-        statistic_increment(thd->status_var.ha_prepare_count,&LOCK_status);
+        status_var_increment(thd->status_var.ha_prepare_count);
       }
       DBUG_EXECUTE_IF("crash_commit_after_prepare", abort(););
       if (error || (is_real_trans && xid &&
@@ -765,7 +765,7 @@ int ha_commit_one_phase(THD *thd, bool a
         my_error(ER_ERROR_DURING_COMMIT, MYF(0), err);
         error=1;
       }
-      statistic_increment(thd->status_var.ha_commit_count,&LOCK_status);
+      status_var_increment(thd->status_var.ha_commit_count);
       *ht= 0;
     }
     trans->nht=0;
@@ -821,7 +821,7 @@ int ha_rollback_trans(THD *thd, bool all
         my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), err);
         error=1;
       }
-      statistic_increment(thd->status_var.ha_rollback_count,&LOCK_status);
+      status_var_increment(thd->status_var.ha_rollback_count);
       *ht= 0;
     }
     trans->nht=0;
@@ -1236,8 +1236,7 @@ int ha_rollback_to_savepoint(THD *thd, S
       my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), err);
       error=1;
     }
-    statistic_increment(thd->status_var.ha_savepoint_rollback_count,
-                        &LOCK_status);
+    status_var_increment(thd->status_var.ha_savepoint_rollback_count);
     trans->no_2pc|=(*ht)->prepare == 0;
   }
   /*
@@ -1252,7 +1251,7 @@ int ha_rollback_to_savepoint(THD *thd, S
       my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), err);
       error=1;
     }
-    statistic_increment(thd->status_var.ha_rollback_count,&LOCK_status);
+    status_var_increment(thd->status_var.ha_rollback_count);
     *ht=0; // keep it conveniently zero-filled
   }
   DBUG_RETURN(error);
@@ -1285,7 +1284,7 @@ int ha_savepoint(THD *thd, SAVEPOINT *sv
       my_error(ER_GET_ERRNO, MYF(0), err);
       error=1;
     }
-    statistic_increment(thd->status_var.ha_savepoint_count,&LOCK_status);
+    status_var_increment(thd->status_var.ha_savepoint_count);
   }
   sv->nht=trans->nht;
 #endif /* USING_TRANSACTIONS */
@@ -1471,7 +1470,7 @@ handler *handler::clone(MEM_ROOT *mem_ro
 
 void handler::ha_statistic_increment(ulong SSV::*offset) const
 {
-  statistic_increment(table->in_use->status_var.*offset, &LOCK_status);
+  status_var_increment(table->in_use->status_var.*offset);
 }
 
 
@@ -1567,8 +1566,7 @@ int handler::read_first_row(byte * buf, 
   register int error;
   DBUG_ENTER("handler::read_first_row");
 
-  statistic_increment(table->in_use->status_var.ha_read_first_count,
-                      &LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_read_first_count);
 
   /*
     If there is very few deleted rows in the table, find the first row by
@@ -2810,7 +2808,7 @@ int ha_discover(THD *thd, const char *db
     error= 0;
 
   if (!error)
-    statistic_increment(thd->status_var.ha_discover_count,&LOCK_status);
+    status_var_increment(thd->status_var.ha_discover_count);
   DBUG_RETURN(error);
 }
 

--- 1.255/sql/sql_insert.cc	2007-03-20 18:22:01 -06:00
+++ 1.256/sql/sql_insert.cc	2007-03-20 18:22:02 -06:00
@@ -2315,7 +2315,7 @@ bool delayed_insert::handle_inserts(void
 
     if (table->s->blob_fields)
       free_delayed_insert_blobs(table);
-    thread_safe_sub(delayed_rows_in_use,1,&LOCK_delayed_status);
+    thread_safe_decrement(delayed_rows_in_use,&LOCK_delayed_status);
     thread_safe_increment(delayed_insert_writes,&LOCK_delayed_status);
     pthread_mutex_lock(&mutex);
 

--- 1.637/sql/sql_parse.cc	2007-03-20 18:22:02 -06:00
+++ 1.638/sql/sql_parse.cc	2007-03-20 18:22:02 -06:00
@@ -702,8 +702,7 @@ bool dispatch_command(enum enum_server_c
   case COM_INIT_DB:
   {
     LEX_STRING tmp;
-    statistic_increment(thd->status_var.com_stat[SQLCOM_CHANGE_DB],
-			&LOCK_status);
+    status_var_increment(thd->status_var.com_stat[SQLCOM_CHANGE_DB]);
     thd->convert_string(&tmp, system_charset_info,
 			packet, packet_length-1, thd->charset());
     if (!mysql_change_db(thd, tmp.str, FALSE))
@@ -738,7 +737,7 @@ bool dispatch_command(enum enum_server_c
       break;
     }
 
-    statistic_increment(thd->status_var.com_other, &LOCK_status);
+    status_var_increment(thd->status_var.com_other);
     thd->enable_slow_log= opt_log_slow_admin_statements;
     db.str= thd->alloc(db_len + tbl_len + 2);
     db.length= db_len;
@@ -754,7 +753,7 @@ bool dispatch_command(enum enum_server_c
   }
   case COM_CHANGE_USER:
   {
-    statistic_increment(thd->status_var.com_other, &LOCK_status);
+    status_var_increment(thd->status_var.com_other);
     char *user= (char*) packet, *packet_end= packet+ packet_length;
     char *passwd= strend(user)+1;
 
@@ -932,8 +931,7 @@ bool dispatch_command(enum enum_server_c
     /* used as fields initializator */
     lex_start(thd, 0, 0);
 
-    statistic_increment(thd->status_var.com_stat[SQLCOM_SHOW_FIELDS],
-			&LOCK_status);
+    status_var_increment(thd->status_var.com_stat[SQLCOM_SHOW_FIELDS]);
     bzero((char*) &table_list,sizeof(table_list));
     if (thd->copy_db_to(&table_list.db, &dummy))
       break;
@@ -996,8 +994,7 @@ bool dispatch_command(enum enum_server_c
       LEX_STRING db, alias;
       HA_CREATE_INFO create_info;
 
-      statistic_increment(thd->status_var.com_stat[SQLCOM_CREATE_DB],
-			  &LOCK_status);
+      status_var_increment(thd->status_var.com_stat[SQLCOM_CREATE_DB]);
       if (thd->LEX_STRING_make(&db, packet, packet_length -1) ||
           thd->LEX_STRING_make(&alias, db.str, db.length) ||
           check_db_name(&db))
@@ -1016,8 +1013,7 @@ bool dispatch_command(enum enum_server_c
     }
   case COM_DROP_DB:				// QQ: To be removed
     {
-      statistic_increment(thd->status_var.com_stat[SQLCOM_DROP_DB],
-			  &LOCK_status);
+      status_var_increment(thd->status_var.com_stat[SQLCOM_DROP_DB]);
       LEX_STRING db;
 
       if (thd->LEX_STRING_make(&db, packet, packet_length - 1) ||
@@ -1046,7 +1042,7 @@ bool dispatch_command(enum enum_server_c
       ushort flags;
       uint32 slave_server_id;
 
-      statistic_increment(thd->status_var.com_other,&LOCK_status);
+      status_var_increment(thd->status_var.com_other);
       thd->enable_slow_log= opt_log_slow_admin_statements;
       if (check_global_access(thd, REPL_SLAVE_ACL))
 	break;
@@ -1072,8 +1068,7 @@ bool dispatch_command(enum enum_server_c
   case COM_REFRESH:
   {
     bool not_used;
-    statistic_increment(thd->status_var.com_stat[SQLCOM_FLUSH],
-                        &LOCK_status);
+    status_var_increment(thd->status_var.com_stat[SQLCOM_FLUSH]);
     ulong options= (ulong) (uchar) packet[0];
     if (check_global_access(thd,RELOAD_ACL))
       break;
@@ -1085,7 +1080,7 @@ bool dispatch_command(enum enum_server_c
 #ifndef EMBEDDED_LIBRARY
   case COM_SHUTDOWN:
   {
-    statistic_increment(thd->status_var.com_other, &LOCK_status);
+    status_var_increment(thd->status_var.com_other);
     if (check_global_access(thd,SHUTDOWN_ACL))
       break; /* purecov: inspected */
     /*
@@ -1136,8 +1131,7 @@ bool dispatch_command(enum enum_server_c
 #endif
 
     general_log_print(thd, command, NullS);
-    statistic_increment(thd->status_var.com_stat[SQLCOM_SHOW_STATUS],
-			&LOCK_status);
+    status_var_increment(thd->status_var.com_stat[SQLCOM_SHOW_STATUS]);
     calc_sum_of_all_status(&current_global_status_var);
     uptime= (ulong) (thd->start_time - server_start_time);
     length= my_snprintf((char*) buff, buff_len - 1,
@@ -1169,12 +1163,11 @@ bool dispatch_command(enum enum_server_c
     break;
   }
   case COM_PING:
-    statistic_increment(thd->status_var.com_other, &LOCK_status);
+    status_var_increment(thd->status_var.com_other);
     send_ok(thd);				// Tell client we are alive
     break;
   case COM_PROCESS_INFO:
-    statistic_increment(thd->status_var.com_stat[SQLCOM_SHOW_PROCESSLIST],
-			&LOCK_status);
+    status_var_increment(thd->status_var.com_stat[SQLCOM_SHOW_PROCESSLIST]);
     if (!thd->security_ctx->priv_user[0] &&
         check_global_access(thd, PROCESS_ACL))
       break;
@@ -1185,15 +1178,14 @@ bool dispatch_command(enum enum_server_c
     break;
   case COM_PROCESS_KILL:
   {
-    statistic_increment(thd->status_var.com_stat[SQLCOM_KILL], &LOCK_status);
+    status_var_increment(thd->status_var.com_stat[SQLCOM_KILL]);
     ulong id=(ulong) uint4korr(packet);
     sql_kill(thd,id,false);
     break;
   }
   case COM_SET_OPTION:
   {
-    statistic_increment(thd->status_var.com_stat[SQLCOM_SET_OPTION],
-			&LOCK_status);
+    status_var_increment(thd->status_var.com_stat[SQLCOM_SET_OPTION]);
     uint opt_command= uint2korr(packet);
 
     switch (opt_command) {
@@ -1212,7 +1204,7 @@ bool dispatch_command(enum enum_server_c
     break;
   }
   case COM_DEBUG:
-    statistic_increment(thd->status_var.com_other, &LOCK_status);
+    status_var_increment(thd->status_var.com_other);
     if (check_global_access(thd, SUPER_ACL))
       break;					/* purecov: inspected */
     mysql_print_status();
@@ -1769,8 +1761,7 @@ mysql_execute_command(THD *thd)
 #ifdef HAVE_REPLICATION
   } /* endif unlikely slave */
 #endif
-  statistic_increment(thd->status_var.com_stat[lex->sql_command],
-                      &LOCK_status);
+  status_var_increment(thd->status_var.com_stat[lex->sql_command]);
 
   switch (lex->sql_command) {
   case SQLCOM_SHOW_EVENTS:

--- 1.500/sql/sql_select.cc	2007-03-20 18:22:02 -06:00
+++ 1.501/sql/sql_select.cc	2007-03-20 18:22:02 -06:00
@@ -6178,8 +6178,7 @@ make_join_readinfo(JOIN *join, ulonglong
 	join->thd->server_status|=SERVER_QUERY_NO_GOOD_INDEX_USED;
 	tab->read_first_record= join_init_quick_read_record;
 	if (statistics)
-	  statistic_increment(join->thd->status_var.select_range_check_count,
-			      &LOCK_status);
+	  status_var_increment(join->thd->status_var.select_range_check_count);
       }
       else
       {
@@ -6189,15 +6188,13 @@ make_join_readinfo(JOIN *join, ulonglong
 	  if (tab->select && tab->select->quick)
 	  {
 	    if (statistics)
-	      statistic_increment(join->thd->status_var.select_range_count,
-				  &LOCK_status);
+	      status_var_increment(join->thd->status_var.select_range_count);
 	  }
 	  else
 	  {
 	    join->thd->server_status|=SERVER_QUERY_NO_INDEX_USED;
 	    if (statistics)
-	      statistic_increment(join->thd->status_var.select_scan_count,
-				  &LOCK_status);
+	      status_var_increment(join->thd->status_var.select_scan_count);
 	  }
 	}
 	else
@@ -6205,15 +6202,13 @@ make_join_readinfo(JOIN *join, ulonglong
 	  if (tab->select && tab->select->quick)
 	  {
 	    if (statistics)
-	      statistic_increment(join->thd->status_var.select_full_range_join_count,
-				  &LOCK_status);
+	      status_var_increment(join->thd->status_var.select_full_range_join_count);
 	  }
 	  else
 	  {
 	    join->thd->server_status|=SERVER_QUERY_NO_INDEX_USED;
 	    if (statistics)
-	      statistic_increment(join->thd->status_var.select_full_join_count,
-				  &LOCK_status);
+	      status_var_increment(join->thd->status_var.select_full_join_count);
 	  }
 	}
 	if (!table->no_keyread)
@@ -9258,7 +9253,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARA
               (int) distinct, (int) save_sum_fields,
               (ulong) rows_limit,test(group)));
 
-  statistic_increment(thd->status_var.created_tmp_tables, &LOCK_status);
+  status_var_increment(thd->status_var.created_tmp_tables);
 
   if (use_temp_pool && !(test_flags & TEST_KEEP_TMP_TABLES))
     temp_pool_slot = bitmap_lock_set_next(&temp_pool);
@@ -10120,8 +10115,7 @@ static bool create_myisam_tmp_table(TABL
     table->db_stat=0;
     goto err;
   }
-  statistic_increment(table->in_use->status_var.created_tmp_disk_tables,
-		      &LOCK_status);
+  status_var_increment(table->in_use->status_var.created_tmp_disk_tables);
   share->db_record_offset= 1;
   DBUG_RETURN(0);
  err:

--- 1.418/sql/ha_ndbcluster.cc	2007-03-20 18:22:02 -06:00
+++ 1.419/sql/ha_ndbcluster.cc	2007-03-20 18:22:02 -06:00
@@ -2629,7 +2629,7 @@ int ha_ndbcluster::write_row(byte *recor
       DBUG_RETURN(peek_res);
   }
 
-  statistic_increment(thd->status_var.ha_write_count, &LOCK_status);
+  status_var_increment(thd->status_var.ha_write_count);
   if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
     table->timestamp_field->set_time();
 
@@ -2851,7 +2851,7 @@ int ha_ndbcluster::update_row(const byte
       DBUG_RETURN(peek_res);
   }
 
-  statistic_increment(thd->status_var.ha_update_count, &LOCK_status);
+  status_var_increment(thd->status_var.ha_update_count);
   if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
   {
     table->timestamp_field->set_time();
@@ -3018,7 +3018,7 @@ int ha_ndbcluster::delete_row(const byte
   DBUG_ENTER("delete_row");
   m_write_op= TRUE;
 
-  statistic_increment(thd->status_var.ha_delete_count,&LOCK_status);
+  status_var_increment(thd->status_var.ha_delete_count);
   m_rows_changed++;
 
   if (m_use_partition_function &&
@@ -3374,7 +3374,7 @@ int ha_ndbcluster::index_read_idx(byte *
                               const byte *key, uint key_len, 
                               enum ha_rkey_function find_flag)
 {
-  statistic_increment(current_thd->status_var.ha_read_key_count, &LOCK_status);
+  status_var_increment(current_thd->status_var.ha_read_key_count);
   DBUG_ENTER("ha_ndbcluster::index_read_idx");
   DBUG_PRINT("enter", ("index_no: %u, key_len: %u", index_no, key_len));  
   close_scan();
@@ -3386,8 +3386,7 @@ int ha_ndbcluster::index_read_idx(byte *
 int ha_ndbcluster::index_next(byte *buf)
 {
   DBUG_ENTER("ha_ndbcluster::index_next");
-  statistic_increment(current_thd->status_var.ha_read_next_count,
-                      &LOCK_status);
+  status_var_increment(current_thd->status_var.ha_read_next_count);
   DBUG_RETURN(next_result(buf));
 }
 
@@ -3395,8 +3394,7 @@ int ha_ndbcluster::index_next(byte *buf)
 int ha_ndbcluster::index_prev(byte *buf)
 {
   DBUG_ENTER("ha_ndbcluster::index_prev");
-  statistic_increment(current_thd->status_var.ha_read_prev_count,
-                      &LOCK_status);
+  status_var_increment(current_thd->status_var.ha_read_prev_count);
   DBUG_RETURN(next_result(buf));
 }
 
@@ -3404,8 +3402,7 @@ int ha_ndbcluster::index_prev(byte *buf)
 int ha_ndbcluster::index_first(byte *buf)
 {
   DBUG_ENTER("ha_ndbcluster::index_first");
-  statistic_increment(current_thd->status_var.ha_read_first_count,
-                      &LOCK_status);
+  status_var_increment(current_thd->status_var.ha_read_first_count);
   // Start the ordered index scan and fetch the first row
 
   // Only HA_READ_ORDER indexes get called by index_first
@@ -3416,7 +3413,7 @@ int ha_ndbcluster::index_first(byte *buf
 int ha_ndbcluster::index_last(byte *buf)
 {
   DBUG_ENTER("ha_ndbcluster::index_last");
-  statistic_increment(current_thd->status_var.ha_read_last_count,&LOCK_status);
+  status_var_increment(current_thd->status_var.ha_read_last_count);
   DBUG_RETURN(ordered_index_scan(0, 0, TRUE, TRUE, buf, NULL));
 }
 
@@ -3602,8 +3599,7 @@ int ha_ndbcluster::rnd_end()
 int ha_ndbcluster::rnd_next(byte *buf)
 {
   DBUG_ENTER("rnd_next");
-  statistic_increment(current_thd->status_var.ha_read_rnd_next_count,
-                      &LOCK_status);
+  status_var_increment(current_thd->status_var.ha_read_rnd_next_count);
 
   if (!m_active_cursor)
     DBUG_RETURN(full_table_scan(buf));
@@ -3621,8 +3617,7 @@ int ha_ndbcluster::rnd_next(byte *buf)
 int ha_ndbcluster::rnd_pos(byte *buf, byte *pos)
 {
   DBUG_ENTER("rnd_pos");
-  statistic_increment(current_thd->status_var.ha_read_rnd_count,
-                      &LOCK_status);
+  status_var_increment(current_thd->status_var.ha_read_rnd_count);
   // The primary key for the record is stored in pos
   // Perform a pk_read using primary key "index"
   {

--- 1.162/include/my_global.h	2007-03-20 18:22:02 -06:00
+++ 1.163/include/my_global.h	2007-03-20 18:22:02 -06:00
@@ -434,17 +434,7 @@ C_MODE_END
 #ifdef HAVE_ALLOCA_H
 #include <alloca.h>
 #endif
-#ifdef HAVE_ATOMIC_ADD
-#define new my_arg_new
-#define need_to_restore_new 1
-C_MODE_START
-#include <asm/atomic.h>
-C_MODE_END
-#ifdef need_to_restore_new /* probably safer than #ifdef new */
-#undef new
-#undef need_to_restore_new
-#endif
-#endif
+
 #include <errno.h>				/* Recommended by debian */
 /* We need the following to go around a problem with openssl on solaris */
 #if defined(HAVE_CRYPT_H)
@@ -1440,14 +1430,6 @@ do { doubleget_union _tmp; \
 #else
 #define my_sprintf(buff,args) ((ulong) sprintf args, (ulong) strlen(buff))
 #endif
-#endif
-
-#ifndef THREAD
-#define thread_safe_increment(V,L) (V)++
-#define thread_safe_add(V,C,L)     (V)+=(C)
-#define thread_safe_sub(V,C,L)     (V)-=(C)
-#define statistic_increment(V,L)   (V)++
-#define statistic_add(V,C,L)       (V)+=(C)
 #endif
 
 #ifdef HAVE_CHARSET_utf8

--- 1.97/storage/federated/ha_federated.cc	2007-03-20 18:22:02 -06:00
+++ 1.98/storage/federated/ha_federated.cc	2007-03-20 18:22:02 -06:00
@@ -1777,7 +1777,7 @@ int ha_federated::write_row(byte *buf)
   values_string.length(0);
   insert_string.length(0);
   insert_field_value_string.length(0);
-  statistic_increment(table->in_use->status_var.ha_write_count, &LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_write_count);
   if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
     table->timestamp_field->set_time();
 
@@ -2244,8 +2244,7 @@ int ha_federated::index_read_idx_with_re
   *result= 0;                                   // In case of errors
   index_string.length(0);
   sql_query.length(0);
-  statistic_increment(table->in_use->status_var.ha_read_key_count,
-                      &LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_read_key_count);
 
   sql_query.append(share->select_query);
 
@@ -2359,8 +2358,7 @@ int ha_federated::read_range_next()
 int ha_federated::index_next(byte *buf)
 {
   DBUG_ENTER("ha_federated::index_next");
-  statistic_increment(table->in_use->status_var.ha_read_next_count,
-		      &LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_read_next_count);
   DBUG_RETURN(read_next(buf, stored_result));
 }
 
@@ -2561,8 +2559,7 @@ int ha_federated::rnd_pos(byte *buf, byt
 {
   int result;
   DBUG_ENTER("ha_federated::rnd_pos");
-  statistic_increment(table->in_use->status_var.ha_read_rnd_count,
-                      &LOCK_status);
+  status_var_increment(table->in_use->status_var.ha_read_rnd_count);
   if (table->s->primary_key != MAX_KEY)
   {
     /* We have a primary key, so use index_read_idx to find row */

--- 1.207/sql/sql_prepare.cc	2007-03-20 18:22:02 -06:00
+++ 1.208/sql/sql_prepare.cc	2007-03-20 18:22:02 -06:00
@@ -2413,7 +2413,7 @@ void mysql_stmt_fetch(THD *thd, char *pa
 
   /* First of all clear possible warnings from the previous command */
   mysql_reset_thd_for_next_command(thd);
-  statistic_increment(thd->status_var.com_stmt_fetch, &LOCK_status);
+  status_var_increment(thd->status_var.com_stmt_fetch);
   if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_fetch")))
     DBUG_VOID_RETURN;
 
@@ -2477,7 +2477,7 @@ void mysql_stmt_reset(THD *thd, char *pa
   /* First of all clear possible warnings from the previous command */
   mysql_reset_thd_for_next_command(thd);
 
-  statistic_increment(thd->status_var.com_stmt_reset, &LOCK_status);
+  status_var_increment(thd->status_var.com_stmt_reset);
   if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_reset")))
     DBUG_VOID_RETURN;
 
@@ -2581,7 +2581,7 @@ void mysql_stmt_get_longdata(THD *thd, c
 #endif
   DBUG_ENTER("mysql_stmt_get_longdata");
 
-  statistic_increment(thd->status_var.com_stmt_send_long_data, &LOCK_status);
+  status_var_increment(thd->status_var.com_stmt_send_long_data);
 #ifndef EMBEDDED_LIBRARY
   /* Minimal size of long data packet is 6 bytes */
   if (packet_length <= MYSQL_LONG_DATA_HEADER)
@@ -2832,7 +2832,7 @@ bool Prepared_statement::prepare(const c
     However, it seems handy if com_stmt_prepare is increased always,
     no matter what kind of prepare is processed.
   */
-  statistic_increment(thd->status_var.com_stmt_prepare, &LOCK_status);
+  status_var_increment(thd->status_var.com_stmt_prepare);
 
   /*
     alloc_query() uses thd->memroot && thd->query, so we should call
@@ -2951,7 +2951,7 @@ bool Prepared_statement::execute(String 
   Query_arena *old_stmt_arena;
   bool error= TRUE;
 
-  statistic_increment(thd->status_var.com_stmt_execute, &LOCK_status);
+  status_var_increment(thd->status_var.com_stmt_execute);
 
   /* Check if we got an error when sending long data */
   if (state == Query_arena::ERROR)
@@ -3073,7 +3073,7 @@ error:
 bool Prepared_statement::deallocate()
 {
   /* We account deallocate in the same manner as mysql_stmt_close */
-  statistic_increment(thd->status_var.com_stmt_close, &LOCK_status);
+  status_var_increment(thd->status_var.com_stmt_close);
   if (flags & (uint) IS_IN_USE)
   {
     my_error(ER_PS_NO_RECURSION, MYF(0));
Thread
bk commit into 5.1 tree (malff:1.2472) BUG#21554marc.alff21 Mar