MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Alexey Kopytov Date:September 12 2008 12:14pm
Subject:bzr commit into mysql-6.0 branch (alexeyk:2738) WL#4541
View as plain text  
#At file:///Volumes/10.211.55.5/dtrace/mysql-6.0-dtrace/

 2738 Alexey Kopytov	2008-09-12
      WL #4541: Improved DTrace support in server
      
      Extended and improved the current set of DTrace probes based on
      suggestions and patches from various sources. Fixed some build
      issues with libmysqld and newer Solaris releases.
modified:
  .bzr-mysql/default.conf
  libmysql/Makefile.am
  libmysql/Makefile.shared
  sql/Makefile.am
  sql/filesort.cc
  sql/handler.cc
  sql/mysql_priv.h
  sql/mysqld.cc
  sql/net_serv.cc
  sql/probes.d
  sql/probes.h
  sql/scheduler.cc
  sql/sp_head.cc
  sql/sql_cache.cc
  sql/sql_connect.cc
  sql/sql_cursor.cc
  sql/sql_delete.cc
  sql/sql_insert.cc
  sql/sql_parse.cc
  sql/sql_prepare.cc
  sql/sql_select.cc
  sql/sql_update.cc

per-file messages:
  .bzr-mysql/default.conf
    Fixed the tree name.
  libmysql/Makefile.am
    Added probes.h to the list of files copied over from sql/ since
    net_serv.cc now includes it.
  libmysql/Makefile.shared
    Added probes.h to the list of files copied over from sql/ since
    net_serv.cc now includes it.
  sql/Makefile.am
    Modified the Makefile to include new source files with probes.
    Fixed the problem with probes.o not being updated when necessary.
  sql/filesort.cc
    Added filesort-start and filesort-done.
  sql/handler.cc
    Added handler-*lock-{start,done} and 
    {insert,update,delete}-row-{start,done} probes.
  sql/mysql_priv.h
    Added a workaround to exclude DTrace probes from the embedded 
    build. A proper solution requires significant changes to
    Makefiles and has been postponed.
  sql/mysqld.cc
    Added the connection-done probe.
  sql/net_serv.cc
    Added a workaround to exclude DTrace probes from the client
    library build. A proper solution requires significant changes
    to Makefile and has been postponed.
  sql/probes.d
    Updated the provider definition to reflect modifications to the
    set of probes and interfaces.
  sql/probes.h
    Regenerated probes.h from the updated probes.d.
  sql/scheduler.cc
    Added the connection-start probe.
  sql/sp_head.cc
    Added the query-exec-start probe.
  sql/sql_cache.cc
    Added query-cache-{hit,miss} probes.
  sql/sql_connect.cc
    Added connection-start probe.
  sql/sql_cursor.cc
    Added query-exec-{start,done}.
  sql/sql_delete.cc
    Renamed delete-end to delete-done, added multi-delete-done,
    fixed the problem with delete-done not firing in case of a 
    failure.
  sql/sql_insert.cc
    Renamed insert-end to insert-done. Added insert-select-done.
  sql/sql_parse.cc
    Added command-{start,done}, query-{start,done} and 
    query-parse-{start,done}.
  sql/sql_prepare.cc
    Added query-exec-{start,done}.
  sql/sql_select.cc
    Updated select-start, renamed select-end to select-done.
  sql/sql_update.cc
    Added update-{start,done} and multi-update-{start,done}.
=== modified file '.bzr-mysql/default.conf'
--- a/.bzr-mysql/default.conf	2008-07-15 20:02:29 +0000
+++ b/.bzr-mysql/default.conf	2008-09-12 12:14:22 +0000
@@ -1,5 +1,5 @@
 [MYSQL]
-tree_location = bzr+ssh://bk-internal.mysql.com/bzrroot/server/mysql-6.0-backup/
+tree_location = bzr+ssh://bk-internal.mysql.com/bzrroot/server/mysql-6.0/
 post_commit_to = commits@stripped
 post_push_to = commits@stripped
-tree_name = mysql-6.0-backup
+tree_name = mysql-6.0

=== modified file 'libmysql/Makefile.am'
--- a/libmysql/Makefile.am	2007-11-22 11:39:07 +0000
+++ b/libmysql/Makefile.am	2008-09-12 12:14:22 +0000
@@ -67,6 +67,8 @@ link_sources:
 	  done; \
 	  rm -f net.c; \
 	  @LN_CP_F@ $(top_srcdir)/sql/net_serv.cc net.c ; \
+	  rm -f probes.h; \
+	  @LN_CP_F@ $(top_srcdir)/sql/probes.h probes.h
 	  rm -f password.c; \
 	  @LN_CP_F@ $(top_srcdir)/sql/password.c password.c
 	  echo timestamp > link_sources

=== modified file 'libmysql/Makefile.shared'
--- a/libmysql/Makefile.shared	2008-05-29 15:44:11 +0000
+++ b/libmysql/Makefile.shared	2008-09-12 12:14:22 +0000
@@ -107,7 +107,7 @@ clean-local:
 	      `echo $(sql_cmn_objects) | sed "s;\.lo;.c;g"` \
 	       $(CHARSET_SRCS) $(CHARSET_OBJS) \
 	       $(mystringsextra) $(mysysheaders) $(vioheaders) \
-               net.c
+               net.c probes.h
 
 conf_to_src_SOURCES = conf_to_src.c
 conf_to_src_LDADD=

=== modified file 'sql/Makefile.am'
--- a/sql/Makefile.am	2008-07-09 07:12:43 +0000
+++ b/sql/Makefile.am	2008-09-12 12:14:22 +0000
@@ -31,10 +31,19 @@ EXTRA_PROGRAMS =	gen_lex_hash
 bin_PROGRAMS =		mysql_tzinfo_to_sql
 DTRACE =                @DTRACE@
 DTRACEFLAGS =           @DTRACEFLAGS@
-DTRACEFILES =           handler.o \
-			filesort.o \
-			sql_insert.o \
+DTRACEFILES =           filesort.o \
+			handler.o \
+			mysqld.o \
+			net_serv.o \
+			scheduler.o \
+			sp_head.o \
+			sql_cache.o \
+			sql_connect.o \
+			sql_cursor.o \
 			sql_delete.o \
+			sql_insert.o \
+			sql_parse.o \
+			sql_prepare.o \
 			sql_select.o \
 			sql_update.o
 
@@ -216,8 +225,10 @@ install-exec-hook:
 
 SUFFIXES : .d
 
-.d.o : $(DTRACEFILES)
+.d.o :
 	$(DTRACE) $(DTRACEFLAGS) -G -s $< $(DTRACEFILES)
 
+probes.o : $(DTRACEFILES)
+
 # Don't update the files from bitkeeper
 %::SCCS/s.%

=== modified file 'sql/filesort.cc'
--- a/sql/filesort.cc	2008-07-17 19:55:18 +0000
+++ b/sql/filesort.cc	2008-09-12 12:14:22 +0000
@@ -121,7 +121,7 @@ ha_rows filesort(THD *thd, TABLE *table,
   TABLE_LIST *tab= table->pos_in_table_list;
   Item_subselect *subselect= tab ? tab->containing_subselect() : 0;
 
-  MYSQL_FILESORT_START();
+  MYSQL_FILESORT_START(table->s->db.str, table->s->table_name.str);
 
   /*
    Release InnoDB's adaptive hash index latch (if holding) before
@@ -333,8 +333,10 @@ ha_rows filesort(THD *thd, TABLE *table,
 #endif
   memcpy(&table->sort, &table_sort, sizeof(FILESORT_INFO));
   DBUG_PRINT("exit",("records: %ld", (long) records));
-  MYSQL_FILESORT_END();
-  DBUG_RETURN(error ? HA_POS_ERROR : records);
+  if (error)
+    records= HA_POS_ERROR;
+  MYSQL_FILESORT_DONE(error, records);
+  DBUG_RETURN(records);
 } /* filesort */
 
 

=== modified file 'sql/handler.cc'
--- a/sql/handler.cc	2008-07-09 07:12:43 +0000
+++ b/sql/handler.cc	2008-09-12 12:14:22 +0000
@@ -5264,13 +5264,42 @@ int handler::ha_external_lock(THD *thd, 
   */
   DBUG_ASSERT(next_insert_id == 0);
 
+  if (MYSQL_HANDLER_RDLOCK_START_ENABLED() ||
+      MYSQL_HANDLER_WRLOCK_START_ENABLED() ||
+      MYSQL_HANDLER_UNLOCK_START_ENABLED())
+  {
+    if (lock_type == F_RDLCK)
+      MYSQL_HANDLER_RDLOCK_START(table_share->db.str,
+                                 table_share->table_name.str);
+    else if (lock_type == F_WRLCK)
+      MYSQL_HANDLER_WRLOCK_START(table_share->db.str,
+                                 table_share->table_name.str);
+    else if (lock_type == F_UNLCK)
+      MYSQL_HANDLER_UNLOCK_START(table_share->db.str,
+                                 table_share->table_name.str);
+  }
+
   /*
     We cache the table flags if the locking succeeded. Otherwise, we
     keep them as they were when they were fetched in ha_open().
   */
-  MYSQL_EXTERNAL_LOCK(lock_type);
-
   int error= external_lock(thd, lock_type);
+
+  if (MYSQL_HANDLER_RDLOCK_DONE_ENABLED() ||
+      MYSQL_HANDLER_WRLOCK_DONE_ENABLED() ||
+      MYSQL_HANDLER_UNLOCK_DONE_ENABLED())
+  {
+    if (lock_type == F_RDLCK)
+      MYSQL_HANDLER_RDLOCK_DONE(error, table_share->db.str,
+                                 table_share->table_name.str);
+    else if (lock_type == F_WRLCK)
+      MYSQL_HANDLER_WRLOCK_DONE(error, table_share->db.str,
+                                 table_share->table_name.str);
+    else if (lock_type == F_UNLCK)
+      MYSQL_HANDLER_UNLOCK_DONE(error, table_share->db.str,
+                                 table_share->table_name.str);
+  }
+  
   if (error == 0)
     cached_table_flags= table_flags();
   DBUG_RETURN(error);
@@ -5304,15 +5333,17 @@ int handler::ha_write_row(uchar *buf)
   int error;
   Log_func *log_func= Write_rows_log_event::binlog_row_logging_function;
   DBUG_ENTER("handler::ha_write_row");
-  MYSQL_INSERT_ROW_START();
 
+  MYSQL_INSERT_ROW_START(table_share->db.str, table_share->table_name.str);
   mark_trx_read_write();
-
-  if (unlikely(error= write_row(buf)))
+  error= write_row(buf);
+  MYSQL_INSERT_ROW_DONE(error,
+                        table_share->db.str, table_share->table_name.str);
+  
+  if (unlikely(error != 0))
     DBUG_RETURN(error);
   if (unlikely(error= binlog_log_row(table, 0, buf, log_func)))
     DBUG_RETURN(error); /* purecov: inspected */
-  MYSQL_INSERT_ROW_END();
   DBUG_RETURN(0);
 }
 
@@ -5328,9 +5359,13 @@ int handler::ha_update_row(const uchar *
    */
   DBUG_ASSERT(new_data == table->record[0]);
 
+  MYSQL_UPDATE_ROW_START(table_share->db.str, table_share->table_name.str);
   mark_trx_read_write();
+  error= update_row(old_data, new_data);
+  MYSQL_UPDATE_ROW_DONE(error,
+                        table_share->db.str, table_share->table_name.str);
 
-  if (unlikely(error= update_row(old_data, new_data)))
+  if (unlikely(error != 0))
     return error;
   if (unlikely(error= binlog_log_row(table, old_data, new_data, log_func)))
     return error;
@@ -5342,9 +5377,13 @@ int handler::ha_delete_row(const uchar *
   int error;
   Log_func *log_func= Delete_rows_log_event::binlog_row_logging_function;
 
+  MYSQL_DELETE_ROW_START(table_share->db.str, table_share->table_name.str);
   mark_trx_read_write();
+  error= delete_row(buf);
+  MYSQL_DELETE_ROW_DONE(error,
+                        table_share->db.str, table_share->table_name.str);
 
-  if (unlikely(error= delete_row(buf)))
+  if (unlikely(error != 0))
     return error;
   if (unlikely(error= binlog_log_row(table, buf, 0, log_func)))
     return error;

=== modified file 'sql/mysql_priv.h'
--- a/sql/mysql_priv.h	2008-07-22 10:57:48 +0000
+++ b/sql/mysql_priv.h	2008-09-12 12:14:22 +0000
@@ -46,6 +46,11 @@
 
 #ifdef HAVE_DTRACE
 #define _DTRACE_VERSION 1
+#else
+#undef _DTRACE_VERSION
+#endif
+#ifdef EMBEDDED_LIBRARY
+#undef _DTRACE_VERSION
 #endif
 #include "probes.h"
 

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2008-07-19 03:03:39 +0000
+++ b/sql/mysqld.cc	2008-09-12 12:14:22 +0000
@@ -1905,6 +1905,7 @@ void close_connection(THD *thd, uint err
   }
   if (lock)
     (void) pthread_mutex_unlock(&LOCK_thread_count);
+  MYSQL_CONNECTION_DONE((int) errcode, thd->thread_id);
   DBUG_VOID_RETURN;
 }
 #endif /* EMBEDDED_LIBRARY */

=== modified file 'sql/net_serv.cc'
--- a/sql/net_serv.cc	2008-05-29 15:44:11 +0000
+++ b/sql/net_serv.cc	2008-09-12 12:14:22 +0000
@@ -58,6 +58,13 @@
 #define MYSQL_CLIENT
 #endif /*EMBEDDED_LIBRARY */
 
+#ifdef HAVE_DTRACE
+/* Limit DTrace probes to server code for now */
+#ifndef MYSQL_SERVER
+#undef _DTRACE_VERSION
+#endif
+#endif
+#include "probes.h"
 
 /*
   The following handles the differences when this is linked between the
@@ -364,8 +371,12 @@ my_bool
 my_net_write(NET *net,const uchar *packet,size_t len)
 {
   uchar buff[NET_HEADER_SIZE];
+  my_bool rc;
   if (unlikely(!net->vio)) /* nowhere to write */
     return 0;
+
+  MYSQL_NET_WRITE_START(len);
+
   /*
     Big packets are handled by splitting them in packets of MAX_PACKET_LENGTH
     length. The last packet is always a packet that is < MAX_PACKET_LENGTH.
@@ -378,7 +389,10 @@ my_net_write(NET *net,const uchar *packe
     buff[3]= (uchar) net->pkt_nr++;
     if (net_write_buff(net, buff, NET_HEADER_SIZE) ||
 	net_write_buff(net, packet, z_size))
+    {
+      MYSQL_NET_WRITE_DONE(1);
       return 1;
+    }
     packet += z_size;
     len-=     z_size;
   }
@@ -386,11 +400,16 @@ my_net_write(NET *net,const uchar *packe
   int3store(buff,len);
   buff[3]= (uchar) net->pkt_nr++;
   if (net_write_buff(net, buff, NET_HEADER_SIZE))
+  {
+    MYSQL_NET_WRITE_DONE(1);
     return 1;
+  }
 #ifndef DEBUG_DATA_PACKETS
   DBUG_DUMP("packet_header", buff, NET_HEADER_SIZE);
 #endif
-  return test(net_write_buff(net,packet,len));
+  rc= test(net_write_buff(net,packet,len));
+  MYSQL_NET_WRITE_DONE(rc);
+  return rc;
 }
 
 /**
@@ -428,9 +447,12 @@ net_write_command(NET *net,uchar command
   ulong length=len+1+head_len;			/* 1 extra byte for command */
   uchar buff[NET_HEADER_SIZE+1];
   uint header_size=NET_HEADER_SIZE+1;
+  my_bool rc;
   DBUG_ENTER("net_write_command");
   DBUG_PRINT("enter",("length: %lu", (ulong) len));
 
+  MYSQL_NET_WRITE_START(length);
+  
   buff[4]=command;				/* For first packet */
 
   if (length >= MAX_PACKET_LENGTH)
@@ -444,7 +466,10 @@ net_write_command(NET *net,uchar command
       if (net_write_buff(net, buff, header_size) ||
 	  net_write_buff(net, header, head_len) ||
 	  net_write_buff(net, packet, len))
-	DBUG_RETURN(1);
+      {
+        MYSQL_NET_WRITE_DONE(1);
+        DBUG_RETURN(1);
+      }
       packet+= len;
       length-= MAX_PACKET_LENGTH;
       len= MAX_PACKET_LENGTH;
@@ -455,9 +480,11 @@ net_write_command(NET *net,uchar command
   }
   int3store(buff,length);
   buff[3]= (uchar) net->pkt_nr++;
-  DBUG_RETURN(test(net_write_buff(net, buff, header_size) ||
-                   (head_len && net_write_buff(net, header, head_len)) ||
-                   net_write_buff(net, packet, len) || net_flush(net)));
+  rc= test(net_write_buff(net, buff, header_size) ||
+           (head_len && net_write_buff(net, header, head_len)) ||
+           net_write_buff(net, packet, len) || net_flush(net));
+  MYSQL_NET_WRITE_DONE(rc);
+  DBUG_RETURN(rc);
 }
 
 /**
@@ -985,6 +1012,8 @@ my_net_read(NET *net)
 {
   size_t len, complen;
 
+  MYSQL_NET_READ_START();
+  
 #ifdef HAVE_COMPRESS
   if (!net->compress)
   {
@@ -1008,6 +1037,7 @@ my_net_read(NET *net)
     net->read_pos = net->buff + net->where_b;
     if (len != packet_error)
       net->read_pos[len]=0;		/* Safeguard for mysql_use_result */
+    MYSQL_NET_READ_DONE(0, len);
     return len;
 #ifdef HAVE_COMPRESS
   }
@@ -1091,7 +1121,10 @@ my_net_read(NET *net)
 
       net->where_b=buf_length;
       if ((packet_len = my_real_read(net,&complen)) == packet_error)
+      {
+        MYSQL_NET_READ_DONE(1, 0);
 	return packet_error;
+      }
       if (my_uncompress(net->buff + net->where_b, packet_len,
 			&complen))
       {
@@ -1100,6 +1133,7 @@ my_net_read(NET *net)
 #ifdef MYSQL_SERVER
 	my_error(ER_NET_UNCOMPRESS_ERROR, MYF(0));
 #endif
+        MYSQL_NET_READ_DONE(1, 0);
 	return packet_error;
       }
       buf_length+= complen;
@@ -1114,6 +1148,7 @@ my_net_read(NET *net)
     net->read_pos[len]=0;		/* Safeguard for mysql_use_result */
   }
 #endif /* HAVE_COMPRESS */
+  MYSQL_NET_READ_DONE(0, len);
   return len;
 }
 

=== modified file 'sql/probes.d'
--- a/sql/probes.d	2007-09-21 07:09:31 +0000
+++ b/sql/probes.d	2008-09-12 12:14:22 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004-2005 MySQL AB
+/* Copyright (C) 2008 MySQL AB
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -13,18 +13,137 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA */
 
+/*
+  The actual probe names in DTrace scripts will replace '__' by '-'. Thus
+  insert__row__start will be insert-row-start.
+
+  Recommendations for adding new probes:
+
+  - each probe should have the minimal set of arguments required to
+  unambiguously identify the context in which the probe fires. Redundant
+  probes (i.e. the ones that can be obtained in user scripts from previous
+  probes' arguments or otherwise) may be added for convenience.
+
+  - try to avoid computationally expensive probe arguments. If impossible,
+  use *_ENABLED() macros to check if the probe is activated before
+  performing expensive calculations for a probe argument.
+
+  - all *-done probes should have a status argument wherever applicable to make
+  it possible for user scripts to figure out whether the completed operation
+  was successful or not.
+  
+  - for all status arguments, a non-zero value should be returned on error or
+  failure, 0 should be returned on success.
+*/
+
 provider mysql {
-probe external_lock(int);
-probe insert_row_start();
-probe insert_row_end();
-probe filesort_start();
-probe filesort_end();
-probe delete_start();
-probe delete_end();
-probe insert_start();
-probe insert_end();
-probe select_start();
-probe select_end();
-probe update_start();
-probe update_end();
+  
+  /* The following ones fire when creating or closing a client connection */
+  probe connection__start(unsigned long conn_id, char *user, char *host);
+  probe connection__done(int status, unsigned long conn_id);
+
+  /*
+    Fire at the start/end of any client command processing (including SQL
+    queries).
+  */
+  probe command__start(unsigned long conn_id, int command);
+  probe command__done(int status);
+  
+  /*
+    The following probes fire at the start/end of any SQL query processing,
+    respectively.
+
+    query_start() has a lot of parameters that can be used to pick up
+    parameters for a lot of other probes here.  For simplicity reasons we also
+    add the query string to most other DTrace probes as well. Hostname is
+    either the hostname or the IP address of the MySQL Client.
+  */
+  probe query__start(char *query,
+                     unsigned long conn_id,
+                     char *db_name);
+  probe query__done(int status); 
+
+  /* Fire at the start/end of SQL query parsing */
+  probe query__parse__start(char *query);
+  probe query__parse__done(int status);
+
+  /* Track whether the query hits the query cache or not */
+  probe query__cache__hit(char *query, unsigned long rows);
+  probe query__cache__miss(char *query);
+
+  /*
+    This probe fires when the actual query execution starts, i.e. after
+    parsing and checking the query cache, but before privilege checks,
+    optimizing, etc.
+
+    Query means also all independent queries of a stored procedure and prepared
+    statements. Also the stored procedure itself is a query.
+
+    exec_type is:
+    0:           Executed query from sql_parse, top-level query (sql_parse.cc)
+    1:           Executed prepared statement (sql_prepare.cc)
+    2:           Executed cursor statement (sql_cursor.cc)
+    3:           Executed query in stored procedure (sp_head.cc)
+  */
+  probe query__exec__start(char *query,
+                           unsigned long connid,
+                           char *db_name,
+                           int exec_type);
+  probe query__exec__done(int status);
+
+  /* These probes fire when performing write operations towards any handler */
+  probe insert__row__start(char *db, char *table);
+  probe insert__row__done(int status, char *db, char *table);
+  probe update__row__start(char *db, char *table);
+  probe update__row__done(int status, char *db, char *table);
+  probe delete__row__start(char *db, char *table);
+  probe delete__row__done(int status, char *db, char *table);
+
+  /*
+    These probes fire when calling external_lock for any handler
+    depending on the lock type being acquired or released.
+  */
+  probe handler__rdlock__start(char *db, char *table);
+  probe handler__wrlock__start(char *db, char *table);
+  probe handler__unlock__start(char *db, char *table);
+  probe handler__rdlock__done(int status, char *db, char * table);
+  probe handler__wrlock__done(int status, char *db, char * table);
+  probe handler__unlock__done(int status, char *db, char * table);
+  
+  /*
+    These probes fire when a filesort activity happens in a query.
+  */
+  probe filesort__start(char *db, char *table);
+  probe filesort__done(int status, unsigned long rows);
+  /*
+    The query types SELECT, INSERT, INSERT AS SELECT, UPDATE, UPDATE with
+    multiple tables, DELETE, DELETE with multiple tables are all probed.
+    The start probe always contains the query text.
+  */
+  probe select__start(char *query);
+  probe select__done(int status, unsigned long rows);
+  probe insert__start(char *query);
+  probe insert__done(int status, unsigned long rows);
+  probe insert__select__start(char *query);
+  probe insert__select__done(int status, unsigned long rows);
+  probe update__start(char *query);
+  probe update__done(int status,
+                     unsigned long rowsmatches, unsigned long rowschanged);
+  probe multi__update__start(char *query);
+  probe multi__update__done(int status,
+                            unsigned long rowsmatches, unsigned long rowschanged);
+  probe delete__start(char *query);
+  probe delete__done(int status, unsigned long rows);
+  probe multi__delete__start(char *query);
+  probe multi__delete__done(int status, unsigned long rows);
+
+  /*
+    These probes can be used to measure the time waiting for network traffic
+    or identify network-related problems.
+  */
+  probe net__read__start();
+  probe net__read__done(int status, unsigned long bytes);
+  probe net__write__start(unsigned long bytes);
+  probe net__write__done(int status);
+
 };

=== modified file 'sql/probes.h'
--- a/sql/probes.h	2007-09-21 07:09:31 +0000
+++ b/sql/probes.h	2008-09-12 12:14:22 +0000
@@ -13,114 +13,362 @@ extern "C" {
 
 #if _DTRACE_VERSION
 
-#define	MYSQL_DELETE_END() \
-	__dtrace_mysql___delete_end()
-#define	MYSQL_DELETE_END_ENABLED() \
-	__dtraceenabled_mysql___delete_end()
-#define	MYSQL_DELETE_START() \
-	__dtrace_mysql___delete_start()
+#define	MYSQL_COMMAND_DONE(arg0) \
+	__dtrace_mysql___command__done(arg0)
+#define	MYSQL_COMMAND_DONE_ENABLED() \
+	__dtraceenabled_mysql___command__done()
+#define	MYSQL_COMMAND_START(arg0, arg1) \
+	__dtrace_mysql___command__start(arg0, arg1)
+#define	MYSQL_COMMAND_START_ENABLED() \
+	__dtraceenabled_mysql___command__start()
+#define	MYSQL_CONNECTION_DONE(arg0, arg1) \
+	__dtrace_mysql___connection__done(arg0, arg1)
+#define	MYSQL_CONNECTION_DONE_ENABLED() \
+	__dtraceenabled_mysql___connection__done()
+#define	MYSQL_CONNECTION_START(arg0, arg1, arg2) \
+	__dtrace_mysql___connection__start(arg0, arg1, arg2)
+#define	MYSQL_CONNECTION_START_ENABLED() \
+	__dtraceenabled_mysql___connection__start()
+#define	MYSQL_DELETE_DONE(arg0, arg1) \
+	__dtrace_mysql___delete__done(arg0, arg1)
+#define	MYSQL_DELETE_DONE_ENABLED() \
+	__dtraceenabled_mysql___delete__done()
+#define	MYSQL_DELETE_ROW_DONE(arg0, arg1, arg2) \
+	__dtrace_mysql___delete__row__done(arg0, arg1, arg2)
+#define	MYSQL_DELETE_ROW_DONE_ENABLED() \
+	__dtraceenabled_mysql___delete__row__done()
+#define	MYSQL_DELETE_ROW_START(arg0, arg1) \
+	__dtrace_mysql___delete__row__start(arg0, arg1)
+#define	MYSQL_DELETE_ROW_START_ENABLED() \
+	__dtraceenabled_mysql___delete__row__start()
+#define	MYSQL_DELETE_START(arg0) \
+	__dtrace_mysql___delete__start(arg0)
 #define	MYSQL_DELETE_START_ENABLED() \
-	__dtraceenabled_mysql___delete_start()
-#define	MYSQL_EXTERNAL_LOCK(arg0) \
-	__dtrace_mysql___external_lock(arg0)
-#define	MYSQL_EXTERNAL_LOCK_ENABLED() \
-	__dtraceenabled_mysql___external_lock()
-#define	MYSQL_FILESORT_END() \
-	__dtrace_mysql___filesort_end()
-#define	MYSQL_FILESORT_END_ENABLED() \
-	__dtraceenabled_mysql___filesort_end()
-#define	MYSQL_FILESORT_START() \
-	__dtrace_mysql___filesort_start()
+	__dtraceenabled_mysql___delete__start()
+#define	MYSQL_FILESORT_DONE(arg0, arg1) \
+	__dtrace_mysql___filesort__done(arg0, arg1)
+#define	MYSQL_FILESORT_DONE_ENABLED() \
+	__dtraceenabled_mysql___filesort__done()
+#define	MYSQL_FILESORT_START(arg0, arg1) \
+	__dtrace_mysql___filesort__start(arg0, arg1)
 #define	MYSQL_FILESORT_START_ENABLED() \
-	__dtraceenabled_mysql___filesort_start()
-#define	MYSQL_INSERT_END() \
-	__dtrace_mysql___insert_end()
-#define	MYSQL_INSERT_END_ENABLED() \
-	__dtraceenabled_mysql___insert_end()
-#define	MYSQL_INSERT_ROW_END() \
-	__dtrace_mysql___insert_row_end()
-#define	MYSQL_INSERT_ROW_END_ENABLED() \
-	__dtraceenabled_mysql___insert_row_end()
-#define	MYSQL_INSERT_ROW_START() \
-	__dtrace_mysql___insert_row_start()
+	__dtraceenabled_mysql___filesort__start()
+#define	MYSQL_HANDLER_RDLOCK_DONE(arg0, arg1, arg2) \
+	__dtrace_mysql___handler__rdlock__done(arg0, arg1, arg2)
+#define	MYSQL_HANDLER_RDLOCK_DONE_ENABLED() \
+	__dtraceenabled_mysql___handler__rdlock__done()
+#define	MYSQL_HANDLER_RDLOCK_START(arg0, arg1) \
+	__dtrace_mysql___handler__rdlock__start(arg0, arg1)
+#define	MYSQL_HANDLER_RDLOCK_START_ENABLED() \
+	__dtraceenabled_mysql___handler__rdlock__start()
+#define	MYSQL_HANDLER_UNLOCK_DONE(arg0, arg1, arg2) \
+	__dtrace_mysql___handler__unlock__done(arg0, arg1, arg2)
+#define	MYSQL_HANDLER_UNLOCK_DONE_ENABLED() \
+	__dtraceenabled_mysql___handler__unlock__done()
+#define	MYSQL_HANDLER_UNLOCK_START(arg0, arg1) \
+	__dtrace_mysql___handler__unlock__start(arg0, arg1)
+#define	MYSQL_HANDLER_UNLOCK_START_ENABLED() \
+	__dtraceenabled_mysql___handler__unlock__start()
+#define	MYSQL_HANDLER_WRLOCK_DONE(arg0, arg1, arg2) \
+	__dtrace_mysql___handler__wrlock__done(arg0, arg1, arg2)
+#define	MYSQL_HANDLER_WRLOCK_DONE_ENABLED() \
+	__dtraceenabled_mysql___handler__wrlock__done()
+#define	MYSQL_HANDLER_WRLOCK_START(arg0, arg1) \
+	__dtrace_mysql___handler__wrlock__start(arg0, arg1)
+#define	MYSQL_HANDLER_WRLOCK_START_ENABLED() \
+	__dtraceenabled_mysql___handler__wrlock__start()
+#define	MYSQL_INSERT_DONE(arg0, arg1) \
+	__dtrace_mysql___insert__done(arg0, arg1)
+#define	MYSQL_INSERT_DONE_ENABLED() \
+	__dtraceenabled_mysql___insert__done()
+#define	MYSQL_INSERT_ROW_DONE(arg0, arg1, arg2) \
+	__dtrace_mysql___insert__row__done(arg0, arg1, arg2)
+#define	MYSQL_INSERT_ROW_DONE_ENABLED() \
+	__dtraceenabled_mysql___insert__row__done()
+#define	MYSQL_INSERT_ROW_START(arg0, arg1) \
+	__dtrace_mysql___insert__row__start(arg0, arg1)
 #define	MYSQL_INSERT_ROW_START_ENABLED() \
-	__dtraceenabled_mysql___insert_row_start()
-#define	MYSQL_INSERT_START() \
-	__dtrace_mysql___insert_start()
+	__dtraceenabled_mysql___insert__row__start()
+#define	MYSQL_INSERT_SELECT_DONE(arg0, arg1) \
+	__dtrace_mysql___insert__select__done(arg0, arg1)
+#define	MYSQL_INSERT_SELECT_DONE_ENABLED() \
+	__dtraceenabled_mysql___insert__select__done()
+#define	MYSQL_INSERT_SELECT_START(arg0) \
+	__dtrace_mysql___insert__select__start(arg0)
+#define	MYSQL_INSERT_SELECT_START_ENABLED() \
+	__dtraceenabled_mysql___insert__select__start()
+#define	MYSQL_INSERT_START(arg0) \
+	__dtrace_mysql___insert__start(arg0)
 #define	MYSQL_INSERT_START_ENABLED() \
-	__dtraceenabled_mysql___insert_start()
-#define	MYSQL_SELECT_END() \
-	__dtrace_mysql___select_end()
-#define	MYSQL_SELECT_END_ENABLED() \
-	__dtraceenabled_mysql___select_end()
-#define	MYSQL_SELECT_START() \
-	__dtrace_mysql___select_start()
+	__dtraceenabled_mysql___insert__start()
+#define	MYSQL_MULTI_DELETE_DONE(arg0, arg1) \
+	__dtrace_mysql___multi__delete__done(arg0, arg1)
+#define	MYSQL_MULTI_DELETE_DONE_ENABLED() \
+	__dtraceenabled_mysql___multi__delete__done()
+#define	MYSQL_MULTI_DELETE_START(arg0) \
+	__dtrace_mysql___multi__delete__start(arg0)
+#define	MYSQL_MULTI_DELETE_START_ENABLED() \
+	__dtraceenabled_mysql___multi__delete__start()
+#define	MYSQL_MULTI_UPDATE_DONE(arg0, arg1, arg2) \
+	__dtrace_mysql___multi__update__done(arg0, arg1, arg2)
+#define	MYSQL_MULTI_UPDATE_DONE_ENABLED() \
+	__dtraceenabled_mysql___multi__update__done()
+#define	MYSQL_MULTI_UPDATE_START(arg0) \
+	__dtrace_mysql___multi__update__start(arg0)
+#define	MYSQL_MULTI_UPDATE_START_ENABLED() \
+	__dtraceenabled_mysql___multi__update__start()
+#define	MYSQL_NET_READ_DONE(arg0, arg1) \
+	__dtrace_mysql___net__read__done(arg0, arg1)
+#define	MYSQL_NET_READ_DONE_ENABLED() \
+	__dtraceenabled_mysql___net__read__done()
+#define	MYSQL_NET_READ_START() \
+	__dtrace_mysql___net__read__start()
+#define	MYSQL_NET_READ_START_ENABLED() \
+	__dtraceenabled_mysql___net__read__start()
+#define	MYSQL_NET_WRITE_DONE(arg0) \
+	__dtrace_mysql___net__write__done(arg0)
+#define	MYSQL_NET_WRITE_DONE_ENABLED() \
+	__dtraceenabled_mysql___net__write__done()
+#define	MYSQL_NET_WRITE_START(arg0) \
+	__dtrace_mysql___net__write__start(arg0)
+#define	MYSQL_NET_WRITE_START_ENABLED() \
+	__dtraceenabled_mysql___net__write__start()
+#define	MYSQL_QUERY_CACHE_HIT(arg0, arg1) \
+	__dtrace_mysql___query__cache__hit(arg0, arg1)
+#define	MYSQL_QUERY_CACHE_HIT_ENABLED() \
+	__dtraceenabled_mysql___query__cache__hit()
+#define	MYSQL_QUERY_CACHE_MISS(arg0) \
+	__dtrace_mysql___query__cache__miss(arg0)
+#define	MYSQL_QUERY_CACHE_MISS_ENABLED() \
+	__dtraceenabled_mysql___query__cache__miss()
+#define	MYSQL_QUERY_DONE(arg0) \
+	__dtrace_mysql___query__done(arg0)
+#define	MYSQL_QUERY_DONE_ENABLED() \
+	__dtraceenabled_mysql___query__done()
+#define	MYSQL_QUERY_EXEC_DONE(arg0) \
+	__dtrace_mysql___query__exec__done(arg0)
+#define	MYSQL_QUERY_EXEC_DONE_ENABLED() \
+	__dtraceenabled_mysql___query__exec__done()
+#define	MYSQL_QUERY_EXEC_START(arg0, arg1, arg2, arg3) \
+	__dtrace_mysql___query__exec__start(arg0, arg1, arg2, arg3)
+#define	MYSQL_QUERY_EXEC_START_ENABLED() \
+	__dtraceenabled_mysql___query__exec__start()
+#define	MYSQL_QUERY_PARSE_DONE(arg0) \
+	__dtrace_mysql___query__parse__done(arg0)
+#define	MYSQL_QUERY_PARSE_DONE_ENABLED() \
+	__dtraceenabled_mysql___query__parse__done()
+#define	MYSQL_QUERY_PARSE_START(arg0) \
+	__dtrace_mysql___query__parse__start(arg0)
+#define	MYSQL_QUERY_PARSE_START_ENABLED() \
+	__dtraceenabled_mysql___query__parse__start()
+#define	MYSQL_QUERY_START(arg0, arg1, arg2) \
+	__dtrace_mysql___query__start(arg0, arg1, arg2)
+#define	MYSQL_QUERY_START_ENABLED() \
+	__dtraceenabled_mysql___query__start()
+#define	MYSQL_SELECT_DONE(arg0, arg1) \
+	__dtrace_mysql___select__done(arg0, arg1)
+#define	MYSQL_SELECT_DONE_ENABLED() \
+	__dtraceenabled_mysql___select__done()
+#define	MYSQL_SELECT_START(arg0) \
+	__dtrace_mysql___select__start(arg0)
 #define	MYSQL_SELECT_START_ENABLED() \
-	__dtraceenabled_mysql___select_start()
-#define	MYSQL_UPDATE_END() \
-	__dtrace_mysql___update_end()
-#define	MYSQL_UPDATE_END_ENABLED() \
-	__dtraceenabled_mysql___update_end()
-#define	MYSQL_UPDATE_START() \
-	__dtrace_mysql___update_start()
+	__dtraceenabled_mysql___select__start()
+#define	MYSQL_UPDATE_DONE(arg0, arg1, arg2) \
+	__dtrace_mysql___update__done(arg0, arg1, arg2)
+#define	MYSQL_UPDATE_DONE_ENABLED() \
+	__dtraceenabled_mysql___update__done()
+#define	MYSQL_UPDATE_ROW_DONE(arg0, arg1, arg2) \
+	__dtrace_mysql___update__row__done(arg0, arg1, arg2)
+#define	MYSQL_UPDATE_ROW_DONE_ENABLED() \
+	__dtraceenabled_mysql___update__row__done()
+#define	MYSQL_UPDATE_ROW_START(arg0, arg1) \
+	__dtrace_mysql___update__row__start(arg0, arg1)
+#define	MYSQL_UPDATE_ROW_START_ENABLED() \
+	__dtraceenabled_mysql___update__row__start()
+#define	MYSQL_UPDATE_START(arg0) \
+	__dtrace_mysql___update__start(arg0)
 #define	MYSQL_UPDATE_START_ENABLED() \
-	__dtraceenabled_mysql___update_start()
+	__dtraceenabled_mysql___update__start()
 
 
-extern void __dtrace_mysql___delete_end(void);
-extern int __dtraceenabled_mysql___delete_end(void);
-extern void __dtrace_mysql___delete_start(void);
-extern int __dtraceenabled_mysql___delete_start(void);
-extern void __dtrace_mysql___external_lock(int);
-extern int __dtraceenabled_mysql___external_lock(void);
-extern void __dtrace_mysql___filesort_end(void);
-extern int __dtraceenabled_mysql___filesort_end(void);
-extern void __dtrace_mysql___filesort_start(void);
-extern int __dtraceenabled_mysql___filesort_start(void);
-extern void __dtrace_mysql___insert_end(void);
-extern int __dtraceenabled_mysql___insert_end(void);
-extern void __dtrace_mysql___insert_row_end(void);
-extern int __dtraceenabled_mysql___insert_row_end(void);
-extern void __dtrace_mysql___insert_row_start(void);
-extern int __dtraceenabled_mysql___insert_row_start(void);
-extern void __dtrace_mysql___insert_start(void);
-extern int __dtraceenabled_mysql___insert_start(void);
-extern void __dtrace_mysql___select_end(void);
-extern int __dtraceenabled_mysql___select_end(void);
-extern void __dtrace_mysql___select_start(void);
-extern int __dtraceenabled_mysql___select_start(void);
-extern void __dtrace_mysql___update_end(void);
-extern int __dtraceenabled_mysql___update_end(void);
-extern void __dtrace_mysql___update_start(void);
-extern int __dtraceenabled_mysql___update_start(void);
+extern void __dtrace_mysql___command__done(int);
+extern int __dtraceenabled_mysql___command__done(void);
+extern void __dtrace_mysql___command__start(ulong, int);
+extern int __dtraceenabled_mysql___command__start(void);
+extern void __dtrace_mysql___connection__done(int, ulong);
+extern int __dtraceenabled_mysql___connection__done(void);
+extern void __dtrace_mysql___connection__start(ulong, char *, char *);
+extern int __dtraceenabled_mysql___connection__start(void);
+extern void __dtrace_mysql___delete__done(int, ulong);
+extern int __dtraceenabled_mysql___delete__done(void);
+extern void __dtrace_mysql___delete__row__done(int, char *, char *);
+extern int __dtraceenabled_mysql___delete__row__done(void);
+extern void __dtrace_mysql___delete__row__start(char *, char *);
+extern int __dtraceenabled_mysql___delete__row__start(void);
+extern void __dtrace_mysql___delete__start(char *);
+extern int __dtraceenabled_mysql___delete__start(void);
+extern void __dtrace_mysql___filesort__done(int, ulong);
+extern int __dtraceenabled_mysql___filesort__done(void);
+extern void __dtrace_mysql___filesort__start(char *, char *);
+extern int __dtraceenabled_mysql___filesort__start(void);
+extern void __dtrace_mysql___handler__rdlock__done(int, char *, char *);
+extern int __dtraceenabled_mysql___handler__rdlock__done(void);
+extern void __dtrace_mysql___handler__rdlock__start(char *, char *);
+extern int __dtraceenabled_mysql___handler__rdlock__start(void);
+extern void __dtrace_mysql___handler__unlock__done(int, char *, char *);
+extern int __dtraceenabled_mysql___handler__unlock__done(void);
+extern void __dtrace_mysql___handler__unlock__start(char *, char *);
+extern int __dtraceenabled_mysql___handler__unlock__start(void);
+extern void __dtrace_mysql___handler__wrlock__done(int, char *, char *);
+extern int __dtraceenabled_mysql___handler__wrlock__done(void);
+extern void __dtrace_mysql___handler__wrlock__start(char *, char *);
+extern int __dtraceenabled_mysql___handler__wrlock__start(void);
+extern void __dtrace_mysql___insert__done(int, ulong);
+extern int __dtraceenabled_mysql___insert__done(void);
+extern void __dtrace_mysql___insert__row__done(int, char *, char *);
+extern int __dtraceenabled_mysql___insert__row__done(void);
+extern void __dtrace_mysql___insert__row__start(char *, char *);
+extern int __dtraceenabled_mysql___insert__row__start(void);
+extern void __dtrace_mysql___insert__select__done(int, ulong);
+extern int __dtraceenabled_mysql___insert__select__done(void);
+extern void __dtrace_mysql___insert__select__start(char *);
+extern int __dtraceenabled_mysql___insert__select__start(void);
+extern void __dtrace_mysql___insert__start(char *);
+extern int __dtraceenabled_mysql___insert__start(void);
+extern void __dtrace_mysql___multi__delete__done(int, ulong);
+extern int __dtraceenabled_mysql___multi__delete__done(void);
+extern void __dtrace_mysql___multi__delete__start(char *);
+extern int __dtraceenabled_mysql___multi__delete__start(void);
+extern void __dtrace_mysql___multi__update__done(int, ulong, ulong);
+extern int __dtraceenabled_mysql___multi__update__done(void);
+extern void __dtrace_mysql___multi__update__start(char *);
+extern int __dtraceenabled_mysql___multi__update__start(void);
+extern void __dtrace_mysql___net__read__done(int, ulong);
+extern int __dtraceenabled_mysql___net__read__done(void);
+extern void __dtrace_mysql___net__read__start(void);
+extern int __dtraceenabled_mysql___net__read__start(void);
+extern void __dtrace_mysql___net__write__done(int);
+extern int __dtraceenabled_mysql___net__write__done(void);
+extern void __dtrace_mysql___net__write__start(ulong);
+extern int __dtraceenabled_mysql___net__write__start(void);
+extern void __dtrace_mysql___query__cache__hit(char *, ulong);
+extern int __dtraceenabled_mysql___query__cache__hit(void);
+extern void __dtrace_mysql___query__cache__miss(char *);
+extern int __dtraceenabled_mysql___query__cache__miss(void);
+extern void __dtrace_mysql___query__done(int);
+extern int __dtraceenabled_mysql___query__done(void);
+extern void __dtrace_mysql___query__exec__done(int);
+extern int __dtraceenabled_mysql___query__exec__done(void);
+extern void __dtrace_mysql___query__exec__start(char *, ulong, char *, int);
+extern int __dtraceenabled_mysql___query__exec__start(void);
+extern void __dtrace_mysql___query__parse__done(int);
+extern int __dtraceenabled_mysql___query__parse__done(void);
+extern void __dtrace_mysql___query__parse__start(char *);
+extern int __dtraceenabled_mysql___query__parse__start(void);
+extern void __dtrace_mysql___query__start(char *, ulong, char *);
+extern int __dtraceenabled_mysql___query__start(void);
+extern void __dtrace_mysql___select__done(int, ulong);
+extern int __dtraceenabled_mysql___select__done(void);
+extern void __dtrace_mysql___select__start(char *);
+extern int __dtraceenabled_mysql___select__start(void);
+extern void __dtrace_mysql___update__done(int, ulong, ulong);
+extern int __dtraceenabled_mysql___update__done(void);
+extern void __dtrace_mysql___update__row__done(int, char *, char *);
+extern int __dtraceenabled_mysql___update__row__done(void);
+extern void __dtrace_mysql___update__row__start(char *, char *);
+extern int __dtraceenabled_mysql___update__row__start(void);
+extern void __dtrace_mysql___update__start(char *);
+extern int __dtraceenabled_mysql___update__start(void);
 
 #else
 
-#define	MYSQL_DELETE_END()
-#define	MYSQL_DELETE_END_ENABLED() (0)
-#define	MYSQL_DELETE_START()
+#define	MYSQL_COMMAND_DONE(arg0)
+#define	MYSQL_COMMAND_DONE_ENABLED() (0)
+#define	MYSQL_COMMAND_START(arg0, arg1)
+#define	MYSQL_COMMAND_START_ENABLED() (0)
+#define	MYSQL_CONNECTION_DONE(arg0, arg1)
+#define	MYSQL_CONNECTION_DONE_ENABLED() (0)
+#define	MYSQL_CONNECTION_START(arg0, arg1, arg2)
+#define	MYSQL_CONNECTION_START_ENABLED() (0)
+#define	MYSQL_DELETE_DONE(arg0, arg1)
+#define	MYSQL_DELETE_DONE_ENABLED() (0)
+#define	MYSQL_DELETE_ROW_DONE(arg0, arg1, arg2)
+#define	MYSQL_DELETE_ROW_DONE_ENABLED() (0)
+#define	MYSQL_DELETE_ROW_START(arg0, arg1)
+#define	MYSQL_DELETE_ROW_START_ENABLED() (0)
+#define	MYSQL_DELETE_START(arg0)
 #define	MYSQL_DELETE_START_ENABLED() (0)
-#define	MYSQL_EXTERNAL_LOCK(arg0)
-#define	MYSQL_EXTERNAL_LOCK_ENABLED() (0)
-#define	MYSQL_FILESORT_END()
-#define	MYSQL_FILESORT_END_ENABLED() (0)
-#define	MYSQL_FILESORT_START()
+#define	MYSQL_FILESORT_DONE(arg0, arg1)
+#define	MYSQL_FILESORT_DONE_ENABLED() (0)
+#define	MYSQL_FILESORT_START(arg0, arg1)
 #define	MYSQL_FILESORT_START_ENABLED() (0)
-#define	MYSQL_INSERT_END()
-#define	MYSQL_INSERT_END_ENABLED() (0)
-#define	MYSQL_INSERT_ROW_END()
-#define	MYSQL_INSERT_ROW_END_ENABLED() (0)
-#define	MYSQL_INSERT_ROW_START()
+#define	MYSQL_HANDLER_RDLOCK_DONE(arg0, arg1, arg2)
+#define	MYSQL_HANDLER_RDLOCK_DONE_ENABLED() (0)
+#define	MYSQL_HANDLER_RDLOCK_START(arg0, arg1)
+#define	MYSQL_HANDLER_RDLOCK_START_ENABLED() (0)
+#define	MYSQL_HANDLER_UNLOCK_DONE(arg0, arg1, arg2)
+#define	MYSQL_HANDLER_UNLOCK_DONE_ENABLED() (0)
+#define	MYSQL_HANDLER_UNLOCK_START(arg0, arg1)
+#define	MYSQL_HANDLER_UNLOCK_START_ENABLED() (0)
+#define	MYSQL_HANDLER_WRLOCK_DONE(arg0, arg1, arg2)
+#define	MYSQL_HANDLER_WRLOCK_DONE_ENABLED() (0)
+#define	MYSQL_HANDLER_WRLOCK_START(arg0, arg1)
+#define	MYSQL_HANDLER_WRLOCK_START_ENABLED() (0)
+#define	MYSQL_INSERT_DONE(arg0, arg1)
+#define	MYSQL_INSERT_DONE_ENABLED() (0)
+#define	MYSQL_INSERT_ROW_DONE(arg0, arg1, arg2)
+#define	MYSQL_INSERT_ROW_DONE_ENABLED() (0)
+#define	MYSQL_INSERT_ROW_START(arg0, arg1)
 #define	MYSQL_INSERT_ROW_START_ENABLED() (0)
-#define	MYSQL_INSERT_START()
+#define	MYSQL_INSERT_SELECT_DONE(arg0, arg1)
+#define	MYSQL_INSERT_SELECT_DONE_ENABLED() (0)
+#define	MYSQL_INSERT_SELECT_START(arg0)
+#define	MYSQL_INSERT_SELECT_START_ENABLED() (0)
+#define	MYSQL_INSERT_START(arg0)
 #define	MYSQL_INSERT_START_ENABLED() (0)
-#define	MYSQL_SELECT_END()
-#define	MYSQL_SELECT_END_ENABLED() (0)
-#define	MYSQL_SELECT_START()
+#define	MYSQL_MULTI_DELETE_DONE(arg0, arg1)
+#define	MYSQL_MULTI_DELETE_DONE_ENABLED() (0)
+#define	MYSQL_MULTI_DELETE_START(arg0)
+#define	MYSQL_MULTI_DELETE_START_ENABLED() (0)
+#define	MYSQL_MULTI_UPDATE_DONE(arg0, arg1, arg2)
+#define	MYSQL_MULTI_UPDATE_DONE_ENABLED() (0)
+#define	MYSQL_MULTI_UPDATE_START(arg0)
+#define	MYSQL_MULTI_UPDATE_START_ENABLED() (0)
+#define	MYSQL_NET_READ_DONE(arg0, arg1)
+#define	MYSQL_NET_READ_DONE_ENABLED() (0)
+#define	MYSQL_NET_READ_START()
+#define	MYSQL_NET_READ_START_ENABLED() (0)
+#define	MYSQL_NET_WRITE_DONE(arg0)
+#define	MYSQL_NET_WRITE_DONE_ENABLED() (0)
+#define	MYSQL_NET_WRITE_START(arg0)
+#define	MYSQL_NET_WRITE_START_ENABLED() (0)
+#define	MYSQL_QUERY_CACHE_HIT(arg0, arg1)
+#define	MYSQL_QUERY_CACHE_HIT_ENABLED() (0)
+#define	MYSQL_QUERY_CACHE_MISS(arg0)
+#define	MYSQL_QUERY_CACHE_MISS_ENABLED() (0)
+#define	MYSQL_QUERY_DONE(arg0)
+#define	MYSQL_QUERY_DONE_ENABLED() (0)
+#define	MYSQL_QUERY_EXEC_DONE(arg0)
+#define	MYSQL_QUERY_EXEC_DONE_ENABLED() (0)
+#define	MYSQL_QUERY_EXEC_START(arg0, arg1, arg2, arg3)
+#define	MYSQL_QUERY_EXEC_START_ENABLED() (0)
+#define	MYSQL_QUERY_PARSE_DONE(arg0)
+#define	MYSQL_QUERY_PARSE_DONE_ENABLED() (0)
+#define	MYSQL_QUERY_PARSE_START(arg0)
+#define	MYSQL_QUERY_PARSE_START_ENABLED() (0)
+#define	MYSQL_QUERY_START(arg0, arg1, arg2)
+#define	MYSQL_QUERY_START_ENABLED() (0)
+#define	MYSQL_SELECT_DONE(arg0, arg1)
+#define	MYSQL_SELECT_DONE_ENABLED() (0)
+#define	MYSQL_SELECT_START(arg0)
 #define	MYSQL_SELECT_START_ENABLED() (0)
-#define	MYSQL_UPDATE_END()
-#define	MYSQL_UPDATE_END_ENABLED() (0)
-#define	MYSQL_UPDATE_START()
+#define	MYSQL_UPDATE_DONE(arg0, arg1, arg2)
+#define	MYSQL_UPDATE_DONE_ENABLED() (0)
+#define	MYSQL_UPDATE_ROW_DONE(arg0, arg1, arg2)
+#define	MYSQL_UPDATE_ROW_DONE_ENABLED() (0)
+#define	MYSQL_UPDATE_ROW_START(arg0, arg1)
+#define	MYSQL_UPDATE_ROW_START_ENABLED() (0)
+#define	MYSQL_UPDATE_START(arg0)
 #define	MYSQL_UPDATE_START_ENABLED() (0)
 
 #endif

=== modified file 'sql/scheduler.cc'
--- a/sql/scheduler.cc	2008-06-27 19:07:13 +0000
+++ b/sql/scheduler.cc	2008-09-12 12:14:22 +0000
@@ -601,6 +601,8 @@ pthread_handler_t libevent_thread_proc(v
       else
       {
         /* login successful */
+        MYSQL_CONNECTION_START(thd->thread_id, thd->security_ctx->priv_user,
+                               (char *) thd->security_ctx->host_or_ip);
         thd->scheduler.logged_in= TRUE;
         prepare_new_connection_state(thd);
         if (!libevent_needs_immediate_processing(thd))

=== modified file 'sql/sp_head.cc'
--- a/sql/sp_head.cc	2008-07-15 16:29:51 +0000
+++ b/sql/sp_head.cc	2008-09-12 12:14:22 +0000
@@ -2882,7 +2882,12 @@ sp_instr_stmt::print(String *str)
 int
 sp_instr_stmt::exec_core(THD *thd, uint *nextp)
 {
+  MYSQL_QUERY_EXEC_START(thd->query,
+                         thd->thread_id,
+                         (char *) (thd->db ? thd->db: ""),
+                         3);
   int res= mysql_execute_command(thd);
+  MYSQL_QUERY_EXEC_DONE(res);
   *nextp= m_ip+1;
   return res;
 }

=== modified file 'sql/sql_cache.cc'
--- a/sql/sql_cache.cc	2008-07-18 13:30:53 +0000
+++ b/sql/sql_cache.cc	2008-09-12 12:14:22 +0000
@@ -1482,12 +1482,14 @@ def_week_frmt: %lu",                    
   thd->status_var.last_query_cost= 0.0;
   thd->main_da.disable_status();
 
+  MYSQL_QUERY_CACHE_HIT(thd->query, (ulong) thd->limit_found_rows);
   BLOCK_UNLOCK_RD(query_block);
   DBUG_RETURN(1);				// Result sent to client
 
 err_unlock:
   STRUCT_UNLOCK(&structure_guard_mutex);
 err:
+  MYSQL_QUERY_CACHE_MISS(thd->query);
   DBUG_RETURN(0);				// Query was not cached
 }
 

=== modified file 'sql/sql_connect.cc'
--- a/sql/sql_connect.cc	2008-06-27 09:26:03 +0000
+++ b/sql/sql_connect.cc	2008-09-12 12:14:22 +0000
@@ -1144,6 +1144,9 @@ pthread_handler_t handle_one_connection(
     if (login_connection(thd))
       goto end_thread;
 
+    MYSQL_CONNECTION_START(thd->thread_id, thd->security_ctx->priv_user,
+                           (char *) thd->security_ctx->host_or_ip);
+  
     prepare_new_connection_state(thd);
 
     while (!net->error && net->vio != 0 &&

=== modified file 'sql/sql_cursor.cc'
--- a/sql/sql_cursor.cc	2008-06-06 19:19:04 +0000
+++ b/sql/sql_cursor.cc	2008-09-12 12:14:22 +0000
@@ -166,8 +166,12 @@ int mysql_open_cursor(THD *thd, uint fla
     thd->lock_id= sensitive_cursor->get_lock_id();
     thd->cursor= sensitive_cursor;
   }
-
+  MYSQL_QUERY_EXEC_START(thd->query,
+                         thd->thread_id,
+                         (char *) (thd->db ? thd->db : ""),
+                         2);
   rc= mysql_execute_command(thd);
+  MYSQL_QUERY_EXEC_DONE(rc);
 
   lex->result= save_result;
   thd->lock_id= &thd->main_lock_id;

=== modified file 'sql/sql_delete.cc'
--- a/sql/sql_delete.cc	2008-07-18 13:30:53 +0000
+++ b/sql/sql_delete.cc	2008-09-12 12:14:22 +0000
@@ -37,7 +37,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *
                   bool reset_auto_increment)
 {
   bool          will_batch;
-  int		error, loc_error;
+  int		error, loc_error, res;
   TABLE		*table;
   SQL_SELECT	*select=0;
   READ_RECORD	info;
@@ -52,11 +52,15 @@ bool mysql_delete(THD *thd, TABLE_LIST *
   DBUG_ENTER("mysql_delete");
 
   if (open_and_lock_tables(thd, table_list))
+  {
+    MYSQL_DELETE_DONE(1, 0);
     DBUG_RETURN(TRUE);
+  }
   if (!(table= table_list->table))
   {
     my_error(ER_VIEW_DELETE_MERGE_VIEW, MYF(0),
 	     table_list->view_db.str, table_list->view_name.str);
+    MYSQL_DELETE_DONE(1, 0);
     DBUG_RETURN(TRUE);
   }
   thd_proc_info(thd, "init");
@@ -160,7 +164,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *
   {
     free_underlaid_joins(thd, select_lex);
     thd->row_count_func= 0;
-    MYSQL_DELETE_END();
+    MYSQL_DELETE_DONE(0, 0);
     my_ok(thd, (ha_rows) thd->row_count_func);  // No matching records
     DBUG_RETURN(0);
   }
@@ -178,7 +182,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *
     delete select;
     free_underlaid_joins(thd, select_lex);
     thd->row_count_func= 0;
-    MYSQL_DELETE_END();
+    MYSQL_DELETE_DONE(0, 0);
     my_ok(thd, (ha_rows) thd->row_count_func);
     /*
       We don't need to call reset_auto_increment in this case, because
@@ -401,17 +405,18 @@ cleanup:
 
   DEBUG_SYNC(thd, "at_delete_end");
 
-  MYSQL_DELETE_END();
   if (error < 0 || (thd->lex->ignore && !thd->is_fatal_error))
   {
     thd->row_count_func= deleted;
     my_ok(thd, (ha_rows) thd->row_count_func);
     DBUG_PRINT("info",("%ld records deleted",(long) deleted));
   }
-  DBUG_RETURN(error >= 0 || thd->is_error());
+  res= error >= 0 || thd->is_error();
+  MYSQL_DELETE_DONE(res, (ulong) deleted);
+  DBUG_RETURN(res);
 
 err:
-  MYSQL_DELETE_END();
+  MYSQL_DELETE_DONE(1, 0);
   DBUG_RETURN(TRUE);
 }
 
@@ -745,6 +750,7 @@ bool multi_delete::send_data(List<Item> 
       }
     }
   }
+  MYSQL_MULTI_DELETE_DONE(0, (ulong) deleted);
   DBUG_RETURN(0);
 }
 

=== modified file 'sql/sql_insert.cc'
--- a/sql/sql_insert.cc	2008-07-21 03:55:09 +0000
+++ b/sql/sql_insert.cc	2008-09-12 12:14:22 +0000
@@ -604,18 +604,25 @@ bool mysql_insert(THD *thd,TABLE_LIST *t
   {
     my_error(ER_DELAYED_INSERT_TABLE_LOCKED, MYF(0),
              table_list->table_name);
+    MYSQL_INSERT_DONE(1, 0);
     DBUG_RETURN(TRUE);
   }
 
   if (table_list->lock_type == TL_WRITE_DELAYED)
   {
     if (open_and_lock_for_insert_delayed(thd, table_list))
+    {
+      MYSQL_INSERT_DONE(1, 0);
       DBUG_RETURN(TRUE);
+    }
   }
   else
   {
     if (open_and_lock_tables(thd, table_list))
+    {
+      MYSQL_INSERT_DONE(1, 0);
       DBUG_RETURN(TRUE);
+    }
   }
   lock_type= table_list->lock_type;
 
@@ -986,7 +993,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *t
     ::my_ok(thd, (ulong) thd->row_count_func, id, buff);
   }
   thd->abort_on_warning= 0;
-  MYSQL_INSERT_END();
+  MYSQL_INSERT_DONE(0, (ulong) thd->row_count_func);
   DBUG_RETURN(FALSE);
 
 abort:
@@ -999,7 +1006,7 @@ abort:
   if (!joins_freed)
     free_underlaid_joins(thd, &thd->lex->select_lex);
   thd->abort_on_warning= 0;
-  MYSQL_INSERT_END();
+  MYSQL_INSERT_DONE(1, 0);
   DBUG_RETURN(TRUE);
 }
 
@@ -3221,6 +3228,7 @@ bool select_insert::send_eof()
   if (error)
   {
     table->file->print_error(error,MYF(0));
+    MYSQL_INSERT_SELECT_DONE(error, 0);
     DBUG_RETURN(1);
   }
   char buff[160];
@@ -3240,6 +3248,7 @@ bool select_insert::send_eof()
      thd->first_successful_insert_id_in_prev_stmt :
      (info.copied ? autoinc_value_of_last_inserted_row : 0));
   ::my_ok(thd, (ulong) thd->row_count_func, id, buff);
+  MYSQL_INSERT_SELECT_DONE(0, (ulong) thd->row_count_func);
   DBUG_RETURN(0);
 }
 
@@ -3293,6 +3302,10 @@ void select_insert::abort() {
     table->file->ha_release_auto_increment();
   }
 
+  if (MYSQL_INSERT_SELECT_DONE_ENABLED())
+    MYSQL_INSERT_SELECT_DONE(0, (ulong) (info.copied + info.deleted +
+                                         info.updated));
+
   DBUG_VOID_RETURN;
 }
 

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2008-07-24 08:26:24 +0000
+++ b/sql/sql_parse.cc	2008-09-12 12:14:22 +0000
@@ -828,7 +828,8 @@ bool dispatch_command(enum enum_server_c
 #if defined(ENABLED_PROFILING)
   thd->profiling.start_new_query();
 #endif
-
+  MYSQL_COMMAND_START(thd->thread_id, command);
+  
   thd->command=command;
   /*
     Commands which always take a long time are logged into
@@ -1034,6 +1035,8 @@ bool dispatch_command(enum enum_server_c
   {
     if (alloc_query(thd, packet, packet_length))
       break;					// fatal error is set
+    MYSQL_QUERY_START(thd->query, thd->thread_id,
+                      (char *) (thd->db ? thd->db : ""));
     char *packet_end= thd->query + thd->query_length;
     /* 'b' stands for 'buffer' parameter', special for 'my_snprintf' */
     const char* end_of_stmt= NULL;
@@ -1074,12 +1077,18 @@ bool dispatch_command(enum enum_server_c
         length--;
       }
 
+      if (MYSQL_QUERY_DONE_ENABLED())
+        MYSQL_QUERY_DONE(thd->is_error());
+      
 #if defined(ENABLED_PROFILING)
       thd->profiling.finish_current_query();
       thd->profiling.start_new_query("continuing");
       thd->profiling.set_query_source(beginning_of_next_stmt, length);
 #endif
 
+      MYSQL_QUERY_START(thd->query, thd->thread_id,
+                        (char *) (thd->db ? thd->db : ""));
+      
       pthread_mutex_lock(&LOCK_thread_count);
       thd->query_length= length;
       thd->query= beginning_of_next_stmt;
@@ -1462,7 +1471,14 @@ bool dispatch_command(enum enum_server_c
 #if defined(ENABLED_PROFILING)
   thd->profiling.finish_current_query();
 #endif
-
+  if (MYSQL_QUERY_DONE_ENABLED() || MYSQL_COMMAND_DONE_ENABLED())
+  {
+    int res= (int) thd->is_error();
+    if (command == COM_QUERY)
+      MYSQL_QUERY_DONE(res);
+    MYSQL_COMMAND_DONE(res);
+  }
+  
   DBUG_RETURN(error);
 }
 
@@ -2836,6 +2852,7 @@ end_with_restore_list:
       break;
     DBUG_ASSERT(select_lex->offset_limit == 0);
     unit->set_limit(select_lex);
+    MYSQL_UPDATE_START(thd->query);
     res= (up_result= mysql_update(thd, all_tables,
                                   select_lex->item_list,
                                   lex->value_list,
@@ -2895,7 +2912,7 @@ end_with_restore_list:
 #ifdef HAVE_REPLICATION
     }  /* unlikely */
 #endif
-
+    MYSQL_MULTI_UPDATE_START(thd->query);
     res= mysql_multi_update(thd, all_tables,
                             &select_lex->item_list,
                             &lex->value_list,
@@ -2948,6 +2965,7 @@ end_with_restore_list:
       break;
     }
 
+    MYSQL_INSERT_START(thd->query);
     res= mysql_insert(thd, all_tables, lex->field_list, lex->many_values,
 		      lex->update_list, lex->value_list,
                       lex->duplicates, lex->ignore);
@@ -2991,6 +3009,8 @@ end_with_restore_list:
 
     if (!(res= open_and_lock_tables(thd, all_tables)))
     {
+      MYSQL_INSERT_SELECT_START(thd->query);
+      
       /* Skip first table, which is the table we are inserting in */
       TABLE_LIST *second_table= first_table->next_local;
       select_lex->table_list.first= (uchar*) second_table;
@@ -3079,6 +3099,7 @@ end_with_restore_list:
       break;
     }
 
+    MYSQL_DELETE_START(thd->query);
     res = mysql_delete(thd, all_tables, select_lex->where,
                        &select_lex->order_list,
                        unit->select_limit_cnt, select_lex->options,
@@ -3109,6 +3130,7 @@ end_with_restore_list:
       goto error;
 
     thd_proc_info(thd, "init");
+    MYSQL_MULTI_DELETE_START(thd->query);
     if ((res= open_and_lock_tables(thd, all_tables)))
       break;
 
@@ -5744,6 +5766,7 @@ void mysql_init_multi_delete(LEX *lex)
 void mysql_parse(THD *thd, const char *inBuf, uint length,
                  const char ** found_semicolon)
 {
+  int error;
   DBUG_ENTER("mysql_parse");
 
   DBUG_EXECUTE_IF("parser_debug", turn_parser_debug_on(););
@@ -5812,7 +5835,13 @@ void mysql_parse(THD *thd, const char *i
             thd->server_status|= SERVER_MORE_RESULTS_EXISTS;
           }
           lex->set_trg_event_type_for_tables();
-          mysql_execute_command(thd);
+	  MYSQL_QUERY_EXEC_START(thd->query,
+                                 thd->thread_id,
+                                 (char *) (thd->db ? thd->db : ""),
+                                 0);
+
+          error= mysql_execute_command(thd);
+	  MYSQL_QUERY_EXEC_DONE(error);
 	}
       }
     }
@@ -7688,6 +7717,8 @@ bool parse_sql(THD *thd,
   bool mysql_parse_status;
   DBUG_ASSERT(thd->m_parser_state == NULL);
 
+  MYSQL_QUERY_PARSE_START(thd->query);
+  
   /* Backup creation context. */
 
   Object_creation_ctx *backup_ctx= NULL;
@@ -7719,6 +7750,8 @@ bool parse_sql(THD *thd,
 
   /* That's it. */
 
+  MYSQL_QUERY_PARSE_DONE(mysql_parse_status || thd->is_fatal_error);
+  
   return mysql_parse_status || thd->is_fatal_error;
 }
 

=== modified file 'sql/sql_prepare.cc'
--- a/sql/sql_prepare.cc	2008-07-15 16:29:51 +0000
+++ b/sql/sql_prepare.cc	2008-09-12 12:14:22 +0000
@@ -3568,7 +3568,12 @@ bool Prepared_statement::execute(String 
     if (query_cache_send_result_to_client(thd, thd->query,
                                           thd->query_length) <= 0)
     {
+      MYSQL_QUERY_EXEC_START(thd->query,
+                             thd->thread_id,
+                             (char *) (thd->db ? thd->db : ""),
+                             1);
       error= mysql_execute_command(thd);
+      MYSQL_QUERY_EXEC_DONE(error);
     }
   }
 

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2008-07-17 19:55:18 +0000
+++ b/sql/sql_select.cc	2008-09-12 12:14:22 +0000
@@ -31,6 +31,7 @@
 #include "mysql_priv.h"
 #include "sql_select.h"
 #include "sql_cursor.h"
+
 #include <m_ctype.h>
 #include <my_bit.h>
 #include <hash.h>
@@ -273,7 +274,7 @@ bool handle_select(THD *thd, LEX *lex, s
   bool res;
   register SELECT_LEX *select_lex = &lex->select_lex;
   DBUG_ENTER("handle_select");
-  MYSQL_SELECT_START();
+  MYSQL_SELECT_START(thd->query);
 
   if (select_lex->master_unit()->is_union() || 
       select_lex->master_unit()->fake_select_lex)
@@ -307,7 +308,8 @@ bool handle_select(THD *thd, LEX *lex, s
   if (unlikely(res))
     result->abort();
 
-  MYSQL_SELECT_END();
+  MYSQL_SELECT_DONE((int) res, (ulong) thd->limit_found_rows);
+
   DBUG_RETURN(res);
 }
 

=== modified file 'sql/sql_update.cc'
--- a/sql/sql_update.cc	2008-07-17 19:55:18 +0000
+++ b/sql/sql_update.cc	2008-09-12 12:14:22 +0000
@@ -209,7 +209,10 @@ int mysql_update(THD *thd,
   for ( ; ; )
   {
     if (open_tables(thd, &table_list, &table_count, 0))
+    {
+      MYSQL_UPDATE_DONE(1, 0, 0);
       DBUG_RETURN(1);
+    }
 
     if (table_list->multitable_view)
     {
@@ -218,21 +221,27 @@ int mysql_update(THD *thd,
       /* pass counter value */
       thd->lex->table_count= table_count;
       /* convert to multiupdate */
+      MYSQL_UPDATE_DONE(2, 0, 0);
       DBUG_RETURN(2);
     }
     if (!lock_tables(thd, table_list, table_count, 0, &need_reopen))
       break;
     if (!need_reopen)
+    {
+      MYSQL_UPDATE_DONE(1, 0, 0);
       DBUG_RETURN(1);
+    }
     close_tables_for_reopen(thd, &table_list, FALSE);
   }
 
   if (mysql_handle_derived(thd->lex, &mysql_derived_prepare) ||
       (thd->fill_derived_tables() &&
        mysql_handle_derived(thd->lex, &mysql_derived_filling)))
+  {
+    MYSQL_UPDATE_DONE(1, 0, 0);
     DBUG_RETURN(1);
+  }
 
-  MYSQL_UPDATE_START();
   thd_proc_info(thd, "init");
   table= table_list->table;
 
@@ -292,7 +301,7 @@ int mysql_update(THD *thd,
   if (select_lex->inner_refs_list.elements &&
     fix_inner_refs(thd, all_fields, select_lex, select_lex->ref_pointer_array))
   {
-    MYSQL_UPDATE_END();
+    MYSQL_UPDATE_DONE(1, 0, 0);
     DBUG_RETURN(-1);
   }
 
@@ -321,8 +330,8 @@ int mysql_update(THD *thd,
   if (prune_partitions(thd, table, conds))
   {
     free_underlaid_joins(thd, select_lex);
-    MYSQL_UPDATE_END();
     my_ok(thd);				// No matching records
+    MYSQL_UPDATE_DONE(0, 0, 0);
     DBUG_RETURN(0);
   }
 #endif
@@ -337,8 +346,8 @@ int mysql_update(THD *thd,
     free_underlaid_joins(thd, select_lex);
     if (error)
       goto abort;				// Error in where
-    MYSQL_UPDATE_END();
     my_ok(thd);				// No matching records
+    MYSQL_UPDATE_DONE(0, 0, 0);
     DBUG_RETURN(0);
   }
   if (!select && limit != HA_POS_ERROR)
@@ -811,7 +820,6 @@ int mysql_update(THD *thd,
   id= thd->arg_of_last_insert_id_function ?
     thd->first_successful_insert_id_in_prev_stmt : 0;
 
-  MYSQL_UPDATE_END();
   if (error < 0)
   {
     char buff[STRING_BUFFER_USUAL_SIZE];
@@ -824,7 +832,10 @@ int mysql_update(THD *thd,
   }
   thd->count_cuted_fields= CHECK_FIELD_IGNORE;		/* calc cuted fields */
   thd->abort_on_warning= 0;
-  DBUG_RETURN((error >= 0 || thd->is_error()) ? 1 : 0);
+
+  res= (error >= 0 || thd->is_error()) ? 1 : 0;
+  MYSQL_UPDATE_DONE(res, (ulong) found, (ulong) updated);
+  DBUG_RETURN(res);
 
 err:
   delete select;
@@ -837,7 +848,7 @@ err:
   thd->abort_on_warning= 0;
 
 abort:
-  MYSQL_UPDATE_END();
+  MYSQL_UPDATE_DONE(1, 0, 0);
   DBUG_RETURN(1);
 }
 
@@ -1591,7 +1602,10 @@ bool multi_update::send_data(List<Item> 
                                                *values_for_table[offset], 0,
                                                table->triggers,
                                                TRG_EVENT_UPDATE))
+      {
+        MYSQL_MULTI_UPDATE_DONE(1, 0, 0);
 	DBUG_RETURN(1);
+      }
 
       found++;
       if (!can_compare_record || compare_record(table))
@@ -1604,7 +1618,10 @@ bool multi_update::send_data(List<Item> 
           if (error == VIEW_CHECK_SKIP)
             continue;
           else if (error == VIEW_CHECK_ERROR)
+          {
+            MYSQL_MULTI_UPDATE_DONE(1, 0, 0);
             DBUG_RETURN(1);
+          }
         }
         if (!updated++)
         {
@@ -1634,6 +1651,7 @@ bool multi_update::send_data(List<Item> 
 
             prepare_record_for_error_message(error, table);
             table->file->print_error(error,MYF(flags));
+            MYSQL_MULTI_UPDATE_DONE(1, 0, 0);
             DBUG_RETURN(1);
           }
         }
@@ -1658,7 +1676,10 @@ bool multi_update::send_data(List<Item> 
       if (table->triggers &&
           table->triggers->process_triggers(thd, TRG_EVENT_UPDATE,
                                             TRG_ACTION_AFTER, TRUE))
+      {
+        MYSQL_MULTI_UPDATE_DONE(1, 0, 0);
         DBUG_RETURN(1);
+      }
     }
     else
     {
@@ -1701,12 +1722,14 @@ bool multi_update::send_data(List<Item> 
                                          error, 1))
         {
           do_update=0;
+          MYSQL_MULTI_UPDATE_DONE(1, 0, 0);
 	  DBUG_RETURN(1);			// Not a table_is_full error
 	}
         found++;
       }
     }
   }
+  MYSQL_UPDATE_DONE(0, (ulong) found, (ulong) updated);
   DBUG_RETURN(0);
 }
 

Thread
bzr commit into mysql-6.0 branch (alexeyk:2738) WL#4541Alexey Kopytov12 Sep