diff options
author | Michael Widenius <monty@askmonty.org> | 2010-08-05 22:56:11 +0300 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2010-08-05 22:56:11 +0300 |
commit | d042146e5b41b6222df3e6b4c16a44f3ef2939b7 (patch) | |
tree | e40f5b435f7d17ed1c24dfb787ab8cd5f4f7d5d8 /sql/sp_head.cc | |
parent | 3e610bc58d0ba325fdca3b06dfa976ecc513dc1e (diff) | |
parent | f0f21036951f6fed2fddeb58375425f957751fd5 (diff) | |
download | mariadb-git-d042146e5b41b6222df3e6b4c16a44f3ef2939b7.tar.gz |
Merge with MariaDB 5.1.49
Removed references to HA_END_SPACE_KEY (which has been 0 for a long time)
Diffstat (limited to 'sql/sp_head.cc')
-rw-r--r-- | sql/sp_head.cc | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/sql/sp_head.cc b/sql/sp_head.cc index f7dc2c83641..9f9219566d7 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -34,6 +34,36 @@ extern "C" uchar *sp_table_key(const uchar *ptr, size_t *plen, my_bool first); +/** + Helper function which operates on a THD object to set the query start_time to + the current time. + + @param[in, out] thd The session object + +*/ + +static void reset_start_time_for_sp(THD *thd) +{ + /* + Do nothing if the context is a trigger or function because time should be + constant during the execution of those. + */ + if (!thd->in_sub_stmt) + { + /* + First investigate if there is a cached time stamp + */ + if (thd->user_time) + { + thd->start_time= thd->user_time; + } + else + { + my_micro_time_and_time(&thd->start_time); + } + } +} + Item_result sp_map_result_type(enum enum_field_types type) { @@ -1227,10 +1257,13 @@ sp_head::execute(THD *thd) 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 - + /* + We need to reset start_time to allow for time to flow inside a stored + procedure. This is only done for SP since time is suppose to be constant + during execution of triggers and functions. + */ + reset_start_time_for_sp(thd); + /* We have to set thd->stmt_arena before executing the instruction to store in the instruction free_list all new items, created @@ -1842,8 +1875,6 @@ sp_head::execute_procedure(THD *thd, List<Item> *args) { bool err_status= FALSE; uint params = m_pcont->context_var_count(); - /* Query start time may be reset in a multi-stmt SP; keep this for later. */ - ulonglong utime_before_sp_exec= thd->utime_after_lock; sp_rcontext *save_spcont, *octx; sp_rcontext *nctx = NULL; bool save_enable_slow_log; @@ -2036,8 +2067,6 @@ sp_head::execute_procedure(THD *thd, List<Item> *args) delete nctx; thd->spcont= save_spcont; - thd->utime_after_lock= utime_before_sp_exec; - DBUG_RETURN(err_status); } |