diff options
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | sql/set_var.cc | 2 | ||||
-rw-r--r-- | sql/sql_lex.cc | 2 | ||||
-rw-r--r-- | sql/sql_parse.cc | 4 | ||||
-rw-r--r-- | sql/sql_profile.cc | 90 | ||||
-rw-r--r-- | sql/sql_profile.h | 3 | ||||
-rw-r--r-- | sql/sql_select.cc | 4 |
7 files changed, 45 insertions, 62 deletions
diff --git a/configure.in b/configure.in index 3e0e6c9762b..f81e70f6173 100644 --- a/configure.in +++ b/configure.in @@ -669,7 +669,7 @@ fi # Add query profiler AC_ARG_ENABLE(profiling, - [ --disable-profiling Build a version without query profiling code ], + AS_HELP_STRING([--disable-profiling], [Build a version without query profiling code]), [ ENABLED_PROFILING=$enableval ], [ ENABLED_PROFILING=yes ]) diff --git a/sql/set_var.cc b/sql/set_var.cc index c02561261c0..dad6be06aa2 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -548,7 +548,7 @@ static sys_var_thd_bit sys_unique_checks("unique_checks", 0, #ifdef ENABLED_PROFILING static sys_var_thd_bit sys_profiling("profiling", NULL, set_option_bit, ulonglong(OPTION_PROFILING)); -sys_var_thd_ulong sys_profiling_history_size("profiling_history_size", +static sys_var_thd_ulong sys_profiling_history_size("profiling_history_size", &SV::profiling_history_size); #endif diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 47fe2e8ac0e..8742a9630b6 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -173,9 +173,7 @@ void lex_start(THD *thd, uchar *buf,uint length) lex->proc_list.first= 0; lex->escape_used= FALSE; lex->reset_query_tables_list(FALSE); -#ifdef ENABLED_PROFILING lex->profile_options= PROFILE_NONE; -#endif lex->nest_level=0 ; lex->allow_sum_func= 0; lex->in_sum_func= NULL; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 449d57c2b2d..370fa4a19c5 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2707,7 +2707,7 @@ mysql_execute_command(THD *thd) if (res) goto error; #else - my_error(ER_FEATURE_DISABLED, MYF(0), "query profiling", "enable-profiling"); + my_error(ER_FEATURE_DISABLED, MYF(0), "SHOW PROFILES", "enable-profiling"); goto error; #endif break; @@ -2724,7 +2724,7 @@ mysql_execute_command(THD *thd) if (res) goto error; #else - my_error(ER_FEATURE_DISABLED, MYF(0), "query profiling", "enable-profiling"); + my_error(ER_FEATURE_DISABLED, MYF(0), "SHOW PROFILE", "enable-profiling"); goto error; #endif break; diff --git a/sql/sql_profile.cc b/sql/sql_profile.cc index 86f6854206d..1d38b313bd3 100644 --- a/sql/sql_profile.cc +++ b/sql/sql_profile.cc @@ -1,9 +1,8 @@ -/* Copyright (C) 2005 MySQL AB +/* 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; either version 2 of the License, or - (at your option) any later version. + 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 @@ -12,7 +11,7 @@ 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 */ + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "mysql_priv.h" @@ -42,24 +41,24 @@ int fill_query_profile_statistics_info(THD *thd, struct st_table_list *tables, ST_FIELD_INFO query_profile_statistics_info[]= { /* name, length, type, value, maybe_null, old_name */ - {"Query_id", 20, MYSQL_TYPE_LONG, 0, false, NULL}, - {"Seq", 20, MYSQL_TYPE_LONG, 0, false, NULL}, - {"State", 30, MYSQL_TYPE_STRING, 0, false, NULL}, - {"Duration", TIME_FLOAT_DIGITS, MYSQL_TYPE_DOUBLE, 0, false, NULL}, - {"CPU_user", TIME_FLOAT_DIGITS, MYSQL_TYPE_DOUBLE, 0, true, NULL}, - {"CPU_system", TIME_FLOAT_DIGITS, MYSQL_TYPE_DOUBLE, 0, true, NULL}, - {"Context_voluntary", 20, MYSQL_TYPE_LONG, 0, true, NULL}, - {"Context_involuntary", 20, MYSQL_TYPE_LONG, 0, true, NULL}, - {"Block_ops_in", 20, MYSQL_TYPE_LONG, 0, true, NULL}, - {"Block_ops_out", 20, MYSQL_TYPE_LONG, 0, true, NULL}, - {"Messages_sent", 20, MYSQL_TYPE_LONG, 0, true, NULL}, - {"Messages_received", 20, MYSQL_TYPE_LONG, 0, true, NULL}, - {"Page_faults_major", 20, MYSQL_TYPE_LONG, 0, true, NULL}, - {"Page_faults_minor", 20, MYSQL_TYPE_LONG, 0, true, NULL}, - {"Swaps", 20, MYSQL_TYPE_LONG, 0, true, NULL}, - {"Source_function", 30, MYSQL_TYPE_STRING, 0, true, NULL}, - {"Source_file", 20, MYSQL_TYPE_STRING, 0, true, NULL}, - {"Source_line", 20, MYSQL_TYPE_LONG, 0, true, NULL}, + {"QUERY_ID", 20, MYSQL_TYPE_LONG, 0, false, NULL}, + {"SEQ", 20, MYSQL_TYPE_LONG, 0, false, NULL}, + {"STATE", 30, MYSQL_TYPE_STRING, 0, false, NULL}, + {"DURATION", TIME_FLOAT_DIGITS, MYSQL_TYPE_DOUBLE, 0, false, NULL}, + {"CPU_USER", TIME_FLOAT_DIGITS, MYSQL_TYPE_DOUBLE, 0, true, NULL}, + {"CPU_SYSTEM", TIME_FLOAT_DIGITS, MYSQL_TYPE_DOUBLE, 0, true, NULL}, + {"CONTEXT_VOLUNTARY", 20, MYSQL_TYPE_LONG, 0, true, NULL}, + {"CONTEXT_INVOLUNTARY", 20, MYSQL_TYPE_LONG, 0, true, NULL}, + {"BLOCK_OPS_IN", 20, MYSQL_TYPE_LONG, 0, true, NULL}, + {"BLOCK_OPS_OUT", 20, MYSQL_TYPE_LONG, 0, true, NULL}, + {"MESSAGES_SENT", 20, MYSQL_TYPE_LONG, 0, true, NULL}, + {"MESSAGES_RECEIVED", 20, MYSQL_TYPE_LONG, 0, true, NULL}, + {"PAGE_FAULTS_MAJOR", 20, MYSQL_TYPE_LONG, 0, true, NULL}, + {"PAGE_FAULTS_MINOR", 20, MYSQL_TYPE_LONG, 0, true, NULL}, + {"SWAPS", 20, MYSQL_TYPE_LONG, 0, true, NULL}, + {"SOURCE_FUNCTION", 30, MYSQL_TYPE_STRING, 0, true, NULL}, + {"SOURCE_FILE", 20, MYSQL_TYPE_STRING, 0, true, NULL}, + {"SOURCE_LINE", 20, MYSQL_TYPE_LONG, 0, true, NULL}, {NULL, 0, MYSQL_TYPE_STRING, 0, true, NULL} }; @@ -107,20 +106,9 @@ void PROFILE_ENTRY::set_status(const char *status_arg, const char *function_arg, Compute all the space we'll need to allocate one block for everything we'll need, instead of N mallocs. */ - if (status_arg != NULL) - sizes[0]= strlen(status_arg) + 1; - else - sizes[0]= 0; - - if (function_arg != NULL) - sizes[1]= strlen(function_arg) + 1; - else - sizes[1]= 0; - - if (file_arg != NULL) - sizes[2]= strlen(file_arg) + 1; - else - sizes[2]= 0; + sizes[0]= (status_arg == NULL) ? 0 : strlen(status_arg) + 1; + sizes[1]= (function_arg == NULL) ? 0 : strlen(function_arg) + 1; + sizes[2]= (file_arg == NULL) ? 0 : strlen(file_arg) + 1; allocated_status_memory= (char *) my_malloc(sizes[0] + sizes[1] + sizes[2], MYF(0)); DBUG_ASSERT(allocated_status_memory != NULL); @@ -237,7 +225,6 @@ void QUERY_PROFILE::status(const char *status_arg, */ saved_mem_root= thd->mem_root; thd->mem_root= &profiling->mem_root; - //thd->mem_root= NULL; if (function_arg && file_arg) { @@ -375,7 +362,6 @@ bool QUERY_PROFILE::show(uint options) protocol->store(entry->status, strlen(entry->status), system_charset_info); protocol->store((double)(entry->time_usecs - last_time)/(1000.0*1000), (uint32) TIME_FLOAT_DIGITS-1, &elapsed); - //protocol->store((double)(entry->time - last_time)/(1000*1000*10)); if (options & PROFILE_CPU) { @@ -739,54 +725,54 @@ int PROFILING::fill_statistics_info(THD *thd, struct st_table_list *tables, Item #ifdef HAVE_GETRUSAGE table->field[4]->store((double)RUSAGE_DIFF_USEC(entry->rusage.ru_utime, last_rusage->ru_utime)/(1000.0*1000)); - table->field[4]->null_ptr= NULL; + table->field[4]->set_notnull(); table->field[5]->store((double)RUSAGE_DIFF_USEC(entry->rusage.ru_stime, last_rusage->ru_stime)/(1000.0*1000)); - table->field[5]->null_ptr= NULL; + table->field[5]->set_notnull(); #else /* TODO: Add CPU-usage info for non-BSD systems */ #endif #ifdef HAVE_GETRUSAGE table->field[6]->store((uint32)(entry->rusage.ru_nvcsw - last_rusage->ru_nvcsw)); - table->field[6]->null_ptr= NULL; + table->field[6]->set_notnull(); table->field[7]->store((uint32)(entry->rusage.ru_nivcsw - last_rusage->ru_nivcsw)); - table->field[7]->null_ptr= NULL; + table->field[7]->set_notnull(); #else /* TODO: Add context switch info for non-BSD systems */ #endif #ifdef HAVE_GETRUSAGE table->field[8]->store((uint32)(entry->rusage.ru_inblock - last_rusage->ru_inblock)); - table->field[8]->null_ptr= NULL; + table->field[8]->set_notnull(); table->field[9]->store((uint32)(entry->rusage.ru_oublock - last_rusage->ru_oublock)); - table->field[9]->null_ptr= NULL; + table->field[9]->set_notnull(); #else /* TODO: Add block IO info for non-BSD systems */ #endif #ifdef HAVE_GETRUSAGE table->field[10]->store((uint32)(entry->rusage.ru_msgsnd - last_rusage->ru_msgsnd), true); - table->field[10]->null_ptr= NULL; + table->field[10]->set_notnull(); table->field[11]->store((uint32)(entry->rusage.ru_msgrcv - last_rusage->ru_msgrcv), true); - table->field[11]->null_ptr= NULL; + table->field[11]->set_notnull(); #else /* TODO: Add message info for non-BSD systems */ #endif #ifdef HAVE_GETRUSAGE table->field[12]->store((uint32)(entry->rusage.ru_majflt - last_rusage->ru_majflt), true); - table->field[12]->null_ptr= NULL; + table->field[12]->set_notnull(); table->field[13]->store((uint32)(entry->rusage.ru_minflt - last_rusage->ru_minflt), true); - table->field[13]->null_ptr= NULL; + table->field[13]->set_notnull(); #else /* TODO: Add page fault info for non-BSD systems */ #endif #ifdef HAVE_GETRUSAGE table->field[14]->store((uint32)(entry->rusage.ru_nswap - last_rusage->ru_nswap), true); - table->field[14]->null_ptr= NULL; + table->field[14]->set_notnull(); #else /* TODO: Add swap info for non-BSD systems */ #endif @@ -795,11 +781,11 @@ int PROFILING::fill_statistics_info(THD *thd, struct st_table_list *tables, Item { table->field[15]->store(entry->function, strlen(entry->function), system_charset_info); - table->field[15]->null_ptr= NULL; + table->field[15]->set_notnull(); table->field[16]->store(entry->file, strlen(entry->file), system_charset_info); - table->field[16]->null_ptr= NULL; + table->field[16]->set_notnull(); table->field[17]->store(entry->line, true); - table->field[17]->null_ptr= NULL; + table->field[17]->set_notnull(); } if (schema_table_store_record(thd, table)) diff --git a/sql/sql_profile.h b/sql/sql_profile.h index 006760cab79..944856a9f80 100644 --- a/sql/sql_profile.h +++ b/sql/sql_profile.h @@ -2,8 +2,7 @@ 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; either version 2 of the License, or - (at your option) any later version. + 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 diff --git a/sql/sql_select.cc b/sql/sql_select.cc index c9e334b7784..1ee84ca9e3d 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1234,8 +1234,8 @@ JOIN::optimize() if (!group_list && ! exec_tmp_table1->distinct && order && simple_order) { - thd_proc_info(thd, "Sorting for order"); - if (create_sort_index(thd, this, order, + thd_proc_info(thd, "Sorting for order"); + if (create_sort_index(thd, this, order, HA_POS_ERROR, HA_POS_ERROR)) { DBUG_RETURN(1); |