1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Prevent bugs by making DBUG_* expressions syntactically equivalent

to a single statement.
---
Bug#24795: SHOW PROFILE

Profiling is only partially functional on some architectures.  Where 
there is no getrusage() system call, presently Null values are 
returned where it would be required.  Notably, Windows needs some love 
applied to make it as useful.

  Syntax this adds:
  
  SHOW PROFILES
  
  SHOW PROFILE [types] [FOR QUERY n] [OFFSET n] [LIMIT n]
   where "n" is an integer
   and "types" is zero or many (comma-separated) of
      "CPU"
      "MEMORY" (not presently supported)
      "BLOCK IO"
      "CONTEXT SWITCHES"
      "PAGE FAULTS"
      "IPC"
      "SWAPS"
      "SOURCE"
      "ALL"

It also adds a session variable (boolean) "profiling", set to "no"
by default, and (integer) profiling_history_size, set to 15 by 
default.

This patch abstracts setting THDs' "proc_info" behind a macro that 
can be used as a hook into the profiling code when profiling 
support is compiled in.  All future code in this line should use
that mechanism for setting thd->proc_info.

---

Tests are now set to omit the statistics.

---

Adds an Information_schema table, "profiling" for access to 
"show profile" data.
---
Merge zippy.cornsilk.net:/home/cmiller/work/mysql/mysql-5.0-community-3--bug24795
into  zippy.cornsilk.net:/home/cmiller/work/mysql/mysql-5.0-community
---
Fix merge problems.
---
Fixed one bug in the query_source being NULL.  

Updated test results.
---
Include more thorough profiling tests.

Improve support for prepared statements.

Use session-specific query IDs, starting at zero.
---
Selecting from I_S.profiling is no longer quashed in profiling, as
requested by Giuseppe.

Limit the size of captured query text.

No longer log queries that are zero length.
This commit is contained in:
cmiller@zippy.cornsilk.net
2007-02-22 10:03:08 -05:00
parent dffdc8118b
commit 6e096ee8d9
48 changed files with 1602 additions and 574 deletions

View File

@@ -645,7 +645,7 @@ impossible position";
if (read_packet)
{
thd->proc_info = "Sending binlog event to slave";
thd_proc_info(thd, "Sending binlog event to slave");
if (my_net_write(net, (char*)packet->ptr(), packet->length()) )
{
errmsg = "Failed on my_net_write()";
@@ -683,7 +683,7 @@ impossible position";
bool loop_breaker = 0;
/* need this to break out of the for loop from switch */
thd->proc_info = "Finished reading one binlog; switching to next binlog";
thd_proc_info(thd, "Finished reading one binlog; switching to next binlog");
switch (mysql_bin_log.find_next_log(&linfo, 1)) {
case LOG_INFO_EOF:
loop_breaker = (flags & BINLOG_DUMP_NON_BLOCK);
@@ -729,14 +729,14 @@ end:
(void)my_close(file, MYF(MY_WME));
send_eof(thd);
thd->proc_info = "Waiting to finalize termination";
thd_proc_info(thd, "Waiting to finalize termination");
pthread_mutex_lock(&LOCK_thread_count);
thd->current_linfo = 0;
pthread_mutex_unlock(&LOCK_thread_count);
DBUG_VOID_RETURN;
err:
thd->proc_info = "Waiting to finalize termination";
thd_proc_info(thd, "Waiting to finalize termination");
end_io_cache(&log);
/*
Exclude iteration through thread list
@@ -888,7 +888,7 @@ int stop_slave(THD* thd, MASTER_INFO* mi, bool net_report )
if (check_access(thd, SUPER_ACL, any_db,0,0,0,0))
return 1;
thd->proc_info = "Killing slave";
thd_proc_info(thd, "Killing slave");
int thread_mask;
lock_slave_threads(mi);
// Get a mask of _running_ threads
@@ -915,7 +915,7 @@ int stop_slave(THD* thd, MASTER_INFO* mi, bool net_report )
ER(ER_SLAVE_WAS_NOT_RUNNING));
}
unlock_slave_threads(mi);
thd->proc_info = 0;
thd_proc_info(thd, 0);
if (slave_errno)
{
@@ -1071,7 +1071,7 @@ bool change_master(THD* thd, MASTER_INFO* mi)
DBUG_RETURN(TRUE);
}
thd->proc_info = "Changing master";
thd_proc_info(thd, "Changing master");
LEX_MASTER_INFO* lex_mi= &thd->lex->mi;
// TODO: see if needs re-write
if (init_master_info(mi, master_info_file, relay_log_info_file, 0,
@@ -1196,7 +1196,7 @@ bool change_master(THD* thd, MASTER_INFO* mi)
if (need_relay_log_purge)
{
relay_log_purge= 1;
THD_PROC_INFO(thd, "Purging old relay logs");
thd_proc_info(thd, "Purging old relay logs");
if (purge_relay_logs(&mi->rli, thd,
0 /* not only reset, but also reinit */,
&errmsg))
@@ -1259,7 +1259,7 @@ bool change_master(THD* thd, MASTER_INFO* mi)
pthread_mutex_unlock(&mi->rli.data_lock);
unlock_slave_threads(mi);
thd->proc_info = 0;
thd_proc_info(thd, 0);
send_ok(thd);
DBUG_RETURN(FALSE);
}