mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 10:14:19 +01:00
607c224969
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. BitKeeper/deleted/.del-profile.result: Rename: mysql-test/r/profile.result -> BitKeeper/deleted/.del-profile.result BitKeeper/deleted/.del-profile.test: Rename: mysql-test/t/profile.test -> BitKeeper/deleted/.del-profile.test BitKeeper/deleted/.del-sql_profile.cc: Rename: sql/sql_profile.cc -> BitKeeper/deleted/.del-sql_profile.cc BitKeeper/deleted/.del-sql_profile.h: Rename: sql/sql_profile.h -> BitKeeper/deleted/.del-sql_profile.h configure.in: Add a configure-time option to enable/disable query profiling. The default is enabled. include/my_dbug.h: DBUG_* statements should be syntactically equivalent to a single statement. myisam/mi_open.c: DBUG_* statements should be syntactically equivalent to a single statement. mysql-test/r/information_schema.result: Updated (re-recorded) tests that I missed somehow. I verified these for correctness. mysql-test/r/information_schema_db.result: Updated test results I missed. mysql-test/r/mysqlshow.result: Fix merge problems. ndb/src/ndbapi/DictCache.cpp: DBUG_* statements should be syntactically equivalent to a single statement. sql/ha_archive.cc: Abstract setting thread-info into a function or macro. --- Manual merge, undoing first patch. sql/ha_berkeley.cc: Include patch backported to 5.0-global. THD::options is a ulonglong, not ulong. sql/ha_myisam.cc: Abstract setting thread-info into a function or macro. --- Manual merge, undoing first patch. sql/ha_myisammrg.cc: DBUG_* statements should be syntactically equivalent to a single statement. sql/ha_ndbcluster.cc: DBUG_* statements should be syntactically equivalent to a single statement. sql/item_cmpfunc.cc: DBUG_* statements should be syntactically equivalent to a single statement. sql/item_func.cc: Abstract setting thread-info into a function or macro. --- Manual merge, undoing first patch. sql/lock.cc: Abstract setting thread-info into a function or macro. --- Manual merge, undoing first patch. sql/log_event.cc: Abstract setting thread-info into a function or macro. --- Manual merge, undoing first patch. sql/mysql_priv.h: Use 64-bit constants for the 64-bit bit field. Add a new option bit for whether profiling is active or not. sql/mysqld.cc: Add semicolon to DBUG statement. Add a new system variable and set it. --- Set the minimum, which is zero and not 50. sql/repl_failsafe.cc: Abstract setting thread-info into a function or macro. --- Manual merge, undoing first patch. sql/set_var.cc: Make a new system global variable and session variable, to determine behavior of profiling. --- Include patch backported to 5.0-global. THD::options is a ulonglong, not ulong. sql/set_var.h: The THD::options bit field is ulonglong, not ulong. sql/slave.cc: Abstract setting thread-info into a function or macro. --- Manual merge, undoing first patch. --- Include patch backported to 5.0-global. THD::options is a ulonglong, not ulong. sql/sp_head.cc: Abstract setting thread-info into a function or macro. --- Manual merge, undoing first patch. sql/sql_base.cc: Abstract setting thread-info into a function or macro. --- Manual merge, undoing first patch. --- Include patch backported to 5.0-global. THD::options is a ulonglong, not ulong. sql/sql_cache.cc: DBUG_* statements should be syntactically equivalent to a single statement. --- Fix merge problems. sql/sql_class.cc: Insert a pointer to the current thread in the profiling code. --- Manual merge, undoing first patch. --- Fix merge problems. sql/sql_class.h: Create a new system variable, profiling_history_size, and add a member to THD to hold profiling information about this thread's execution. --- Manual merge, undoing first patch. sql/sql_delete.cc: Abstract setting thread-info into a function or macro. --- Manual merge, undoing first patch. --- Include patch backported to 5.0-global. THD::options is a ulonglong, not ulong. sql/sql_insert.cc: Abstract setting thread-info into a function or macro. --- Manual merge, undoing first patch. --- Fix merge problems. sql/sql_lex.cc: Initialize profiling options to empty. --- Manual merge, undoing first patch. sql/sql_lex.h: Add info to the lexer object so that we can hold data that comes from parsing statements. Reuse memory addresses of uints that can't occur in the same state- ment. This is dangerous because it involves knowledge of what symbols are never used together, which is information stored obliquely in another file. --- Manual merge, undoing first patch. sql/sql_parse.cc: Add hooks to the parser to jump to profiling code. If profiling is not present, then return an error message upon being used. --- Manual merge, undoing first patch. --- Fix merge problems. --- Include patch backported to 5.0-global. THD::options is a ulonglong, not ulong. sql/sql_prepare.cc: From prepared statement execution, set the query source in the profiler, as we can't get it from thd . --- Make it less expensive to limit the size of the queries. sql/sql_repl.cc: Abstract setting thread-info into a function or macro. --- Manual merge, undoing first patch. sql/sql_select.cc: Abstract setting thread-info into a function or macro. --- Manual merge, undoing first patch. --- Fix merge problems. sql/sql_show.cc: Abstract setting thread-info into a function or macro. Also, remove "static" qualification on schema_table_store_record() so that external functions may use it. --- Manual merge, undoing first patch. sql/sql_table.cc: Abstract setting thread-info into a function or macro. --- Manual merge, undoing first patch. sql/sql_update.cc: Abstract setting thread-info into a function or macro. --- Manual merge, undoing first patch. sql/sql_view.cc: Abstract setting thread-info into a function or macro. --- Manual merge, undoing first patch. sql/sql_yacc.yy: Add new lexer symbols and insert new grammatical rules necessary to retreive profiling information. --- Manual merge, undoing first patch. --- Fix merge problems. sql/table.h: Add enum item for query profiling. BitKeeper/deleted/.del-profiling-master.opt: New BitKeeper file ``mysql-test/t/profiling-master.opt'' mysql-test/r/profiling.result: New BitKeeper file ``mysql-test/r/profiling.result'' --- Include more verbose that describes the queries so far. Include Giuseppe's tests. --- Selecting from I_S.profiling is no longer quashed in profiling, as requested by Giuseppe. mysql-test/t/profiling.test: New BitKeeper file ``mysql-test/t/profiling.test'' --- Include more verbose that describes the queries so far. Include Giuseppe's tests. --- Selecting from I_S.profiling is no longer quashed in profiling, as requested by Giuseppe. sql/sql_profile.cc: New BitKeeper file ``sql/sql_profile.cc'' --- If query_source is NULL, as can sometimes happen, then don't try to copy that memory. --- Make each new session use its own numbering of query_ids, and not show the global-pool numbers to the user. Provide a way for prepared statements to set the query_source. --- 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. sql/sql_profile.h: New BitKeeper file ``sql/sql_profile.h'' --- Make each new session use its own numbering of query_ids, and not show the global-pool numbers to the user. Provide a way for prepared statements to set the query_source. --- Make it less expensive to limit the size of the queries.
105 lines
3.7 KiB
C
105 lines
3.7 KiB
C
/* Copyright (C) 2000 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 _dbug_h
|
|
#define _dbug_h
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
#if !defined(DBUG_OFF) && !defined(_lint)
|
|
extern int _db_on_,_no_db_;
|
|
extern FILE *_db_fp_;
|
|
extern char *_db_process_;
|
|
extern int _db_keyword_(const char *keyword);
|
|
extern int _db_strict_keyword_(const char *keyword);
|
|
extern void _db_setjmp_(void);
|
|
extern void _db_longjmp_(void);
|
|
extern void _db_push_(const char *control);
|
|
extern void _db_pop_(void);
|
|
extern void _db_enter_(const char *_func_,const char *_file_,uint _line_,
|
|
const char **_sfunc_,const char **_sfile_,
|
|
uint *_slevel_, char ***);
|
|
extern void _db_return_(uint _line_,const char **_sfunc_,const char **_sfile_,
|
|
uint *_slevel_);
|
|
extern void _db_pargs_(uint _line_,const char *keyword);
|
|
extern void _db_doprnt_ _VARARGS((const char *format,...))
|
|
ATTRIBUTE_FORMAT(printf, 1, 2);
|
|
extern void _db_dump_(uint _line_,const char *keyword,const char *memory,
|
|
uint length);
|
|
extern void _db_output_(uint flag);
|
|
extern void _db_end_(void);
|
|
extern void _db_lock_file(void);
|
|
extern void _db_unlock_file(void);
|
|
|
|
#define DBUG_ENTER(a) const char *_db_func_, *_db_file_; uint _db_level_; \
|
|
char **_db_framep_; \
|
|
_db_enter_ (a,__FILE__,__LINE__,&_db_func_,&_db_file_,&_db_level_, \
|
|
&_db_framep_)
|
|
#define DBUG_LEAVE \
|
|
(_db_return_ (__LINE__, &_db_func_, &_db_file_, &_db_level_))
|
|
#define DBUG_RETURN(a1) do {DBUG_LEAVE; return(a1);} while(0)
|
|
#define DBUG_VOID_RETURN do {DBUG_LEAVE; return;} while(0)
|
|
#define DBUG_EXECUTE(keyword,a1) \
|
|
do {if (_db_on_) {if (_db_keyword_ (keyword)) { a1 }}} while(0)
|
|
#define DBUG_PRINT(keyword,arglist) \
|
|
do {if (_db_on_) {_db_pargs_(__LINE__,keyword); _db_doprnt_ arglist;}} while(0)
|
|
#define DBUG_PUSH(a1) _db_push_ (a1)
|
|
#define DBUG_POP() _db_pop_ ()
|
|
#define DBUG_PROCESS(a1) (_db_process_ = a1)
|
|
#define DBUG_FILE (_db_fp_)
|
|
#define DBUG_SETJMP(a1) (_db_setjmp_ (), setjmp (a1))
|
|
#define DBUG_LONGJMP(a1,a2) (_db_longjmp_ (), longjmp (a1, a2))
|
|
#define DBUG_DUMP(keyword,a1,a2)\
|
|
do {if (_db_on_) {_db_dump_(__LINE__,keyword,a1,a2);}} while(0)
|
|
#define DBUG_IN_USE (_db_fp_ && _db_fp_ != stderr)
|
|
#define DEBUGGER_OFF _no_db_=1;_db_on_=0;
|
|
#define DEBUGGER_ON _no_db_=0
|
|
#define DBUG_END() _db_end_ ()
|
|
#define DBUG_LOCK_FILE { _db_lock_file(); }
|
|
#define DBUG_UNLOCK_FILE { _db_unlock_file(); }
|
|
#define DBUG_OUTPUT(A) { _db_output_(A); }
|
|
#define DBUG_ASSERT(A) assert(A)
|
|
#define DBUG_EXECUTE_IF(keyword,a1) \
|
|
do {if (_db_on_) {if (_db_strict_keyword_ (keyword)) { a1 }}} while(0)
|
|
#else /* No debugger */
|
|
|
|
#define DBUG_ENTER(a1)
|
|
#define DBUG_RETURN(a1) return(a1)
|
|
#define DBUG_VOID_RETURN return
|
|
#define DBUG_EXECUTE(keyword,a1) {}
|
|
#define DBUG_EXECUTE_IF(keyword,a1) {}
|
|
#define DBUG_PRINT(keyword,arglist) {}
|
|
#define DBUG_PUSH(a1) {}
|
|
#define DBUG_POP() {}
|
|
#define DBUG_PROCESS(a1) {}
|
|
#define DBUG_FILE (stderr)
|
|
#define DBUG_SETJMP setjmp
|
|
#define DBUG_LONGJMP longjmp
|
|
#define DBUG_DUMP(keyword,a1,a2) {}
|
|
#define DBUG_IN_USE 0
|
|
#define DEBUGGER_OFF
|
|
#define DEBUGGER_ON
|
|
#define DBUG_END()
|
|
#define DBUG_LOCK_FILE
|
|
#define DBUG_UNLOCK_FILE
|
|
#define DBUG_OUTPUT(A)
|
|
#define DBUG_ASSERT(A) {}
|
|
#define DBUG_LEAVE
|
|
#endif
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif
|