summaryrefslogtreecommitdiff
path: root/sql/sp.cc
diff options
context:
space:
mode:
authorunknown <sergefp@mysql.com>2005-08-03 03:37:32 +0000
committerunknown <sergefp@mysql.com>2005-08-03 03:37:32 +0000
commitb323667ffc7176482073ca7d626560dcd8d7ee75 (patch)
treeab04bd1a5e1f34ad54866fd6df3fab3dfb0ae2e2 /sql/sp.cc
parent11abe15eab3f444b600200e965cf18539af55392 (diff)
downloadmariadb-git-b323667ffc7176482073ca7d626560dcd8d7ee75.tar.gz
Prelocking-free SPs, post-review fixes:
* Don't activate prelocking mode for evaluating procedure arguments when it is not necessary. * Code structure simplification and cleanup. * Cleanup in .test files mysql-test/r/sp-prelocking.result: Prelocking-free SPs, post-review fixes: Added comment, s/testdb/mysqltest/, fixed a wrong test (error wasnt reported because of known bug in mysqltestrun) mysql-test/r/sp-security.result: Don't drop the table we're not using. mysql-test/r/sp.result: Prelocking-free SPs, post-review fixes: remove redundant "drop table if exists t3" statements mysql-test/t/sp-prelocking.test: Prelocking-free SPs, post-review fixes: Added comment, s/testdb/mysqltest/, fixed a wrong test (error wasnt reported because of known bug in mysqltestrun) mysql-test/t/sp-security.test: Don't drop the table we're not using. mysql-test/t/sp.test: Prelocking-free SPs, post-review fixes: remove redundant "drop table if exists t3" statements sql/sp.cc: New, better defined, sp_get_prelocking_info() function to get info about statement prelocking options sql/sp.h: Prelocking-free SPs, post-review fixes: New, better defined, sp_get_prelocking_info() function to get info about statement prelocking options sql/sp_cache.h: Prelocking-free SPs, post-review fixes: Amended the comments sql/sp_head.cc: Prelocking-free SPs, post-review fixes: Amend the comments, simplify the code that attaches removes statement's prelocking tables. sql/sql_base.cc: Prelocking-free SPs, post-review fixes: * Use a better defined sp_get_prelocking_info() function to get info about statement prelocking options * Don't activate prelocked mode for evaluation of SP arguments that use tables but don't need prelocking. sql/sql_class.cc: Prelocking-free SPs, post-review fixes: Initialize THD members in the order they are declared.
Diffstat (limited to 'sql/sp.cc')
-rw-r--r--sql/sp.cc43
1 files changed, 21 insertions, 22 deletions
diff --git a/sql/sp.cc b/sql/sp.cc
index 3d513b16d07..0cc1c988217 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -1176,40 +1176,39 @@ extern "C" byte* sp_sroutine_key(const byte *ptr, uint *plen, my_bool first)
/*
- Check if routines in routines_list require sp_cache_routines_and_add_tables
- call.
+ Check if
+ - current statement (the one in thd->lex) needs table prelocking
+ - first routine in thd->lex->sroutines_list needs to execute its body in
+ prelocked mode.
SYNOPSIS
- sp_need_cache_routines()
- thd
- routines
- need_skip_first OUT TRUE - don't do prelocking for the 1st element in
- routines list.
- FALSE- otherwise
+ sp_get_prelocking_info()
+ thd Current thread, thd->lex is the statement to be
+ checked.
+ need_prelocking OUT TRUE - prelocked mode should be activated
+ before executing the statement
+ FALSE - Don't activate prelocking
+ first_no_prelocking OUT TRUE - Tables used by first routine in
+ thd->lex->sroutines_list should be
+ prelocked.
+ FALSE - Otherwise.
NOTES
This function assumes that for any "CALL proc(...)" statement routines_list
will have 'proc' as first element (it may have several, consider e.g.
"proc(sp_func(...)))". This property is currently guaranted by the parser.
-
- RETURN
- TRUE Need to sp_cache_routines_and_add_tables call for this statement.
- FALSE Otherwise.
*/
-bool sp_need_cache_routines(THD *thd, SQL_LIST *routines_list, bool *need_skip_first)
+void sp_get_prelocking_info(THD *thd, bool *need_prelocking,
+ bool *first_no_prelocking)
{
Sroutine_hash_entry *routine;
- routine= (Sroutine_hash_entry*)routines_list->first;
-
- *need_skip_first= FALSE;
- if (!routine)
- return FALSE;
+ routine= (Sroutine_hash_entry*)thd->lex->sroutines_list.first;
- if (routine->key.str[0] != TYPE_ENUM_PROCEDURE)
- return TRUE;
+ DBUG_ASSERT(routine);
+ bool first_is_procedure= (routine->key.str[0] == TYPE_ENUM_PROCEDURE);
- *need_skip_first= TRUE;
- return TRUE;
+ *first_no_prelocking= first_is_procedure;
+ *need_prelocking= !first_is_procedure || test(routine->next);
}