summaryrefslogtreecommitdiff
path: root/sql/sp_head.cc
diff options
context:
space:
mode:
authorChad MILLER <chad@mysql.com>2009-05-06 09:06:32 -0400
committerChad MILLER <chad@mysql.com>2009-05-06 09:06:32 -0400
commit128afdc3e5d06381f525e0d9cdc2df7c497e886c (patch)
treeb7a5df1540af07a49f7d577804919b7027fc4edf /sql/sp_head.cc
parent0f95bd31058f21f0872191eac49809622725564d (diff)
parent9d58239dea8c615a10a0939e34d052b22808e75f (diff)
downloadmariadb-git-128afdc3e5d06381f525e0d9cdc2df7c497e886c.tar.gz
Merge community up to enterprise, thus ending the community-server
adventure.
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 90730d11886..240948d217c 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -1103,15 +1103,36 @@ sp_head::execute(THD *thd)
*/
thd->spcont->callers_arena= &backup_arena;
+#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
+ /* 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) && defined(COMMUNITY_SERVER)
+ /*
+ 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) && defined(COMMUNITY_SERVER)
+ 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
@@ -1188,6 +1209,10 @@ sp_head::execute(THD *thd)
}
} while (!err_status && !thd->killed);
+#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
+ 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
@@ -2520,9 +2545,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)
{
@@ -2610,6 +2635,10 @@ sp_instr_stmt::execute(THD *thd, uint *nextp)
query= thd->query;
query_length= thd->query_length;
+#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
+ /* 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)))
{