summaryrefslogtreecommitdiff
path: root/sql/sp_head.cc
diff options
context:
space:
mode:
authorunknown <cmiller@zippy.cornsilk.net>2007-12-10 15:28:17 -0500
committerunknown <cmiller@zippy.cornsilk.net>2007-12-10 15:28:17 -0500
commitb536aa6756c572cbf249e04045925f0932088270 (patch)
treef638aa8fef4b2b2b59a72b2018d27d00fd9625c3 /sql/sp_head.cc
parentf77684f3a8da57a113d8c607c5a3d5b895b98952 (diff)
parentaac083b4d9c389132b46893bc7d9f3eadaf66463 (diff)
downloadmariadb-git-b536aa6756c572cbf249e04045925f0932088270.tar.gz
Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into zippy.cornsilk.net:/home/cmiller/work/mysql/mysql-5.0-community CMakeLists.txt: Auto merged include/config-win.h: Auto merged include/my_sys.h: Auto merged libmysql/CMakeLists.txt: Auto merged myisam/mi_open.c: Auto merged mysql-test/r/information_schema.result: Auto merged mysql-test/r/information_schema_db.result: Auto merged mysql-test/r/symlink.result: Auto merged mysql-test/t/information_schema.test: Auto merged mysql-test/t/symlink.test: Auto merged mysys/my_symlink2.c: Auto merged sql/ha_myisam.cc: Auto merged sql/ha_ndbcluster.cc: Auto merged sql/item_cmpfunc.cc: Auto merged sql/item_func.cc: Auto merged sql/log_event.cc: Auto merged sql/mysql_priv.h: Auto merged sql/mysqld.cc: Auto merged sql/set_var.cc: Auto merged sql/set_var.h: Auto merged sql/slave.cc: Auto merged sql/sp_head.cc: Auto merged sql/sql_base.cc: Auto merged sql/sql_class.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_insert.cc: Auto merged sql/sql_lex.h: Auto merged sql/sql_parse.cc: Auto merged sql/sql_prepare.cc: Auto merged sql/sql_repl.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_table.cc: Auto merged sql/sql_view.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/structs.h: Auto merged sql/table.h: Auto merged support-files/mysql.spec.sh: Auto merged win/configure.js: Auto merged Makefile.am: Manual merge. client/mysqlcheck.c: Manual merge. configure.in: Manual merge. mysql-test/r/mysqlcheck.result: Manual merge. mysql-test/t/mysqlcheck.test: Manual merge. sql/sql_delete.cc: Manual merge. sql/sql_update.cc: Manual merge.
Diffstat (limited to 'sql/sp_head.cc')
-rw-r--r--sql/sp_head.cc33
1 files changed, 31 insertions, 2 deletions
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index e55ba81b117..2b98e08fd73 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -1092,15 +1092,36 @@ sp_head::execute(THD *thd)
*/
thd->spcont->callers_arena= &backup_arena;
+#if defined(ENABLED_PROFILING)
+ /* Discard the initial part of executing routines. */
+ thd->profiling.discard_current_query();
+#endif
do
{
sp_instr *i;
uint hip; // Handler ip
+#if defined(ENABLED_PROFILING)
+ /*
+ Treat each "instr" of a routine as discrete unit that could be profiled.
+ Profiling only records information for segments of code that set the
+ source of the query, and almost all kinds of instructions in s-p do not.
+ */
+ thd->profiling.finish_current_query();
+ thd->profiling.start_new_query("continuing inside routine");
+#endif
+
i = get_instr(ip); // Returns NULL when we're done.
if (i == NULL)
+ {
+#if defined(ENABLED_PROFILING)
+ thd->profiling.discard_current_query();
+#endif
break;
+ }
+
DBUG_PRINT("execute", ("Instruction %u", ip));
+
/* Don't change NOW() in FUNCTION or TRIGGER */
if (!thd->in_sub_stmt)
thd->set_time(); // Make current_time() et al work
@@ -1177,6 +1198,10 @@ sp_head::execute(THD *thd)
}
} while (!err_status && !thd->killed);
+#if defined(ENABLED_PROFILING)
+ thd->profiling.finish_current_query();
+ thd->profiling.start_new_query("tail end of routine");
+#endif
thd->restore_active_arena(&execute_arena, &backup_arena);
thd->spcont->pop_all_cursors(); // To avoid memory leaks after an error
@@ -2497,9 +2522,9 @@ sp_lex_keeper::reset_lex_and_exec_core(THD *thd, uint *nextp,
m_lex->unit.cleanup();
- thd->proc_info="closing tables";
+ thd_proc_info(thd, "closing tables");
close_thread_tables(thd);
- thd->proc_info= 0;
+ thd_proc_info(thd, 0);
if (m_lex->query_tables_own_last)
{
@@ -2587,6 +2612,10 @@ sp_instr_stmt::execute(THD *thd, uint *nextp)
query= thd->query;
query_length= thd->query_length;
+#if defined(ENABLED_PROFILING)
+ /* This s-p instr is profilable and will be captured. */
+ thd->profiling.set_query_source(m_query.str, m_query.length);
+#endif
if (!(res= alloc_query(thd, m_query.str, m_query.length+1)) &&
!(res=subst_spvars(thd, this, &m_query)))
{