The world's most popular open source database
00001 /* -*- C++ -*- */ 00002 /* Copyright (C) 2002 MySQL AB 00003 00004 This program is free software; you can redistribute it and/or modify 00005 it under the terms of the GNU General Public License as published by 00006 the Free Software Foundation; either version 2 of the License, or 00007 (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU General Public License for more details. 00013 00014 You should have received a copy of the GNU General Public License 00015 along with this program; if not, write to the Free Software 00016 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 00017 00018 #ifndef _SP_H_ 00019 #define _SP_H_ 00020 00021 // Return codes from sp_create_*, sp_drop_*, and sp_show_*: 00022 #define SP_OK 0 00023 #define SP_KEY_NOT_FOUND -1 00024 #define SP_OPEN_TABLE_FAILED -2 00025 #define SP_WRITE_ROW_FAILED -3 00026 #define SP_DELETE_ROW_FAILED -4 00027 #define SP_GET_FIELD_FAILED -5 00028 #define SP_PARSE_ERROR -6 00029 #define SP_INTERNAL_ERROR -7 00030 #define SP_NO_DB_ERROR -8 00031 #define SP_BAD_IDENTIFIER -9 00032 #define SP_BODY_TOO_LONG -10 00033 00034 /* Drop all routines in database 'db' */ 00035 int 00036 sp_drop_db_routines(THD *thd, char *db); 00037 00038 sp_head * 00039 sp_find_routine(THD *thd, int type, sp_name *name, 00040 sp_cache **cp, bool cache_only); 00041 00042 int 00043 sp_exist_routines(THD *thd, TABLE_LIST *procs, bool any, bool no_error); 00044 00045 int 00046 sp_routine_exists_in_table(THD *thd, int type, sp_name *name); 00047 00048 int 00049 sp_create_procedure(THD *thd, sp_head *sp); 00050 00051 int 00052 sp_drop_procedure(THD *thd, sp_name *name); 00053 00054 00055 int 00056 sp_update_procedure(THD *thd, sp_name *name, st_sp_chistics *chistics); 00057 00058 int 00059 sp_show_create_procedure(THD *thd, sp_name *name); 00060 00061 int 00062 sp_show_status_procedure(THD *thd, const char *wild); 00063 00064 int 00065 sp_create_function(THD *thd, sp_head *sp); 00066 00067 int 00068 sp_drop_function(THD *thd, sp_name *name); 00069 00070 int 00071 sp_update_function(THD *thd, sp_name *name, st_sp_chistics *chistics); 00072 00073 int 00074 sp_show_create_function(THD *thd, sp_name *name); 00075 00076 int 00077 sp_show_status_function(THD *thd, const char *wild); 00078 00079 00080 /* 00081 Procedures for pre-caching of stored routines and building table list 00082 for prelocking. 00083 */ 00084 void sp_get_prelocking_info(THD *thd, bool *need_prelocking, 00085 bool *first_no_prelocking); 00086 void sp_add_used_routine(LEX *lex, Query_arena *arena, 00087 sp_name *rt, char rt_type); 00088 void sp_remove_not_own_routines(LEX *lex); 00089 void sp_update_sp_used_routines(HASH *dst, HASH *src); 00090 int sp_cache_routines_and_add_tables(THD *thd, LEX *lex, 00091 bool first_no_prelock); 00092 int sp_cache_routines_and_add_tables_for_view(THD *thd, LEX *lex, 00093 TABLE_LIST *view); 00094 int sp_cache_routines_and_add_tables_for_triggers(THD *thd, LEX *lex, 00095 TABLE_LIST *table); 00096 00097 extern "C" byte* sp_sroutine_key(const byte *ptr, uint *plen, my_bool first); 00098 00099 /* 00100 Routines which allow open/lock and close mysql.proc table even when 00101 we already have some tables open and locked. 00102 */ 00103 TABLE *open_proc_table_for_read(THD *thd, Open_tables_state *backup); 00104 void close_proc_table(THD *thd, Open_tables_state *backup); 00105 00106 00107 /* 00108 Do a "use new_db". The current db is stored at old_db. If new_db is the 00109 same as the current one, nothing is changed. dbchangedp is set to true if 00110 the db was actually changed. 00111 */ 00112 00113 int 00114 sp_use_new_db(THD *thd, LEX_STRING new_db, LEX_STRING *old_db, 00115 bool no_access_check, bool *dbchangedp); 00116 00117 #endif /* _SP_H_ */
1.4.7

