1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

Bug#24795: Add SHOW PROFILE

Patch contributed by Jeremy Cole.  CLA received Oct 2006 by Kaj Arnö

Add rudimentary query profiling support.


libmysqld/Makefile.am:
  Add profile file to source list.
sql/Makefile.am:
  Add profiling files to source and header lists.
sql/ha_archive.cc:
  Macro-ized other discovered instances of setting proc_info.
sql/ha_myisam.cc:
  Macroize setting thread-state info
sql/item_func.cc:
  Macro-ized other discovered instances of setting proc_info.
sql/lex.h:
  Add lexer info for profiling.
sql/lock.cc:
  Macroize setting thread-state info
sql/log_event.cc:
  Macro-ized other discovered instances of setting proc_info.
sql/mysql_priv.h:
  Set constants for profiling.
sql/repl_failsafe.cc:
  Macro-ized other discovered instances of setting proc_info.
sql/slave.cc:
  Macro-ized other discovered instances of setting proc_info.
sql/sp_head.cc:
  Macro-ized other discovered instances of setting proc_info.
sql/sql_base.cc:
  Macroize setting thread-state info
  ---
  Macro-ized other discovered instances of setting proc_info.
sql/sql_cache.cc:
  Macroize setting thread-state info
sql/sql_class.cc:
  Integrate profiling.
sql/sql_class.h:
  Instantiate profiling object.
sql/sql_delete.cc:
  Macroize setting thread-state info
sql/sql_insert.cc:
  Macroize setting thread-state info
  ---
  Macro-ized other discovered instances of setting proc_info.
sql/sql_lex.cc:
  Initialize profiling.
sql/sql_lex.h:
  Define lex tokens and allocate space for profiling options.
sql/sql_parse.cc:
  Integrate profiling.
  ---
  Macro-ized other discovered instances of setting proc_info.
sql/sql_repl.cc:
  Macro-ized other discovered instances of setting proc_info.
sql/sql_select.cc:
  Macroize setting thread-state info.
  
  Clean up some lines.
sql/sql_show.cc:
  Macro-ized other discovered instances of setting proc_info.
  ---
  Revert bad use of macro.
sql/sql_table.cc:
  Macroize setting thread-state info
sql/sql_update.cc:
  Macroize setting thread-state info
sql/sql_view.cc:
  Macro-ized other discovered instances of setting proc_info.
sql/sql_yacc.yy:
  Add parser info for profiling.
  ---
  Fix new YACC shift/reduce conflict.  (Now at 249.)
mysql-test/r/profile.result:
  Test profiling code.
  ---
  A not-very-useful result.
mysql-test/t/profile.test:
  Test profiling code.
  ---
  Test syntax, but not values of profiles code.
sql/sql_profile.cc:
  Add profiling code.
  ---
  Add wishlist comment.
sql/sql_profile.h:
  Add profiling code.
  ---
  Changed the value of the macro so that it's syntactically equivalent to a
  single statement.
This commit is contained in:
unknown
2007-01-03 17:15:10 -05:00
parent 96fa010c66
commit 66dfd85cf4
33 changed files with 976 additions and 134 deletions

View File

@ -670,6 +670,7 @@ void query_cache_insert(NET *net, const char *packet, ulong length)
void query_cache_abort(NET *net)
{
DBUG_ENTER("query_cache_abort");
THD *thd= current_thd;
/* See the comment on double-check locking usage above. */
if (net->query_cache_query == 0)
@ -688,6 +689,7 @@ void query_cache_abort(NET *net)
net->query_cache_query);
if (query_block) // Test if changed by other thread
{
THD_PROC_INFO(thd, "storing result in query cache");
DUMP(&query_cache);
BLOCK_LOCK_WR(query_block);
// The following call will remove the lock on query_block
@ -725,6 +727,7 @@ void query_cache_end_of_result(THD *thd)
query_block= ((Query_cache_block*) thd->net.query_cache_query);
if (query_block)
{
THD_PROC_INFO(thd, "storing result in query cache");
DUMP(&query_cache);
BLOCK_LOCK_WR(query_block);
Query_cache_query *header= query_block->query();
@ -1089,6 +1092,8 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
DBUG_PRINT("qcache", ("No active database"));
}
THD_PROC_INFO(thd, "checking query cache for query");
// fill all gaps between fields with 0 to get repeatable key
bzero(&flags, QUERY_CACHE_FLAGS_SIZE);
flags.client_long_flag= test(thd->client_capabilities & CLIENT_LONG_FLAG);
@ -1163,6 +1168,7 @@ sql mode: 0x%lx, sort len: %lu, conncat len: %lu",
}
// Check access;
THD_PROC_INFO(thd, "checking privileges on cached query");
block_table= query_block->table(0);
block_table_end= block_table+query_block->n_tables;
for (; block_table != block_table_end; block_table++)
@ -1255,6 +1261,7 @@ sql mode: 0x%lx, sort len: %lu, conncat len: %lu",
Send cached result to client
*/
#ifndef EMBEDDED_LIBRARY
THD_PROC_INFO(thd, "sending cached result to client");
do
{
DBUG_PRINT("qcache", ("Results (len: %lu used: %lu headers: %lu)",
@ -1332,9 +1339,11 @@ void Query_cache::invalidate(THD *thd, TABLE_LIST *tables_used,
void Query_cache::invalidate(CHANGED_TABLE_LIST *tables_used)
{
THD *thd= current_thd;
DBUG_ENTER("Query_cache::invalidate (changed table list)");
if (tables_used)
{
THD_PROC_INFO(thd, "invalidating query cache entries (table list)");
STRUCT_LOCK(&structure_guard_mutex);
if (query_cache_size > 0 && !flush_in_progress)
{
@ -1365,9 +1374,11 @@ void Query_cache::invalidate(CHANGED_TABLE_LIST *tables_used)
*/
void Query_cache::invalidate_locked_for_write(TABLE_LIST *tables_used)
{
THD *thd= current_thd;
DBUG_ENTER("Query_cache::invalidate_locked_for_write");
if (tables_used)
{
THD_PROC_INFO(thd, "invalidating query cache entries (table)");
STRUCT_LOCK(&structure_guard_mutex);
if (query_cache_size > 0 && !flush_in_progress)
{
@ -1417,6 +1428,7 @@ void Query_cache::invalidate(THD *thd, const char *key, uint32 key_length,
STRUCT_LOCK(&structure_guard_mutex);
if (query_cache_size > 0 && !flush_in_progress)
{
THD_PROC_INFO(thd, "invalidating query cache entries (key)");
using_transactions= using_transactions &&
(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN));
if (using_transactions) // used for innodb => has_transactions() is TRUE