Below is the list of changes that have just been committed into a local
5.0 repository of kaa. When kaa does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-09-11 19:44:02+04:00, kaa@polly.(none) +16 -0
WL #3848 "DTrace".
This patch adds basic DTrace support and a few sample probes to server code.
config/ac-macros/dtrace.m4@stripped, 2007-09-11 19:43:58+04:00, kaa@polly.(none) +25 -0
New BitKeeper file ``config/ac-macros/dtrace.m4''
config/ac-macros/dtrace.m4@stripped, 2007-09-11 19:43:58+04:00, kaa@polly.(none) +0 -0
configure.in@stripped, 2007-09-11 19:43:57+04:00, kaa@polly.(none) +2 -0
Added DTrace-related macros.
include/my_trace.h@stripped, 2007-09-11 19:43:58+04:00, kaa@polly.(none) +86 -0
New BitKeeper file ``include/my_trace.h''
include/my_trace.h@stripped, 2007-09-11 19:43:58+04:00, kaa@polly.(none) +0 -0
myisam/mi_locking.c@stripped, 2007-09-11 19:43:57+04:00, kaa@polly.(none) +9 -0
Added DTrace probes for MyISAM table locks.
mysys/Makefile.am@stripped, 2007-09-11 19:43:57+04:00, kaa@polly.(none) +14 -2
Added support for DTrace.
mysys/my_pread.c@stripped, 2007-09-11 19:43:57+04:00, kaa@polly.(none) +6 -0
Added DTrace probes for I/O functions in mysys.
mysys/my_read.c@stripped, 2007-09-11 19:43:57+04:00, kaa@polly.(none) +8 -0
Added DTrace probes for I/O functions in mysys.
mysys/my_trace.c@stripped, 2007-09-11 19:43:58+04:00, kaa@polly.(none) +131 -0
New BitKeeper file ``mysys/my_trace.c''
mysys/my_trace.c@stripped, 2007-09-11 19:43:58+04:00, kaa@polly.(none) +0 -0
mysys/my_write.c@stripped, 2007-09-11 19:43:57+04:00, kaa@polly.(none) +5 -1
Added DTrace probes for I/O functions in mysys.
sql/mysqld.cc@stripped, 2007-09-11 19:43:57+04:00, kaa@polly.(none) +5 -1
Added DTrace probes for threads and connections.
sql/net_serv.cc@stripped, 2007-09-11 19:43:57+04:00, kaa@polly.(none) +41 -7
Added DTraces probes for network operations.
sql/sp.cc@stripped, 2007-09-11 19:43:57+04:00, kaa@polly.(none) +6 -2
Added DTrace probes around MYSQLparse().
sql/sql_parse.cc@stripped, 2007-09-11 19:43:57+04:00, kaa@polly.(none) +18 -5
Added DTrace probes around MYSQLparse().
sql/sql_prepare.cc@stripped, 2007-09-11 19:43:58+04:00, kaa@polly.(none) +5 -1
Added DTrace probes for parser and query execution.
sql/sql_trigger.cc@stripped, 2007-09-11 19:43:58+04:00, kaa@polly.(none) +8 -2
Added DTrace probes for query parser.
sql/sql_view.cc@stripped, 2007-09-11 19:43:58+04:00, kaa@polly.(none) +3 -0
Added DTrace probes for query parser.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: kaa
# Host: polly.(none)
# Root: /home/kaa/src/maint/dtrace/my50-dtrace
--- 1.441/configure.in 2007-04-26 18:06:40 +04:00
+++ 1.442/configure.in 2007-09-11 19:43:57 +04:00
@@ -44,6 +44,7 @@ sinclude(config/ac-macros/alloca.m4)
sinclude(config/ac-macros/check_cpu.m4)
sinclude(config/ac-macros/character_sets.m4)
sinclude(config/ac-macros/compiler_flag.m4)
+sinclude(config/ac-macros/dtrace.m4)
sinclude(config/ac-macros/ha_archive.m4)
sinclude(config/ac-macros/ha_berkeley.m4)
sinclude(config/ac-macros/ha_blackhole.m4)
@@ -2521,6 +2522,7 @@ AC_SUBST(readline_h_ln_cmd)
MYSQL_CHECK_BIG_TABLES
MYSQL_CHECK_MAX_INDEXES
+MYSQL_CHECK_DTRACE
MYSQL_CHECK_BDB
MYSQL_CHECK_INNODB
MYSQL_CHECK_EXAMPLEDB
--- 1.45/myisam/mi_locking.c 2007-01-03 10:52:44 +03:00
+++ 1.46/myisam/mi_locking.c 2007-09-11 19:43:57 +04:00
@@ -22,6 +22,8 @@
#include "myisamdef.h"
+#include <my_trace.h>
+
/* lock table by F_UNLCK, F_RDLCK or F_WRLCK */
int mi_lock_database(MI_INFO *info, int lock_type)
@@ -55,6 +57,7 @@ int mi_lock_database(MI_INFO *info, int
{
switch (lock_type) {
case F_UNLCK:
+ MY_TRACE1(myisam__unlock__start, info->filename);
if (info->lock_type == F_RDLCK)
count= --share->r_locks;
else
@@ -124,8 +127,10 @@ int mi_lock_database(MI_INFO *info, int
}
info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED);
info->lock_type= F_UNLCK;
+ MY_TRACE1(myisam__unlock__stop, info->filename);
break;
case F_RDLCK:
+ MY_TRACE1(myisam__rdlock__start, info->filename);
if (info->lock_type == F_WRLCK)
{
/*
@@ -147,6 +152,7 @@ int mi_lock_database(MI_INFO *info, int
share->w_locks--;
share->r_locks++;
info->lock_type=lock_type;
+ MY_TRACE1(myisam__rdlock__stop, info->filename);
break;
}
if (!share->r_locks && !share->w_locks)
@@ -170,8 +176,10 @@ int mi_lock_database(MI_INFO *info, int
share->r_locks++;
share->tot_locks++;
info->lock_type=lock_type;
+ MY_TRACE1(myisam__rdlock__stop, info->filename);
break;
case F_WRLCK:
+ MY_TRACE1(myisam__wrlock__start, info->filename);
if (info->lock_type == F_RDLCK)
{ /* Change READONLY to RW */
if (share->r_locks == 1)
@@ -218,6 +226,7 @@ int mi_lock_database(MI_INFO *info, int
info->invalidator=info->s->invalidator;
share->w_locks++;
share->tot_locks++;
+ MY_TRACE1(myisam__wrlock__stop, info->filename);
break;
default:
break; /* Impossible */
--- 1.76/mysys/Makefile.am 2007-03-12 16:52:30 +03:00
+++ 1.77/mysys/Makefile.am 2007-09-11 19:43:57 +04:00
@@ -55,10 +55,10 @@ libmysys_a_SOURCES = my_init.c my_get
my_gethostbyname.c rijndael.c my_aes.c sha1.c \
my_handler.c my_netware.c my_largepage.c \
my_memmem.c \
- my_windac.c my_access.c base64.c my_libwrap.c
+ my_windac.c my_access.c base64.c my_libwrap.c my_trace.c
EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \
thr_mutex.c thr_rwlock.c mf_soundex.c my_conio.c \
- my_wincond.c my_winthread.c CMakeLists.txt
+ my_wincond.c my_winthread.c CMakeLists.txt mysqlprovider.d
libmysys_a_LIBADD = @THREAD_LOBJECTS@
# test_dir_DEPENDENCIES= $(LIBRARIES)
# testhash_DEPENDENCIES= $(LIBRARIES)
@@ -75,6 +75,18 @@ DEFS = -DDEFAULT_BASEDIR=\"$(prefix)\"
@DEFS@
libmysys_a_DEPENDENCIES= @THREAD_LOBJECTS@
+
+if HAVE_DTRACE
+libmysys.a: $(libmysys_a_OBJECTS) $(libmysys_a_DEPENDENCIES) @dtrace_obj@
+ -rm -f libmysys.a
+ $(libmysys_a_AR) libmysys.a @dtrace_obj@ $(libmysys_a_OBJECTS) $(libmysys_a_LIBADD)
+ $(RANLIB) libmysys.a
+@dtrace_obj@: my_trace.o mysqlprovider.d
+ dtrace -o tmp_dtrace.o -G -s mysqlprovider.d my_trace.o
+ ld -r -o @dtrace_obj@ tmp_dtrace.o my_trace.o
+ -rm -f tmp_dtrace.o
+endif
+
# I hope this always does the right thing. Otherwise this is only test programs
FLAGS=$(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) @NOINST_LDFLAGS@
--- 1.14/mysys/my_pread.c 2007-03-28 21:46:36 +04:00
+++ 1.15/mysys/my_pread.c 2007-09-11 19:43:57 +04:00
@@ -19,6 +19,7 @@
#ifdef HAVE_PREAD
#include <unistd.h>
#endif
+#include <my_trace.h>
/* Read a chunk of bytes from a file */
@@ -31,6 +32,7 @@ uint my_pread(File Filedes, byte *Buffer
DBUG_PRINT("my",("Fd: %d Seek: %lu Buffer: 0x%lx Count: %u MyFlags: %d",
Filedes, (ulong) offset, (long) Buffer, Count, MyFlags));
+ MY_TRACE1(disk__read__start, Filedes);
for (;;)
{
#ifndef __WIN__
@@ -70,6 +72,7 @@ uint my_pread(File Filedes, byte *Buffer
if ((int) readbytes == -1 || (MyFlags & (MY_FNABP | MY_NABP)))
DBUG_RETURN(MY_FILE_ERROR); /* Return with error */
}
+ MY_TRACE2(disk__read__stop, Filedes, readbytes);
if (MyFlags & (MY_NABP | MY_FNABP))
DBUG_RETURN(0); /* Read went ok; Return 0 */
DBUG_RETURN(readbytes); /* purecov: inspected */
@@ -89,6 +92,8 @@ uint my_pwrite(int Filedes, const byte *
Filedes, (ulong) offset, (long) Buffer, Count, MyFlags));
errors=0; written=0L;
+ MY_TRACE1(disk__write__start, Filedes);
+
for (;;)
{
#ifndef HAVE_PREAD
@@ -143,6 +148,7 @@ uint my_pwrite(int Filedes, const byte *
else
break; /* Return bytes written */
}
+ MY_TRACE2(disk__write__stop, Filedes, writenbytes + writenbytes);
if (MyFlags & (MY_NABP | MY_FNABP))
DBUG_RETURN(0); /* Want only errors */
DBUG_RETURN(writenbytes+written); /* purecov: inspected */
--- 1.17/mysys/my_read.c 2007-03-28 21:46:36 +04:00
+++ 1.18/mysys/my_read.c 2007-09-11 19:43:57 +04:00
@@ -16,6 +16,7 @@
#include "mysys_priv.h"
#include "mysys_err.h"
#include <errno.h>
+#include <my_trace.h>
/*
@@ -41,6 +42,8 @@ uint my_read(File Filedes, byte *Buffer,
Filedes, (long) Buffer, Count, MyFlags));
save_count= Count;
+ MY_TRACE1(disk__read__start, Filedes);
+
for (;;)
{
errno= 0; /* Linux doesn't reset this */
@@ -68,7 +71,10 @@ uint my_read(File Filedes, byte *Buffer,
}
if ((int) readbytes == -1 ||
((MyFlags & (MY_FNABP | MY_NABP)) && !(MyFlags & MY_FULL_IO)))
+ {
+ MY_TRACE2(disk__read__stop, Filedes, 0);
DBUG_RETURN(MY_FILE_ERROR); /* Return with error */
+ }
if (readbytes > 0 && (MyFlags & MY_FULL_IO))
{
Buffer+= readbytes;
@@ -77,6 +83,8 @@ uint my_read(File Filedes, byte *Buffer,
}
}
+ MY_TRACE2(disk__read__stop, Filedes, save_count);
+
if (MyFlags & (MY_NABP | MY_FNABP))
readbytes= 0; /* Ok on read */
else if (MyFlags & MY_FULL_IO)
--- 1.15/mysys/my_write.c 2007-03-28 20:01:08 +04:00
+++ 1.16/mysys/my_write.c 2007-09-11 19:43:57 +04:00
@@ -16,7 +16,7 @@
#include "mysys_priv.h"
#include "mysys_err.h"
#include <errno.h>
-
+#include <my_trace.h>
/* Write a chunk of bytes to a file */
@@ -29,6 +29,8 @@ uint my_write(int Filedes, const byte *B
Filedes, (long) Buffer, Count, MyFlags));
errors=0; written=0L;
+ MY_TRACE1(disk__write__start, Filedes);
+
for (;;)
{
if ((writenbytes = (uint) write(Filedes, Buffer, Count)) == Count)
@@ -83,11 +85,13 @@ uint my_write(int Filedes, const byte *B
my_error(EE_WRITE, MYF(ME_BELL+ME_WAITTANG),
my_filename(Filedes),my_errno);
}
+ MY_TRACE2(disk__write__stop, Filedes, MY_FILE_ERROR);
DBUG_RETURN(MY_FILE_ERROR); /* Error on read */
}
else
break; /* Return bytes written */
}
+ MY_TRACE2(disk__write__stop, Filedes, writenbytes + written);
if (MyFlags & (MY_NABP | MY_FNABP))
DBUG_RETURN(0); /* Want only errors */
DBUG_RETURN(writenbytes+written);
--- 1.609/sql/mysqld.cc 2007-05-02 16:25:09 +04:00
+++ 1.610/sql/mysqld.cc 2007-09-11 19:43:57 +04:00
@@ -33,6 +33,8 @@
#include "ha_ndbcluster.h"
#endif
+#include <my_trace.h>
+
#ifdef HAVE_INNOBASE_DB
#define OPT_INNODB_DEFAULT 1
#else
@@ -1637,6 +1639,7 @@ void close_connection(THD *thd, uint err
}
if (lock)
(void) pthread_mutex_unlock(&LOCK_thread_count);
+ MY_TRACE1(connection__closed, thd->thread_id);
DBUG_VOID_RETURN;
}
#endif /* EMBEDDED_LIBRARY */
@@ -1707,6 +1710,7 @@ void end_thread(THD *thd, bool put_in_ca
#endif
{
my_thread_end();
+ MY_TRACE1(thread__closed, thd->thread_id);
pthread_exit(0);
}
DBUG_VOID_RETURN;
@@ -3432,7 +3436,6 @@ int main(int argc, char **argv)
/* ^^^ Nothing should be before this line! */
DEBUGGER_OFF;
-
/* Set signal used to kill MySQL */
#if defined(SIGUSR2)
thr_kill_signal= thd_lib_detected == THD_LIB_LT ? SIGINT : SIGUSR2;
@@ -4050,6 +4053,7 @@ static void create_new_thread(THD *thd)
(void) pthread_mutex_unlock(&LOCK_thread_count);
}
+ MY_TRACE1(thread__created, thd->thread_id);
DBUG_PRINT("info",("Thread created"));
DBUG_VOID_RETURN;
}
--- 1.100/sql/net_serv.cc 2007-03-28 21:46:37 +04:00
+++ 1.101/sql/net_serv.cc 2007-09-11 19:43:57 +04:00
@@ -50,6 +50,7 @@
#include <violite.h>
#include <signal.h>
#include <errno.h>
+#include <my_trace.h>
#ifdef __NETWARE__
#include <sys/select.h>
@@ -369,9 +370,13 @@ my_bool net_flush(NET *net)
my_bool
my_net_write(NET *net,const char *packet,ulong len)
{
+ my_bool rc;
uchar buff[NET_HEADER_SIZE];
if (unlikely(!net->vio)) /* nowhere to write */
return 0;
+#ifdef MYSQL_SERVER
+ MY_TRACE1(net__write__start, len);
+#endif
/*
Big packets are handled by splitting them in packets of MAX_PACKET_LENGTH
length. The last packet is always a packet that is < MAX_PACKET_LENGTH.
@@ -383,8 +388,13 @@ my_net_write(NET *net,const char *packet
int3store(buff, z_size);
buff[3]= (uchar) net->pkt_nr++;
if (net_write_buff(net, (char*) buff, NET_HEADER_SIZE) ||
- net_write_buff(net, packet, z_size))
+ net_write_buff(net, packet, z_size))
+ {
+#ifdef MYSQL_SERVER
+ MY_TRACE1(net__write__stop, 1);
+#endif
return 1;
+ }
packet += z_size;
len-= z_size;
}
@@ -392,11 +402,20 @@ my_net_write(NET *net,const char *packet
int3store(buff,len);
buff[3]= (uchar) net->pkt_nr++;
if (net_write_buff(net,(char*) buff,NET_HEADER_SIZE))
+ {
+#ifdef MYSQL_SERVER
+ MY_TRACE1(net__write__stop, 1);
+#endif
return 1;
+ }
#ifndef DEBUG_DATA_PACKETS
DBUG_DUMP("packet_header",(char*) buff,NET_HEADER_SIZE);
#endif
- return test(net_write_buff(net,packet,len));
+ rc= test(net_write_buff(net,packet,len));
+#ifdef MYSQL_SERVER
+ MY_TRACE1(net__write__stop, rc);
+#endif
+ return rc;
}
/*
@@ -984,6 +1003,9 @@ my_net_read(NET *net)
{
ulong len,complen;
+#ifdef MYSQL_SERVER
+ MY_TRACE(net__read__start);
+#endif
#ifdef HAVE_COMPRESS
if (!net->compress)
{
@@ -1007,6 +1029,9 @@ my_net_read(NET *net)
net->read_pos = net->buff + net->where_b;
if (len != packet_error)
net->read_pos[len]=0; /* Safeguard for mysql_use_result */
+#ifdef MYSQL_SERVER
+ MY_TRACE1(net__read__stop, len);
+#endif
return len;
#ifdef HAVE_COMPRESS
}
@@ -1090,16 +1115,22 @@ my_net_read(NET *net)
net->where_b=buf_length;
if ((packet_len = my_real_read(net,&complen)) == packet_error)
- return packet_error;
+ {
+#ifdef MYSQL_SERVER
+ MY_TRACE1(net__read__stop, packet_error);
+#endif
+ return packet_error;
+ }
if (my_uncompress((byte*) net->buff + net->where_b, &packet_len,
&complen))
{
- net->error= 2; /* caller will close socket */
- net->report_error= 1;
+ net->error= 2; /* caller will close socket */
+ net->report_error= 1;
#ifdef MYSQL_SERVER
- net->last_errno=ER_NET_UNCOMPRESS_ERROR;
+ net->last_errno=ER_NET_UNCOMPRESS_ERROR;
+ MY_TRACE1(net__read__stop, packet_error);
#endif
- return packet_error;
+ return packet_error;
}
buf_length+=packet_len;
}
@@ -1113,6 +1144,9 @@ my_net_read(NET *net)
net->read_pos[len]=0; /* Safeguard for mysql_use_result */
}
#endif /* HAVE_COMPRESS */
+#ifdef MYSQL_SERVER
+ MY_TRACE1(net__read__stop, len);
+#endif
return len;
}
--- 1.618/sql/sql_parse.cc 2007-04-24 13:08:00 +04:00
+++ 1.619/sql/sql_parse.cc 2007-09-11 19:43:57 +04:00
@@ -20,6 +20,7 @@
#include <m_ctype.h>
#include <myisam.h>
#include <my_dir.h>
+#include <my_trace.h>
#ifdef HAVE_INNOBASE_DB
#include "ha_innodb.h"
@@ -1093,6 +1094,8 @@ pthread_handler_t handle_one_connection(
pthread_detach_this_thread();
+ MY_TRACE1(connection__created, thd->thread_id);
+
#if !defined( __WIN__) && !defined(OS2) // Win32 calls this in pthread_create
/* The following calls needs to be done before we call DBUG_ macros */
if (!(test_flags & TEST_NO_THREADS) & my_thread_init())
@@ -5976,6 +5979,7 @@ void mysql_init_multi_delete(LEX *lex)
void mysql_parse(THD *thd, char *inBuf, uint length)
{
+ int rc;
DBUG_ENTER("mysql_parse");
DBUG_EXECUTE_IF("parser_debug", turn_parser_debug_on(););
@@ -5987,8 +5991,11 @@ void mysql_parse(THD *thd, char *inBuf,
sp_cache_flush_obsolete(&thd->sp_proc_cache);
sp_cache_flush_obsolete(&thd->sp_func_cache);
-
- if (!MYSQLparse((void *)thd) && ! thd->is_fatal_error)
+
+ MY_TRACE1(query__parse__start, thd->query);
+ rc= MYSQLparse((void *)thd);
+ MY_TRACE1(query__parse__stop, thd->query);
+ if (!rc && ! thd->is_fatal_error)
{
#ifndef NO_EMBEDDED_ACCESS_CHECKS
if (mqh_used && thd->user_connect &&
@@ -6015,8 +6022,10 @@ void mysql_parse(THD *thd, char *inBuf,
(thd->query_length= (ulong)(lex->found_semicolon - thd->query)))
thd->query_length--;
/* Actually execute the query */
- mysql_execute_command(thd);
- query_cache_end_of_result(thd);
+ MY_TRACE1(query__execute__start, thd->query);
+ mysql_execute_command(thd);
+ MY_TRACE1(query__execute__stop, thd->query);
+ query_cache_end_of_result(thd);
}
}
}
@@ -6057,10 +6066,14 @@ bool mysql_test_parse_for_slave(THD *thd
{
LEX *lex= thd->lex;
bool error= 0;
+ int rc;
DBUG_ENTER("mysql_test_parse_for_slave");
mysql_init_query(thd, (uchar*) inBuf, length);
- if (!MYSQLparse((void*) thd) && ! thd->is_fatal_error &&
+ MY_TRACE1(query__parse__start, thd->query);
+ rc= MYSQLparse((void*) thd);
+ MY_TRACE1(query__parse__stop, thd->query);
+ if (!rc && ! thd->is_fatal_error &&
all_tables_not_ok(thd,(TABLE_LIST*) lex->select_lex.table_list.first))
error= 1; /* Ignore question */
thd->end_statement();
--- 1.109/sql/sql_view.cc 2007-04-21 02:36:15 +04:00
+++ 1.110/sql/sql_view.cc 2007-09-11 19:43:58 +04:00
@@ -21,6 +21,7 @@
#include "sp.h"
#include "sp_head.h"
#include "sp_cache.h"
+#include <my_trace.h>
#define MD5_BUFF_LENGTH 33
@@ -1017,7 +1018,9 @@ bool mysql_make_view(THD *thd, File_pars
MODE_IGNORE_SPACE | MODE_NO_BACKSLASH_ESCAPES);
CHARSET_INFO *save_cs= thd->variables.character_set_client;
thd->variables.character_set_client= system_charset_info;
+ MY_TRACE1(query__parse__start, thd->query);
res= MYSQLparse((void *)thd);
+ MY_TRACE1(query__parse__stop, thd->query);
if ((old_lex->sql_command == SQLCOM_SHOW_FIELDS) ||
(old_lex->sql_command == SQLCOM_SHOW_CREATE))
--- 1.65/sql/sql_trigger.cc 2007-03-07 12:24:42 +03:00
+++ 1.66/sql/sql_trigger.cc 2007-09-11 19:43:58 +04:00
@@ -19,6 +19,7 @@
#include "sp_head.h"
#include "sql_trigger.h"
#include "parse_file.h"
+#include <my_trace.h>
static const LEX_STRING triggers_file_type=
{(char *) STRING_WITH_LEN("TRIGGERS")};
@@ -976,12 +977,17 @@ bool Table_triggers_list::check_n_load(T
{
trg_sql_mode= itm++;
LEX_STRING *trg_definer= it_definer++;
+ int rc;
thd->variables.sql_mode= (ulong)*trg_sql_mode;
lex_start(thd, (uchar*)trg_create_str->str, trg_create_str->length);
- thd->spcont= 0;
- if (MYSQLparse((void *)thd) || thd->is_fatal_error)
+ thd->spcont= 0;
+ MY_TRACE1(query__parse__start, thd->query);
+ rc= MYSQLparse((void *)thd);
+ MY_TRACE1(query__parse__stop, thd->query);
+
+ if (rc || thd->is_fatal_error)
{
/* Currently sphead is always deleted in case of a parse error */
DBUG_ASSERT(lex.sphead == 0);
--- New file ---
+++ config/ac-macros/dtrace.m4 07/09/11 19:43:58
dnl ---------------------------------------------------------------------------
dnl Macro: MYSQL_CHECK_DTRACE
dnl Sets HAVE_DTRACE if --enable-dtrace is used and the target platform
dnl has DTrace support.
dnl ---------------------------------------------------------------------------
AC_DEFUN([MYSQL_CHECK_DTRACE], [
AC_CHECK_HEADER(sys/sdt.h)
AC_MSG_CHECKING([if DTrace support will be enabled])
AC_ARG_ENABLE(dtrace,
AC_HELP_STRING([--enable-dtrace], [Enable DTrace support]),
[enable_dtrace=$enableval])
if test "$enable_dtrace" == "yes" -a "$ac_cv_header_sys_sdt_h" == "yes"; then
AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_DTRACE], [1], [DTrace support])
dtrace_obj="my_dtrace.$OBJEXT"
else
dtrace_obj=""
AC_MSG_RESULT([no])
fi
AC_SUBST(dtrace_obj)
AM_CONDITIONAL([HAVE_DTRACE], [ test "$enable_dtrace" == "yes" ])
])
--- New file ---
+++ include/my_trace.h 07/09/11 19:43:58
/* Copyright (C) 2007 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 */
#ifndef _my_trace_h
#define _my_trace_h
#ifdef __cplusplus
extern "C" {
#endif
#include <my_global.h>
#ifdef HAVE_DTRACE
#define HAVE_MY_TRACE
#include <sys/sdt.h>
#define MY_TRACE(name) \
my_trace_##name()
#define MY_TRACE1(name, arg1) \
my_trace_##name(arg1)
#define MY_TRACE2(name, arg1, arg2) \
my_trace_##name(arg1, arg2)
#define MY_TRACE3(name, arg1, arg2, arg3) \
my_trace_##name(arg1, arg2, arg3)
#define MY_TRACE4(name, arg1, arg2, arg3, arg4) \
my_trace_##name(arg1, arg2, arg3, arg4)
#define MY_TRACE5(name, arg1, arg2, arg3, arg4, arg5) \
my_trace_##name(arg1, arg2, arg3, arg4, arg5)
extern void my_trace_myisam__wrlock__start(const char *file);
extern void my_trace_myisam__wrlock__stop(const char *file);
extern void my_trace_myisam__rdlock__start(const char *file);
extern void my_trace_myisam__rdlock__stop(const char *file);
extern void my_trace_myisam__unlock__start(const char *file);
extern void my_trace_myisam__unlock__stop(const char *file);
extern void my_trace_disk__read__start(int);
extern void my_trace_disk__read__stop(int, ulong);
extern void my_trace_disk__write__start(int);
extern void my_trace_disk__write__stop(int, ulong);
extern void my_trace_net__write__start(ulong);
extern void my_trace_net__write__stop(char);
extern void my_trace_net__read__start(void);
extern void my_trace_net__read__stop(ulong);
extern void my_trace_query__parse__start(const char *query);
extern void my_trace_query__parse__stop(const char *query);
extern void my_trace_query__execute__start(const char *query);
extern void my_trace_query__execute__stop(const char *query);
extern void my_trace_thread__created(ulong);
extern void my_trace_thread__closed(ulong);
extern void my_trace_connection__created(ulong);
extern void my_trace_connection__closed(ulong);
#else /* HAVE_DTRACE */
#define MY_TRACE(name)
#define MY_TRACE1(name, arg1)
#define MY_TRACE2(name, arg1, arg2)
#define MY_TRACE3(name, arg1, arg2, arg3)
#define MY_TRACE4(name, arg1, arg2, arg3, arg4)
#define MY_TRACE5(name, arg1, arg2, arg3, arg4, arg5)
#endif /* HAVE_DTRACE */
#ifdef __cplusplus
}
#endif
#endif /* _my_trace_h */
--- New file ---
+++ mysys/my_trace.c 07/09/11 19:43:58
/* Copyright (C) 2007 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 */
#include "mysys_priv.h"
#include <my_trace.h>
#ifdef HAVE_DTRACE
void my_trace_myisam__wrlock__start(const char *file)
{
DTRACE_PROBE1(mysql, myisam__wrlock__start, file);
}
void my_trace_myisam__wrlock__stop(const char *file)
{
DTRACE_PROBE1(mysql, myisam__wrlock__stop, file);
}
void my_trace_myisam__rdlock__start(const char *file)
{
DTRACE_PROBE1(mysql, myisam__rdlock__start, file);
}
void my_trace_myisam__rdlock__stop(const char *file)
{
DTRACE_PROBE1(mysql, myisam__rdlock__stop, file);
}
void my_trace_myisam__unlock__start(const char *file)
{
DTRACE_PROBE1(mysql, myisam__unlock__start, file);
}
void my_trace_myisam__unlock__stop(const char *file)
{
DTRACE_PROBE1(mysql, myisam__unlock__stop, file);
}
void my_trace_disk__read__start(int fd)
{
DTRACE_PROBE1(mysql, disk__read__start, my_filename(fd));
}
void my_trace_disk__read__stop(int fd, ulong bytes)
{
DTRACE_PROBE2(mysql, disk__read__stop, my_filename(fd), bytes);
}
void my_trace_disk__write__start(int fd)
{
DTRACE_PROBE1(mysql, disk__write__start, my_filename(fd));
}
void my_trace_disk__write__stop(int fd, ulong bytes)
{
DTRACE_PROBE2(mysql, disk__write__stop, my_filename(fd), bytes);
}
void my_trace_net__write__start(ulong len)
{
DTRACE_PROBE1(mysql, net__write__start, len);
}
void my_trace_net__write__stop(char rc)
{
DTRACE_PROBE1(mysql, net__write__stop, rc)
}
void my_trace_net__read__start(void)
{
DTRACE_PROBE(mysql, net__read__start);
}
void my_trace_net__read__stop(ulong len)
{
DTRACE_PROBE1(mysql, net__read__stop, len);
}
void my_trace_query__parse__start(const char *query)
{
DTRACE_PROBE1(mysql, query__parse__start, query);
}
void my_trace_query__parse__stop(const char *query)
{
DTRACE_PROBE1(mysql, query__parse__stop, query);
}
void my_trace_query__execute__start(const char *query)
{
DTRACE_PROBE1(mysql, query__execute__start, query);
}
void my_trace_query__execute__stop(const char *query)
{
DTRACE_PROBE1(mysql, query__execute__stop, query);
}
void my_trace_thread__created(ulong id)
{
DTRACE_PROBE1(mysql, thread__created, id);
}
void my_trace_thread__closed(ulong id)
{
DTRACE_PROBE1(mysql, thread__closed, id);
}
void my_trace_connection__created(ulong id)
{
DTRACE_PROBE1(mysql, connection__created, id);
}
void my_trace_connection__closed(ulong id)
{
DTRACE_PROBE1(mysql, connection__closed, id);
}
#endif /* HAVE_DTRACE */
--- 1.129/sql/sp.cc 2007-04-12 13:46:07 +04:00
+++ 1.130/sql/sp.cc 2007-09-11 19:43:57 +04:00
@@ -21,6 +21,7 @@
#include "sql_trigger.h"
#include <my_user.h>
+#include <my_trace.h>
static bool
create_string(THD *thd, String *buf,
@@ -399,7 +400,7 @@ db_load_routine(THD *thd, int type, sp_n
LEX_STRING_WITH_INIT definer_host_name(definer_host_name_holder,
HOSTNAME_LENGTH);
- int ret;
+ int ret, rc;
thd->variables.sql_mode= sql_mode;
thd->variables.select_limit= HA_POS_ERROR;
@@ -437,7 +438,10 @@ db_load_routine(THD *thd, int type, sp_n
lex_start(thd, (uchar*)defstr.c_ptr(), defstr.length());
thd->spcont= 0;
- if (MYSQLparse(thd) || thd->is_fatal_error || newlex.sphead == NULL)
+ MY_TRACE1(query__parse__start, thd->query);
+ rc= MYSQLparse(thd);
+ MY_TRACE1(query__parse__stop, thd->query);
+ if (rc || thd->is_fatal_error || newlex.sphead == NULL)
{
sp_head *sp= newlex.sphead;
--- 1.198/sql/sql_prepare.cc 2007-03-28 21:46:37 +04:00
+++ 1.199/sql/sql_prepare.cc 2007-09-11 19:43:58 +04:00
@@ -80,6 +80,7 @@ When one supplies long data for a placeh
#else
#include <mysql_com.h>
#endif
+#include <my_trace.h>
/* A result class used to send cursor rows using the binary protocol. */
@@ -2264,9 +2265,10 @@ void mysql_stmt_execute(THD *thd, char *
statement.
*/
DBUG_ASSERT(thd->free_list == NULL);
-
+ MY_TRACE1(query__execute__start, stmt->query);
error= stmt->execute(&expanded_query,
test(flags & (ulong) CURSOR_TYPE_READ_ONLY));
+ MY_TRACE1(query__execute__stop, stmt->query);
if (!(specialflag & SPECIAL_NO_PRIOR))
my_pthread_setprio(pthread_self(), WAIT_PRIOR);
if (error == 0)
@@ -2803,8 +2805,10 @@ bool Prepared_statement::prepare(const c
lex->safe_to_cache_query= FALSE;
lex->stmt_prepare_mode= TRUE;
+ MY_TRACE1(query__parse__start, thd->query);
error= MYSQLparse((void *)thd) || thd->is_fatal_error ||
thd->net.report_error || init_param_array(this);
+ MY_TRACE1(query__parse__stop, thd->query);
/*
While doing context analysis of the query (in check_prepared_statement)
| Thread |
|---|
| • bk commit into 5.0 tree (kaa:1.2478) | Alexey Kopytov | 11 Sep |