The world's most popular open source database
#include "mysql_priv.h"#include "sp.h"#include "sp_head.h"#include "sp_cache.h"#include "sql_trigger.h"#include <my_user.h>Include dependency graph for sp.cc:

Go to the source code of this file.
Classes | |
| struct | st_used_field |
| struct | Sroutine_hash_entry |
Defines | |
| #define | SP_DEFAULT_ACCESS_MAPPING SP_CONTAINS_SQL |
Enumerations | |
| enum | { MYSQL_PROC_FIELD_DB = 0, MYSQL_PROC_FIELD_NAME, MYSQL_PROC_FIELD_TYPE, MYSQL_PROC_FIELD_SPECIFIC_NAME, MYSQL_PROC_FIELD_LANGUAGE, MYSQL_PROC_FIELD_ACCESS, MYSQL_PROC_FIELD_DETERMINISTIC, MYSQL_PROC_FIELD_SECURITY_TYPE, MYSQL_PROC_FIELD_PARAM_LIST, MYSQL_PROC_FIELD_RETURNS, MYSQL_PROC_FIELD_BODY, MYSQL_PROC_FIELD_DEFINER, MYSQL_PROC_FIELD_CREATED, MYSQL_PROC_FIELD_MODIFIED, MYSQL_PROC_FIELD_SQL_MODE, MYSQL_PROC_FIELD_COMMENT, MYSQL_PROC_FIELD_COUNT } |
Functions | |
| static bool | create_string (THD *thd, String *buf, int sp_type, sp_name *name, const char *params, ulong paramslen, const char *returns, ulong returnslen, const char *body, ulong bodylen, st_sp_chistics *chistics, const LEX_STRING *definer_user, const LEX_STRING *definer_host) |
| static int | db_load_routine (THD *thd, int type, sp_name *name, sp_head **sphp, ulong sql_mode, const char *params, const char *returns, const char *body, st_sp_chistics &chistics, const char *definer, longlong created, longlong modified) |
| void | close_proc_table (THD *thd, Open_tables_state *backup) |
| TABLE * | open_proc_table_for_read (THD *thd, Open_tables_state *backup) |
| static TABLE * | open_proc_table_for_update (THD *thd) |
| static int | db_find_routine_aux (THD *thd, int type, sp_name *name, TABLE *table) |
| static int | db_find_routine (THD *thd, int type, sp_name *name, sp_head **sphp) |
| static void | sp_returns_type (THD *thd, String &result, sp_head *sp) |
| static int | db_create_routine (THD *thd, int type, sp_head *sp) |
| static int | db_drop_routine (THD *thd, int type, sp_name *name) |
| static int | db_update_routine (THD *thd, int type, sp_name *name, st_sp_chistics *chistics) |
| static int | print_field_values (THD *thd, TABLE *table, struct st_used_field *used_fields, int type, const char *wild) |
| static int | db_show_routine_status (THD *thd, int type, const char *wild) |
| int | sp_drop_db_routines (THD *thd, char *db) |
| sp_head * | sp_find_routine (THD *thd, int type, sp_name *name, sp_cache **cp, bool cache_only) |
| int | sp_exist_routines (THD *thd, TABLE_LIST *routines, bool any, bool no_error) |
| int | sp_routine_exists_in_table (THD *thd, int type, sp_name *name) |
| int | sp_create_procedure (THD *thd, sp_head *sp) |
| int | sp_drop_procedure (THD *thd, sp_name *name) |
| int | sp_update_procedure (THD *thd, sp_name *name, st_sp_chistics *chistics) |
| int | sp_show_create_procedure (THD *thd, sp_name *name) |
| int | sp_show_status_procedure (THD *thd, const char *wild) |
| int | sp_create_function (THD *thd, sp_head *sp) |
| int | sp_drop_function (THD *thd, sp_name *name) |
| int | sp_update_function (THD *thd, sp_name *name, st_sp_chistics *chistics) |
| int | sp_show_create_function (THD *thd, sp_name *name) |
| int | sp_show_status_function (THD *thd, const char *wild) |
| byte * | sp_sroutine_key (const byte *ptr, uint *plen, my_bool first) |
| void | sp_get_prelocking_info (THD *thd, bool *need_prelocking, bool *first_no_prelocking) |
| static bool | add_used_routine (LEX *lex, Query_arena *arena, const LEX_STRING *key, TABLE_LIST *belong_to_view) |
| void | sp_add_used_routine (LEX *lex, Query_arena *arena, sp_name *rt, char rt_type) |
| void | sp_remove_not_own_routines (LEX *lex) |
| void | sp_update_sp_used_routines (HASH *dst, HASH *src) |
| static void | sp_update_stmt_used_routines (THD *thd, LEX *lex, HASH *src, TABLE_LIST *belong_to_view) |
| static void | sp_update_stmt_used_routines (THD *thd, LEX *lex, SQL_LIST *src, TABLE_LIST *belong_to_view) |
| static int | sp_cache_routines_and_add_tables_aux (THD *thd, LEX *lex, Sroutine_hash_entry *start, bool first_no_prelock) |
| int | sp_cache_routines_and_add_tables (THD *thd, LEX *lex, bool first_no_prelock) |
| int | sp_cache_routines_and_add_tables_for_view (THD *thd, LEX *lex, TABLE_LIST *view) |
| int | sp_cache_routines_and_add_tables_for_triggers (THD *thd, LEX *lex, TABLE_LIST *table) |
| int | sp_use_new_db (THD *thd, LEX_STRING new_db, LEX_STRING *old_db, bool no_access_check, bool *dbchangedp) |
Variables | |
| bool | mysql_proc_table_exists = 1 |
| static struct st_used_field | init_fields [] |
| #define SP_DEFAULT_ACCESS_MAPPING SP_CONTAINS_SQL |
| anonymous enum |
Definition at line 47 of file sp.cc.
00048 { 00049 MYSQL_PROC_FIELD_DB = 0, 00050 MYSQL_PROC_FIELD_NAME, 00051 MYSQL_PROC_FIELD_TYPE, 00052 MYSQL_PROC_FIELD_SPECIFIC_NAME, 00053 MYSQL_PROC_FIELD_LANGUAGE, 00054 MYSQL_PROC_FIELD_ACCESS, 00055 MYSQL_PROC_FIELD_DETERMINISTIC, 00056 MYSQL_PROC_FIELD_SECURITY_TYPE, 00057 MYSQL_PROC_FIELD_PARAM_LIST, 00058 MYSQL_PROC_FIELD_RETURNS, 00059 MYSQL_PROC_FIELD_BODY, 00060 MYSQL_PROC_FIELD_DEFINER, 00061 MYSQL_PROC_FIELD_CREATED, 00062 MYSQL_PROC_FIELD_MODIFIED, 00063 MYSQL_PROC_FIELD_SQL_MODE, 00064 MYSQL_PROC_FIELD_COMMENT, 00065 MYSQL_PROC_FIELD_COUNT 00066 };
| static bool add_used_routine | ( | LEX * | lex, | |
| Query_arena * | arena, | |||
| const LEX_STRING * | key, | |||
| TABLE_LIST * | belong_to_view | |||
| ) | [static] |
Definition at line 1377 of file sp.cc.
References FALSE, hash_search(), Sroutine_hash_entry::key, key, LEX_STRING::length, memcpy, my_hash_insert(), LEX_STRING::str, and TRUE.
Referenced by sp_add_used_routine(), sp_cache_routines_and_add_tables_for_triggers(), and sp_update_stmt_used_routines().
01380 { 01381 if (!hash_search(&lex->sroutines, (byte *)key->str, key->length)) 01382 { 01383 Sroutine_hash_entry *rn= 01384 (Sroutine_hash_entry *)arena->alloc(sizeof(Sroutine_hash_entry) + 01385 key->length); 01386 if (!rn) // OOM. Error will be reported using fatal_error(). 01387 return FALSE; 01388 rn->key.length= key->length; 01389 rn->key.str= (char *)rn + sizeof(Sroutine_hash_entry); 01390 memcpy(rn->key.str, key->str, key->length); 01391 my_hash_insert(&lex->sroutines, (byte *)rn); 01392 lex->sroutines_list.link_in_list((byte *)rn, (byte **)&rn->next); 01393 rn->belong_to_view= belong_to_view; 01394 return TRUE; 01395 } 01396 return FALSE; 01397 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void close_proc_table | ( | THD * | thd, | |
| Open_tables_state * | backup | |||
| ) |
Definition at line 85 of file sp.cc.
References close_thread_tables().
Referenced by db_find_routine(), fill_schema_proc(), open_proc_table_for_read(), and sp_routine_exists_in_table().
00086 { 00087 close_thread_tables(thd); 00088 thd->restore_backup_open_tables_state(backup); 00089 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static bool create_string | ( | THD * | thd, | |
| String * | buf, | |||
| int | sp_type, | |||
| sp_name * | name, | |||
| const char * | params, | |||
| ulong | paramslen, | |||
| const char * | returns, | |||
| ulong | returnslen, | |||
| const char * | body, | |||
| ulong | bodylen, | |||
| st_sp_chistics * | chistics, | |||
| const LEX_STRING * | definer_user, | |||
| const LEX_STRING * | definer_host | |||
| ) | [static] |
Definition at line 1761 of file sp.cc.
References append_definer(), append_identifier(), append_unescaped(), buf, FALSE, name, STRING_WITH_LEN, TRUE, TYPE_ENUM_FUNCTION, and USER_HOST_BUFF_SIZE.
01770 { 01771 /* Make some room to begin with */ 01772 if (buf->alloc(100 + name->m_qname.length + paramslen + returnslen + bodylen + 01773 chistics->comment.length + 10 /* length of " DEFINER= "*/ + 01774 USER_HOST_BUFF_SIZE)) 01775 return FALSE; 01776 01777 buf->append(STRING_WITH_LEN("CREATE ")); 01778 append_definer(thd, buf, definer_user, definer_host); 01779 if (type == TYPE_ENUM_FUNCTION) 01780 buf->append(STRING_WITH_LEN("FUNCTION ")); 01781 else 01782 buf->append(STRING_WITH_LEN("PROCEDURE ")); 01783 append_identifier(thd, buf, name->m_name.str, name->m_name.length); 01784 buf->append('('); 01785 buf->append(params, paramslen); 01786 buf->append(')'); 01787 if (type == TYPE_ENUM_FUNCTION) 01788 { 01789 buf->append(STRING_WITH_LEN(" RETURNS ")); 01790 buf->append(returns, returnslen); 01791 } 01792 buf->append('\n'); 01793 switch (chistics->daccess) { 01794 case SP_NO_SQL: 01795 buf->append(STRING_WITH_LEN(" NO SQL\n")); 01796 break; 01797 case SP_READS_SQL_DATA: 01798 buf->append(STRING_WITH_LEN(" READS SQL DATA\n")); 01799 break; 01800 case SP_MODIFIES_SQL_DATA: 01801 buf->append(STRING_WITH_LEN(" MODIFIES SQL DATA\n")); 01802 break; 01803 case SP_DEFAULT_ACCESS: 01804 case SP_CONTAINS_SQL: 01805 /* Do nothing */ 01806 break; 01807 } 01808 if (chistics->detistic) 01809 buf->append(STRING_WITH_LEN(" DETERMINISTIC\n")); 01810 if (chistics->suid == SP_IS_NOT_SUID) 01811 buf->append(STRING_WITH_LEN(" SQL SECURITY INVOKER\n")); 01812 if (chistics->comment.length) 01813 { 01814 buf->append(STRING_WITH_LEN(" COMMENT ")); 01815 append_unescaped(buf, chistics->comment.str, chistics->comment.length); 01816 buf->append('\n'); 01817 } 01818 buf->append(body, bodylen); 01819 return TRUE; 01820 }
Here is the call graph for this function:

| static int db_create_routine | ( | THD * | thd, | |
| int | type, | |||
| sp_head * | sp | |||
| ) | [static] |
Definition at line 511 of file sp.cc.
References access, String::append(), append_definer(), String::c_ptr(), Field::char_length(), close_thread_tables(), charset_info_st::cset, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, ER, ER_BINLOG_CREATE_ROUTINE_NEED_SUPER, ER_BINLOG_UNSAFE_ROUTINE, FALSE, st_table::field, st_table_share::fields, st_table::file, handler::ha_write_row(), MYSQL_LOG::is_open(), String::length(), LEX_STRING::length, sp_head::m_body, sp_head::m_body_begin, sp_head::m_chistics, sp_head::m_db, sp_head::m_name, sp_head::m_params, sp_head::m_type, my_message(), MYF, mysql_bin_log, mysql_change_db(), MYSQL_PROC_FIELD_ACCESS, MYSQL_PROC_FIELD_BODY, MYSQL_PROC_FIELD_COMMENT, MYSQL_PROC_FIELD_COUNT, MYSQL_PROC_FIELD_CREATED, MYSQL_PROC_FIELD_DB, MYSQL_PROC_FIELD_DEFINER, MYSQL_PROC_FIELD_DETERMINISTIC, MYSQL_PROC_FIELD_MODIFIED, MYSQL_PROC_FIELD_NAME, MYSQL_PROC_FIELD_PARAM_LIST, MYSQL_PROC_FIELD_RETURNS, MYSQL_PROC_FIELD_SECURITY_TYPE, MYSQL_PROC_FIELD_SPECIFIC_NAME, MYSQL_PROC_FIELD_SQL_MODE, MYSQL_PROC_FIELD_TYPE, NAME_LEN, NullS, my_charset_handler_st::numchars, open_proc_table_for_update(), String::ptr(), st_table::record, restore_record, st_table::s, String::set_charset(), SP_BAD_IDENTIFIER, SP_BODY_TOO_LONG, SP_DEFAULT_ACCESS_MAPPING, SP_GET_FIELD_FAILED, SP_INTERNAL_ERROR, SP_NO_DB_ERROR, SP_OK, SP_OPEN_TABLE_FAILED, sp_returns_type(), sp_use_new_db(), SP_WRITE_ROW_FAILED, LEX_STRING::str, STRING_WITH_LEN, strlen(), strxnmov(), SUPER_ACL, system_charset_info, TRUE, trust_function_creators, TYPE_ENUM_FUNCTION, and USER_HOST_BUFF_SIZE.
Referenced by sp_create_function(), and sp_create_procedure().
00512 { 00513 int ret; 00514 TABLE *table; 00515 char definer[USER_HOST_BUFF_SIZE]; 00516 char old_db_buf[NAME_LEN+1]; 00517 LEX_STRING old_db= { old_db_buf, sizeof(old_db_buf) }; 00518 bool dbchanged; 00519 DBUG_ENTER("db_create_routine"); 00520 DBUG_PRINT("enter", ("type: %d name: %.*s",type,sp->m_name.length, 00521 sp->m_name.str)); 00522 00523 if ((ret= sp_use_new_db(thd, sp->m_db, &old_db, 0, &dbchanged))) 00524 { 00525 ret= SP_NO_DB_ERROR; 00526 goto done; 00527 } 00528 00529 if (!(table= open_proc_table_for_update(thd))) 00530 ret= SP_OPEN_TABLE_FAILED; 00531 else 00532 { 00533 restore_record(table, s->default_values); // Get default values for fields 00534 00535 /* NOTE: all needed privilege checks have been already done. */ 00536 strxnmov(definer, sizeof(definer)-1, thd->lex->definer->user.str, "@", 00537 thd->lex->definer->host.str, NullS); 00538 00539 if (table->s->fields != MYSQL_PROC_FIELD_COUNT) 00540 { 00541 ret= SP_GET_FIELD_FAILED; 00542 goto done; 00543 } 00544 00545 if (system_charset_info->cset->numchars(system_charset_info, 00546 sp->m_name.str, 00547 sp->m_name.str+sp->m_name.length) > 00548 table->field[MYSQL_PROC_FIELD_NAME]->char_length()) 00549 { 00550 ret= SP_BAD_IDENTIFIER; 00551 goto done; 00552 } 00553 if (sp->m_body.length > table->field[MYSQL_PROC_FIELD_BODY]->field_length) 00554 { 00555 ret= SP_BODY_TOO_LONG; 00556 goto done; 00557 } 00558 table->field[MYSQL_PROC_FIELD_DB]-> 00559 store(sp->m_db.str, sp->m_db.length, system_charset_info); 00560 table->field[MYSQL_PROC_FIELD_NAME]-> 00561 store(sp->m_name.str, sp->m_name.length, system_charset_info); 00562 table->field[MYSQL_PROC_FIELD_TYPE]-> 00563 store((longlong)type, TRUE); 00564 table->field[MYSQL_PROC_FIELD_SPECIFIC_NAME]-> 00565 store(sp->m_name.str, sp->m_name.length, system_charset_info); 00566 if (sp->m_chistics->daccess != SP_DEFAULT_ACCESS) 00567 table->field[MYSQL_PROC_FIELD_ACCESS]-> 00568 store((longlong)sp->m_chistics->daccess, TRUE); 00569 table->field[MYSQL_PROC_FIELD_DETERMINISTIC]-> 00570 store((longlong)(sp->m_chistics->detistic ? 1 : 2), TRUE); 00571 if (sp->m_chistics->suid != SP_IS_DEFAULT_SUID) 00572 table->field[MYSQL_PROC_FIELD_SECURITY_TYPE]-> 00573 store((longlong)sp->m_chistics->suid, TRUE); 00574 table->field[MYSQL_PROC_FIELD_PARAM_LIST]-> 00575 store(sp->m_params.str, sp->m_params.length, system_charset_info); 00576 if (sp->m_type == TYPE_ENUM_FUNCTION) 00577 { 00578 String retstr(64); 00579 sp_returns_type(thd, retstr, sp); 00580 table->field[MYSQL_PROC_FIELD_RETURNS]-> 00581 store(retstr.ptr(), retstr.length(), system_charset_info); 00582 } 00583 table->field[MYSQL_PROC_FIELD_BODY]-> 00584 store(sp->m_body.str, sp->m_body.length, system_charset_info); 00585 table->field[MYSQL_PROC_FIELD_DEFINER]-> 00586 store(definer, (uint)strlen(definer), system_charset_info); 00587 ((Field_timestamp *)table->field[MYSQL_PROC_FIELD_CREATED])->set_time(); 00588 ((Field_timestamp *)table->field[MYSQL_PROC_FIELD_MODIFIED])->set_time(); 00589 table->field[MYSQL_PROC_FIELD_SQL_MODE]-> 00590 store((longlong)thd->variables.sql_mode, TRUE); 00591 if (sp->m_chistics->comment.str) 00592 table->field[MYSQL_PROC_FIELD_COMMENT]-> 00593 store(sp->m_chistics->comment.str, sp->m_chistics->comment.length, 00594 system_charset_info); 00595 00596 if ((sp->m_type == TYPE_ENUM_FUNCTION) && 00597 !trust_function_creators && mysql_bin_log.is_open()) 00598 { 00599 if (!sp->m_chistics->detistic) 00600 { 00601 /* 00602 Note that this test is not perfect; one could use 00603 a non-deterministic read-only function in an update statement. 00604 */ 00605 enum enum_sp_data_access access= 00606 (sp->m_chistics->daccess == SP_DEFAULT_ACCESS) ? 00607 SP_DEFAULT_ACCESS_MAPPING : sp->m_chistics->daccess; 00608 if (access == SP_CONTAINS_SQL || 00609 access == SP_MODIFIES_SQL_DATA) 00610 { 00611 my_message(ER_BINLOG_UNSAFE_ROUTINE, 00612 ER(ER_BINLOG_UNSAFE_ROUTINE), MYF(0)); 00613 ret= SP_INTERNAL_ERROR; 00614 goto done; 00615 } 00616 } 00617 if (!(thd->security_ctx->master_access & SUPER_ACL)) 00618 { 00619 my_message(ER_BINLOG_CREATE_ROUTINE_NEED_SUPER, 00620 ER(ER_BINLOG_CREATE_ROUTINE_NEED_SUPER), MYF(0)); 00621 ret= SP_INTERNAL_ERROR; 00622 goto done; 00623 } 00624 } 00625 00626 ret= SP_OK; 00627 if (table->file->ha_write_row(table->record[0])) 00628 ret= SP_WRITE_ROW_FAILED; 00629 else if (mysql_bin_log.is_open()) 00630 { 00631 thd->clear_error(); 00632 00633 String log_query; 00634 log_query.set_charset(system_charset_info); 00635 log_query.append(STRING_WITH_LEN("CREATE ")); 00636 append_definer(thd, &log_query, &thd->lex->definer->user, 00637 &thd->lex->definer->host); 00638 log_query.append(thd->lex->stmt_definition_begin, 00639 (char *)sp->m_body_begin - 00640 thd->lex->stmt_definition_begin + 00641 sp->m_body.length); 00642 00643 /* Such a statement can always go directly to binlog, no trans cache */ 00644 thd->binlog_query(THD::MYSQL_QUERY_TYPE, 00645 log_query.c_ptr(), log_query.length(), FALSE, FALSE); 00646 } 00647 00648 } 00649 00650 done: 00651 close_thread_tables(thd); 00652 if (dbchanged) 00653 (void) mysql_change_db(thd, old_db.str, 1); 00654 DBUG_RETURN(ret); 00655 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static int db_drop_routine | ( | THD * | thd, | |
| int | type, | |||
| sp_name * | name | |||
| ) | [static] |
Definition at line 659 of file sp.cc.
References close_thread_tables(), db_find_routine_aux(), DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, st_table::file, handler::ha_delete_row(), name, open_proc_table_for_update(), st_table::record, SP_DELETE_ROW_FAILED, SP_OK, and SP_OPEN_TABLE_FAILED.
Referenced by sp_drop_function(), and sp_drop_procedure().
00660 { 00661 TABLE *table; 00662 int ret; 00663 DBUG_ENTER("db_drop_routine"); 00664 DBUG_PRINT("enter", ("type: %d name: %.*s", 00665 type, name->m_name.length, name->m_name.str)); 00666 00667 if (!(table= open_proc_table_for_update(thd))) 00668 DBUG_RETURN(SP_OPEN_TABLE_FAILED); 00669 if ((ret= db_find_routine_aux(thd, type, name, table)) == SP_OK) 00670 { 00671 if (table->file->ha_delete_row(table->record[0])) 00672 ret= SP_DELETE_ROW_FAILED; 00673 } 00674 close_thread_tables(thd); 00675 DBUG_RETURN(ret); 00676 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 272 of file sp.cc.
References bzero, close_proc_table(), db_find_routine_aux(), db_load_routine(), DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, FALSE, st_table::field, st_table_share::fields, get_field(), String::length(), my_charset_bin, MYSQL_PROC_FIELD_ACCESS, MYSQL_PROC_FIELD_BODY, MYSQL_PROC_FIELD_COMMENT, MYSQL_PROC_FIELD_COUNT, MYSQL_PROC_FIELD_CREATED, MYSQL_PROC_FIELD_DEFINER, MYSQL_PROC_FIELD_DETERMINISTIC, MYSQL_PROC_FIELD_MODIFIED, MYSQL_PROC_FIELD_PARAM_LIST, MYSQL_PROC_FIELD_RETURNS, MYSQL_PROC_FIELD_SECURITY_TYPE, MYSQL_PROC_FIELD_SQL_MODE, name, NULL, open_proc_table_for_read(), String::ptr(), st_table::s, SP_DEFAULT_ACCESS_MAPPING, SP_GET_FIELD_FAILED, SP_OK, SP_OPEN_TABLE_FAILED, TRUE, TYPE_ENUM_PROCEDURE, Field::val_int(), and Field::val_str().
Referenced by sp_cache_routines_and_add_tables_aux(), and sp_find_routine().
00273 { 00274 TABLE *table; 00275 const char *params, *returns, *body; 00276 int ret; 00277 const char *definer; 00278 longlong created; 00279 longlong modified; 00280 st_sp_chistics chistics; 00281 char *ptr; 00282 uint length; 00283 char buff[65]; 00284 String str(buff, sizeof(buff), &my_charset_bin); 00285 ulong sql_mode; 00286 Open_tables_state open_tables_state_backup; 00287 DBUG_ENTER("db_find_routine"); 00288 DBUG_PRINT("enter", ("type: %d name: %.*s", 00289 type, name->m_name.length, name->m_name.str)); 00290 00291 *sphp= 0; // In case of errors 00292 if (!(table= open_proc_table_for_read(thd, &open_tables_state_backup))) 00293 DBUG_RETURN(SP_OPEN_TABLE_FAILED); 00294 00295 if ((ret= db_find_routine_aux(thd, type, name, table)) != SP_OK) 00296 goto done; 00297 00298 if (table->s->fields != MYSQL_PROC_FIELD_COUNT) 00299 { 00300 ret= SP_GET_FIELD_FAILED; 00301 goto done; 00302 } 00303 00304 bzero((char *)&chistics, sizeof(chistics)); 00305 if ((ptr= get_field(thd->mem_root, 00306 table->field[MYSQL_PROC_FIELD_ACCESS])) == NULL) 00307 { 00308 ret= SP_GET_FIELD_FAILED; 00309 goto done; 00310 } 00311 switch (ptr[0]) { 00312 case 'N': 00313 chistics.daccess= SP_NO_SQL; 00314 break; 00315 case 'C': 00316 chistics.daccess= SP_CONTAINS_SQL; 00317 break; 00318 case 'R': 00319 chistics.daccess= SP_READS_SQL_DATA; 00320 break; 00321 case 'M': 00322 chistics.daccess= SP_MODIFIES_SQL_DATA; 00323 break; 00324 default: 00325 chistics.daccess= SP_DEFAULT_ACCESS_MAPPING; 00326 } 00327 00328 if ((ptr= get_field(thd->mem_root, 00329 table->field[MYSQL_PROC_FIELD_DETERMINISTIC])) == NULL) 00330 { 00331 ret= SP_GET_FIELD_FAILED; 00332 goto done; 00333 } 00334 chistics.detistic= (ptr[0] == 'N' ? FALSE : TRUE); 00335 00336 if ((ptr= get_field(thd->mem_root, 00337 table->field[MYSQL_PROC_FIELD_SECURITY_TYPE])) == NULL) 00338 { 00339 ret= SP_GET_FIELD_FAILED; 00340 goto done; 00341 } 00342 chistics.suid= (ptr[0] == 'I' ? SP_IS_NOT_SUID : SP_IS_SUID); 00343 00344 if ((params= get_field(thd->mem_root, 00345 table->field[MYSQL_PROC_FIELD_PARAM_LIST])) == NULL) 00346 { 00347 params= ""; 00348 } 00349 00350 if (type == TYPE_ENUM_PROCEDURE) 00351 returns= ""; 00352 else if ((returns= get_field(thd->mem_root, 00353 table->field[MYSQL_PROC_FIELD_RETURNS])) == NULL) 00354 { 00355 ret= SP_GET_FIELD_FAILED; 00356 goto done; 00357 } 00358 00359 if ((body= get_field(thd->mem_root, 00360 table->field[MYSQL_PROC_FIELD_BODY])) == NULL) 00361 { 00362 ret= SP_GET_FIELD_FAILED; 00363 goto done; 00364 } 00365 00366 // Get additional information 00367 if ((definer= get_field(thd->mem_root, 00368 table->field[MYSQL_PROC_FIELD_DEFINER])) == NULL) 00369 { 00370 ret= SP_GET_FIELD_FAILED; 00371 goto done; 00372 } 00373 00374 modified= table->field[MYSQL_PROC_FIELD_MODIFIED]->val_int(); 00375 created= table->field[MYSQL_PROC_FIELD_CREATED]->val_int(); 00376 00377 sql_mode= (ulong) table->field[MYSQL_PROC_FIELD_SQL_MODE]->val_int(); 00378 00379 table->field[MYSQL_PROC_FIELD_COMMENT]->val_str(&str, &str); 00380 00381 ptr= 0; 00382 if ((length= str.length())) 00383 ptr= thd->strmake(str.ptr(), length); 00384 chistics.comment.str= ptr; 00385 chistics.comment.length= length; 00386 00387 close_proc_table(thd, &open_tables_state_backup); 00388 table= 0; 00389 00390 ret= db_load_routine(thd, type, name, sphp, 00391 sql_mode, params, returns, body, chistics, 00392 definer, created, modified); 00393 00394 done: 00395 if (table) 00396 close_proc_table(thd, &open_tables_state_backup); 00397 DBUG_RETURN(ret); 00398 }
Here is the call graph for this function:


