summaryrefslogtreecommitdiff
path: root/sql/sp_head.h
diff options
context:
space:
mode:
authorunknown <pem@mysql.comhem.se>2005-02-08 20:52:50 +0100
committerunknown <pem@mysql.comhem.se>2005-02-08 20:52:50 +0100
commit41d556e3ada1a9b1e1dd26ef2f398a5cf74b86b2 (patch)
treee0f8f8584de8f0be190160f0562d6a75d0039e60 /sql/sp_head.h
parent61e36a967b46dcc37d0cff1deaf9e775244fb756 (diff)
downloadmariadb-git-41d556e3ada1a9b1e1dd26ef2f398a5cf74b86b2.tar.gz
WL#2130: Table locking for stored FUNCTIONs
Collect all tables and SPs refered by a statement, and open all tables with an implicit LOCK TABLES. Do find things refered by triggers and views, we open them first (and then repeat this until nothing new is found), before doing the actual lock tables. mysql-test/r/information_schema.result: Updated result for WL#2130. mysql-test/r/lock.result: Updated result for WL#2130. mysql-test/r/sp-error.result: Updated result for WL#2130. mysql-test/r/sp.result: Updated result for WL#2130. mysql-test/r/view.result: Updated result for WL#2130. mysql-test/t/information_schema.test: Disabled one test case due to a bug involving LOCK TABLES, which shows up with WL#2130. mysql-test/t/lock.test: New error message with WL#2130. This change is under debate and might change in the future, but will do for now. mysql-test/t/sp-error.test: Updated for WL#2130. Some tests are voided when table access does work from functions. mysql-test/t/sp.test: Updated for WL#2130. mysql-test/t/view.test: Updated for WL#2130. sql/item_func.cc: We now have to set net.no_send_ok for functions too, with WL#2130. sql/share/errmsg.txt: Reused an error code since the old use was voided by WL#2130, but a new one was needed instead (similar, but more specific restriction). sql/sp.cc: Fixed error handling and collection of used tables for WL#2130. sql/sp.h: Fixed error handling and collection of used tables for WL#2130. sql/sp_head.cc: Added support functions for collecting and merging hash tables and lists of used tables from SPs and substatements, for WL#2130. sql/sp_head.h: Added support functions for collecting and merging hash tables and lists of used tables from SPs and substatements, for WL#2130. sql/sql_base.cc: Changed the way table->query_id is tested and set during with locked tables in effect. This makes some SP test cases work with WL#2130, but has a side effect on some error cases with explicit LOCK TABLES. It's still debated if this is the correct way, so it might change. sql/sql_class.h: Added flags for circumventing some interference between WL#2130 and mysql_make_view(). sql/sql_derived.cc: Added some missing initializations. (Potential bugs.) sql/sql_lex.cc: Clear the new hash tables for WL#2130. sql/sql_lex.h: Added hash tables for procedures and tables too (as for functions), for WL#2130. sql/sql_parse.cc: WL#2130: Make table accesses from stored functions work by adding an implicit LOCK TABLES around (most) executed statements. To do this, we have to go through a loop where we collect all SPs and tables in mysql_execute_statement. sql/sql_prepare.cc: Cache both functions and procedures for WL#2130. sql/sql_show.cc: Added some missing initializations. (Potential bugs.) sql/sql_view.cc: Shortcut mysql_make_view() if thd->shortcut_make_view is true during the pre-open phase for collecting tables in WL#2130. Otherwise, the similar mechanism here causes interference. sql/sql_yacc.yy: For WL#2130, added caching of procedures and disallowed LOCK/UNLOCK TABLES in SPs.
Diffstat (limited to 'sql/sp_head.h')
-rw-r--r--sql/sp_head.h24
1 files changed, 19 insertions, 5 deletions
diff --git a/sql/sp_head.h b/sql/sp_head.h
index c4d2068661c..5df9c753048 100644
--- a/sql/sp_head.h
+++ b/sql/sp_head.h
@@ -92,11 +92,6 @@ public:
uint m_old_cmq; // Old CLIENT_MULTI_QUERIES value
st_sp_chistics *m_chistics;
ulong m_sql_mode; // For SHOW CREATE
-#if NOT_USED_NOW
- // QQ We're not using this at the moment.
- List<char *> m_calls; // Called procedures.
- List<char *> m_tables; // Used tables.
-#endif
LEX_STRING m_qname; // db.name
LEX_STRING m_db;
LEX_STRING m_name;
@@ -108,6 +103,7 @@ public:
LEX_STRING m_definer_host;
longlong m_created;
longlong m_modified;
+ HASH m_sptabs; /* Merged table lists */
// Pointers set during parsing
uchar *m_param_begin, *m_param_end, *m_returns_begin, *m_returns_end,
*m_body_begin;
@@ -897,4 +893,22 @@ void
sp_restore_security_context(THD *thd, sp_head *sp,st_sp_security_context *ctxp);
#endif /* NO_EMBEDDED_ACCESS_CHECKS */
+bool
+sp_merge_table_list(THD *thd, HASH *h, TABLE_LIST *table,
+ LEX *lex_for_tmp_check = 0);
+void
+sp_merge_routine_tables(THD *thd, LEX *lex);
+void
+sp_merge_table_hash(HASH *hdst, HASH *hsrc);
+TABLE_LIST *
+sp_hash_to_table_list(THD *thd, HASH *h);
+bool
+sp_open_and_lock_tables(THD *thd, TABLE_LIST *tables);
+void
+sp_unlock_tables(THD *thd);
+TABLE_LIST *
+sp_add_to_query_tables(THD *thd, LEX *lex,
+ const char *db, const char *name,
+ thr_lock_type locktype);
+
#endif /* _SP_HEAD_H_ */