MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Alexey Kopytov Date:December 4 2008 10:06am
Subject:bzr commit into mysql-6.0 branch (alexeyk:2742) Bug#40468
View as plain text  
#At file:///Users/kaa/src/bzr/mysql-6.0-dtrace/

 2742 Alexey Kopytov	2008-12-04
      Bug #40468: Storage engines code cannot be instrumented with DTrace probes
       
      This patch changes the way we build DTrace-enabled binary to allow inserting probes
      into code outside of sql/, namely mysys and storage engines. A few additional probes
      were added to test the idea.
      
      As a side effect of this build system overhaul, DTrace-enabled binary can now be
      built on Mac OS X.
      
      This patch also enables DTrace support by default on those platforms that have it.
removed:
  storage/falcon/falcon_probes.d
  storage/falcon/falcon_probes.h
added:
  include/probes_mysql_nodtrace.h
  scripts/dheadgen.pl
  storage/falcon/probes_falcon.d
  storage/falcon/probes_falcon.h
  storage/falcon/probes_falcon_nodtrace.h
renamed:
  sql/probes.d => sql/probes_mysql.d
  sql/probes.h => include/probes_mysql.h
modified:
  config/ac-macros/dtrace.m4
  include/Makefile.am
  libmysql/Makefile.shared
  libmysqld/Makefile.am
  mysys/Makefile.am
  mysys/mf_keycache.c
  scripts/Makefile.am
  sql/Makefile.am
  sql/backup/Makefile.am
  sql/backup/kernel.cc
  sql/filesort.cc
  sql/ha_ndbcluster.cc
  sql/ha_partition.cc
  sql/handler.cc
  sql/mysql_priv.h
  sql/mysqld.cc
  sql/net_serv.cc
  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
  storage/archive/Makefile.am
  storage/archive/ha_archive.cc
  storage/blackhole/Makefile.am
  storage/blackhole/ha_blackhole.cc
  storage/csv/Makefile.am
  storage/csv/ha_tina.cc
  storage/example/Makefile.am
  storage/example/ha_example.cc
  storage/falcon/Makefile.am
  storage/falcon/ha_falcon.cpp
  storage/falcon/ha_falcon.h
  storage/federated/Makefile.am
  storage/federated/ha_federated.cc
  storage/federated/ha_federated.h
  storage/heap/Makefile.am
  storage/heap/ha_heap.cc
  storage/maria/Makefile.am
  storage/maria/ha_maria.cc
  storage/myisam/Makefile.am
  storage/myisam/ha_myisam.cc
  storage/myisammrg/Makefile.am
  storage/myisammrg/ha_myisammrg.cc
  sql/probes_mysql.d
  include/probes_mysql.h

=== modified file 'config/ac-macros/dtrace.m4'
--- a/config/ac-macros/dtrace.m4	2007-09-12 04:16:59 +0000
+++ b/config/ac-macros/dtrace.m4	2008-12-04 10:05:56 +0000
@@ -2,19 +2,37 @@ dnl ------------------------------------
 dnl Macro: DTRACE_TEST
 dnl ---------------------------------------------------------------------------
 AC_ARG_ENABLE(dtrace,
-    [  --enable-dtrace      Build with support for the DTRACE.],
-    [ 
-      AC_DEFINE([HAVE_DTRACE], [1], [Enables DTRACE Support])
-      AC_CHECK_PROGS(DTRACE, dtrace)
-      ENABLE_DTRACE="yes" 
-      AC_SUBST(DTRACEFLAGS)
-      AC_SUBST(HAVE_DTRACE)
+    AC_HELP_STRING([--enable-dtrace],[Build with support for DTrace.]),
+    [
+      ENABLE_DTRACE="$enable_dtrace"
     ],
     [
-      ENABLE_DTRACE="no" 
+      ENABLE_DTRACE="yes" 
     ]
-    )
+)
+DTRACEFLAGS=""
+HAVE_DTRACE=""
+HAVE_DTRACE_DASH_G=""
+if test "$ENABLE_DTRACE" = "yes"; then
+  AC_CHECK_PROGS(DTRACE, dtrace, [not found])
+  if test "$DTRACE" = "not found"; then
+    ENABLE_DTRACE="no"
+  else
+    AC_DEFINE([HAVE_DTRACE], [1], [Defined to 1 if DTrace support is enabled])
+    case "$target_os" in
+      *solaris*)
+        HAVE_DTRACE_DASH_G="yes"
+        ;;
+      *)
+        HAVE_DTRACE_DASH_G="no"
+        ;;
+    esac
+  fi
+fi
+AC_SUBST(DTRACEFLAGS)
+AC_SUBST(HAVE_DTRACE)
 AM_CONDITIONAL([HAVE_DTRACE], [ test "$ENABLE_DTRACE" = "yes" ])
+AM_CONDITIONAL([HAVE_DTRACE_DASH_G], [ test "$HAVE_DTRACE_DASH_G" = "yes" ])
 dnl ---------------------------------------------------------------------------
 dnl End Macro: DTRACE_TEST
 dnl ---------------------------------------------------------------------------

=== modified file 'include/Makefile.am'
--- a/include/Makefile.am	2008-09-12 08:58:52 +0000
+++ b/include/Makefile.am	2008-12-04 10:05:56 +0000
@@ -38,9 +38,10 @@ noinst_HEADERS =	config-win.h config-net
 			my_vle.h my_user.h my_atomic.h atomic/nolock.h \
 			atomic/rwlock.h atomic/x86-gcc.h atomic/generic-msvc.h \
 			atomic/gcc_builtins.h my_libwrap.h my_stacktrace.h \
-			wqueue.h
+			wqueue.h probes_mysql.h probes_mysql_nodtrace.h
 
-EXTRA_DIST =        mysql.h.pp mysql/plugin.h.pp
+EXTRA_DIST =        mysql.h.pp mysql/plugin.h.pp dtrace.make dtrace_headers.make \
+                    dtrace_objects.make
 
 # Remove built files and the symlinked directories
 CLEANFILES =            $(BUILT_SOURCES) readline openssl
@@ -66,5 +67,17 @@ my_config.h: config.h
 dist-hook:
 	$(RM) -f $(distdir)/mysql_version.h $(distdir)/my_config.h
 
+if HAVE_DTRACE
+BUILT_SOURCES += probes_mysql_dtrace.h
+CLEANFILES += probes_mysql_dtrace.h
+DTRACEPROVIDER = $(top_srcdir)/sql/probes_mysql.d
+
+probes_mysql_dtrace.h: $(DTRACEPROVIDER)
+	$(DTRACE) $(DTRACEFLAGS) -h -s $< -o $@
+endif
+
+probes_mysql_nodtrace.h: $(DTRACEPROVIDER)
+	$(top_srcdir)/scripts/dheadgen.pl -f $^ > $@
+
 # Don't update the files from bitkeeper
 %::SCCS/s.%

=== renamed file 'sql/probes.h' => 'include/probes_mysql.h'
--- a/sql/probes.h	2008-10-10 16:23:30 +0000
+++ b/include/probes_mysql.h	2008-12-04 10:05:56 +0000
@@ -1,381 +1,13 @@
-/*
- * Generated by dtrace(1M).
- */
+#ifndef PROBES_MYSQL_H
 
-#ifndef	_PROBES_H
-#define	_PROBES_H
+#define PROBES_MYSQL_H
 
+#include <my_global.h>
 
-
-#ifdef	__cplusplus
-extern "C" {
-#endif
-
-#if _DTRACE_VERSION && defined(HAVE_DTRACE)
-
-#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, arg2, arg3) \
-	__dtrace_mysql___command__start(arg0, arg1, arg2, arg3)
-#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) \
-	__dtrace_mysql___delete__row__done(arg0)
-#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_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_HANDLER_RDLOCK_DONE(arg0) \
-	__dtrace_mysql___handler__rdlock__done(arg0)
-#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) \
-	__dtrace_mysql___handler__unlock__done(arg0)
-#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) \
-	__dtrace_mysql___handler__wrlock__done(arg0)
-#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) \
-	__dtrace_mysql___insert__row__done(arg0)
-#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_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_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, arg4, arg5) \
-	__dtrace_mysql___query__exec__start(arg0, arg1, arg2, arg3, arg4, arg5)
-#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, arg3, arg4) \
-	__dtrace_mysql___query__start(arg0, arg1, arg2, arg3, arg4)
-#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_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) \
-	__dtrace_mysql___update__row__done(arg0)
-#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()
-
-
-extern void __dtrace_mysql___command__done(int);
-extern int __dtraceenabled_mysql___command__done(void);
-extern void __dtrace_mysql___command__start(unsigned long, int, char *, char *);
-extern int __dtraceenabled_mysql___command__start(void);
-extern void __dtrace_mysql___connection__done(int, unsigned long);
-extern int __dtraceenabled_mysql___connection__done(void);
-extern void __dtrace_mysql___connection__start(unsigned long, char *, char *);
-extern int __dtraceenabled_mysql___connection__start(void);
-extern void __dtrace_mysql___delete__done(int, unsigned long);
-extern int __dtraceenabled_mysql___delete__done(void);
-extern void __dtrace_mysql___delete__row__done(int);
-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, unsigned long);
-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);
-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);
-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);
-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, unsigned long);
-extern int __dtraceenabled_mysql___insert__done(void);
-extern void __dtrace_mysql___insert__row__done(int);
-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, unsigned long);
-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, unsigned long);
-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, unsigned long, unsigned long);
-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, unsigned long);
-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(unsigned long);
-extern int __dtraceenabled_mysql___net__write__start(void);
-extern void __dtrace_mysql___query__cache__hit(char *, unsigned long);
-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 *, unsigned long, char *, char *, 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 *, unsigned long, char *, char *, char *);
-extern int __dtraceenabled_mysql___query__start(void);
-extern void __dtrace_mysql___select__done(int, unsigned long);
-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, unsigned long, unsigned long);
-extern int __dtraceenabled_mysql___update__done(void);
-extern void __dtrace_mysql___update__row__done(int);
-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);
-
+#if defined(HAVE_DTRACE) && !defined(DISABLE_DTRACE)
+#include "probes_mysql_dtrace.h"
 #else
-
-#define	MYSQL_COMMAND_DONE(arg0)
-#define	MYSQL_COMMAND_DONE_ENABLED() (0)
-#define	MYSQL_COMMAND_START(arg0, arg1, arg2, arg3)
-#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)
-#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_FILESORT_DONE(arg0, arg1)
-#define	MYSQL_FILESORT_DONE_ENABLED() (0)
-#define	MYSQL_FILESORT_START(arg0, arg1)
-#define	MYSQL_FILESORT_START_ENABLED() (0)
-#define	MYSQL_HANDLER_RDLOCK_DONE(arg0)
-#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)
-#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)
-#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)
-#define	MYSQL_INSERT_ROW_DONE_ENABLED() (0)
-#define	MYSQL_INSERT_ROW_START(arg0, arg1)
-#define	MYSQL_INSERT_ROW_START_ENABLED() (0)
-#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_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, arg4, arg5)
-#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, arg3, arg4)
-#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_DONE(arg0, arg1, arg2)
-#define	MYSQL_UPDATE_DONE_ENABLED() (0)
-#define	MYSQL_UPDATE_ROW_DONE(arg0)
-#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
-
-
-#ifdef	__cplusplus
-}
+#include "probes_mysql_nodtrace.h"
 #endif
 
-#endif	/* _PROBES_H */
+#endif /* PROBES_MYSQL_H */

=== added file 'include/probes_mysql_nodtrace.h'
--- a/include/probes_mysql_nodtrace.h	1970-01-01 00:00:00 +0000
+++ b/include/probes_mysql_nodtrace.h	2008-12-04 10:05:56 +0000
@@ -0,0 +1,137 @@
+/*
+ * Generated by dheadgen(1).
+ */
+
+#ifndef	_PROBES_MYSQL_D
+#define	_PROBES_MYSQL_D
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+#define	MYSQL_CONNECTION_START(arg0, arg1, arg2)
+#define	MYSQL_CONNECTION_START_ENABLED() (0)
+#define	MYSQL_CONNECTION_DONE(arg0, arg1)
+#define	MYSQL_CONNECTION_DONE_ENABLED() (0)
+#define	MYSQL_COMMAND_START(arg0, arg1, arg2, arg3)
+#define	MYSQL_COMMAND_START_ENABLED() (0)
+#define	MYSQL_COMMAND_DONE(arg0)
+#define	MYSQL_COMMAND_DONE_ENABLED() (0)
+#define	MYSQL_QUERY_START(arg0, arg1, arg2, arg3, arg4)
+#define	MYSQL_QUERY_START_ENABLED() (0)
+#define	MYSQL_QUERY_DONE(arg0)
+#define	MYSQL_QUERY_DONE_ENABLED() (0)
+#define	MYSQL_QUERY_PARSE_START(arg0)
+#define	MYSQL_QUERY_PARSE_START_ENABLED() (0)
+#define	MYSQL_QUERY_PARSE_DONE(arg0)
+#define	MYSQL_QUERY_PARSE_DONE_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_EXEC_START(arg0, arg1, arg2, arg3, arg4, arg5)
+#define	MYSQL_QUERY_EXEC_START_ENABLED() (0)
+#define	MYSQL_QUERY_EXEC_DONE(arg0)
+#define	MYSQL_QUERY_EXEC_DONE_ENABLED() (0)
+#define	MYSQL_INSERT_ROW_START(arg0, arg1)
+#define	MYSQL_INSERT_ROW_START_ENABLED() (0)
+#define	MYSQL_INSERT_ROW_DONE(arg0)
+#define	MYSQL_INSERT_ROW_DONE_ENABLED() (0)
+#define	MYSQL_UPDATE_ROW_START(arg0, arg1)
+#define	MYSQL_UPDATE_ROW_START_ENABLED() (0)
+#define	MYSQL_UPDATE_ROW_DONE(arg0)
+#define	MYSQL_UPDATE_ROW_DONE_ENABLED() (0)
+#define	MYSQL_DELETE_ROW_START(arg0, arg1)
+#define	MYSQL_DELETE_ROW_START_ENABLED() (0)
+#define	MYSQL_DELETE_ROW_DONE(arg0)
+#define	MYSQL_DELETE_ROW_DONE_ENABLED() (0)
+#define	MYSQL_READ_ROW_START(arg0, arg1)
+#define	MYSQL_READ_ROW_START_ENABLED() (0)
+#define	MYSQL_READ_ROW_DONE(arg0)
+#define	MYSQL_READ_ROW_DONE_ENABLED() (0)
+#define	MYSQL_INDEX_READ_ROW_START(arg0, arg1)
+#define	MYSQL_INDEX_READ_ROW_START_ENABLED() (0)
+#define	MYSQL_INDEX_READ_ROW_DONE(arg0)
+#define	MYSQL_INDEX_READ_ROW_DONE_ENABLED() (0)
+#define	MYSQL_HANDLER_RDLOCK_START(arg0, arg1)
+#define	MYSQL_HANDLER_RDLOCK_START_ENABLED() (0)
+#define	MYSQL_HANDLER_WRLOCK_START(arg0, arg1)
+#define	MYSQL_HANDLER_WRLOCK_START_ENABLED() (0)
+#define	MYSQL_HANDLER_UNLOCK_START(arg0, arg1)
+#define	MYSQL_HANDLER_UNLOCK_START_ENABLED() (0)
+#define	MYSQL_HANDLER_RDLOCK_DONE(arg0)
+#define	MYSQL_HANDLER_RDLOCK_DONE_ENABLED() (0)
+#define	MYSQL_HANDLER_WRLOCK_DONE(arg0)
+#define	MYSQL_HANDLER_WRLOCK_DONE_ENABLED() (0)
+#define	MYSQL_HANDLER_UNLOCK_DONE(arg0)
+#define	MYSQL_HANDLER_UNLOCK_DONE_ENABLED() (0)
+#define	MYSQL_FILESORT_START(arg0, arg1)
+#define	MYSQL_FILESORT_START_ENABLED() (0)
+#define	MYSQL_FILESORT_DONE(arg0, arg1)
+#define	MYSQL_FILESORT_DONE_ENABLED() (0)
+#define	MYSQL_SELECT_START(arg0)
+#define	MYSQL_SELECT_START_ENABLED() (0)
+#define	MYSQL_SELECT_DONE(arg0, arg1)
+#define	MYSQL_SELECT_DONE_ENABLED() (0)
+#define	MYSQL_INSERT_START(arg0)
+#define	MYSQL_INSERT_START_ENABLED() (0)
+#define	MYSQL_INSERT_DONE(arg0, arg1)
+#define	MYSQL_INSERT_DONE_ENABLED() (0)
+#define	MYSQL_INSERT_SELECT_START(arg0)
+#define	MYSQL_INSERT_SELECT_START_ENABLED() (0)
+#define	MYSQL_INSERT_SELECT_DONE(arg0, arg1)
+#define	MYSQL_INSERT_SELECT_DONE_ENABLED() (0)
+#define	MYSQL_UPDATE_START(arg0)
+#define	MYSQL_UPDATE_START_ENABLED() (0)
+#define	MYSQL_UPDATE_DONE(arg0, arg1, arg2)
+#define	MYSQL_UPDATE_DONE_ENABLED() (0)
+#define	MYSQL_MULTI_UPDATE_START(arg0)
+#define	MYSQL_MULTI_UPDATE_START_ENABLED() (0)
+#define	MYSQL_MULTI_UPDATE_DONE(arg0, arg1, arg2)
+#define	MYSQL_MULTI_UPDATE_DONE_ENABLED() (0)
+#define	MYSQL_DELETE_START(arg0)
+#define	MYSQL_DELETE_START_ENABLED() (0)
+#define	MYSQL_DELETE_DONE(arg0, arg1)
+#define	MYSQL_DELETE_DONE_ENABLED() (0)
+#define	MYSQL_MULTI_DELETE_START(arg0)
+#define	MYSQL_MULTI_DELETE_START_ENABLED() (0)
+#define	MYSQL_MULTI_DELETE_DONE(arg0, arg1)
+#define	MYSQL_MULTI_DELETE_DONE_ENABLED() (0)
+#define	MYSQL_NET_READ_START()
+#define	MYSQL_NET_READ_START_ENABLED() (0)
+#define	MYSQL_NET_READ_DONE(arg0, arg1)
+#define	MYSQL_NET_READ_DONE_ENABLED() (0)
+#define	MYSQL_NET_WRITE_START(arg0)
+#define	MYSQL_NET_WRITE_START_ENABLED() (0)
+#define	MYSQL_NET_WRITE_DONE(arg0)
+#define	MYSQL_NET_WRITE_DONE_ENABLED() (0)
+#define	MYSQL_KEYCACHE_READ_START(arg0, arg1, arg2, arg3)
+#define	MYSQL_KEYCACHE_READ_START_ENABLED() (0)
+#define	MYSQL_KEYCACHE_READ_BLOCK(arg0)
+#define	MYSQL_KEYCACHE_READ_BLOCK_ENABLED() (0)
+#define	MYSQL_KEYCACHE_READ_HIT()
+#define	MYSQL_KEYCACHE_READ_HIT_ENABLED() (0)
+#define	MYSQL_KEYCACHE_READ_MISS()
+#define	MYSQL_KEYCACHE_READ_MISS_ENABLED() (0)
+#define	MYSQL_KEYCACHE_READ_DONE(arg0, arg1)
+#define	MYSQL_KEYCACHE_READ_DONE_ENABLED() (0)
+#define	MYSQL_KEYCACHE_WRITE_START(arg0, arg1, arg2, arg3)
+#define	MYSQL_KEYCACHE_WRITE_START_ENABLED() (0)
+#define	MYSQL_KEYCACHE_WRITE_BLOCK(arg0)
+#define	MYSQL_KEYCACHE_WRITE_BLOCK_ENABLED() (0)
+#define	MYSQL_KEYCACHE_WRITE_DONE(arg0, arg1)
+#define	MYSQL_KEYCACHE_WRITE_DONE_ENABLED() (0)
+#define	MYSQL_BACKUP_START()
+#define	MYSQL_BACKUP_START_ENABLED() (0)
+#define	MYSQL_BACKUP_DONE(arg0)
+#define	MYSQL_BACKUP_DONE_ENABLED() (0)
+#define	MYSQL_RESTORE_START()
+#define	MYSQL_RESTORE_START_ENABLED() (0)
+#define	MYSQL_RESTORE_DONE(arg0)
+#define	MYSQL_RESTORE_DONE_ENABLED() (0)
+
+#ifdef  __cplusplus
+}
+#endif
+
+#endif  /* _PROBES_MYSQL_D */

=== modified file 'libmysql/Makefile.shared'
--- a/libmysql/Makefile.shared	2008-10-02 12:08:09 +0000
+++ b/libmysql/Makefile.shared	2008-12-04 10:05:56 +0000
@@ -89,7 +89,8 @@ DEFS =			-DDEFAULT_CHARSET_HOME="\"$(MYS
 			-DDEFAULT_HOME_ENV=MYSQL_HOME \
 			-DDEFAULT_GROUP_SUFFIX_ENV=MYSQL_GROUP_SUFFIX \
 			-DDEFAULT_SYSCONFDIR="\"$(sysconfdir)\"" \
-			-DSHAREDIR="\"$(MYSQLSHAREdir)\"" $(target_defs)
+			-DSHAREDIR="\"$(MYSQLSHAREdir)\"" -DDISABLE_DTRACE \
+			$(target_defs)
 
 if HAVE_YASSL
 yassl_las = $(top_builddir)/extra/yassl/src/libyassl.la \
@@ -107,7 +108,7 @@ clean-local:
 	      `echo $(sql_cmn_objects) | sed "s;\.lo;.c;g"` \
 	       $(CHARSET_SRCS) $(CHARSET_OBJS) \
 	       $(mystringsextra) $(mysysheaders) $(vioheaders) \
-               net.c probes.h
+               net.c
 
 conf_to_src_SOURCES = conf_to_src.c
 conf_to_src_LDADD=

=== modified file 'libmysqld/Makefile.am'
--- a/libmysqld/Makefile.am	2008-09-23 14:33:18 +0000
+++ b/libmysqld/Makefile.am	2008-12-04 10:05:56 +0000
@@ -30,7 +30,8 @@ DEFS =			-DEMBEDDED_LIBRARY -DMYSQL_SERV
 			-DSHAREDIR="\"$(MYSQLSHAREdir)\"" \
 			@DEFS@ \
 			-DLIBDIR="\"$(MYSQLLIBdir)\"" \
-			-DPLUGINDIR="\"$(pkgplugindir)\""
+			-DPLUGINDIR="\"$(pkgplugindir)\"" \
+			-DDISABLE_DTRACE
 INCLUDES=		-I$(top_builddir)/include -I$(top_srcdir)/include \
 			-I$(top_builddir)/sql -I$(top_srcdir)/sql \
 			-I$(top_srcdir)/sql/examples \

=== modified file 'mysys/Makefile.am'
--- a/mysys/Makefile.am	2008-07-23 08:52:08 +0000
+++ b/mysys/Makefile.am	2008-12-04 10:05:56 +0000
@@ -130,6 +130,21 @@ test_base64$(EXEEXT): base64.c $(LIBRARI
 	$(LINK) $(FLAGS) -DMAIN  ./test_base64.c $(LDADD) $(LIBS)
 	$(RM) -f ./test_base64.c
 
+if HAVE_DTRACE_DASH_G
+abs_top_srcdir = @abs_top_srcdir@
+libmysys_a_LIBADD += probes_mysql.o
+libmysys_a_DEPENDENCIES += probes_mysql.o dtrace_files dtrace_providers
+CLEANFILES = probes_mysql.o dtrace_files dtrace_providers
+DTRACEFILES = mf_keycache.o
+DTRACEPROVIDER = $(abs_top_srcdir)/sql/probes_mysql.d
+
+dtrace_files:
+	echo $(DTRACEFILES) > $@
+dtrace_providers:
+	echo $(DTRACEPROVIDER) > $@
+probes_mysql.o: $(DTRACEPROVIDER) $(DTRACEFILES)
+	$(DTRACE) $(DTRACEFLAGS) -G -s $< $(DTRACEFILES) -o $@
+endif
 
 # Don't update the files from bitkeeper
 %::SCCS/s.%

=== modified file 'mysys/mf_keycache.c'
--- a/mysys/mf_keycache.c	2008-08-20 10:29:58 +0000
+++ b/mysys/mf_keycache.c	2008-12-04 10:05:56 +0000
@@ -112,6 +112,7 @@
 #include <my_bit.h>
 #include <errno.h>
 #include <stdarg.h>
+#include "probes_mysql.h"
 
 /*
   Some compilation flags have been added specifically for this module
@@ -2570,6 +2571,14 @@ uchar *key_cache_read(KEY_CACHE *keycach
     uint status;
     int page_st;
 
+    if (MYSQL_KEYCACHE_READ_START_ENABLED())
+    {
+      MYSQL_KEYCACHE_READ_START(my_filename(file), length,
+                                (ulong) (keycache->blocks_used *
+                                         keycache->key_cache_block_size),
+                                (ulong) (keycache->blocks_unused *
+                                         keycache->key_cache_block_size));
+    }
     /*
       When the key cache is once initialized, we use the cache_lock to
       reliably distinguish the cases of normal operation, resizing, and
@@ -2619,6 +2628,9 @@ uchar *key_cache_read(KEY_CACHE *keycach
 
       /* Request the cache block that matches file/pos. */
       keycache->global_cache_r_requests++;
+
+      MYSQL_KEYCACHE_READ_BLOCK(keycache->key_cache_block_size);
+  
       block=find_key_block(keycache, file, filepos, level, 0, &page_st);
       if (!block)
       {
@@ -2638,6 +2650,7 @@ uchar *key_cache_read(KEY_CACHE *keycach
       {
         if (page_st != PAGE_READ)
         {
+          MYSQL_KEYCACHE_READ_MISS();
           /* The requested page is to be read into the block buffer */
           read_block(keycache, block,
                      keycache->key_cache_block_size, read_length+offset,
@@ -2662,6 +2675,10 @@ uchar *key_cache_read(KEY_CACHE *keycach
           my_errno= -1;
           block->status|= BLOCK_ERROR;
         }
+        else
+        {
+          MYSQL_KEYCACHE_READ_HIT();
+        }
       }
 
       /* block status may have added BLOCK_ERROR in the above 'if'. */
@@ -2706,7 +2723,16 @@ uchar *key_cache_read(KEY_CACHE *keycach
 #ifndef THREAD
       /* This is only true if we where able to read everything in one block */
       if (return_buffer)
+      {
+        if (MYSQL_KEYCACHE_READ_DONE_ENABLED())
+        {
+          MYSQL_KEYCACHE_READ_DONE((ulong) (keycache->blocks_used *
+                                            keycache->key_cache_block_size),
+                                   (ulong) (keycache->blocks_unused *
+                                            keycache->key_cache_block_size));
+        }
 	DBUG_RETURN(block->buffer);
+      }
 #endif
   next_block:
       buff+= read_length;
@@ -2714,6 +2740,13 @@ uchar *key_cache_read(KEY_CACHE *keycach
       offset= 0;
 
     } while ((length-= read_length));
+    if (MYSQL_KEYCACHE_READ_DONE_ENABLED())
+    {
+      MYSQL_KEYCACHE_READ_DONE((ulong) (keycache->blocks_used *
+                                        keycache->key_cache_block_size),
+                               (ulong) (keycache->blocks_unused *
+                                        keycache->key_cache_block_size));
+    }
     goto end;
   }
 
@@ -3047,6 +3080,15 @@ int key_cache_write(KEY_CACHE *keycache,
     uint offset;
     int page_st;
 
+    if (MYSQL_KEYCACHE_WRITE_START_ENABLED())
+    {
+      MYSQL_KEYCACHE_WRITE_START(my_filename(file), length,
+                                 (ulong) (keycache->blocks_used *
+                                          keycache->key_cache_block_size),
+                                 (ulong) (keycache->blocks_unused *
+                                          keycache->key_cache_block_size));
+    }
+  
     /*
       When the key cache is once initialized, we use the cache_lock to
       reliably distinguish the cases of normal operation, resizing, and
@@ -3082,6 +3124,8 @@ int key_cache_write(KEY_CACHE *keycache,
       /* Cache could be disabled in a later iteration. */
       if (!keycache->can_be_used)
 	goto no_key_cache;
+
+      MYSQL_KEYCACHE_WRITE_BLOCK(keycache->key_cache_block_size);
       /* Start writing at the beginning of the cache block. */
       filepos-= offset;
       /* Do not write beyond the end of the cache block. */
@@ -3289,6 +3333,15 @@ end:
     dec_counter_for_resize_op(keycache);
     keycache_pthread_mutex_unlock(&keycache->cache_lock);
   }
+  
+  if (MYSQL_KEYCACHE_WRITE_DONE_ENABLED())
+  {
+    MYSQL_KEYCACHE_WRITE_DONE((ulong) (keycache->blocks_used *
+                                       keycache->key_cache_block_size),
+                              (ulong) (keycache->blocks_unused *
+                                       keycache->key_cache_block_size));
+  }
+  
 #if !defined(DBUG_OFF) && defined(EXTRA_DEBUG)
   DBUG_EXECUTE("exec",
                test_key_cache(keycache, "end of key_cache_write", 1););

=== modified file 'scripts/Makefile.am'
--- a/scripts/Makefile.am	2008-06-26 17:48:42 +0000
+++ b/scripts/Makefile.am	2008-12-04 10:05:56 +0000
@@ -37,7 +37,8 @@ bin_SCRIPTS =		@server_scripts@ \
 			mysqld_multi
 
 noinst_SCRIPTS =	make_binary_distribution \
-			make_sharedlib_distribution
+			make_sharedlib_distribution \
+			dheadgen.pl
 
 EXTRA_SCRIPTS =		make_binary_distribution.sh \
 			make_sharedlib_distribution.sh \
@@ -59,7 +60,8 @@ EXTRA_SCRIPTS =		make_binary_distributio
 			mysqlhotcopy.sh \
 			mysqldumpslow.sh \
 			mysqld_multi.sh \
-			mysqld_safe.sh
+			mysqld_safe.sh \
+			dheadgen.pl
 
 EXTRA_DIST =		$(EXTRA_SCRIPTS) \
 			mysqlaccess.conf \
@@ -111,7 +113,7 @@ mysqlbug: ${top_builddir}/config.status 
 mysql_fix_privilege_tables.sql: mysql_system_tables.sql \
 				mysql_system_tables_fix.sql
 	@echo "Building $@";
-	@cat mysql_system_tables.sql mysql_system_tables_fix.sql > $@
+	@cat $(srcdir)/mysql_system_tables.sql $(srcdir)/mysql_system_tables_fix.sql > $@
 
 #
 # Build mysql_fix_privilege_tables_sql.c from
@@ -124,7 +126,7 @@ mysql_fix_privilege_tables_sql.c: comp_s
 	sleep 2
 	$(top_builddir)/scripts/comp_sql$(EXEEXT) \
 	  mysql_fix_privilege_tables \
-	    $(top_srcdir)/scripts/mysql_fix_privilege_tables.sql $@
+	    $(top_builddir)/scripts/mysql_fix_privilege_tables.sql $@
 
 
 SUFFIXES = .sh

=== added file 'scripts/dheadgen.pl'
--- a/scripts/dheadgen.pl	1970-01-01 00:00:00 +0000
+++ b/scripts/dheadgen.pl	2008-12-04 10:05:56 +0000
@@ -0,0 +1,338 @@
+#!/usr/bin/perl -w
+
+#
+# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+# 
+#    * Redistributions of source code must retain the above copyright
+#      notice, this list of conditions and the following disclaimer. 
+#    * Redistributions in binary form must reproduce the above copyright
+#      notice, this list of conditions and the following disclaimer in  
+#      the documentation and/or other materials provided with the       
+#      distribution.
+#    * Neither the name of the above-listed copyright holders nor the names
+#      of its contributors may be used to endorse or promote products derived
+#      from this software without specific prior written permission.  
+#       
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED  
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,     
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR      
+# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  
+# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING    
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS      
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# ident	"@(#)dheadgen.pl	1.4	07/06/24 SMI"
+
+#
+# DTrace Header Generator
+# -----------------------
+#
+# This script is meant to mimic the output of dtrace(1M) with the -h
+# (headergen) flag on system that lack native support for DTrace. This script
+# is intended to be integrated into projects that use DTrace's static tracing
+# facilities (USDT), and invoked as part of the build process to have a
+# common build process on all target systems. To facilitate this, this script
+# is licensed under a BSD license. On system with native DTrace support, the
+# dtrace(1M) command will be invoked to create the full header file; on other
+# systems, this script will generated a stub header file.
+#
+# Normally, generated macros take the form PROVIDER_PROBENAME().  It may be
+# desirable to customize the output of this script and of dtrace(1M) to
+# tailor the precise macro name. To do this, edit the emit_dtrace() subroutine
+# to pattern match for the lines you want to customize.
+#
+
+use strict;
+
+my @lines;
+my @tokens = ();
+my $lineno = 0;
+my $newline = 1;
+my $eof = 0;
+my $infile;
+my $outfile;
+my $force = 0;
+
+sub emit_dtrace {
+	my ($line) = @_;
+
+	#
+	# Insert customization here. For example, if you want to change the
+	# name of the macros you may do something like this:
+	#
+	# $line =~ s/(\s)[A-Z]+_/\1TRACE_MOZILLA_/;
+	#
+
+	print $line;
+}
+
+#
+# The remaining code deals with parsing D provider definitions and emitting
+# the stub header file. There should be no need to edit this absent a bug.
+#
+
+#
+# Emit the two relevant macros for each probe in the given provider:
+#    PROVIDER_PROBENAME(<args>)
+#    PROVIDER_PROBENAME_ENABLED() (0)
+#
+sub emit_provider {
+	my ($provname, @probes) = @_;
+
+	$provname = uc($provname);
+
+	foreach my $probe (@probes) {
+		my $probename = uc($$probe{'name'});
+		my $argc = $$probe{'argc'};
+		my $line;
+
+		$probename =~ s/__/_/g;
+
+		$line = "#define\t${provname}_${probename}(";
+		for (my $i = 0; $i < $argc; $i++) {
+			$line .= ($i == 0 ? '' : ', ');
+			$line .= "arg$i";
+		}
+		$line .= ")\n";
+		emit_dtrace($line);
+		
+		$line = "#define\t${provname}_${probename}_ENABLED() (0)\n";
+		emit_dtrace($line);
+	}
+
+	emit_dtrace("\n");
+}
+
+sub emit_prologue {
+	my ($filename) = @_;
+
+	$filename =~ s/.*\///g;
+	$filename = uc($filename);
+	$filename =~ s/\./_/g;
+
+	emit_dtrace <<"EOF";
+/*
+ * Generated by dheadgen(1).
+ */
+
+#ifndef\t_${filename}
+#define\t_${filename}
+
+#ifdef\t__cplusplus
+extern "C" {
+#endif
+
+EOF
+}
+
+sub emit_epilogue {
+	my ($filename) = @_;
+
+	$filename =~ s/.*\///g;
+	$filename = uc($filename);
+	$filename =~ s/\./_/g;
+
+	emit_dtrace <<"EOF";
+#ifdef  __cplusplus
+}
+#endif
+
+#endif  /* _$filename */
+EOF
+}
+
+#
+# Get the next token from the file keeping track of the line number.
+#
+sub get_token {
+	my ($eof_ok) = @_;
+	my $tok;
+
+	while (1) {
+		while (scalar(@tokens) == 0) {
+			if (scalar(@lines) == 0) {
+				$eof = 1;
+				return if ($eof_ok);
+				die "expected more data at line $lineno";
+			}
+
+			$lineno++;
+			push(@tokens, split(/(\s+|\n|[(){},#;]|\/\*|\*\/)/,
+			    shift(@lines)));
+		}
+
+		$tok = shift(@tokens);
+		next if ($tok eq '');
+		next if ($tok =~ /^[ \t]+$/);
+
+		return ($tok);
+	}
+}
+
+#
+# Ignore newlines, comments and typedefs
+#
+sub next_token {
+	my ($eof_ok) = @_;
+	my $tok;
+
+	while (1) {
+		$tok = get_token($eof_ok);
+		return if ($eof_ok && $eof);
+		if ($tok eq "typedef" or $tok =~ /^#/) {
+		  while (1) {
+		    $tok = get_token(0);
+		    last if ($tok eq "\n");
+		  }
+		  next;
+		} elsif ($tok eq '/*') {
+			while (get_token(0) ne '*/') {
+				next;
+			}
+			next;
+		} elsif ($tok eq "\n") {
+			next;
+		}
+
+		last;
+	}
+
+	return ($tok);
+}
+
+sub expect_token {
+	my ($t) = @_;
+	my $tok;
+
+	while (($tok = next_token(0)) eq "\n") {
+		next;
+	}
+
+	die "expected '$t' at line $lineno rather than '$tok'" if ($t ne $tok);
+}
+
+sub get_args {
+	expect_token('(');
+
+	my $tok = next_token(0);
+	my @args = ();
+
+	return (@args) if ($tok eq ')');
+
+	if ($tok eq 'void') {
+		expect_token(')');
+		return (@args);
+	}
+
+	my $arg = $tok;
+
+	while (1) {
+		$tok = next_token(0);
+		if ($tok eq ',' || $tok eq ')') {
+			push(@args, $arg);
+			$arg = '';
+			last if ($tok eq ')');
+		} else {
+			$arg = "$arg $tok";
+		}
+	}
+
+	return (@args);
+}
+
+sub usage {
+	die "usage: $0 [-f] <filename.d>\n";
+}
+
+usage() if (scalar(@ARGV) < 1);
+if ($ARGV[0] eq '-f') {
+	usage() if (scalar(@ARGV < 2));
+	$force = 1;
+	shift;
+}
+$infile = $ARGV[0];
+usage() if ($infile !~ /(.+)\.d$/);
+
+#
+# If the system has native support for DTrace, we'll use that binary instead.
+#
+if (-x '/usr/sbin/dtrace' && !$force) {
+	open(my $dt, '-|', "/usr/sbin/dtrace -C -h -s $infile -o /dev/stdout")
+	    or die "can't invoke dtrace(1M)";
+
+	while (<$dt>) {
+		emit_dtrace($_);
+	}
+
+	close($dt);
+
+	exit(0);
+}
+
+emit_prologue($infile);
+
+open(my $d, '<', $infile) or die "couldn't open $infile";
+@lines = <$d>;
+close($d);
+
+while (1) {
+	my $nl = 0;
+	my $tok = next_token(1);
+	last if $eof;
+
+	if ($newline && $tok eq '#') {
+		while (1) {
+			$tok = get_token(0);
+
+			last if ($tok eq "\n");
+		}
+		$nl = 1;
+	} elsif ($tok eq "\n") {
+		$nl = 1;
+	} elsif ($tok eq 'provider') {
+		my $provname = next_token(0);
+		my @probes = ();
+		expect_token('{');
+
+		while (1) {
+			$tok = next_token(0);
+			if ($tok eq 'probe') {
+				my $probename = next_token(0);
+				my @args = get_args();
+
+				next while (next_token(0) ne ';');
+
+				push(@probes, {
+				    'name' => $probename,
+				    'argc' => scalar(@args)
+				});
+
+			} elsif ($tok eq '}') {
+				expect_token(';');
+
+				emit_provider($provname, @probes);
+
+				last;
+			}
+		}
+
+	} else {
+		die "syntax error at line $lineno near '$tok'\n";
+	}
+
+	$newline = $nl;
+}
+
+emit_epilogue($infile);
+
+exit(0);

=== modified file 'sql/Makefile.am'
--- a/sql/Makefile.am	2008-10-10 16:23:30 +0000
+++ b/sql/Makefile.am	2008-12-04 10:05:56 +0000
@@ -29,9 +29,9 @@ SUBDIRS =		share backup
 libexec_PROGRAMS =	mysqld
 EXTRA_PROGRAMS =	gen_lex_hash
 bin_PROGRAMS =		mysql_tzinfo_to_sql
-DTRACE =                @DTRACE@
-DTRACEFLAGS =           @DTRACEFLAGS@
 DTRACEFILES =           filesort.o \
+			ha_partition.o \
+			ha_ndbcluster.o \
 			handler.o \
 			mysqld.o \
 			net_serv.o \
@@ -96,7 +96,7 @@ noinst_HEADERS =	item.h item_func.h item
 			sql_plugin.h authors.h event_parse_data.h \
 			event_data_objects.h event_scheduler.h \
 			sql_partition.h partition_info.h partition_element.h \
-			probes.h sql_audit.h transaction.h \
+			sql_audit.h transaction.h \
 			contributors.h sql_servers.h ddl_blocker.h \
 			si_objects.h si_logs.h sql_plist.h mdl.h records.h \
 			rpl_handler.h replication.h
@@ -149,10 +149,6 @@ mysqld_SOURCES =	sql_lex.cc sql_handler.
 			event_parse_data.cc mdl.cc transaction.cc \
 			rpl_handler.cc
 
-if HAVE_DTRACE
-  mysqld_SOURCES += probes.d
-endif
-
 nodist_mysqld_SOURCES =	mini_client_errors.c pack.c client.c my_time.c my_user.c 
 
 libndb_la_CPPFLAGS=	@ndbcluster_includes@
@@ -179,7 +175,7 @@ BUILT_MAINT_SRC =	sql_yacc.cc sql_yacc.h
 BUILT_SOURCES =		$(BUILT_MAINT_SRC) lex_hash.h link_sources
 EXTRA_DIST =		udf_example.c udf_example.def $(BUILT_MAINT_SRC) \
 			nt_servc.cc nt_servc.h message.mc CMakeLists.txt \
-			probes.d \
+			probes_mysql.d \
 			udf_example.c udf_example.def
 CLEANFILES =        	lex_hash.h sql_yacc.output link_sources
 DISTCLEANFILES =        $(EXTRA_PROGRAMS)
@@ -212,12 +208,6 @@ lex_hash.h:	gen_lex_hash.cc lex.h
 udf_example_la_SOURCES= udf_example.c
 udf_example_la_LDFLAGS= -module -rpath $(pkglibdir)
 
-probes.h: probes.d
-	$(DTRACE) $(DTRACEFLAGS) -h -s probes.d
-	mv probes.h probes.h.bak
-	sed "s/#include <unistd.h>//g" probes.h.bak > probes.h
-	rm probes.h.bak
-
 # We might have some stuff not built in this build, but that we want to install
 install-exec-hook:
 	$(mkinstalldirs) $(DESTDIR)$(libexecdir) $(DESTDIR)$(pkglibdir)
@@ -225,12 +215,25 @@ install-exec-hook:
 	test ! -f mysqld-debug.sym.gz   || $(INSTALL_DATA)    mysqld-debug.sym.gz   $(DESTDIR)$(pkglibdir)
 	test ! -f mysqld.sym.gz         || $(INSTALL_DATA)    mysqld.sym.gz         $(DESTDIR)$(pkglibdir)
 
-SUFFIXES : .d
-
-.d.o :
-	$(DTRACE) $(DTRACEFLAGS) -G -s $< $(DTRACEFILES)
-
-probes.o : $(DTRACEFILES)
+if HAVE_DTRACE_DASH_G
+abs_top_srcdir = @abs_top_srcdir@
+mysqld_LDADD += probes_all.o
+mysqld_DEPENDENCIES += probes_all.o dtrace_files dtrace_providers
+CLEANFILES += dtrace_files dtrace_providers probes_all.o
+DTRACEPROVIDER = $(abs_top_srcdir)/sql/probes_mysql.d
+
+dtrace_files:
+	echo $(DTRACEFILES) > $@
+dtrace_providers:
+	echo $(DTRACEPROVIDER) > $@
+
+DTRACEDIRS = . ../mysys $(patsubst %,$(top_builddir)/storage/%,@mysql_se_dirs@) backup
+
+probes_all.o: probes_mysql.d $(DTRACEFILES)
+	providers=`(for i in $(DTRACEDIRS); do cat $$i/dtrace_providers 2>/dev/null; done) | tr " " "\n" | sort | uniq | sed -e '/^$$/d' -e 's/^/-s /'`; \
+	objects=`for i in $(DTRACEDIRS); do f=\`cat $$i/dtrace_files 2>/dev/null\`; for j in $$f; do test -f $$i/$$j && echo -n "$$i/$$j "; done; done`; \
+	$(DTRACE) $(DTRACEFLAGS) -G $$providers $$objects -o $@
+endif
 
 # Don't update the files from bitkeeper
 %::SCCS/s.%

=== modified file 'sql/backup/Makefile.am'
--- a/sql/backup/Makefile.am	2008-08-27 17:30:49 +0000
+++ b/sql/backup/Makefile.am	2008-12-04 10:05:56 +0000
@@ -79,6 +79,23 @@ DEFS = \
   @DEFS@
 
 EXTRA_DIST =	CMakeLists.txt 
-	
+
+if HAVE_DTRACE_DASH_G
+abs_top_srcdir = @abs_top_srcdir@
+CLEANFILES = probes_mysql.o dtrace_files dtrace_providers
+DTRACEFILES = .libs/kernel.o
+DTRACEPROVIDER = $(abs_top_srcdir)/sql/probes_mysql.d
+libbackup_la_LIBADD += probes_mysql.o
+# libbackupstream.la has to be added to dependencies explicitely
+libbackup_la_DEPENDENCIES = libbackupstream.la probes_mysql.o dtrace_files dtrace_providers
+
+dtrace_files:
+	echo $(DTRACEFILES) >$@
+dtrace_providers:
+	echo $(DTRACEPROVIDER) >$@
+probes_mysql.o: $(DTRACEPROVIDER) $(DTRACEFILES)
+	$(DTRACE) $(DTRACEFLAGS) -G -s $< $(DTRACEFILES) -o $@
+endif
+
 # Don't update the files from bitkeeper
 %::SCCS/s.%

=== modified file 'sql/backup/kernel.cc'
--- a/sql/backup/kernel.cc	2008-10-09 13:07:54 +0000
+++ b/sql/backup/kernel.cc	2008-12-04 10:05:56 +0000
@@ -84,6 +84,7 @@
 #include "be_nodata.h"
 #include "ddl_blocker.h"
 #include "transaction.h"
+#include "probes_mysql.h"
 
 
 /** 
@@ -203,8 +204,12 @@ execute_backup_command(THD *thd, LEX *le
 
     // perform backup
 
+    MYSQL_BACKUP_START();
+    
     res= context.do_backup();
- 
+
+    MYSQL_BACKUP_DONE(res);
+    
     if (res)
       DBUG_RETURN(send_error(context, ER_BACKUP_BACKUP));
 
@@ -221,7 +226,11 @@ execute_backup_command(THD *thd, LEX *le
     
     DEBUG_SYNC(thd, "after_backup_start_restore");
 
-    res= context.do_restore();      
+    MYSQL_RESTORE_START();
+    
+    res= context.do_restore();
+
+    MYSQL_RESTORE_DONE(res);
 
     DEBUG_SYNC(thd, "restore_before_end");
 

=== modified file 'sql/filesort.cc'
--- a/sql/filesort.cc	2008-10-10 16:23:30 +0000
+++ b/sql/filesort.cc	2008-12-04 10:05:56 +0000
@@ -27,6 +27,7 @@
 #endif
 #include <m_ctype.h>
 #include "sql_sort.h"
+#include "probes_mysql.h"
 
 #ifndef THREAD
 #define SKIP_DBUG_IN_FILESORT

=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc	2008-09-15 09:27:48 +0000
+++ b/sql/ha_ndbcluster.cc	2008-12-04 10:05:56 +0000
@@ -42,6 +42,7 @@
 #include "ha_ndbcluster_connection.h"
 
 #include <mysql/plugin.h>
+#include "probes_mysql.h"
 
 #ifdef ndb_dynamite
 #undef assert
@@ -4042,7 +4043,9 @@ int ha_ndbcluster::index_read(uchar *buf
 {
   key_range start_key;
   bool descending= FALSE;
+  int rc;
   DBUG_ENTER("ha_ndbcluster::index_read");
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   DBUG_PRINT("enter", ("active_index: %u, key_len: %u, find_flag: %d", 
                        active_index, key_len, find_flag));
 
@@ -4060,43 +4063,62 @@ int ha_ndbcluster::index_read(uchar *buf
   default:
     break;
   }
-  DBUG_RETURN(read_range_first_to_buf(&start_key, 0, descending,
-                                      m_sorted, buf));
+  rc= read_range_first_to_buf(&start_key, 0, descending,
+                              m_sorted, buf);
+  MYSQL_INDEX_READ_ROW_DONE(rc);
+  DBUG_RETURN(rc);
 }
 
 
 int ha_ndbcluster::index_next(uchar *buf)
 {
+  int rc;
   DBUG_ENTER("ha_ndbcluster::index_next");
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   ha_statistic_increment(&SSV::ha_read_next_count);
-  DBUG_RETURN(next_result(buf));
+  rc= next_result(buf);
+  MYSQL_INDEX_READ_ROW_DONE(rc);
+  DBUG_RETURN(rc);
 }
 
 
 int ha_ndbcluster::index_prev(uchar *buf)
 {
+  int rc;
   DBUG_ENTER("ha_ndbcluster::index_prev");
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   ha_statistic_increment(&SSV::ha_read_prev_count);
-  DBUG_RETURN(next_result(buf));
+  rc= next_result(buf);
+  MYSQL_INDEX_READ_ROW_DONE(rc);
+  DBUG_RETURN(rc);
 }
 
 
 int ha_ndbcluster::index_first(uchar *buf)
 {
+  int rc;
   DBUG_ENTER("ha_ndbcluster::index_first");
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   ha_statistic_increment(&SSV::ha_read_first_count);
   // Start the ordered index scan and fetch the first row
 
   // Only HA_READ_ORDER indexes get called by index_first
-  DBUG_RETURN(ordered_index_scan(0, 0, TRUE, FALSE, buf, NULL));
+  rc= ordered_index_scan(0, 0, TRUE, FALSE, buf, NULL);
+  MYSQL_INDEX_READ_ROW_DONE(rc);
+  DBUG_RETURN(rc);
 }
 
 
 int ha_ndbcluster::index_last(uchar *buf)
 {
+  int rc;
   DBUG_ENTER("ha_ndbcluster::index_last");
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
+
   ha_statistic_increment(&SSV::ha_read_last_count);
-  DBUG_RETURN(ordered_index_scan(0, 0, TRUE, TRUE, buf, NULL));
+  rc= ordered_index_scan(0, 0, TRUE, TRUE, buf, NULL);
+  MYSQL_INDEX_READ_ROW_DONE(rc);
+  DBUG_RETURN(rc);
 }
 
 int ha_ndbcluster::index_read_last(uchar * buf, const uchar * key, uint key_len)
@@ -4188,15 +4210,23 @@ int ha_ndbcluster::read_range_first(cons
                                     bool eq_r, bool sorted)
 {
   uchar* buf= table->record[0];
+  int rc;
   DBUG_ENTER("ha_ndbcluster::read_range_first");
-  DBUG_RETURN(read_range_first_to_buf(start_key, end_key, FALSE,
-                                      sorted, buf));
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
+  rc= read_range_first_to_buf(start_key, end_key, FALSE,
+                              sorted, buf);
+  MYSQL_INDEX_READ_ROW_DONE(rc);
+  DBUG_RETURN(rc);
 }
 
 int ha_ndbcluster::read_range_next()
 {
+  int rc;
   DBUG_ENTER("ha_ndbcluster::read_range_next");
-  DBUG_RETURN(next_result(table->record[0]));
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
+  rc= next_result(table->record[0]);
+  MYSQL_INDEX_READ_ROW_DONE(rc);
+  DBUG_RETURN(rc);
 }
 
 
@@ -4277,12 +4307,14 @@ int ha_ndbcluster::rnd_next(uchar *buf)
 int ha_ndbcluster::rnd_pos(uchar *buf, uchar *pos)
 {
   DBUG_ENTER("rnd_pos");
+  MYSQL_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   ha_statistic_increment(&SSV::ha_read_rnd_count);
   // The primary key for the record is stored in pos
   // Perform a pk_read using primary key "index"
   {
     part_id_range part_spec;
     uint key_length= ref_length;
+    int rc;
     if (m_user_defined_partitioning)
     {
       if (table_share->primary_key == MAX_KEY)
@@ -4309,7 +4341,9 @@ int ha_ndbcluster::rnd_pos(uchar *buf, u
       DBUG_PRINT("info", ("partition id %u", part_spec.start_part));
     }
     DBUG_DUMP("key", pos, key_length);
-    DBUG_RETURN(pk_read(pos, key_length, buf, part_spec.start_part));
+    rc= pk_read(pos, key_length, buf, part_spec.start_part);
+    MYSQL_READ_ROW_DONE(rc);
+    DBUG_RETURN(rc);
   }
 }
 

=== modified file 'sql/ha_partition.cc'
--- a/sql/ha_partition.cc	2008-10-13 19:26:56 +0000
+++ b/sql/ha_partition.cc	2008-12-04 10:05:56 +0000
@@ -57,6 +57,7 @@
 #include "ha_partition.h"
 
 #include <mysql/plugin.h>
+#include "probes_mysql.h"
 
 static const char *ha_par_ext= ".par";
 #ifdef NOT_USED
@@ -3394,7 +3395,8 @@ int ha_partition::rnd_next(uchar *buf)
   int result= HA_ERR_END_OF_FILE;
   uint part_id= m_part_spec.start_part;
   DBUG_ENTER("ha_partition::rnd_next");
-
+  MYSQL_READ_ROW_START(table_share->db.str, table_share->table_name.str);
+  
   if (NO_CURRENT_PART_ID == part_id)
   {
     /*
@@ -3415,6 +3417,7 @@ int ha_partition::rnd_next(uchar *buf)
       m_last_part= part_id;
       m_part_spec.start_part= part_id;
       table->status= 0;
+      MYSQL_READ_ROW_DONE(0);
       DBUG_RETURN(0);
     }
 
@@ -3455,6 +3458,7 @@ end:
   m_part_spec.start_part= NO_CURRENT_PART_ID;
 end_dont_reset_start_part:
   table->status= STATUS_NOT_FOUND;
+  MYSQL_READ_ROW_DONE(result);
   DBUG_RETURN(result);
 }
 
@@ -3536,13 +3540,17 @@ int ha_partition::rnd_pos(uchar * buf, u
 {
   uint part_id;
   handler *file;
+  int rc;
   DBUG_ENTER("ha_partition::rnd_pos");
-
+  MYSQL_READ_ROW_START(table_share->db.str, table_share->table_name.str);
+  
   part_id= uint2korr((const uchar *) pos);
   DBUG_ASSERT(part_id < m_tot_parts);
   file= m_file[part_id];
   m_last_part= part_id;
-  DBUG_RETURN(file->rnd_pos(buf, (pos + PARTITION_BYTES_IN_POS)));
+  rc= file->rnd_pos(buf, (pos + PARTITION_BYTES_IN_POS));
+  MYSQL_READ_ROW_DONE(rc);
+  DBUG_RETURN(rc);
 }
 
 
@@ -3686,7 +3694,7 @@ int ha_partition::index_end()
   int error= 0;
   handler **file;
   DBUG_ENTER("ha_partition::index_end");
-
+  
   active_index= MAX_KEY;
   m_part_spec.start_part= NO_CURRENT_PART_ID;
   file= m_file;
@@ -3731,13 +3739,17 @@ int ha_partition::index_read_map(uchar *
                                  key_part_map keypart_map,
                                  enum ha_rkey_function find_flag)
 {
+  int rc;
   DBUG_ENTER("ha_partition::index_read_map");
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   end_range= 0;
   m_index_scan_type= partition_index_read;
   m_start_key.key= key;
   m_start_key.keypart_map= keypart_map;
   m_start_key.flag= find_flag;
-  DBUG_RETURN(common_index_read(buf, TRUE));
+  rc= common_index_read(buf, TRUE);
+  MYSQL_INDEX_READ_ROW_DONE(rc);
+  DBUG_RETURN(rc);
 }
 
 
@@ -3851,11 +3863,15 @@ int ha_partition::common_index_read(ucha
 
 int ha_partition::index_first(uchar * buf)
 {
+  int rc;
   DBUG_ENTER("ha_partition::index_first");
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
 
   end_range= 0;
   m_index_scan_type= partition_index_first;
-  DBUG_RETURN(common_first_last(buf));
+  rc= common_first_last(buf);
+  MYSQL_INDEX_READ_ROW_DONE(rc);
+  DBUG_RETURN(rc);
 }
 
 
@@ -3882,10 +3898,14 @@ int ha_partition::index_first(uchar * bu
 
 int ha_partition::index_last(uchar * buf)
 {
+  int rc;
   DBUG_ENTER("ha_partition::index_last");
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
 
   m_index_scan_type= partition_index_last;
-  DBUG_RETURN(common_first_last(buf));
+  rc= common_first_last(buf);
+  MYSQL_INDEX_READ_ROW_DONE(rc);
+  DBUG_RETURN(rc);
 }
 
 /*
@@ -3931,7 +3951,9 @@ int ha_partition::common_first_last(ucha
 int ha_partition::index_read_last_map(uchar *buf, const uchar *key,
                                       key_part_map keypart_map)
 {
+  int rc;
   DBUG_ENTER("ha_partition::index_read_last");
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
 
   m_ordered= TRUE;				// Safety measure
   end_range= 0;
@@ -3939,7 +3961,9 @@ int ha_partition::index_read_last_map(uc
   m_start_key.key= key;
   m_start_key.keypart_map= keypart_map;
   m_start_key.flag= HA_READ_PREFIX_LAST;
-  DBUG_RETURN(common_index_read(buf, TRUE));
+  rc= common_index_read(buf, TRUE);
+  MYSQL_INDEX_READ_ROW_DONE(rc);
+  DBUG_RETURN(rc);
 }
 
 
@@ -3960,7 +3984,9 @@ int ha_partition::index_read_last_map(uc
 
 int ha_partition::index_next(uchar * buf)
 {
+  int rc;
   DBUG_ENTER("ha_partition::index_next");
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
 
   /*
     TODO(low priority):
@@ -3969,10 +3995,11 @@ int ha_partition::index_next(uchar * buf
   */
   DBUG_ASSERT(m_index_scan_type != partition_index_last);
   if (!m_ordered_scan_ongoing)
-  {
-    DBUG_RETURN(handle_unordered_next(buf, FALSE));
-  }
-  DBUG_RETURN(handle_ordered_next(buf, FALSE));
+    rc= handle_unordered_next(buf, FALSE);
+  else
+    rc= handle_ordered_next(buf, FALSE);
+  MYSQL_INDEX_READ_ROW_DONE(rc);
+  DBUG_RETURN(rc);
 }
 
 
@@ -3996,13 +4023,18 @@ int ha_partition::index_next(uchar * buf
 
 int ha_partition::index_next_same(uchar *buf, const uchar *key, uint keylen)
 {
+  int rc;
   DBUG_ENTER("ha_partition::index_next_same");
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
 
   DBUG_ASSERT(keylen == m_start_key.length);
   DBUG_ASSERT(m_index_scan_type != partition_index_last);
   if (!m_ordered_scan_ongoing)
-    DBUG_RETURN(handle_unordered_next(buf, TRUE));
-  DBUG_RETURN(handle_ordered_next(buf, TRUE));
+    rc= handle_unordered_next(buf, TRUE);
+  else
+    rc= handle_ordered_next(buf, TRUE);
+  MYSQL_INDEX_READ_ROW_DONE(rc);
+  DBUG_RETURN(rc);
 }
 
 
@@ -4023,11 +4055,15 @@ int ha_partition::index_next_same(uchar 
 
 int ha_partition::index_prev(uchar * buf)
 {
+  int rc;
   DBUG_ENTER("ha_partition::index_prev");
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
 
   /* TODO: read comment in index_next */
   DBUG_ASSERT(m_index_scan_type != partition_index_first);
-  DBUG_RETURN(handle_ordered_prev(buf));
+  rc= handle_ordered_prev(buf);
+  MYSQL_INDEX_READ_ROW_DONE(rc);
+  DBUG_RETURN(rc);
 }
 
 
@@ -4058,6 +4094,7 @@ int ha_partition::read_range_first(const
 {
   int error;
   DBUG_ENTER("ha_partition::read_range_first");
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   m_ordered= sorted;
   eq_range= eq_range_arg;
 
@@ -4079,6 +4116,7 @@ int ha_partition::read_range_first(const
 
   m_index_scan_type= partition_read_range;
   error= common_index_read(m_rec0, test(start_key));
+  MYSQL_INDEX_READ_ROW_DONE(error);
   DBUG_RETURN(error);
 }
 
@@ -4097,13 +4135,16 @@ int ha_partition::read_range_first(const
 
 int ha_partition::read_range_next()
 {
+  int rc;
   DBUG_ENTER("ha_partition::read_range_next");
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
 
   if (m_ordered)
-  {
-    DBUG_RETURN(handle_ordered_next(table->record[0], eq_range));
-  }
-  DBUG_RETURN(handle_unordered_next(table->record[0], eq_range));
+    rc= handle_ordered_next(table->record[0], eq_range);
+  else
+    rc= handle_unordered_next(table->record[0], eq_range);
+  MYSQL_INDEX_READ_ROW_DONE(rc);
+  DBUG_RETURN(rc);
 }
 
 

=== modified file 'sql/handler.cc'
--- a/sql/handler.cc	2008-10-17 17:47:16 +0000
+++ b/sql/handler.cc	2008-12-04 10:05:56 +0000
@@ -28,6 +28,7 @@
 #include <myisampack.h>
 #include "myisam.h"
 #include "transaction.h"
+#include "probes_mysql.h"
 
 #ifdef WITH_PARTITION_STORAGE_ENGINE
 #include "ha_partition.h"

=== modified file 'sql/mysql_priv.h'
--- a/sql/mysql_priv.h	2008-10-17 17:47:16 +0000
+++ b/sql/mysql_priv.h	2008-12-04 10:05:56 +0000
@@ -44,16 +44,6 @@
 #include "sql_plugin.h"
 #include "scheduler.h"
 
-#ifdef HAVE_DTRACE
-#define _DTRACE_VERSION 1
-#else
-#undef _DTRACE_VERSION
-#endif
-#ifdef EMBEDDED_LIBRARY
-#undef _DTRACE_VERSION
-#endif
-#include "probes.h"
-
 #ifndef __WIN__
 #include <netdb.h>
 #endif

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2008-10-17 17:47:16 +0000
+++ b/sql/mysqld.cc	2008-12-04 10:05:56 +0000
@@ -28,6 +28,7 @@
 #include "events.h"
 #include "ddl_blocker.h"
 #include "sql_audit.h"
+#include "probes_mysql.h"
 
 #include "../storage/myisam/ha_myisam.h"
 

=== modified file 'sql/net_serv.cc'
--- a/sql/net_serv.cc	2008-10-02 12:08:09 +0000
+++ b/sql/net_serv.cc	2008-12-04 10:05:56 +0000
@@ -58,13 +58,7 @@
 #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"
+#include "probes_mysql.h"
 
 /*
   The following handles the differences when this is linked between the

=== renamed file 'sql/probes.d' => 'sql/probes_mysql.d'
--- a/sql/probes.d	2008-10-02 12:08:09 +0000
+++ b/sql/probes_mysql.d	2008-12-04 10:05:56 +0000
@@ -21,7 +21,7 @@
 
   - 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
+  arguments (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,
@@ -96,14 +96,18 @@ provider mysql {
                            int exec_type);
   probe query__exec__done(int status);
 
-  /* These probes fire when performing write operations towards any handler */
+  /* These probes fire when performing row operations towards any handler */
   probe insert__row__start(char *db, char *table);
   probe insert__row__done(int status);
   probe update__row__start(char *db, char *table);
   probe update__row__done(int status);
   probe delete__row__start(char *db, char *table);
   probe delete__row__done(int status);
-
+  probe read__row__start(char *db, char *table);
+  probe read__row__done(int status);
+  probe index__read__row__start(char *db, char *table);
+  probe index__read__row__done(int status);
+  
   /*
     These probes fire when calling external_lock for any handler
     depending on the lock type being acquired or released.
@@ -136,7 +140,8 @@ provider mysql {
                      unsigned long rowsmatches, unsigned long rowschanged);
   probe multi__update__start(char *query);
   probe multi__update__done(int status,
-                            unsigned long rowsmatches, unsigned long rowschanged);
+                            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);
@@ -151,4 +156,27 @@ provider mysql {
   probe net__write__start(unsigned long bytes);
   probe net__write__done(int status);
 
+  /* MyISAM Key cache probes */
+  probe keycache__read__start(char *filepath, unsigned long  bytes,
+                              unsigned long mem_used, unsigned long mem_free);
+  probe keycache__read__block(unsigned long bytes);
+  probe keycache__read__hit();
+  probe keycache__read__miss();
+  probe keycache__read__done(unsigned long mem_used, unsigned long mem_free);
+  probe keycache__write__start(char *filepath, unsigned long bytes,
+                               unsigned long mem_used, unsigned long mem_free);
+  probe keycache__write__block(unsigned long bytes);
+  probe keycache__write__done(unsigned long mem_used, unsigned long mem_free);
+
+  /* Backup probes */
+  probe backup__start();
+  probe backup__done(int status);
+  probe restore__start();
+  probe restore__done(int status);
 };
+
+#pragma D attributes Evolving/Evolving/Common provider mysql provider
+#pragma D attributes Evolving/Evolving/Common provider mysql module
+#pragma D attributes Evolving/Evolving/Common provider mysql function
+#pragma D attributes Evolving/Evolving/Common provider mysql name
+#pragma D attributes Evolving/Evolving/Common provider mysql args

=== modified file 'sql/scheduler.cc'
--- a/sql/scheduler.cc	2008-10-17 17:47:16 +0000
+++ b/sql/scheduler.cc	2008-12-04 10:05:56 +0000
@@ -23,6 +23,7 @@
 
 #include <mysql_priv.h>
 #include "sql_audit.h"
+#include "probes_mysql.h"
 
 
 /*

=== modified file 'sql/sp_head.cc'
--- a/sql/sp_head.cc	2008-10-17 17:47:16 +0000
+++ b/sql/sp_head.cc	2008-12-04 10:05:56 +0000
@@ -22,6 +22,7 @@
 #include "sp_pcontext.h"
 #include "sp_rcontext.h"
 #include "sp_cache.h"
+#include "probes_mysql.h"
 
 /*
   Sufficient max length of printed destinations and frame offsets (all uints).

=== modified file 'sql/sql_cache.cc'
--- a/sql/sql_cache.cc	2008-10-17 17:47:16 +0000
+++ b/sql/sql_cache.cc	2008-12-04 10:05:56 +0000
@@ -333,6 +333,7 @@ TODO list:
 #include <hash.h>
 #include "../storage/myisammrg/ha_myisammrg.h"
 #include "../storage/myisammrg/myrg_def.h"
+#include "probes_mysql.h"
 
 #ifdef EMBEDDED_LIBRARY
 #include "emb_qcache.h"

=== modified file 'sql/sql_connect.cc'
--- a/sql/sql_connect.cc	2008-10-17 17:47:16 +0000
+++ b/sql/sql_connect.cc	2008-12-04 10:05:56 +0000
@@ -20,6 +20,7 @@
 
 #include "mysql_priv.h"
 #include "sql_audit.h"
+#include "probes_mysql.h"
 
 #if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
 /*

=== modified file 'sql/sql_cursor.cc'
--- a/sql/sql_cursor.cc	2008-10-10 16:23:30 +0000
+++ b/sql/sql_cursor.cc	2008-12-04 10:05:56 +0000
@@ -19,6 +19,7 @@
 #include "mysql_priv.h"
 #include "sql_cursor.h"
 #include "sql_select.h"
+#include "probes_mysql.h"
 
 /****************************************************************************
   Declarations.

=== modified file 'sql/sql_delete.cc'
--- a/sql/sql_delete.cc	2008-10-10 16:23:30 +0000
+++ b/sql/sql_delete.cc	2008-12-04 10:05:56 +0000
@@ -23,6 +23,7 @@
 #include "sql_select.h"
 #include "sp_head.h"
 #include "sql_trigger.h"
+#include "probes_mysql.h"
 
 /**
   Implement DELETE SQL word.

=== modified file 'sql/sql_insert.cc'
--- a/sql/sql_insert.cc	2008-10-17 17:47:16 +0000
+++ b/sql/sql_insert.cc	2008-12-04 10:05:56 +0000
@@ -63,6 +63,7 @@
 #include "rpl_mi.h"
 #include "sql_audit.h"
 #include "transaction.h"
+#include "probes_mysql.h"
 
 #ifndef EMBEDDED_LIBRARY
 static bool delayed_get_table(THD *thd, TABLE_LIST *table_list);

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2008-10-17 17:47:16 +0000
+++ b/sql/sql_parse.cc	2008-12-04 10:05:56 +0000
@@ -31,6 +31,7 @@
 #include <ddl_blocker.h>
 #include "sql_audit.h"
 #include "transaction.h"
+#include "probes_mysql.h"
 
 #ifdef BACKUP_TEST
 #include "backup/backup_test.h"

=== modified file 'sql/sql_prepare.cc'
--- a/sql/sql_prepare.cc	2008-10-10 16:23:30 +0000
+++ b/sql/sql_prepare.cc	2008-12-04 10:05:56 +0000
@@ -95,6 +95,7 @@ When one supplies long data for a placeh
 #else
 #include <mysql_com.h>
 #endif
+#include "probes_mysql.h"
 
 /**
   A result class used to send cursor rows using the binary protocol.

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2008-10-17 17:47:16 +0000
+++ b/sql/sql_select.cc	2008-12-04 10:05:56 +0000
@@ -31,6 +31,7 @@
 #include "mysql_priv.h"
 #include "sql_select.h"
 #include "sql_cursor.h"
+#include "probes_mysql.h"
 
 #include <m_ctype.h>
 #include <my_bit.h>

=== modified file 'sql/sql_update.cc'
--- a/sql/sql_update.cc	2008-10-17 17:47:16 +0000
+++ b/sql/sql_update.cc	2008-12-04 10:05:56 +0000
@@ -23,6 +23,7 @@
 #include "sql_select.h"
 #include "sp_head.h"
 #include "sql_trigger.h"
+#include "probes_mysql.h"
 
 /* Return 0 if row hasn't changed */
 

=== modified file 'storage/archive/Makefile.am'
--- a/storage/archive/Makefile.am	2008-03-06 14:14:53 +0000
+++ b/storage/archive/Makefile.am	2008-12-04 10:05:56 +0000
@@ -97,5 +97,22 @@ valgrind-test: archive_test archive_perf
 	libtool --mode=execute valgrind --leak-check=yes --show-reachable=yes  ./archive_performance
 
 EXTRA_DIST =		CMakeLists.txt plug.in
+
+if HAVE_DTRACE_DASH_G
+abs_top_srcdir = @abs_top_srcdir@
+libarchive_a_LIBADD = probes_mysql.o
+libarchive_a_DEPENDENCIES = probes_mysql.o dtrace_files dtrace_providers
+CLEANFILES = probes_mysql.o dtrace_files dtrace_providers
+DTRACEFILES = libarchive_a-ha_archive.o
+DTRACEPROVIDER = $(abs_top_srcdir)/sql/probes_mysql.d
+
+dtrace_files:
+	echo $(DTRACEFILES) > $@
+dtrace_providers:
+	echo $(DTRACEPROVIDER) > $@
+probes_mysql.o: $(DTRACEPROVIDER) $(DTRACEFILES)
+	$(DTRACE) $(DTRACEFLAGS) -G -s $< $(DTRACEFILES) -o $@
+endif
+
 # Don't update the files from bitkeeper
 %::SCCS/s.%

=== modified file 'storage/archive/ha_archive.cc'
--- a/storage/archive/ha_archive.cc	2008-07-23 08:52:08 +0000
+++ b/storage/archive/ha_archive.cc	2008-12-04 10:05:56 +0000
@@ -24,6 +24,7 @@
 #include <my_dir.h>
 
 #include <mysql/plugin.h>
+#include "probes_mysql.h"
 
 /*
   First, if you want to understand storage engines you should look at 
@@ -917,7 +918,9 @@ int ha_archive::index_read(uchar *buf, c
 {
   int rc;
   DBUG_ENTER("ha_archive::index_read");
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   rc= index_read_idx(buf, active_index, key, key_len, find_flag);
+  MYSQL_INDEX_READ_ROW_DONE(rc);
   DBUG_RETURN(rc);
 }
 
@@ -960,9 +963,11 @@ error:
 int ha_archive::index_next(uchar * buf) 
 { 
   bool found= 0;
+  int rc;
 
   DBUG_ENTER("ha_archive::index_next");
-
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
+  
   while (!(get_row(&archive, buf)))
   {
     if (!memcmp(current_key, buf+current_k_offset, current_key_len))
@@ -972,7 +977,9 @@ int ha_archive::index_next(uchar * buf) 
     }
   }
 
-  DBUG_RETURN(found ? 0 : HA_ERR_END_OF_FILE); 
+  rc= found ? 0 : HA_ERR_END_OF_FILE;
+  MYSQL_INDEX_READ_ROW_DONE(rc);
+  DBUG_RETURN(rc); 
 }
 
 /*
@@ -1098,12 +1105,19 @@ int ha_archive::rnd_next(uchar *buf)
 {
   int rc;
   DBUG_ENTER("ha_archive::rnd_next");
-
+  MYSQL_READ_ROW_START(table_share->db.str, table_share->table_name.str);
+  
   if (share->crashed)
-      DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
+  {
+    MYSQL_READ_ROW_DONE(HA_ERR_CRASHED_ON_USAGE);
+    DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
+  }
 
   if (!scan_rows)
+  {
+    MYSQL_READ_ROW_DONE(HA_ERR_END_OF_FILE);
     DBUG_RETURN(HA_ERR_END_OF_FILE);
+  }
   scan_rows--;
 
   ha_statistic_increment(&SSV::ha_read_rnd_next_count);
@@ -1112,6 +1126,7 @@ int ha_archive::rnd_next(uchar *buf)
 
   table->status=rc ? STATUS_NOT_FOUND: 0;
 
+  MYSQL_READ_ROW_DONE(rc);
   DBUG_RETURN(rc);
 }
 
@@ -1139,12 +1154,17 @@ void ha_archive::position(const uchar *r
 
 int ha_archive::rnd_pos(uchar * buf, uchar *pos)
 {
+  int rc;
   DBUG_ENTER("ha_archive::rnd_pos");
+  MYSQL_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   ha_statistic_increment(&SSV::ha_read_rnd_next_count);
   current_position= (my_off_t)my_get_ptr(pos, ref_length);
   if (azseek(&archive, (size_t)current_position, SEEK_SET) == (size_t)(-1L))
-    DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
-  DBUG_RETURN(get_row(&archive, buf));
+    rc= HA_ERR_CRASHED_ON_USAGE;
+  else
+    rc= get_row(&archive, buf);
+  MYSQL_READ_ROW_DONE(rc);
+  DBUG_RETURN(rc);
 }
 
 /*

=== modified file 'storage/blackhole/Makefile.am'
--- a/storage/blackhole/Makefile.am	2008-01-02 13:00:46 +0000
+++ b/storage/blackhole/Makefile.am	2008-12-04 10:05:56 +0000
@@ -48,5 +48,22 @@ libblackhole_a_SOURCES=	ha_blackhole.cc
 
 
 EXTRA_DIST =		CMakeLists.txt plug.in
+
+if HAVE_DTRACE_DASH_G
+abs_top_srcdir = @abs_top_srcdir@
+libblackhole_a_LIBADD = probes_mysql.o
+libblackhole_a_DEPENDENCIES = probes_mysql.o dtrace_files dtrace_providers
+CLEANFILES = probes_mysql.o dtrace_files dtrace_providers
+DTRACEFILES = libblackhole_a-ha_blackhole.o
+DTRACEPROVIDER = $(abs_top_srcdir)/sql/probes_mysql.d
+
+dtrace_files:
+	echo $(DTRACEFILES) > $@
+dtrace_providers:
+	echo $(DTRACEPROVIDER) > $@
+probes_mysql.o: $(DTRACEPROVIDER) $(DTRACEFILES)
+	$(DTRACE) $(DTRACEFLAGS) -G -s $< $(DTRACEFILES) -o $@
+endif
+
 # Don't update the files from bitkeeper
 %::SCCS/s.%

=== modified file 'storage/blackhole/ha_blackhole.cc'
--- a/storage/blackhole/ha_blackhole.cc	2008-10-03 10:01:20 +0000
+++ b/storage/blackhole/ha_blackhole.cc	2008-12-04 10:05:56 +0000
@@ -21,6 +21,7 @@
 #define MYSQL_SERVER 1
 #include "mysql_priv.h"
 #include "ha_blackhole.h"
+#include "probes_mysql.h"
 
 /* Static declarations for handlerton */
 
@@ -128,18 +129,25 @@ int ha_blackhole::rnd_init(bool scan)
 
 int ha_blackhole::rnd_next(uchar *buf)
 {
+  int rc;
   DBUG_ENTER("ha_blackhole::rnd_next");
+  MYSQL_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   THD *thd= ha_thd();
   if (thd->system_thread == SYSTEM_THREAD_SLAVE_SQL && thd->query == NULL)
-    DBUG_RETURN(0);
-  DBUG_RETURN(HA_ERR_END_OF_FILE);
+    rc= 0;
+  else
+    rc= HA_ERR_END_OF_FILE;
+  MYSQL_READ_ROW_DONE(rc);
+  DBUG_RETURN(rc);
 }
 
 
 int ha_blackhole::rnd_pos(uchar * buf, uchar *pos)
 {
   DBUG_ENTER("ha_blackhole::rnd_pos");
+  MYSQL_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   DBUG_ASSERT(0);
+  MYSQL_READ_ROW_DONE(0);
   DBUG_RETURN(0);
 }
 
@@ -210,11 +218,14 @@ int ha_blackhole::index_read_map(uchar *
                                  key_part_map keypart_map,
                              enum ha_rkey_function find_flag)
 {
+  int rc;
   DBUG_ENTER("ha_blackhole::index_read");
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   THD *thd= ha_thd();
-  if (thd->system_thread == SYSTEM_THREAD_SLAVE_SQL && thd->query == NULL)
-    DBUG_RETURN(0);
-  DBUG_RETURN(HA_ERR_END_OF_FILE);
+  rc= (thd->system_thread == SYSTEM_THREAD_SLAVE_SQL && thd->query == NULL) ?
+    0 : HA_ERR_END_OF_FILE;
+  MYSQL_INDEX_READ_ROW_DONE(rc);
+  DBUG_RETURN(rc);
 }
 
 
@@ -222,28 +233,36 @@ int ha_blackhole::index_read_idx_map(uch
                                  key_part_map keypart_map,
                                  enum ha_rkey_function find_flag)
 {
+  int rc;
   DBUG_ENTER("ha_blackhole::index_read_idx");
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   THD *thd= ha_thd();
-  if (thd->system_thread == SYSTEM_THREAD_SLAVE_SQL && thd->query == NULL)
-    DBUG_RETURN(0);
-  DBUG_RETURN(HA_ERR_END_OF_FILE);
+  rc= (thd->system_thread == SYSTEM_THREAD_SLAVE_SQL && thd->query == NULL) ?
+    0 : HA_ERR_END_OF_FILE;
+  MYSQL_INDEX_READ_ROW_DONE(rc);
+  DBUG_RETURN(rc);
 }
 
 
 int ha_blackhole::index_read_last_map(uchar * buf, const uchar * key,
                                       key_part_map keypart_map)
 {
+  int rc;
   DBUG_ENTER("ha_blackhole::index_read_last");
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   THD *thd= ha_thd();
-  if (thd->system_thread == SYSTEM_THREAD_SLAVE_SQL && thd->query == NULL)
-    DBUG_RETURN(0);
-  DBUG_RETURN(HA_ERR_END_OF_FILE);
+  rc= (thd->system_thread == SYSTEM_THREAD_SLAVE_SQL && thd->query == NULL) ?
+    0 : HA_ERR_END_OF_FILE;
+  MYSQL_INDEX_READ_ROW_DONE(rc);
+  DBUG_RETURN(rc);
 }
 
 
 int ha_blackhole::index_next(uchar * buf)
 {
   DBUG_ENTER("ha_blackhole::index_next");
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
+  MYSQL_INDEX_READ_ROW_DONE(HA_ERR_END_OF_FILE);
   DBUG_RETURN(HA_ERR_END_OF_FILE);
 }
 
@@ -251,6 +270,8 @@ int ha_blackhole::index_next(uchar * buf
 int ha_blackhole::index_prev(uchar * buf)
 {
   DBUG_ENTER("ha_blackhole::index_prev");
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
+  MYSQL_INDEX_READ_ROW_DONE(HA_ERR_END_OF_FILE);
   DBUG_RETURN(HA_ERR_END_OF_FILE);
 }
 
@@ -258,6 +279,8 @@ int ha_blackhole::index_prev(uchar * buf
 int ha_blackhole::index_first(uchar * buf)
 {
   DBUG_ENTER("ha_blackhole::index_first");
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
+  MYSQL_INDEX_READ_ROW_DONE(HA_ERR_END_OF_FILE);
   DBUG_RETURN(HA_ERR_END_OF_FILE);
 }
 
@@ -265,6 +288,8 @@ int ha_blackhole::index_first(uchar * bu
 int ha_blackhole::index_last(uchar * buf)
 {
   DBUG_ENTER("ha_blackhole::index_last");
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
+  MYSQL_INDEX_READ_ROW_DONE(HA_ERR_END_OF_FILE);
   DBUG_RETURN(HA_ERR_END_OF_FILE);
 }
 

=== modified file 'storage/csv/Makefile.am'
--- a/storage/csv/Makefile.am	2007-01-04 18:54:52 +0000
+++ b/storage/csv/Makefile.am	2008-12-04 10:05:56 +0000
@@ -41,5 +41,22 @@ libcsv_a_CXXFLAGS =	$(AM_CFLAGS)
 libcsv_a_SOURCES =	transparent_file.cc ha_tina.cc
 
 EXTRA_DIST =		CMakeLists.txt plug.in
+
+if HAVE_DTRACE_DASH_G
+abs_top_srcdir = @abs_top_srcdir@
+libcsv_a_LIBADD = probes_mysql.o
+libcsv_a_DEPENDENCIES = probes_mysql.o dtrace_files dtrace_providers
+CLEANFILES = probes_mysql.o dtrace_files dtrace_providers
+DTRACEFILES = libcsv_a-ha_tina.o
+DTRACEPROVIDER = $(abs_top_srcdir)/sql/probes_mysql.d
+
+dtrace_files:
+	echo $(DTRACEFILES) > $@
+dtrace_providers:
+	echo $(DTRACEPROVIDER) > $@
+probes_mysql.o: $(DTRACEPROVIDER) $(DTRACEFILES)
+	$(DTRACE) $(DTRACEFLAGS) -G -s $< $(DTRACEFILES) -o $@
+endif
+
 # Don't update the files from bitkeeper
 %::SCCS/s.%

=== modified file 'storage/csv/ha_tina.cc'
--- a/storage/csv/ha_tina.cc	2008-08-23 00:18:35 +0000
+++ b/storage/csv/ha_tina.cc	2008-12-04 10:05:56 +0000
@@ -48,6 +48,7 @@ TODO:
 #include "mysql_priv.h"
 #include <mysql/plugin.h>
 #include "ha_tina.h"
+#include "probes_mysql.h"
 
 
 /*
@@ -1094,9 +1095,13 @@ int ha_tina::rnd_next(uchar *buf)
 {
   int rc;
   DBUG_ENTER("ha_tina::rnd_next");
+  MYSQL_READ_ROW_START(table_share->db.str, table_share->table_name.str);
 
   if (share->crashed)
-      DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
+  {
+    rc= HA_ERR_CRASHED_ON_USAGE;
+    goto end;
+  }
 
   ha_statistic_increment(&SSV::ha_read_rnd_next_count);
 
@@ -1104,13 +1109,19 @@ int ha_tina::rnd_next(uchar *buf)
 
   /* don't scan an empty file */
   if (!local_saved_data_file_length)
-    DBUG_RETURN(HA_ERR_END_OF_FILE);
+  {
+    rc= HA_ERR_END_OF_FILE;
+    goto end;
+  }
 
   if ((rc= find_current_row(buf)))
-    DBUG_RETURN(rc);
+    goto end;
 
   stats.records++;
-  DBUG_RETURN(0);
+
+ end:
+  MYSQL_READ_ROW_DONE(rc);
+  DBUG_RETURN(rc);
 }
 
 /*
@@ -1137,10 +1148,14 @@ void ha_tina::position(const uchar *reco
 
 int ha_tina::rnd_pos(uchar * buf, uchar *pos)
 {
+  int rc;
   DBUG_ENTER("ha_tina::rnd_pos");
+  MYSQL_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   ha_statistic_increment(&SSV::ha_read_rnd_count);
   current_position= (off_t)my_get_ptr(pos,ref_length);
-  DBUG_RETURN(find_current_row(buf));
+  rc= find_current_row(buf);
+  MYSQL_READ_ROW_DONE(rc);
+  DBUG_RETURN(rc);
 }
 
 /*

=== modified file 'storage/example/Makefile.am'
--- a/storage/example/Makefile.am	2008-01-02 13:00:46 +0000
+++ b/storage/example/Makefile.am	2008-12-04 10:05:56 +0000
@@ -48,5 +48,21 @@ libexample_a_SOURCES=	ha_example.cc
 
 
 EXTRA_DIST =		CMakeLists.txt plug.in
+
+if HAVE_DTRACE_DASH_G
+libexample_a_LIBADD = probes_mysql.o
+libexample_a_DEPENDENCIES = probes_mysql.o
+CLEANFILES =
+BUILT_SOURCES = 
+DTRACEFILES = libexample_a-ha_example.o
+DTRACEPROVIDER = $(abs_top_srcdir)/sql/probes_mysql.d
+
+dtrace_files:
+	echo $(DTRACEFILES) > $@
+dtrace_providers:
+	echo $(DTRACEPROVIDER) > $@
+probes_mysql.o: $(DTRACEPROVIDER) $(DTRACEFILES)
+	$(DTRACE) $(DTRACEFLAGS) -G -s $< $(DTRACEFILES) -o $@
+endif
 # Don't update the files from bitkeeper
 %::SCCS/s.%

=== modified file 'storage/example/ha_example.cc'
--- a/storage/example/ha_example.cc	2008-04-09 00:56:49 +0000
+++ b/storage/example/ha_example.cc	2008-12-04 10:05:56 +0000
@@ -95,6 +95,7 @@
 #include "mysql_priv.h"
 #include "ha_example.h"
 #include <mysql/plugin.h>
+#include "probes_mysql.h"
 
 static handler *example_create_handler(handlerton *hton,
                                        TABLE_SHARE *table, 
@@ -429,6 +430,8 @@ int ha_example::index_read_map(uchar *bu
                                __attribute__((unused)))
 {
   DBUG_ENTER("ha_example::index_read");
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
+  MYSQL_INDEX_READ_ROW_DONE(HA_ERR_WRONG_COMMAND);
   DBUG_RETURN(HA_ERR_WRONG_COMMAND);
 }
 
@@ -441,6 +444,8 @@ int ha_example::index_read_map(uchar *bu
 int ha_example::index_next(uchar *buf)
 {
   DBUG_ENTER("ha_example::index_next");
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
+  MYSQL_INDEX_READ_ROW_DONE(HA_ERR_WRONG_COMMAND);
   DBUG_RETURN(HA_ERR_WRONG_COMMAND);
 }
 
@@ -453,6 +458,8 @@ int ha_example::index_next(uchar *buf)
 int ha_example::index_prev(uchar *buf)
 {
   DBUG_ENTER("ha_example::index_prev");
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
+  MYSQL_INDEX_READ_ROW_DONE(HA_ERR_WRONG_COMMAND);
   DBUG_RETURN(HA_ERR_WRONG_COMMAND);
 }
 
@@ -470,6 +477,8 @@ int ha_example::index_prev(uchar *buf)
 int ha_example::index_first(uchar *buf)
 {
   DBUG_ENTER("ha_example::index_first");
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
+  MYSQL_INDEX_READ_ROW_DONE(HA_ERR_WRONG_COMMAND);
   DBUG_RETURN(HA_ERR_WRONG_COMMAND);
 }
 
@@ -487,6 +496,8 @@ int ha_example::index_first(uchar *buf)
 int ha_example::index_last(uchar *buf)
 {
   DBUG_ENTER("ha_example::index_last");
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
+  MYSQL_INDEX_READ_ROW_DONE(HA_ERR_WRONG_COMMAND);
   DBUG_RETURN(HA_ERR_WRONG_COMMAND);
 }
 
@@ -534,6 +545,8 @@ int ha_example::rnd_end()
 int ha_example::rnd_next(uchar *buf)
 {
   DBUG_ENTER("ha_example::rnd_next");
+  MYSQL_READ_ROW_START(table_share->db.str, table_share->table_name.str);
+  MYSQL_READ_ROW_DONE(HA_ERR_END_OF_FILE);
   DBUG_RETURN(HA_ERR_END_OF_FILE);
 }
 
@@ -582,6 +595,8 @@ void ha_example::position(const uchar *r
 int ha_example::rnd_pos(uchar *buf, uchar *pos)
 {
   DBUG_ENTER("ha_example::rnd_pos");
+  MYSQL_READ_ROW_START(table_share->db.str, table_share->table_name.str);
+  MYSQL_READ_ROW_DONE(HA_ERR_END_OF_FILE);
   DBUG_RETURN(HA_ERR_WRONG_COMMAND);
 }
 

=== modified file 'storage/falcon/Makefile.am'
--- a/storage/falcon/Makefile.am	2008-09-03 21:49:18 +0000
+++ b/storage/falcon/Makefile.am	2008-12-04 10:05:56 +0000
@@ -388,8 +388,7 @@ falcon_sources= Agent.cpp Alias.cpp \
 		WalkDeferred.cpp \
 		WString.cpp
 
-noinst_HEADERS=	$(falcon_headers) \
-		falcon_probes.h
+noinst_HEADERS=	$(falcon_headers) probes_falcon.h probes_falcon_nodtrace.h
 
 EXTRA_LTLIBRARIES=	ha_falcon.la
 pkglib_LTLIBRARIES=	@plugin_falcon_shared_target@
@@ -399,11 +398,6 @@ ha_falcon_la_CFLAGS=	$(AM_CFLAGS) -DMYSQ
 ha_falcon_la_LIBADD=	TransformLib/libtransform.la
 ha_falcon_la_SOURCES=	$(falcon_sources)
 
-if HAVE_DTRACE
-  ha_falcon_la_LIBADD+= falcon_probes.o
-endif
-
-
 EXTRA_LIBRARIES=	libfalcon.a libhafalcon.a
 noinst_LIBRARIES=	@plugin_falcon_static_target@
 libfalcon_a_LIBADD=	libhafalcon.a TransformLib/libtransform.a
@@ -426,17 +420,36 @@ libfalcon.a:		$(libfalcon_a_LIBADD)
 		fi
 
 
-EXTRA_DIST=		CMakeLists.txt plug.in \
-			falcon_probes.d
+EXTRA_DIST=		CMakeLists.txt plug.in probes_falcon.d
 
-falcon_probes.h: falcon_probes.d
-	$(DTRACE) $(DTRACEFLAGS) -h -s falcon_probes.d
-	mv falcon_probes.h falcon_probes.h.bak
-	sed "s/#include <unistd.h>//g" falcon_probes.h.bak > falcon_probes.h
-	rm falcon_probes.h.bak
+abs_top_srcdir = @abs_top_srcdir@
+
+if HAVE_DTRACE
+BUILT_SOURCES = probes_falcon_dtrace.h
+CLEANFILES = probes_falcon_dtrace.h
+FALCONPROVIDER = $(abs_top_srcdir)/storage/falcon/probes_falcon.d
+
+probes_falcon_dtrace.h: $(FALCONPROVIDER)
+	$(DTRACE) $(DTRACEFLAGS) -h -s $< -o $@
+
+if HAVE_DTRACE_DASH_G
+libhafalcon_a_LIBADD = probes_all.o
+libhafalcon_a_DEPENDENCIES = probes_all.o dtrace_files dtrace_providers
+CLEANFILES += probes_all.o dtrace_files dtrace_providers
+DTRACEFILES = libhafalcon_a-ha_falcon.o
+MYSQLPROVIDER = $(abs_top_srcdir)/sql/probes_mysql.d
+
+dtrace_files:
+	echo $(DTRACEFILES) > $@
+dtrace_providers:
+	echo $(FALCONPROVIDER) $(MYSQLPROVIDER) > $@
+probes_all.o: $(MYSQLPROVIDER) $(FALCONPROVIDER) $(DTRACEFILES)
+	$(DTRACE) $(DTRACEFLAGS) -G -o $@ -s $(MYSQLPROVIDER) -s $(FALCONPROVIDER) $(DTRACEFILES)
+endif # HAVE_DTRACE_DASH_G
+endif # HAVE_DTRACE
 
-falcon_probes.o:
-	$(DTRACE) $(DTRACEFLAGS) -G -s falcon_probes.d $(DTRACEFILES)
+probes_falcon_nodtrace.h: $(FALCONPROVIDER)
+	$(top_srcdir)/scripts/dheadgen.pl -f $^ > $@
 
 # Don't update the files from bitkeeper
 %::SCCS/s.%

=== removed file 'storage/falcon/falcon_probes.d'
--- a/storage/falcon/falcon_probes.d	2007-12-19 04:33:08 +0000
+++ b/storage/falcon/falcon_probes.d	1970-01-01 00:00:00 +0000
@@ -1,19 +0,0 @@
-/* Copyright (C) 2004-2005 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
-   the Free Software Foundation; version 2 of the License.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA */
-
-provider falcon {
-	probe open();
-	probe close();
-};

=== removed file 'storage/falcon/falcon_probes.h'
--- a/storage/falcon/falcon_probes.h	2007-12-19 04:33:08 +0000
+++ b/storage/falcon/falcon_probes.h	1970-01-01 00:00:00 +0000
@@ -1,45 +0,0 @@
-/*
- * Generated by dtrace(1M).
- */
-
-#ifndef	_FALCON_PROBES_H
-#define	_FALCON_PROBES_H
-
-
-
-#ifdef	__cplusplus
-extern "C" {
-#endif
-
-#if _DTRACE_VERSION
-
-#define	FALCON_CLOSE() \
-	__dtrace_falcon___close()
-#define	FALCON_CLOSE_ENABLED() \
-	__dtraceenabled_falcon___close()
-#define	FALCON_OPEN() \
-	__dtrace_falcon___open()
-#define	FALCON_OPEN_ENABLED() \
-	__dtraceenabled_falcon___open()
-
-
-extern void __dtrace_falcon___close(void);
-extern int __dtraceenabled_falcon___close(void);
-extern void __dtrace_falcon___open(void);
-extern int __dtraceenabled_falcon___open(void);
-
-#else
-
-#define	FALCON_CLOSE()
-#define	FALCON_CLOSE_ENABLED() (0)
-#define	FALCON_OPEN()
-#define	FALCON_OPEN_ENABLED() (0)
-
-#endif
-
-
-#ifdef	__cplusplus
-}
-#endif
-
-#endif	/* _FALCON_PROBES_H */

=== modified file 'storage/falcon/ha_falcon.cpp'
--- a/storage/falcon/ha_falcon.cpp	2008-10-03 05:15:40 +0000
+++ b/storage/falcon/ha_falcon.cpp	2008-12-04 10:05:56 +0000
@@ -20,7 +20,8 @@
 #endif
 
 #include "mysql_priv.h"
-#include "falcon_probes.h"
+#include "probes_mysql.h"
+#include "probes_falcon.h"
 
 #ifdef _WIN32
 #pragma pack()
@@ -488,8 +489,7 @@ int StorageInterface::open(const char *n
 {
 	DBUG_ENTER("StorageInterface::open");
 
-	// Temporarily comment out DTrace probes in Falcon, see bug #36403
-	// FALCON_OPEN();
+	FALCON_OPEN();
 
 	if (!mySqlThread)
 		mySqlThread = current_thd;
@@ -567,8 +567,7 @@ int StorageInterface::close(void)
 
 	unmapFields();
 
-	// Temporarily comment out DTrace probes in Falcon, see bug #36403
-	// FALCON_CLOSE();
+	FALCON_CLOSE();
 
 	DBUG_RETURN(0);
 }
@@ -604,7 +603,9 @@ int StorageInterface::repair(THD* thd, H
 
 int StorageInterface::rnd_next(uchar *buf)
 {
+	int rc= 0;
 	DBUG_ENTER("StorageInterface::rnd_next");
+        MYSQL_READ_ROW_START(table_share->db.str, table_share->table_name.str);
 	ha_statistic_increment(&SSV::ha_read_rnd_next_count);
 
 	if (activeBlobs)
@@ -618,18 +619,20 @@ int StorageInterface::rnd_next(uchar *bu
 			{
 			lastRecord = -1;
 			table->status = STATUS_NOT_FOUND;
-			DBUG_RETURN(HA_ERR_END_OF_FILE);
+			rc= HA_ERR_END_OF_FILE;
+                	goto end;
 			}
-
-		DBUG_RETURN(error(lastRecord));
+		rc= error(lastRecord);
+		goto end;
 		}
 	else
 		table->status = 0;
 
 	decodeRecord(buf);
 	nextRecord = lastRecord + 1;
-
-	DBUG_RETURN(0);
+end:
+	MYSQL_READ_ROW_DONE(rc);
+	DBUG_RETURN(rc);
 }
 
 
@@ -641,7 +644,9 @@ void StorageInterface::unlock_row(void)
 int StorageInterface::rnd_pos(uchar *buf, uchar *pos)
 {
 	int recordNumber;
+	int rc= 0;
 	DBUG_ENTER("StorageInterface::rnd_pos");
+	MYSQL_READ_ROW_START(table_share->db.str, table_share->table_name.str);
 	ha_statistic_increment(&SSV::ha_read_rnd_next_count);
 
 	memcpy(&recordNumber, pos, sizeof(recordNumber));
@@ -654,14 +659,16 @@ int StorageInterface::rnd_pos(uchar *buf
 	if (ret)
 		{
 		table->status = STATUS_NOT_FOUND;
-		DBUG_RETURN(error(ret));
+		rc= error(ret);
+		goto end;
 		}
 
 	lastRecord = recordNumber;
 	decodeRecord(buf);
 	table->status = 0;
-
-	DBUG_RETURN(0);
+end:
+	MYSQL_READ_ROW_DONE(rc);
+	DBUG_RETURN(rc);
 }
 
 void StorageInterface::position(const uchar *record)
@@ -1346,9 +1353,12 @@ int StorageInterface::index_read(uchar *
                                 enum ha_rkey_function find_flag)
 {
 	DBUG_ENTER("StorageInterface::index_read");
-	int ret, which = 0;
+	int rc, ret, which = 0;
+	MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
 	ha_statistic_increment(&SSV::ha_read_key_count);
 
+	const unsigned char *key = (const unsigned char*) keyBytes;
+
 	// XXX This needs to be revisited
 	switch(find_flag)
 		{
@@ -1373,27 +1383,34 @@ int StorageInterface::index_read(uchar *
 		case HA_READ_PREFIX:
 		case HA_READ_KEY_OR_PREV:
 		default:
-			DBUG_RETURN(HA_ERR_UNSUPPORTED);
+			rc= HA_ERR_UNSUPPORTED;
+			goto err;
 		}
 
-	const unsigned char *key = (const unsigned char*) keyBytes;
-
 	if (which)
 		if ((ret = storageTable->setIndexBound(key, key_len, which)))
-			DBUG_RETURN(error(ret));
+			{
+			rc= error(ret);
+			goto err;
+			}
 
 	if ((ret = storageTable->indexScan(indexOrder)))
-		DBUG_RETURN(error(ret));
+		{
+		rc= error(ret);
+		goto err;
+		}
 
 	nextRecord = 0;
 
 	for (;;)
 		{
-		int ret = index_next(buf);
+		int ret = index_next_int(buf);
 
 		if (ret)
-			DBUG_RETURN(ret);
-
+			{
+			rc= ret;
+			goto err;
+			}
 		int comparison = storageTable->compareKey(key, key_len);
 
 		if ((which & LowerBound) && comparison < 0)
@@ -1402,8 +1419,12 @@ int StorageInterface::index_read(uchar *
 		if ((which & UpperBound) && comparison > 0)
 			continue;
 
+		MYSQL_INDEX_READ_ROW_DONE(0);
 		DBUG_RETURN(0);
 		}
+err:
+	MYSQL_INDEX_READ_ROW_DONE(rc);
+	DBUG_RETURN(rc);
 }
 
 int StorageInterface::index_init(uint idx, bool sorted)
@@ -1565,10 +1586,11 @@ int StorageInterface::read_range_first(c
                                       bool eq_range_arg, bool sorted)
 {
 	DBUG_ENTER("StorageInterface::read_range_first");
+	MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
 	storageTable->clearIndexBounds();
 	haveStartKey = false;
 	haveEndKey = false;
-	int ret = 0;
+	int rc, ret = 0;
 
 	if (start_key && !storageTable->isKeyNull((const unsigned char*) start_key->key, start_key->length))
 		{
@@ -1583,7 +1605,10 @@ int StorageInterface::read_range_first(c
 		int ret = storageTable->setIndexBound((const unsigned char*) start_key->key,
 												start_key->length, LowerBound);
 		if (ret)
-			DBUG_RETURN(error(ret));
+			{
+			rc= error(ret);
+			goto end;
+			}
 		}
 
 	if (end_key)
@@ -1594,7 +1619,10 @@ int StorageInterface::read_range_first(c
 		ret = storageTable->setIndexBound((const unsigned char*) end_key->key,
 												end_key->length, UpperBound);
 		if (ret)
-			DBUG_RETURN(error(ret));
+			{
+			rc= error(ret);
+			goto end;
+			}
 		}
 
 	storageTable->indexScan(indexOrder);
@@ -1618,7 +1646,7 @@ int StorageInterface::read_range_first(c
 
 	for (;;)
 		{
-		int result = index_next(table->record[0]);
+		int result = index_next_int(table->record[0]);
 
 		if (result)
 			{
@@ -1626,23 +1654,43 @@ int StorageInterface::read_range_first(c
 				result = HA_ERR_END_OF_FILE;
 
 			table->status = result;
-			DBUG_RETURN(result);
+			rc= result;
+			goto end;
 			}
-
-		DBUG_RETURN(0);
+		rc= 0;
+		break;
 		}
+end:
+	MYSQL_INDEX_READ_ROW_DONE(rc);
+	DBUG_RETURN(rc);
 }
 
 int StorageInterface::index_first(uchar* buf)
 {
+	int rc;
+	MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
 	storageTable->indexScan(indexOrder);
 
-	return index_next(buf);
+	rc= index_next_int(buf);
+	MYSQL_INDEX_READ_ROW_DONE(rc);
+	return rc;
 }
 
 int StorageInterface::index_next(uchar *buf)
 {
+	int rc;
 	DBUG_ENTER("StorageInterface::index_next");
+	MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
+
+	rc= index_next_int(buf);
+
+	MYSQL_INDEX_READ_ROW_DONE(rc);
+	DBUG_RETURN(rc);
+}
+
+int StorageInterface::index_next_int(uchar *buf)
+{
+	DBUG_ENTER("StorageInterface::index_next_int");
 	ha_statistic_increment(&SSV::ha_read_next_count);
 
 	if (activeBlobs)
@@ -1697,21 +1745,25 @@ int StorageInterface::index_next(uchar *
 
 int StorageInterface::index_next_same(uchar *buf, const uchar *key, uint key_len)
 {
+	int ret= 0;
 	DBUG_ENTER("StorageInterface::index_next_same");
+	MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
 	ha_statistic_increment(&SSV::ha_read_next_count);
 
 	for (;;)
 		{
-		int ret = index_next(buf);
+		ret = index_next_int(buf);
 
 		if (ret)
-			DBUG_RETURN(ret);
+			break;
 
 		int comparison = storageTable->compareKey((const unsigned char*) key, key_len);
 
 		if (comparison == 0)
-			DBUG_RETURN(0);
+			break;
 		}
+	MYSQL_INDEX_READ_ROW_DONE(ret);
+	DBUG_RETURN(ret);
 }
 
 double StorageInterface::scan_time(void)

=== modified file 'storage/falcon/ha_falcon.h'
--- a/storage/falcon/ha_falcon.h	2008-09-16 17:58:49 +0000
+++ b/storage/falcon/ha_falcon.h	2008-12-04 10:05:56 +0000
@@ -134,6 +134,7 @@ public:
 	void			checkBinLog(void);
 	void			mapFields(TABLE *table);
 	void			unmapFields(void);
+	int     		index_next_int(uchar *buf);
 
 	static StorageConnection* getStorageConnection(THD* thd);
 	

=== added file 'storage/falcon/probes_falcon.d'
--- a/storage/falcon/probes_falcon.d	1970-01-01 00:00:00 +0000
+++ b/storage/falcon/probes_falcon.d	2008-12-04 10:05:56 +0000
@@ -0,0 +1,25 @@
+/* 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
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA */
+
+provider falcon {
+  probe open();
+  probe close();
+};
+
+#pragma D attributes Evolving/Evolving/Common provider falcon provider
+#pragma D attributes Evolving/Evolving/Common provider falcon module
+#pragma D attributes Evolving/Evolving/Common provider falcon function
+#pragma D attributes Evolving/Evolving/Common provider falcon name
+#pragma D attributes Evolving/Evolving/Common provider falcon args

=== added file 'storage/falcon/probes_falcon.h'
--- a/storage/falcon/probes_falcon.h	1970-01-01 00:00:00 +0000
+++ b/storage/falcon/probes_falcon.h	2008-12-04 10:05:56 +0000
@@ -0,0 +1,13 @@
+#ifndef PROBES_FALCON_H
+
+#define PROBES_FALCON_H
+
+#include <my_global.h>
+
+#if defined(HAVE_DTRACE) && !defined(DISABLE_DTRACE)
+#include "probes_falcon_dtrace.h"
+#else
+#include "probes_falcon_nodtrace.h"
+#endif
+
+#endif /* PROBES_FALCON_H */

=== added file 'storage/falcon/probes_falcon_nodtrace.h'
--- a/storage/falcon/probes_falcon_nodtrace.h	1970-01-01 00:00:00 +0000
+++ b/storage/falcon/probes_falcon_nodtrace.h	2008-12-04 10:05:56 +0000
@@ -0,0 +1,21 @@
+/*
+ * Generated by dheadgen(1).
+ */
+
+#ifndef	_PROBES_FALCON_D
+#define	_PROBES_FALCON_D
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+#define	FALCON_OPEN()
+#define	FALCON_OPEN_ENABLED() (0)
+#define	FALCON_CLOSE()
+#define	FALCON_CLOSE_ENABLED() (0)
+
+#ifdef  __cplusplus
+}
+#endif
+
+#endif  /* _PROBES_FALCON_D */

=== modified file 'storage/federated/Makefile.am'
--- a/storage/federated/Makefile.am	2008-01-02 13:00:46 +0000
+++ b/storage/federated/Makefile.am	2008-12-04 10:05:56 +0000
@@ -48,5 +48,22 @@ libfederated_a_SOURCES=	ha_federated.cc
 
 
 EXTRA_DIST =		CMakeLists.txt plug.in
+
+if HAVE_DTRACE_DASH_G
+abs_top_srcdir = @abs_top_srcdir@
+libfederated_a_LIBADD = probes_mysql.o
+libfederated_a_DEPENDENCIES = probes_mysql.o dtrace_files dtrace_providers
+CLEANFILES = probes_mysql.o dtrace_files dtrace_providers
+DTRACEFILES = libfederated_a-ha_federated.o
+DTRACEPROVIDER = $(abs_top_srcdir)/sql/probes_mysql.d
+
+dtrace_files:
+	echo $(DTRACEFILES) > $@
+dtrace_providers:
+	echo $(DTRACEPROVIDER) > $@
+probes_mysql.o: $(DTRACEPROVIDER) $(DTRACEFILES)
+	$(DTRACE) $(DTRACEFLAGS) -G -s $< $(DTRACEFILES) -o $@
+endif
+
 # Don't update the files from bitkeeper
 %::SCCS/s.%

=== modified file 'storage/federated/ha_federated.cc'
--- a/storage/federated/ha_federated.cc	2008-08-15 19:58:03 +0000
+++ b/storage/federated/ha_federated.cc	2008-12-04 10:05:56 +0000
@@ -385,6 +385,8 @@
 
 #include <mysql/plugin.h>
 
+#include "probes_mysql.h"
+
 /* Variables for federated share methods */
 static HASH federated_open_tables;              // To track open tables
 pthread_mutex_t federated_mutex;                // To init the hash
@@ -2317,12 +2319,16 @@ int ha_federated::delete_row(const uchar
 int ha_federated::index_read(uchar *buf, const uchar *key,
                              uint key_len, ha_rkey_function find_flag)
 {
+  int rc;
   DBUG_ENTER("ha_federated::index_read");
-
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
+  
   free_result();
-  DBUG_RETURN(index_read_idx_with_result_set(buf, active_index, key,
-                                             key_len, find_flag,
-                                             &stored_result));
+  rc= index_read_idx_with_result_set(buf, active_index, key,
+                                     key_len, find_flag,
+                                     &stored_result);
+  MYSQL_INDEX_READ_ROW_DONE(rc);
+  DBUG_RETURN(rc);
 }
 
 
@@ -2345,13 +2351,18 @@ int ha_federated::index_read_idx(uchar *
   int retval;
   MYSQL_RES *mysql_result;
   DBUG_ENTER("ha_federated::index_read_idx");
-
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
+  
   if ((retval= index_read_idx_with_result_set(buf, index, key,
                                               key_len, find_flag,
                                               &mysql_result)))
+  {
+    MYSQL_INDEX_READ_ROW_DONE(retval);
     DBUG_RETURN(retval);
+  }
   mysql_free_result(mysql_result);
   results.elements--;
+  MYSQL_INDEX_READ_ROW_DONE(0);
   DBUG_RETURN(0);
 }
 
@@ -2473,7 +2484,8 @@ int ha_federated::read_range_first(const
                    sizeof(sql_query_buffer),
                    &my_charset_bin);
   DBUG_ENTER("ha_federated::read_range_first");
-
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
+  
   DBUG_ASSERT(!(start_key == NULL && end_key == NULL));
 
   sql_query.length(0);
@@ -2494,18 +2506,25 @@ int ha_federated::read_range_first(const
     goto error;
   }
   
-  DBUG_RETURN(read_next(table->record[0], stored_result));
+  retval= read_next(table->record[0], stored_result);
+  MYSQL_INDEX_READ_ROW_DONE(retval);
+  DBUG_RETURN(retval);
 
 error:
   table->status= STATUS_NOT_FOUND;
+  MYSQL_INDEX_READ_ROW_DONE(retval);
   DBUG_RETURN(retval);
 }
 
 
 int ha_federated::read_range_next()
 {
+  int rc;
   DBUG_ENTER("ha_federated::read_range_next");
-  DBUG_RETURN(rnd_next(table->record[0]));
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
+  rc= rnd_next_int(table->record[0]);
+  MYSQL_INDEX_READ_ROW_DONE(rc);
+  DBUG_RETURN(rc);
 }
 
 
@@ -2594,7 +2613,6 @@ int ha_federated::index_end(void)
   DBUG_RETURN(0);
 }
 
-
 /*
   This is called for each row of the table scan. When you run out of records
   you should return HA_ERR_END_OF_FILE. Fill buff up with the row information.
@@ -2607,7 +2625,18 @@ int ha_federated::index_end(void)
 
 int ha_federated::rnd_next(uchar *buf)
 {
+  int rc;
   DBUG_ENTER("ha_federated::rnd_next");
+  MYSQL_READ_ROW_START(table_share->db.str, table_share->table_name.str);
+  rc= rnd_next_int(buf);
+  MYSQL_READ_ROW_DONE(rc);
+  DBUG_RETURN(rc);
+}
+
+
+int ha_federated::rnd_next_int(uchar *buf)
+{
+  DBUG_ENTER("ha_federated::rnd_next_int");
 
   if (stored_result == 0)
   {
@@ -2712,7 +2741,9 @@ void ha_federated::position(const uchar 
 int ha_federated::rnd_pos(uchar *buf, uchar *pos)
 {
   MYSQL_RES *result;
+  int rc;
   DBUG_ENTER("ha_federated::rnd_pos");
+  MYSQL_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   
   ha_statistic_increment(&SSV::ha_read_rnd_count);
 
@@ -2723,7 +2754,9 @@ int ha_federated::rnd_pos(uchar *buf, uc
   memcpy_fixed(&result->data_cursor, pos + sizeof(MYSQL_RES *),
                sizeof(MYSQL_ROW_OFFSET));
   /* Read a row. */
-  DBUG_RETURN(read_next(buf, result));
+  rc= read_next(buf, result);
+  MYSQL_READ_ROW_DONE(rc);
+  DBUG_RETURN(rc);
 }
 
 

=== modified file 'storage/federated/ha_federated.h'
--- a/storage/federated/ha_federated.h	2008-08-15 12:18:06 +0000
+++ b/storage/federated/ha_federated.h	2008-12-04 10:05:56 +0000
@@ -237,6 +237,7 @@ public:
   int rnd_init(bool scan);                                      //required
   int rnd_end();
   int rnd_next(uchar *buf);                                      //required
+  int rnd_next_int(uchar *buf);
   int rnd_pos(uchar *buf, uchar *pos);                            //required
   void position(const uchar *record);                            //required
   int info(uint);                                              //required

=== modified file 'storage/heap/Makefile.am'
--- a/storage/heap/Makefile.am	2006-12-31 00:32:21 +0000
+++ b/storage/heap/Makefile.am	2008-12-04 10:05:56 +0000
@@ -51,5 +51,21 @@ libheap_a_SOURCES =	hp_open.c hp_extra.c
 
 EXTRA_DIST =		CMakeLists.txt plug.in
 
+if HAVE_DTRACE_DASH_G
+abs_top_srcdir = @abs_top_srcdir@
+libheap_a_LIBADD = probes_mysql.o
+libheap_a_DEPENDENCIES = probes_mysql.o dtrace_files dtrace_providers
+CLEANFILES = probes_mysql.o dtrace_files dtrace_providers
+DTRACEFILES = ha_heap.o
+DTRACEPROVIDER = $(abs_top_srcdir)/sql/probes_mysql.d
+
+dtrace_files:
+	echo $(DTRACEFILES) > $@
+dtrace_providers:
+	echo $(DTRACEPROVIDER) > $@
+probes_mysql.o: $(DTRACEPROVIDER) $(DTRACEFILES)
+	$(DTRACE) $(DTRACEFLAGS) -G -s $< $(DTRACEFILES) -o $@
+endif
+
 # Don't update the files from bitkeeper
 %::SCCS/s.%

=== modified file 'storage/heap/ha_heap.cc'
--- a/storage/heap/ha_heap.cc	2007-12-14 13:21:37 +0000
+++ b/storage/heap/ha_heap.cc	2008-12-04 10:05:56 +0000
@@ -23,6 +23,7 @@
 #include <mysql/plugin.h>
 #include "ha_heap.h"
 #include "heapdef.h"
+#include "probes_mysql.h"
 
 static handler *heap_create_handler(handlerton *hton,
                                     TABLE_SHARE *table, 
@@ -274,21 +275,25 @@ int ha_heap::index_read_map(uchar *buf, 
                             key_part_map keypart_map,
                             enum ha_rkey_function find_flag)
 {
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   DBUG_ASSERT(inited==INDEX);
   ha_statistic_increment(&SSV::ha_read_key_count);
   int error = heap_rkey(file,buf,active_index, key, keypart_map, find_flag);
   table->status = error ? STATUS_NOT_FOUND : 0;
+  MYSQL_INDEX_READ_ROW_DONE(error);
   return error;
 }
 
 int ha_heap::index_read_last_map(uchar *buf, const uchar *key,
                                  key_part_map keypart_map)
 {
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   DBUG_ASSERT(inited==INDEX);
   ha_statistic_increment(&SSV::ha_read_key_count);
   int error= heap_rkey(file, buf, active_index, key, keypart_map,
 		       HA_READ_PREFIX_LAST);
   table->status= error ? STATUS_NOT_FOUND : 0;
+  MYSQL_INDEX_READ_ROW_DONE(error);
   return error;
 }
 
@@ -296,45 +301,55 @@ int ha_heap::index_read_idx_map(uchar *b
                                 key_part_map keypart_map,
                                 enum ha_rkey_function find_flag)
 {
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   ha_statistic_increment(&SSV::ha_read_key_count);
   int error = heap_rkey(file, buf, index, key, keypart_map, find_flag);
   table->status = error ? STATUS_NOT_FOUND : 0;
+  MYSQL_INDEX_READ_ROW_DONE(error);
   return error;
 }
 
 int ha_heap::index_next(uchar * buf)
 {
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   DBUG_ASSERT(inited==INDEX);
   ha_statistic_increment(&SSV::ha_read_next_count);
   int error=heap_rnext(file,buf);
   table->status=error ? STATUS_NOT_FOUND: 0;
+  MYSQL_INDEX_READ_ROW_DONE(error);
   return error;
 }
 
 int ha_heap::index_prev(uchar * buf)
 {
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   DBUG_ASSERT(inited==INDEX);
   ha_statistic_increment(&SSV::ha_read_prev_count);
   int error=heap_rprev(file,buf);
   table->status=error ? STATUS_NOT_FOUND: 0;
+  MYSQL_INDEX_READ_ROW_DONE(error);
   return error;
 }
 
 int ha_heap::index_first(uchar * buf)
 {
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   DBUG_ASSERT(inited==INDEX);
   ha_statistic_increment(&SSV::ha_read_first_count);
   int error=heap_rfirst(file, buf, active_index);
   table->status=error ? STATUS_NOT_FOUND: 0;
+  MYSQL_INDEX_READ_ROW_DONE(error);
   return error;
 }
 
 int ha_heap::index_last(uchar * buf)
 {
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   DBUG_ASSERT(inited==INDEX);
   ha_statistic_increment(&SSV::ha_read_last_count);
   int error=heap_rlast(file, buf, active_index);
   table->status=error ? STATUS_NOT_FOUND: 0;
+  MYSQL_INDEX_READ_ROW_DONE(error);
   return error;
 }
 
@@ -345,9 +360,11 @@ int ha_heap::rnd_init(bool scan)
 
 int ha_heap::rnd_next(uchar *buf)
 {
+  MYSQL_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   ha_statistic_increment(&SSV::ha_read_rnd_next_count);
   int error=heap_scan(file, buf);
   table->status=error ? STATUS_NOT_FOUND: 0;
+  MYSQL_READ_ROW_DONE(error);
   return error;
 }
 
@@ -355,10 +372,12 @@ int ha_heap::rnd_pos(uchar * buf, uchar 
 {
   int error;
   HEAP_PTR heap_position;
+  MYSQL_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   ha_statistic_increment(&SSV::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;
+  MYSQL_READ_ROW_DONE(error);
   return error;
 }
 

=== modified file 'storage/maria/Makefile.am'
--- a/storage/maria/Makefile.am	2008-06-26 05:18:28 +0000
+++ b/storage/maria/Makefile.am	2008-12-04 10:05:56 +0000
@@ -193,5 +193,21 @@ test:
 test-verbose:
 	HARNESS_VERBOSE=1 perl $(top_srcdir)/unittest/unit.pl run $(unittests)
 
+if HAVE_DTRACE_DASH_G
+abs_top_srcdir = @abs_top_srcdir@
+libmaria_a_LIBADD = probes_mysql.o
+libmaria_a_DEPENDENCIES = probes_mysql.o dtrace_files dtrace_providers
+CLEANFILES += probes_mysql.o dtrace_files dtrace_providers
+DTRACEFILES = ha_maria.o
+DTRACEPROVIDER = $(abs_top_srcdir)/sql/probes_mysql.d
+
+dtrace_files:
+	echo $(DTRACEFILES) > $@
+dtrace_providers:
+	echo $(DTRACEPROVIDER) > $@
+probes_mysql.o: $(DTRACEPROVIDER) $(DTRACEFILES)
+	$(DTRACE) $(DTRACEFLAGS) -G -s $< $(DTRACEFILES) -o $@
+endif
+
 # Don't update the files from bitkeeper
 %::SCCS/s.%

=== modified file 'storage/maria/ha_maria.cc'
--- a/storage/maria/ha_maria.cc	2008-09-04 18:30:34 +0000
+++ b/storage/maria/ha_maria.cc	2008-12-04 10:05:56 +0000
@@ -36,6 +36,8 @@ C_MODE_START
 #include "ma_recovery.h"
 C_MODE_END
 
+#include "probes_mysql.h"
+
 /*
   Note that in future versions, only *transactional* Maria tables can
   rollback, so this flag should be up or down conditionally.
@@ -1876,10 +1878,12 @@ int ha_maria::index_read_map(uchar * buf
 			     key_part_map keypart_map,
 			     enum ha_rkey_function find_flag)
 {
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   DBUG_ASSERT(inited == INDEX);
   ha_statistic_increment(&SSV::ha_read_key_count);
   int error= maria_rkey(file, buf, active_index, key, keypart_map, find_flag);
   table->status= error ? STATUS_NOT_FOUND : 0;
+  MYSQL_INDEX_READ_ROW_DONE(error);
   return error;
 }
 
@@ -1888,9 +1892,11 @@ int ha_maria::index_read_idx_map(uchar *
 				 key_part_map keypart_map,
 				 enum ha_rkey_function find_flag)
 {
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   ha_statistic_increment(&SSV::ha_read_key_count);
   int error= maria_rkey(file, buf, index, key, keypart_map, find_flag);
   table->status= error ? STATUS_NOT_FOUND : 0;
+  MYSQL_INDEX_READ_ROW_DONE(error);
   return error;
 }
 
@@ -1899,51 +1905,61 @@ int ha_maria::index_read_last_map(uchar 
 				  key_part_map keypart_map)
 {
   DBUG_ENTER("ha_maria::index_read_last_map");
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   DBUG_ASSERT(inited == INDEX);
   ha_statistic_increment(&SSV::ha_read_key_count);
   int error= maria_rkey(file, buf, active_index, key, keypart_map,
                         HA_READ_PREFIX_LAST);
   table->status= error ? STATUS_NOT_FOUND : 0;
+  MYSQL_INDEX_READ_ROW_DONE(error);
   DBUG_RETURN(error);
 }
 
 
 int ha_maria::index_next(uchar * buf)
 {
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   DBUG_ASSERT(inited == INDEX);
   ha_statistic_increment(&SSV::ha_read_next_count);
   int error= maria_rnext(file, buf, active_index);
   table->status= error ? STATUS_NOT_FOUND : 0;
+  MYSQL_INDEX_READ_ROW_DONE(error);
   return error;
 }
 
 
 int ha_maria::index_prev(uchar * buf)
 {
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   DBUG_ASSERT(inited == INDEX);
   ha_statistic_increment(&SSV::ha_read_prev_count);
   int error= maria_rprev(file, buf, active_index);
   table->status= error ? STATUS_NOT_FOUND : 0;
+  MYSQL_INDEX_READ_ROW_DONE(error);
   return error;
 }
 
 
 int ha_maria::index_first(uchar * buf)
 {
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   DBUG_ASSERT(inited == INDEX);
   ha_statistic_increment(&SSV::ha_read_first_count);
   int error= maria_rfirst(file, buf, active_index);
   table->status= error ? STATUS_NOT_FOUND : 0;
+  MYSQL_INDEX_READ_ROW_DONE(error);
   return error;
 }
 
 
 int ha_maria::index_last(uchar * buf)
 {
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   DBUG_ASSERT(inited == INDEX);
   ha_statistic_increment(&SSV::ha_read_last_count);
   int error= maria_rlast(file, buf, active_index);
   table->status= error ? STATUS_NOT_FOUND : 0;
+  MYSQL_INDEX_READ_ROW_DONE(error);
   return error;
 }
 
@@ -1953,6 +1969,7 @@ int ha_maria::index_next_same(uchar * bu
                               uint length __attribute__ ((unused)))
 {
   int error;
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   DBUG_ASSERT(inited == INDEX);
   ha_statistic_increment(&SSV::ha_read_next_count);
   /*
@@ -1964,6 +1981,7 @@ int ha_maria::index_next_same(uchar * bu
     error= maria_rnext_same(file,buf);
   } while (error == HA_ERR_RECORD_DELETED);
   table->status= error ? STATUS_NOT_FOUND : 0;
+  MYSQL_INDEX_READ_ROW_DONE(error);
   return error;
 }
 
@@ -1986,9 +2004,11 @@ int ha_maria::rnd_end()
 
 int ha_maria::rnd_next(uchar *buf)
 {
+  MYSQL_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   ha_statistic_increment(&SSV::ha_read_rnd_next_count);
   int error= maria_scan(file, buf);
   table->status= error ? STATUS_NOT_FOUND : 0;
+  MYSQL_READ_ROW_DONE(error);
   return error;
 }
 
@@ -2008,9 +2028,11 @@ int ha_maria::restart_rnd_next(uchar *bu
 
 int ha_maria::rnd_pos(uchar *buf, uchar *pos)
 {
+  MYSQL_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   ha_statistic_increment(&SSV::ha_read_rnd_count);
   int error= maria_rrnd(file, buf, my_get_ptr(pos, ref_length));
   table->status= error ? STATUS_NOT_FOUND : 0;
+  MYSQL_READ_ROW_DONE(error);
   return error;
 }
 

=== modified file 'storage/myisam/Makefile.am'
--- a/storage/myisam/Makefile.am	2008-07-09 07:12:43 +0000
+++ b/storage/myisam/Makefile.am	2008-12-04 10:05:56 +0000
@@ -151,5 +151,20 @@ SUFFIXES = .sh
 	@CHMOD@ +x $@-t
 	@MV@ $@-t $@
 
+if HAVE_DTRACE_DASH_G
+abs_top_srcdir = @abs_top_srcdir@
+libmyisam_a_LIBADD = probes_mysql.o
+libmyisam_a_DEPENDENCIES = probes_mysql.o dtrace_files dtrace_providers
+CLEANFILES += probes_mysql.o dtrace_files dtrace_providers
+DTRACEFILES = ha_myisam.o
+DTRACEPROVIDER = $(abs_top_srcdir)/sql/probes_mysql.d
+
+dtrace_files:
+	echo $(DTRACEFILES) > $@
+dtrace_providers:
+	echo $(DTRACEPROVIDER) > $@
+probes_mysql.o: $(DTRACEPROVIDER) $(DTRACEFILES)
+	$(DTRACE) $(DTRACEFLAGS) -G -s $< $(DTRACEFILES) -o $@
+endif
 # Don't update the files from bitkeeper
 %::SCCS/s.%

=== modified file 'storage/myisam/ha_myisam.cc'
--- a/storage/myisam/ha_myisam.cc	2008-07-09 07:12:43 +0000
+++ b/storage/myisam/ha_myisam.cc	2008-12-04 10:05:56 +0000
@@ -28,6 +28,7 @@
 #include <stdarg.h>
 #include "myisamdef.h"
 #include "rt_index.h"
+#include "probes_mysql.h"
 
 ulong myisam_recover_options= HA_RECOVER_NONE;
 
@@ -1519,10 +1520,12 @@ int ha_myisam::index_read_map(uchar *buf
                               key_part_map keypart_map,
                               enum ha_rkey_function find_flag)
 {
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   DBUG_ASSERT(inited==INDEX);
   ha_statistic_increment(&SSV::ha_read_key_count);
   int error=mi_rkey(file, buf, active_index, key, keypart_map, find_flag);
   table->status=error ? STATUS_NOT_FOUND: 0;
+  MYSQL_INDEX_READ_ROW_DONE(error);
   return error;
 }
 
@@ -1530,9 +1533,11 @@ int ha_myisam::index_read_idx_map(uchar 
                                   key_part_map keypart_map,
                                   enum ha_rkey_function find_flag)
 {
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   ha_statistic_increment(&SSV::ha_read_key_count);
   int error=mi_rkey(file, buf, index, key, keypart_map, find_flag);
   table->status=error ? STATUS_NOT_FOUND: 0;
+  MYSQL_INDEX_READ_ROW_DONE(error);
   return error;
 }
 
@@ -1540,47 +1545,57 @@ int ha_myisam::index_read_last_map(uchar
                                    key_part_map keypart_map)
 {
   DBUG_ENTER("ha_myisam::index_read_last");
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   DBUG_ASSERT(inited==INDEX);
   ha_statistic_increment(&SSV::ha_read_key_count);
   int error=mi_rkey(file, buf, active_index, key, keypart_map,
                     HA_READ_PREFIX_LAST);
   table->status=error ? STATUS_NOT_FOUND: 0;
+  MYSQL_INDEX_READ_ROW_DONE(error);
   DBUG_RETURN(error);
 }
 
 int ha_myisam::index_next(uchar *buf)
 {
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   DBUG_ASSERT(inited==INDEX);
   ha_statistic_increment(&SSV::ha_read_next_count);
   int error=mi_rnext(file,buf,active_index);
   table->status=error ? STATUS_NOT_FOUND: 0;
+  MYSQL_INDEX_READ_ROW_DONE(error);
   return error;
 }
 
 int ha_myisam::index_prev(uchar *buf)
 {
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   DBUG_ASSERT(inited==INDEX);
   ha_statistic_increment(&SSV::ha_read_prev_count);
   int error=mi_rprev(file,buf, active_index);
   table->status=error ? STATUS_NOT_FOUND: 0;
+  MYSQL_INDEX_READ_ROW_DONE(error);
   return error;
 }
 
 int ha_myisam::index_first(uchar *buf)
 {
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   DBUG_ASSERT(inited==INDEX);
   ha_statistic_increment(&SSV::ha_read_first_count);
   int error=mi_rfirst(file, buf, active_index);
   table->status=error ? STATUS_NOT_FOUND: 0;
+  MYSQL_INDEX_READ_ROW_DONE(error);
   return error;
 }
 
 int ha_myisam::index_last(uchar *buf)
 {
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   DBUG_ASSERT(inited==INDEX);
   ha_statistic_increment(&SSV::ha_read_last_count);
   int error=mi_rlast(file, buf, active_index);
   table->status=error ? STATUS_NOT_FOUND: 0;
+  MYSQL_INDEX_READ_ROW_DONE(error);
   return error;
 }
 
@@ -1589,6 +1604,7 @@ int ha_myisam::index_next_same(uchar *bu
 			       uint length __attribute__((unused)))
 {
   int error;
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   DBUG_ASSERT(inited==INDEX);
   ha_statistic_increment(&SSV::ha_read_next_count);
   do
@@ -1596,6 +1612,7 @@ int ha_myisam::index_next_same(uchar *bu
     error= mi_rnext_same(file,buf);
   } while (error == HA_ERR_RECORD_DELETED);
   table->status=error ? STATUS_NOT_FOUND: 0;
+  MYSQL_INDEX_READ_ROW_DONE(error);
   return error;
 }
 
@@ -1634,9 +1651,11 @@ int ha_myisam::rnd_init(bool scan)
 
 int ha_myisam::rnd_next(uchar *buf)
 {
+  MYSQL_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   ha_statistic_increment(&SSV::ha_read_rnd_next_count);
   int error=mi_scan(file, buf);
   table->status=error ? STATUS_NOT_FOUND: 0;
+  MYSQL_READ_ROW_DONE(error);
   return error;
 }
 
@@ -1653,9 +1672,11 @@ int ha_myisam::restart_rnd_next(uchar *b
 
 int ha_myisam::rnd_pos(uchar *buf, uchar *pos)
 {
+  MYSQL_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   ha_statistic_increment(&SSV::ha_read_rnd_count);
   int error=mi_rrnd(file, buf, my_get_ptr(pos,ref_length));
   table->status=error ? STATUS_NOT_FOUND: 0;
+  MYSQL_READ_ROW_DONE(error);
   return error;
 }
 

=== modified file 'storage/myisammrg/Makefile.am'
--- a/storage/myisammrg/Makefile.am	2008-04-25 21:45:58 +0000
+++ b/storage/myisammrg/Makefile.am	2008-12-04 10:05:56 +0000
@@ -40,5 +40,21 @@ libmyisammrg_a_SOURCES = myrg_open.c myr
 
 EXTRA_DIST =		CMakeLists.txt plug.in
 
+if HAVE_DTRACE_DASH_G
+abs_top_srcdir = @abs_top_srcdir@
+libmyisammrg_a_LIBADD = probes_mysql.o
+libmyisammrg_a_DEPENDENCIES = probes_mysql.o dtrace_files dtrace_providers
+CLEANFILES = probes_mysql.o dtrace_files dtrace_providers
+DTRACEFILES = ha_myisammrg.o
+DTRACEPROVIDER = $(abs_top_srcdir)/sql/probes_mysql.d
+
+dtrace_files:
+	echo $(DTRACEFILES) > $@
+dtrace_providers:
+	echo $(DTRACEPROVIDER) > $@
+probes_mysql.o: $(DTRACEPROVIDER) $(DTRACEFILES)
+	$(DTRACE) $(DTRACEFLAGS) -G -s $< $(DTRACEFILES) -o $@
+endif
+
 # Don't update the files from bitkeeper
 %::SCCS/s.%

=== modified file 'storage/myisammrg/ha_myisammrg.cc'
--- a/storage/myisammrg/ha_myisammrg.cc	2008-07-24 10:00:56 +0000
+++ b/storage/myisammrg/ha_myisammrg.cc	2008-12-04 10:05:56 +0000
@@ -96,6 +96,7 @@
 #include "../myisam/ha_myisam.h"
 #include "ha_myisammrg.h"
 #include "myrg_def.h"
+#include "probes_mysql.h"
 
 
 static handler *myisammrg_create_handler(handlerton *hton,
@@ -865,10 +866,12 @@ int ha_myisammrg::index_read_map(uchar *
                                  key_part_map keypart_map,
                                  enum ha_rkey_function find_flag)
 {
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   DBUG_ASSERT(this->file->children_attached);
   ha_statistic_increment(&SSV::ha_read_key_count);
   int error=myrg_rkey(file,buf,active_index, key, keypart_map, find_flag);
   table->status=error ? STATUS_NOT_FOUND: 0;
+  MYSQL_INDEX_READ_ROW_DONE(error);
   return error;
 }
 
@@ -876,57 +879,69 @@ int ha_myisammrg::index_read_idx_map(uch
                                      key_part_map keypart_map,
                                      enum ha_rkey_function find_flag)
 {
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   DBUG_ASSERT(this->file->children_attached);
   ha_statistic_increment(&SSV::ha_read_key_count);
   int error=myrg_rkey(file,buf,index, key, keypart_map, find_flag);
   table->status=error ? STATUS_NOT_FOUND: 0;
+  MYSQL_INDEX_READ_ROW_DONE(error);
   return error;
 }
 
 int ha_myisammrg::index_read_last_map(uchar *buf, const uchar *key,
                                       key_part_map keypart_map)
 {
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   DBUG_ASSERT(this->file->children_attached);
   ha_statistic_increment(&SSV::ha_read_key_count);
   int error=myrg_rkey(file,buf,active_index, key, keypart_map,
 		      HA_READ_PREFIX_LAST);
   table->status=error ? STATUS_NOT_FOUND: 0;
+  MYSQL_INDEX_READ_ROW_DONE(error);
   return error;
 }
 
 int ha_myisammrg::index_next(uchar * buf)
 {
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   DBUG_ASSERT(this->file->children_attached);
   ha_statistic_increment(&SSV::ha_read_next_count);
   int error=myrg_rnext(file,buf,active_index);
   table->status=error ? STATUS_NOT_FOUND: 0;
+  MYSQL_INDEX_READ_ROW_DONE(error);
   return error;
 }
 
 int ha_myisammrg::index_prev(uchar * buf)
 {
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   DBUG_ASSERT(this->file->children_attached);
   ha_statistic_increment(&SSV::ha_read_prev_count);
   int error=myrg_rprev(file,buf, active_index);
   table->status=error ? STATUS_NOT_FOUND: 0;
+  MYSQL_INDEX_READ_ROW_DONE(error);
   return error;
 }
 
 int ha_myisammrg::index_first(uchar * buf)
 {
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   DBUG_ASSERT(this->file->children_attached);
   ha_statistic_increment(&SSV::ha_read_first_count);
   int error=myrg_rfirst(file, buf, active_index);
   table->status=error ? STATUS_NOT_FOUND: 0;
+  MYSQL_INDEX_READ_ROW_DONE(error);
   return error;
 }
 
 int ha_myisammrg::index_last(uchar * buf)
 {
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   DBUG_ASSERT(this->file->children_attached);
   ha_statistic_increment(&SSV::ha_read_last_count);
   int error=myrg_rlast(file, buf, active_index);
   table->status=error ? STATUS_NOT_FOUND: 0;
+  MYSQL_INDEX_READ_ROW_DONE(error);
   return error;
 }
 
@@ -935,6 +950,7 @@ int ha_myisammrg::index_next_same(uchar 
                                   uint length __attribute__((unused)))
 {
   int error;
+  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   DBUG_ASSERT(this->file->children_attached);
   ha_statistic_increment(&SSV::ha_read_next_count);
   do
@@ -942,6 +958,7 @@ int ha_myisammrg::index_next_same(uchar 
     error= myrg_rnext_same(file,buf);
   } while (error == HA_ERR_RECORD_DELETED);
   table->status=error ? STATUS_NOT_FOUND: 0;
+  MYSQL_INDEX_READ_ROW_DONE(error);
   return error;
 }
 
@@ -955,20 +972,24 @@ int ha_myisammrg::rnd_init(bool scan)
 
 int ha_myisammrg::rnd_next(uchar *buf)
 {
+  MYSQL_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   DBUG_ASSERT(this->file->children_attached);
   ha_statistic_increment(&SSV::ha_read_rnd_next_count);
   int error=myrg_rrnd(file, buf, HA_OFFSET_ERROR);
   table->status=error ? STATUS_NOT_FOUND: 0;
+  MYSQL_READ_ROW_DONE(error);
   return error;
 }
 
 
 int ha_myisammrg::rnd_pos(uchar * buf, uchar *pos)
 {
+  MYSQL_READ_ROW_START(table_share->db.str, table_share->table_name.str);
   DBUG_ASSERT(this->file->children_attached);
   ha_statistic_increment(&SSV::ha_read_rnd_count);
   int error=myrg_rrnd(file, buf, my_get_ptr(pos,ref_length));
   table->status=error ? STATUS_NOT_FOUND: 0;
+  MYSQL_READ_ROW_DONE(error);
   return error;
 }
 

Thread
bzr commit into mysql-6.0 branch (alexeyk:2742) Bug#40468Alexey Kopytov4 Dec