#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:

Here is the caller graph for this function:

Definition at line 218 of file sp.cc.
References DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, st_table::field, Field::field_length, st_table::file, HA_READ_KEY_EXACT, handler::index_read_idx(), key, key_copy(), st_table::key_info, st_key::key_length, MAX_KEY_LENGTH, my_charset_bin, name, st_table::record, SP_KEY_NOT_FOUND, SP_OK, Field::store(), and TRUE.
Referenced by db_drop_routine(), db_find_routine(), db_update_routine(), and sp_routine_exists_in_table().
00219 { 00220 byte key[MAX_KEY_LENGTH]; // db, name, optional key length type 00221 DBUG_ENTER("db_find_routine_aux"); 00222 DBUG_PRINT("enter", ("type: %d name: %.*s", 00223 type, name->m_name.length, name->m_name.str)); 00224 00225 /* 00226 Create key to find row. We have to use field->store() to be able to 00227 handle VARCHAR and CHAR fields. 00228 Assumption here is that the three first fields in the table are 00229 'db', 'name' and 'type' and the first key is the primary key over the 00230 same fields. 00231 */ 00232 if (name->m_name.length > table->field[1]->field_length) 00233 DBUG_RETURN(SP_KEY_NOT_FOUND); 00234 table->field[0]->store(name->m_db.str, name->m_db.length, &my_charset_bin); 00235 table->field[1]->store(name->m_name.str, name->m_name.length, 00236 &my_charset_bin); 00237 table->field[2]->store((longlong) type, TRUE); 00238 key_copy(key, table->record[0], table->key_info, 00239 table->key_info->key_length); 00240 00241 if (table->file->index_read_idx(table->record[0], 0, 00242 key, table->key_info->key_length, 00243 HA_READ_KEY_EXACT)) 00244 DBUG_RETURN(SP_KEY_NOT_FOUND); 00245 00246 DBUG_RETURN(SP_OK); 00247 }
Here is the call graph for this function:

Here is the caller graph for this function:

| 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 | |||
| ) | [static] |
Definition at line 402 of file sp.cc.
References String::c_ptr(), create_string, HA_POS_ERROR, HOSTNAME_LENGTH, String::length(), LEX_STRING::length, lex_end(), lex_start(), mysql_change_db(), name, NAME_LEN, NULL, parse_user(), String::set_charset(), sp_head::set_definer(), SP_INTERNAL_ERROR, SP_PARSE_ERROR, sp_use_new_db(), LEX_STRING::str, strlen(), system_charset_info, and USERNAME_LENGTH.
Referenced by db_find_routine(), and sp_find_routine().
00406 { 00407 LEX *old_lex= thd->lex, newlex; 00408 String defstr; 00409 char old_db_buf[NAME_LEN+1]; 00410 LEX_STRING old_db= { old_db_buf, sizeof(old_db_buf) }; 00411 bool dbchanged; 00412 ulong old_sql_mode= thd->variables.sql_mode; 00413 ha_rows old_select_limit= thd->variables.select_limit; 00414 sp_rcontext *old_spcont= thd->spcont; 00415 00416 char definer_user_name_holder[USERNAME_LENGTH + 1]; 00417 LEX_STRING definer_user_name= { definer_user_name_holder, USERNAME_LENGTH }; 00418 00419 char definer_host_name_holder[HOSTNAME_LENGTH + 1]; 00420 LEX_STRING definer_host_name= { definer_host_name_holder, HOSTNAME_LENGTH }; 00421 00422 int ret; 00423 00424 thd->variables.sql_mode= sql_mode; 00425 thd->variables.select_limit= HA_POS_ERROR; 00426 00427 thd->lex= &newlex; 00428 newlex.current_select= NULL; 00429 00430 parse_user(definer, strlen(definer), 00431 definer_user_name.str, &definer_user_name.length, 00432 definer_host_name.str, &definer_host_name.length); 00433 00434 defstr.set_charset(system_charset_info); 00435 00436 /* 00437 We have to add DEFINER clause and provide proper routine characterstics in 00438 routine definition statement that we build here to be able to use this 00439 definition for SHOW CREATE PROCEDURE later. 00440 */ 00441 00442 if (!create_string(thd, &defstr, 00443 type, 00444 name, 00445 params, strlen(params), 00446 returns, strlen(returns), 00447 body, strlen(body), 00448 &chistics, &definer_user_name, &definer_host_name)) 00449 { 00450 ret= SP_INTERNAL_ERROR; 00451 goto end; 00452 } 00453 00454 if ((ret= sp_use_new_db(thd, name->m_db, &old_db, 1, &dbchanged))) 00455 goto end; 00456 00457 lex_start(thd, (uchar*)defstr.c_ptr(), defstr.length()); 00458 00459 thd->spcont= 0; 00460 if (MYSQLparse(thd) || thd->is_fatal_error || newlex.sphead == NULL) 00461 { 00462 sp_head *sp= newlex.sphead; 00463 00464 if (dbchanged && (ret= mysql_change_db(thd, old_db.str, 1))) 00465 goto end; 00466 delete sp; 00467 ret= SP_PARSE_ERROR; 00468 } 00469 else 00470 { 00471 if (dbchanged && (ret= mysql_change_db(thd, old_db.str, 1))) 00472 goto end; 00473 *sphp= newlex.sphead; 00474 (*sphp)->set_definer(&definer_user_name, &definer_host_name); 00475 (*sphp)->set_info(created, modified, &chistics, sql_mode); 00476 (*sphp)->optimize(); 00477 } 00478 end: 00479 lex_end(thd->lex); 00480 thd->spcont= old_spcont; 00481 thd->variables.sql_mode= old_sql_mode; 00482 thd->variables.select_limit= old_select_limit; 00483 thd->lex= old_lex; 00484 return ret; 00485 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static int db_show_routine_status | ( | THD * | thd, | |
| int | type, | |||
| const char * | wild | |||
| ) | [static] |
Definition at line 791 of file sp.cc.
References array_elements, DBUG_ENTER, FALSE, st_used_field::field, st_used_field::field_length, st_used_field::field_name, st_used_field::field_type, st_table::file, find_field_in_tables(), HA_ERR_END_OF_FILE, handler::ha_index_init(), handler::index_first(), handler::index_next(), init_fields, memcpy, memset, MYSQL_TYPE_TIMESTAMP, NULL, open_ltable(), print_field_values(), List< T >::push_back(), st_table::record, Protocol::SEND_EOF, Protocol::SEND_NUM_ROWS, setup_tables(), SP_INTERNAL_ERROR, SP_OK, SP_OPEN_TABLE_FAILED, TL_READ, TRUE, and st_table::use_all_columns().
Referenced by sp_show_status_function(), and sp_show_status_procedure().
00792 { 00793 TABLE *table; 00794 TABLE_LIST tables; 00795 int res; 00796 DBUG_ENTER("db_show_routine_status"); 00797 00798 memset(&tables, 0, sizeof(tables)); 00799 tables.db= (char*)"mysql"; 00800 tables.table_name= tables.alias= (char*)"proc"; 00801 00802 if (! (table= open_ltable(thd, &tables, TL_READ))) 00803 { 00804 res= SP_OPEN_TABLE_FAILED; 00805 goto done; 00806 } 00807 else 00808 { 00809 Item *item; 00810 List<Item> field_list; 00811 struct st_used_field *used_field; 00812 TABLE_LIST *leaves= 0; 00813 st_used_field used_fields[array_elements(init_fields)]; 00814 00815 table->use_all_columns(); 00816 memcpy((char*) used_fields, (char*) init_fields, sizeof(used_fields)); 00817 /* Init header */ 00818 for (used_field= &used_fields[0]; 00819 used_field->field_name; 00820 used_field++) 00821 { 00822 switch (used_field->field_type) { 00823 case MYSQL_TYPE_TIMESTAMP: 00824 field_list.push_back(item=new Item_datetime(used_field->field_name)); 00825 break; 00826 default: 00827 field_list.push_back(item=new Item_empty_string(used_field->field_name, 00828 used_field-> 00829 field_length)); 00830 break; 00831 } 00832 } 00833 /* Print header */ 00834 if (thd->protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | 00835 Protocol::SEND_EOF)) 00836 { 00837 res= SP_INTERNAL_ERROR; 00838 goto err_case; 00839 } 00840 00841 /* 00842 Init fields 00843 00844 tables is not VIEW for sure => we can pass 0 as condition 00845 */ 00846 thd->lex->select_lex.context.resolve_in_table_list_only(&tables); 00847 setup_tables(thd, &thd->lex->select_lex.context, 00848 &thd->lex->select_lex.top_join_list, 00849 &tables, &leaves, FALSE); 00850 for (used_field= &used_fields[0]; 00851 used_field->field_name; 00852 used_field++) 00853 { 00854 Item_field *field= new Item_field(&thd->lex->select_lex.context, 00855 "mysql", "proc", 00856 used_field->field_name); 00857 if (!field || 00858 !(used_field->field= find_field_in_tables(thd, field, &tables, NULL, 00859 0, REPORT_ALL_ERRORS, 1, 00860 TRUE))) 00861 { 00862 res= SP_INTERNAL_ERROR; 00863 goto err_case1; 00864 } 00865 } 00866 00867 table->file->ha_index_init(0, 1); 00868 if ((res= table->file->index_first(table->record[0]))) 00869 { 00870 res= (res == HA_ERR_END_OF_FILE) ? 0 : SP_INTERNAL_ERROR; 00871 goto err_case1; 00872 } 00873 if ((res= print_field_values(thd, table, used_fields, type, wild))) 00874 goto err_case1; 00875 while (!table->file->index_next(table->record[0])) 00876 { 00877 if ((res= print_field_values(thd, table, used_fields, type, wild))) 00878 goto err_case1; 00879 } 00880 res= SP_OK; 00881 } 00882 00883 err_case1: 00884 send_eof(thd); 00885 err_case: 00886 table->file->ha_index_end(); 00887 close_thread_tables(thd); 00888 done: 00889 DBUG_RETURN(res); 00890 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static int db_update_routine | ( | THD * | thd, | |
| int | type, | |||
| sp_name * | name, | |||
| st_sp_chistics * | chistics | |||
| ) | [static] |
Definition at line 680 of file sp.cc.
References close_thread_tables(), db_find_routine_aux(), DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, MYSQL_PROC_FIELD_ACCESS, MYSQL_PROC_FIELD_COMMENT, MYSQL_PROC_FIELD_MODIFIED, MYSQL_PROC_FIELD_SECURITY_TYPE, name, open_proc_table_for_update(), SP_OK, SP_OPEN_TABLE_FAILED, SP_WRITE_ROW_FAILED, store_record, system_charset_info, TIMESTAMP_NO_AUTO_SET, and TRUE.
Referenced by sp_update_function(), and sp_update_procedure().
00681 { 00682 TABLE *table; 00683 int ret; 00684 DBUG_ENTER("db_update_routine"); 00685 DBUG_PRINT("enter", ("type: %d name: %.*s", 00686 type, name->m_name.length, name->m_name.str)); 00687 00688 if (!(table= open_proc_table_for_update(thd))) 00689 DBUG_RETURN(SP_OPEN_TABLE_FAILED); 00690 if ((ret= db_find_routine_aux(thd, type, name, table)) == SP_OK) 00691 { 00692 store_record(table,record[1]); 00693 table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET; 00694 ((Field_timestamp *)table->field[MYSQL_PROC_FIELD_MODIFIED])->set_time(); 00695 if (chistics->suid != SP_IS_DEFAULT_SUID) 00696 table->field[MYSQL_PROC_FIELD_SECURITY_TYPE]-> 00697 store((longlong)chistics->suid, TRUE); 00698 if (chistics->daccess != SP_DEFAULT_ACCESS) 00699 table->field[MYSQL_PROC_FIELD_ACCESS]-> 00700 store((longlong)chistics->daccess, TRUE); 00701 if (chistics->comment.str) 00702 table->field[MYSQL_PROC_FIELD_COMMENT]->store(chistics->comment.str, 00703 chistics->comment.length, 00704 system_charset_info); 00705 if ((table->file->ha_update_row(table->record[1],table->record[0]))) 00706 ret= SP_WRITE_ROW_FAILED; 00707 } 00708 close_thread_tables(thd); 00709 DBUG_RETURN(ret); 00710 }
Here is the call graph for this function:

Here is the caller graph for this function:

| TABLE* open_proc_table_for_read | ( | THD * | thd, | |
| Open_tables_state * | backup | |||
| ) |
Definition at line 114 of file sp.cc.
References bzero, close_proc_table(), DBUG_ASSERT, DBUG_ENTER, DBUG_RETURN, st_reginfo::lock_type, mysql_lock_tables(), mysql_proc_table_exists, open_table(), st_table::reginfo, st_table::s, st_table_share::system_table, TL_READ, and st_table::use_all_columns().
Referenced by db_find_routine(), fill_schema_proc(), and sp_routine_exists_in_table().
00115 { 00116 TABLE_LIST tables; 00117 TABLE *table; 00118 bool not_used; 00119 DBUG_ENTER("open_proc_table"); 00120 00121 /* 00122 Speed up things if mysql.proc doesn't exists. mysql_proc_table_exists 00123 is set when we create or read stored procedure or on flush privileges. 00124 */ 00125 if (!mysql_proc_table_exists) 00126 DBUG_RETURN(0); 00127 00128 thd->reset_n_backup_open_tables_state(backup); 00129 00130 bzero((char*) &tables, sizeof(tables)); 00131 tables.db= (char*) "mysql"; 00132 tables.table_name= tables.alias= (char*)"proc"; 00133 if (!(table= open_table(thd, &tables, thd->mem_root, ¬_used, 00134 MYSQL_LOCK_IGNORE_FLUSH))) 00135 { 00136 thd->restore_backup_open_tables_state(backup); 00137 mysql_proc_table_exists= 0; 00138 DBUG_RETURN(0); 00139 } 00140 table->use_all_columns(); 00141 00142 DBUG_ASSERT(table->s->system_table); 00143 00144 table->reginfo.lock_type= TL_READ; 00145 /* 00146 We have to ensure we are not blocked by a flush tables, as this 00147 could lead to a deadlock if we have other tables opened. 00148 */ 00149 if (!(thd->lock= mysql_lock_tables(thd, &table, 1, 00150 MYSQL_LOCK_IGNORE_FLUSH, ¬_used))) 00151 { 00152 close_proc_table(thd, backup); 00153 DBUG_RETURN(0); 00154 } 00155 DBUG_RETURN(table); 00156 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static TABLE* open_proc_table_for_update | ( | THD * | thd | ) | [static] |
Definition at line 174 of file sp.cc.
References bzero, DBUG_ENTER, DBUG_RETURN, mysql_proc_table_exists, open_ltable(), test, TL_WRITE, and st_table::use_all_columns().
Referenced by db_create_routine(), db_drop_routine(), db_update_routine(), and sp_drop_db_routines().
00175 { 00176 TABLE_LIST tables; 00177 TABLE *table; 00178 DBUG_ENTER("open_proc_table"); 00179 00180 bzero((char*) &tables, sizeof(tables)); 00181 tables.db= (char*) "mysql"; 00182 tables.table_name= tables.alias= (char*)"proc"; 00183 tables.lock_type= TL_WRITE; 00184 00185 table= open_ltable(thd, &tables, TL_WRITE); 00186 if (table) 00187 table->use_all_columns(); 00188 00189 /* 00190 Under explicit LOCK TABLES or in prelocked mode we should not 00191 say that mysql.proc table does not exist if we are unable to 00192 open and lock it for writing since this condition may be 00193 transient. 00194 */ 00195 if (!(thd->locked_tables || thd->prelocked_mode) || table) 00196 mysql_proc_table_exists= test(table); 00197 00198 DBUG_RETURN(table); 00199 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static int print_field_values | ( | THD * | thd, | |
| TABLE * | table, | |||
| struct st_used_field * | used_fields, | |||
| int | type, | |||
| const char * | wild | |||
| ) | [static] |
Definition at line 736 of file sp.cc.
References bzero, st_used_field::field, st_table::field, st_used_field::field_name, st_used_field::field_type, get_field(), MYSQL_PROC_FIELD_TYPE, MYSQL_TYPE_TIMESTAMP, Protocol::prepare_for_resend(), String::ptr(), SP_INTERNAL_ERROR, Protocol::store(), wild_compare(), and Protocol::write().
Referenced by db_show_routine_status().
00739 { 00740 Protocol *protocol= thd->protocol; 00741 00742 if (table->field[MYSQL_PROC_FIELD_TYPE]->val_int() == type) 00743 { 00744 String db_string; 00745 String name_string; 00746 struct st_used_field *used_field= used_fields; 00747 00748 if (get_field(thd->mem_root, used_field->field, &db_string)) 00749 db_string.set_ascii("", 0); 00750 used_field+= 1; 00751 get_field(thd->mem_root, used_field->field, &name_string); 00752 00753 if (!wild || !wild[0] || !wild_compare(name_string.ptr(), wild, 0)) 00754 { 00755 protocol->prepare_for_resend(); 00756 protocol->store(&db_string); 00757 protocol->store(&name_string); 00758 for (used_field++; 00759 used_field->field_name; 00760 used_field++) 00761 { 00762 switch (used_field->field_type) { 00763 case MYSQL_TYPE_TIMESTAMP: 00764 { 00765 TIME tmp_time; 00766 00767 bzero((char *)&tmp_time, sizeof(tmp_time)); 00768 ((Field_timestamp *) used_field->field)->get_time(&tmp_time); 00769 protocol->store(&tmp_time); 00770 } 00771 break; 00772 default: 00773 { 00774 String tmp_string; 00775 00776 get_field(thd->mem_root, used_field->field, &tmp_string); 00777 protocol->store(&tmp_string); 00778 } 00779 break; 00780 } 00781 } 00782 if (protocol->write()) 00783 return SP_INTERNAL_ERROR; 00784 } 00785 } 00786 return SP_OK; 00787 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void sp_add_used_routine | ( | LEX * | lex, | |
| Query_arena * | arena, | |||
| sp_name * | rt, | |||
| char | rt_type | |||
| ) |
Definition at line 1420 of file sp.cc.
References add_used_routine(), sp_name::m_sroutines_key, and sp_name::set_routine_type().
01422 { 01423 rt->set_routine_type(rt_type); 01424 (void)add_used_routine(lex, arena, &rt->m_sroutines_key, 0); 01425 lex->sroutines_list_own_last= lex->sroutines_list.next; 01426 lex->sroutines_list_own_elements= lex->sroutines_list.elements; 01427 }
Here is the call graph for this function:

| int sp_cache_routines_and_add_tables | ( | THD * | thd, | |
| LEX * | lex, | |||
| bool | first_no_prelock | |||
| ) |
Definition at line 1669 of file sp.cc.
References sp_cache_routines_and_add_tables_aux().
Referenced by open_tables().
01670 { 01671 return sp_cache_routines_and_add_tables_aux(thd, lex, 01672 (Sroutine_hash_entry *)lex->sroutines_list.first, 01673 first_no_prelock); 01674 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static int sp_cache_routines_and_add_tables_aux | ( | THD * | thd, | |
| LEX * | lex, | |||
| Sroutine_hash_entry * | start, | |||
| bool | first_no_prelock | |||
| ) | [static] |
Definition at line 1563 of file sp.cc.
References db_find_routine(), DBUG_ENTER, ER_SP_PROC_TABLE_CORRUPT, FALSE, memcpy, my_error(), MYF, mysql_proc_table_exists, n, name, NAME_LEN, sp_cache_insert(), sp_cache_lookup(), SP_KEY_NOT_FOUND, SP_OK, SP_OPEN_TABLE_FAILED, SP_PARSE_ERROR, sp_update_stmt_used_routines(), start(), strchr(), strmake_root(), TRUE, and TYPE_ENUM_FUNCTION.
Referenced by sp_cache_routines_and_add_tables(), sp_cache_routines_and_add_tables_for_triggers(), and sp_cache_routines_and_add_tables_for_view().
01566 { 01567 int ret= 0; 01568 bool first= TRUE; 01569 DBUG_ENTER("sp_cache_routines_and_add_tables_aux"); 01570 01571 for (Sroutine_hash_entry *rt= start; rt; rt= rt->next) 01572 { 01573 sp_name name(rt->key.str, rt->key.length); 01574 int type= rt->key.str[0]; 01575 sp_head *sp; 01576 01577 if (!(sp= sp_cache_lookup((type == TYPE_ENUM_FUNCTION ? 01578 &thd->sp_func_cache : &thd->sp_proc_cache), 01579 &name))) 01580 { 01581 name.m_name.str= strchr(name.m_qname.str, '.'); 01582 name.m_db.length= name.m_name.str - name.m_qname.str; 01583 name.m_db.str= strmake_root(thd->mem_root, name.m_qname.str, 01584 name.m_db.length); 01585 name.m_name.str+= 1; 01586 name.m_name.length= name.m_qname.length - name.m_db.length - 1; 01587 01588 switch ((ret= db_find_routine(thd, type, &name, &sp))) 01589 { 01590 case SP_OK: 01591 { 01592 if (type == TYPE_ENUM_FUNCTION) 01593 sp_cache_insert(&thd->sp_func_cache, sp); 01594 else 01595 sp_cache_insert(&thd->sp_proc_cache, sp); 01596 } 01597 break; 01598 case SP_KEY_NOT_FOUND: 01599 ret= SP_OK; 01600 break; 01601 case SP_OPEN_TABLE_FAILED: 01602 /* 01603 Force it to attempt opening it again on subsequent calls; 01604 otherwise we will get one error message the first time, and 01605 then ER_SP_PROC_TABLE_CORRUPT (below) on subsequent tries. 01606 */ 01607 mysql_proc_table_exists= 1; 01608 /* Fall through */ 01609 default: 01610 /* 01611 Any error when loading an existing routine is either some problem 01612 with the mysql.proc table, or a parse error because the contents 01613 has been tampered with (in which case we clear that error). 01614 */ 01615 if (ret == SP_PARSE_ERROR) 01616 thd->clear_error(); 01617 /* 01618 If we cleared the parse error, or when db_find_routine() flagged 01619 an error with it's return value without calling my_error(), we 01620 set the generic "mysql.proc table corrupt" error here. 01621 */ 01622 if (!thd->net.report_error) 01623 { 01624 char n[NAME_LEN*2+2]; 01625 01626 /* m_qname.str is not always \0 terminated */ 01627 memcpy(n, name.m_qname.str, name.m_qname.length); 01628 n[name.m_qname.length]= '\0'; 01629 my_error(ER_SP_PROC_TABLE_CORRUPT, MYF(0), n, ret); 01630 } 01631 break; 01632 } 01633 } 01634 if (sp) 01635 { 01636 if (!(first && first_no_prelock)) 01637 { 01638 sp_update_stmt_used_routines(thd, lex, &sp->m_sroutines, 01639 rt->belong_to_view); 01640 (void)sp->add_used_tables_to_table_list(thd, &lex->query_tables_last, 01641 rt->belong_to_view); 01642 } 01643 sp->propagate_attributes(lex); 01644 } 01645 first= FALSE; 01646 } 01647 DBUG_RETURN(ret); 01648 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int sp_cache_routines_and_add_tables_for_triggers | ( | THD * | thd, | |
| LEX * | lex, | |||
| TABLE_LIST * | table | |||
| ) |
Definition at line 1722 of file sp.cc.
References add_used_routine(), st_table_list::belong_to_view, Table_triggers_list::bodies, FALSE, int(), sp_cache_routines_and_add_tables_aux(), sp_update_stmt_used_routines(), Table_triggers_list::sroutines_key, st_table_list::table, TRG_ACTION_MAX, TRG_EVENT_MAX, and st_table::triggers.
01724 { 01725 int ret= 0; 01726 Table_triggers_list *triggers= table->table->triggers; 01727 if (add_used_routine(lex, thd->stmt_arena, &triggers->sroutines_key, 01728 table->belong_to_view)) 01729 { 01730 Sroutine_hash_entry **last_cached_routine_ptr= 01731 (Sroutine_hash_entry **)lex->sroutines_list.next; 01732 for (int i= 0; i < (int)TRG_EVENT_MAX; i++) 01733 { 01734 for (int j= 0; j < (int)TRG_ACTION_MAX; j++) 01735 { 01736 sp_head *trigger_body= triggers->bodies[i][j]; 01737 if (trigger_body) 01738 { 01739 (void)trigger_body-> 01740 add_used_tables_to_table_list(thd, &lex->query_tables_last, 01741 table->belong_to_view); 01742 sp_update_stmt_used_routines(thd, lex, 01743 &trigger_body->m_sroutines, 01744 table->belong_to_view); 01745 trigger_body->propagate_attributes(lex); 01746 } 01747 } 01748 } 01749 ret= sp_cache_routines_and_add_tables_aux(thd, lex, 01750 *last_cached_routine_ptr, FALSE); 01751 } 01752 return ret; 01753 }
Here is the call graph for this function:

| int sp_cache_routines_and_add_tables_for_view | ( | THD * | thd, | |
| LEX * | lex, | |||
| TABLE_LIST * | view | |||
| ) |
Definition at line 1694 of file sp.cc.
References FALSE, sp_cache_routines_and_add_tables_aux(), sp_update_stmt_used_routines(), st_table_list::top_table(), and st_table_list::view.
01695 { 01696 Sroutine_hash_entry **last_cached_routine_ptr= 01697 (Sroutine_hash_entry **)lex->sroutines_list.next; 01698 sp_update_stmt_used_routines(thd, lex, &view->view->sroutines_list, 01699 view->top_table()); 01700 return sp_cache_routines_and_add_tables_aux(thd, lex, 01701 *last_cached_routine_ptr, FALSE); 01702 }
Here is the call graph for this function:

| int sp_create_function | ( | THD * | thd, | |
| sp_head * | sp | |||
| ) |
Definition at line 1209 of file sp.cc.
References db_create_routine(), DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, LEX_STRING::length, sp_head::m_name, LEX_STRING::str, and TYPE_ENUM_FUNCTION.
Referenced by sp_head::create().
01210 { 01211 int ret; 01212 DBUG_ENTER("sp_create_function"); 01213 DBUG_PRINT("enter", ("name: %.*s", sp->m_name.length, sp->m_name.str)); 01214 01215 ret= db_create_routine(thd, TYPE_ENUM_FUNCTION, sp); 01216 DBUG_RETURN(ret); 01217 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int sp_create_procedure | ( | THD * | thd, | |
| sp_head * | sp | |||
| ) |
Definition at line 1138 of file sp.cc.
References db_create_routine(), DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, LEX_STRING::length, sp_head::m_name, LEX_STRING::str, and TYPE_ENUM_PROCEDURE.
Referenced by sp_head::create().
01139 { 01140 int ret; 01141 DBUG_ENTER("sp_create_procedure"); 01142 DBUG_PRINT("enter", ("name: %.*s", sp->m_name.length, sp->m_name.str)); 01143 01144 ret= db_create_routine(thd, TYPE_ENUM_PROCEDURE, sp); 01145 DBUG_RETURN(ret); 01146 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int sp_drop_db_routines | ( | THD * | thd, | |
| char * | db | |||
| ) |
Definition at line 895 of file sp.cc.
References close_thread_tables(), DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, err, FALSE, st_table::field, st_table::file, handler::ha_delete_row(), HA_ERR_END_OF_FILE, handler::ha_index_end(), handler::ha_index_init(), HA_READ_KEY_EXACT, handler::index_next_same(), handler::index_read(), st_table::key_info, st_key::key_part, MYSQL_PROC_FIELD_DB, open_proc_table_for_update(), Field::ptr, st_table::record, sp_cache_invalidate(), SP_DELETE_ROW_FAILED, SP_KEY_NOT_FOUND, SP_OK, SP_OPEN_TABLE_FAILED, Field::store(), st_key_part_info::store_length, strlen(), system_charset_info, and TRUE.
Referenced by mysql_rm_db().
00896 { 00897 TABLE *table; 00898 int ret; 00899 uint key_len; 00900 DBUG_ENTER("sp_drop_db_routines"); 00901 DBUG_PRINT("enter", ("db: %s", db)); 00902 00903 ret= SP_OPEN_TABLE_FAILED; 00904 if (!(table= open_proc_table_for_update(thd))) 00905 goto err; 00906 00907 table->field[MYSQL_PROC_FIELD_DB]->store(db, strlen(db), system_charset_info); 00908 key_len= table->key_info->key_part[0].store_length; 00909 00910 ret= SP_OK; 00911 table->file->ha_index_init(0, 1); 00912 if (! table->file->index_read(table->record[0], 00913 (byte *)table->field[MYSQL_PROC_FIELD_DB]->ptr, 00914 key_len, HA_READ_KEY_EXACT)) 00915 { 00916 int nxtres; 00917 bool deleted= FALSE; 00918 00919 do 00920 { 00921 if (! table->file->ha_delete_row(table->record[0])) 00922 deleted= TRUE; /* We deleted something */ 00923 else 00924 { 00925 ret= SP_DELETE_ROW_FAILED; 00926 nxtres= 0; 00927 break; 00928 } 00929 } while (! (nxtres= table->file->index_next_same(table->record[0], 00930 (byte *)table->field[MYSQL_PROC_FIELD_DB]->ptr, 00931 key_len))); 00932 if (nxtres != HA_ERR_END_OF_FILE) 00933 ret= SP_KEY_NOT_FOUND; 00934 if (deleted) 00935 sp_cache_invalidate(); 00936 } 00937 table->file->ha_index_end(); 00938 00939 close_thread_tables(thd); 00940 00941 err: 00942 DBUG_RETURN(ret); 00943 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int sp_drop_function | ( | THD * | thd, | |
| sp_name * | name | |||
| ) |
Definition at line 1221 of file sp.cc.
References db_drop_routine(), DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, name, sp_cache_invalidate(), and TYPE_ENUM_FUNCTION.
Referenced by mysql_execute_command().
01222 { 01223 int ret; 01224 DBUG_ENTER("sp_drop_function"); 01225 DBUG_PRINT("enter", ("name: %.*s", name->m_name.length, name->m_name.str)); 01226 01227 ret= db_drop_routine(thd, TYPE_ENUM_FUNCTION, name); 01228 if (!ret) 01229 sp_cache_invalidate(); 01230 DBUG_RETURN(ret); 01231 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int sp_drop_procedure | ( | THD * | thd, | |
| sp_name * | name | |||
| ) |
Definition at line 1150 of file sp.cc.
References db_drop_routine(), DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, name, sp_cache_invalidate(), and TYPE_ENUM_PROCEDURE.
Referenced by mysql_execute_command().
01151 { 01152 int ret; 01153 DBUG_ENTER("sp_drop_procedure"); 01154 DBUG_PRINT("enter", ("name: %.*s", name->m_name.length, name->m_name.str)); 01155 01156 ret= db_drop_routine(thd, TYPE_ENUM_PROCEDURE, name); 01157 if (!ret) 01158 sp_cache_invalidate(); 01159 DBUG_RETURN(ret); 01160 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int sp_exist_routines | ( | THD * | thd, | |
| TABLE_LIST * | routines, | |||
| bool | any, | |||
| bool | no_error | |||
| ) |
Definition at line 1061 of file sp.cc.
References st_table_list::db, DBUG_ENTER, DBUG_RETURN, ER_SP_DOES_NOT_EXIST, FALSE, LEX_STRING::length, my_error(), MYF, mysql_reset_errors(), name, st_table_list::next_global, NULL, sp_find_routine(), LEX_STRING::str, strlen(), st_table_list::table_name, TRUE, TYPE_ENUM_FUNCTION, and TYPE_ENUM_PROCEDURE.
Referenced by mysql_routine_grant().
01062 { 01063 TABLE_LIST *routine; 01064 bool result= 0; 01065 bool sp_object_found; 01066 DBUG_ENTER("sp_exists_routine"); 01067 for (routine= routines; routine; routine= routine->next_global) 01068 { 01069 sp_name *name; 01070 LEX_STRING lex_db; 01071 LEX_STRING lex_name; 01072 lex_db.length= strlen(routine->db); 01073 lex_name.length= strlen(routine->table_name); 01074 lex_db.str= thd->strmake(routine->db, lex_db.length); 01075 lex_name.str= thd->strmake(routine->table_name, lex_name.length); 01076 name= new sp_name(lex_db, lex_name); 01077 name->init_qname(thd); 01078 sp_object_found= sp_find_routine(thd, TYPE_ENUM_PROCEDURE, name, 01079 &thd->sp_proc_cache, FALSE) != NULL || 01080 sp_find_routine(thd, TYPE_ENUM_FUNCTION, name, 01081 &thd->sp_func_cache, FALSE) != NULL; 01082 mysql_reset_errors(thd, TRUE); 01083 if (sp_object_found) 01084 { 01085 if (any) 01086 DBUG_RETURN(1); 01087 result= 1; 01088 } 01089 else if (!any) 01090 { 01091 if (!no_error) 01092 { 01093 my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION or PROCEDURE", 01094 routine->table_name); 01095 DBUG_RETURN(-1); 01096 } 01097 DBUG_RETURN(0); 01098 } 01099 } 01100 DBUG_RETURN(result); 01101 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 969 of file sp.cc.
References db_find_routine(), db_load_routine(), DBUG_ASSERT, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, sp_head::IS_INVOKED, sp_head::m_first_free_instance, sp_head::m_first_instance, sp_head::m_last_cached_sp, sp_head::m_recursion_level, sp_head::m_sql_mode, name, NullS, String::ptr(), sp_cache_insert(), sp_cache_lookup(), SP_OK, sp_returns_type(), strxmov(), TYPE_ENUM_FUNCTION, TYPE_ENUM_PROCEDURE, and USER_HOST_BUFF_SIZE.
Referenced by Item_func_sp::find_and_check_access(), mysql_execute_command(), sp_exist_routines(), Item_func_sp::sp_result_field(), sp_show_create_function(), and sp_show_create_procedure().
00971 { 00972 sp_head *sp; 00973 ulong depth= (type == TYPE_ENUM_PROCEDURE ? 00974 thd->variables.max_sp_recursion_depth : 00975 0); 00976 DBUG_ENTER("sp_find_routine"); 00977 DBUG_PRINT("enter", ("name: %.*s.%.*s, type: %d, cache only %d", 00978 name->m_db.length, name->m_db.str, 00979 name->m_name.length, name->m_name.str, 00980 type, cache_only)); 00981 00982 if ((sp= sp_cache_lookup(cp, name))) 00983 { 00984 ulong level; 00985 sp_head *new_sp; 00986 const char *returns= ""; 00987 char definer[USER_HOST_BUFF_SIZE]; 00988 00989 /* 00990 String buffer for RETURNS data type must have system charset; 00991 64 -- size of "returns" column of mysql.proc. 00992 */ 00993 String retstr(64); 00994 00995 DBUG_PRINT("info", ("found: 0x%lx", (ulong)sp)); 00996 if (sp->m_first_free_instance) 00997 { 00998 DBUG_PRINT("info", ("first free: 0x%lx, level: %lu, flags %x", 00999 (ulong)sp->m_first_free_instance, 01000 sp->m_first_free_instance->m_recursion_level, 01001 sp->m_first_free_instance->m_flags)); 01002 DBUG_ASSERT(!(sp->m_first_free_instance->m_flags & sp_head::IS_INVOKED)); 01003 if (sp->m_first_free_instance->m_recursion_level > depth) 01004 { 01005 sp->recursion_level_error(thd); 01006 DBUG_RETURN(0); 01007 } 01008 DBUG_RETURN(sp->m_first_free_instance); 01009 } 01010 01011 level= sp->m_last_cached_sp->m_recursion_level + 1; 01012 if (level > depth) 01013 { 01014 sp->recursion_level_error(thd); 01015 DBUG_RETURN(0); 01016 } 01017 01018 strxmov(definer, sp->m_definer_user.str, "@", 01019 sp->m_definer_host.str, NullS); 01020 if (type == TYPE_ENUM_FUNCTION) 01021 { 01022 sp_returns_type(thd, retstr, sp); 01023 returns= retstr.ptr(); 01024 } 01025 if (db_load_routine(thd, type, name, &new_sp, 01026 sp->m_sql_mode, sp->m_params.str, returns, 01027 sp->m_body.str, *sp->m_chistics, definer, 01028 sp->m_created, sp->m_modified) == SP_OK) 01029 { 01030 sp->m_last_cached_sp->m_next_cached_sp= new_sp; 01031 new_sp->m_recursion_level= level; 01032 new_sp->m_first_instance= sp; 01033 sp->m_last_cached_sp= sp->m_first_free_instance= new_sp; 01034 DBUG_PRINT("info", ("added level: 0x%lx, level: %lu, flags %x", 01035 (ulong)new_sp, new_sp->m_recursion_level, 01036 new_sp->m_flags)); 01037 DBUG_RETURN(new_sp); 01038 } 01039 DBUG_RETURN(0); 01040 } 01041 if (!cache_only) 01042 { 01043 if (db_find_routine(thd, type, name, &sp) == SP_OK) 01044 { 01045 sp_cache_insert(cp, sp); 01046 DBUG_PRINT("info", ("added new: 0x%lx, level: %lu, flags %x", 01047 (ulong)sp, sp->m_recursion_level, 01048 sp->m_flags)); 01049 } 01050 } 01051 DBUG_RETURN(sp); 01052 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1331 of file sp.cc.
References DBUG_ASSERT, Sroutine_hash_entry::key, Sroutine_hash_entry::next, LEX_STRING::str, test, and TYPE_ENUM_PROCEDURE.
Referenced by open_tables().
01333 { 01334 Sroutine_hash_entry *routine; 01335 routine= (Sroutine_hash_entry*)thd->lex->sroutines_list.first; 01336 01337 DBUG_ASSERT(routine); 01338 bool first_is_procedure= (routine->key.str[0] == TYPE_ENUM_PROCEDURE); 01339 01340 *first_no_prelocking= first_is_procedure; 01341 *need_prelocking= !first_is_procedure || test(routine->next); 01342 }
Here is the caller graph for this function:

| void sp_remove_not_own_routines | ( | LEX * | lex | ) |
Definition at line 1439 of file sp.cc.
References hash_delete(), Sroutine_hash_entry::next, and NULL.
Referenced by close_tables_for_reopen().
01440 { 01441 Sroutine_hash_entry *not_own_rt, *next_rt; 01442 for (not_own_rt= *(Sroutine_hash_entry **)lex->sroutines_list_own_last; 01443 not_own_rt; not_own_rt= next_rt) 01444 { 01445 /* 01446 It is safe to obtain not_own_rt->next after calling hash_delete() now 01447 but we want to be more future-proof. 01448 */ 01449 next_rt= not_own_rt->next; 01450 hash_delete(&lex->sroutines, (byte *)not_own_rt); 01451 } 01452 01453 *(Sroutine_hash_entry **)lex->sroutines_list_own_last= NULL; 01454 lex->sroutines_list.next= lex->sroutines_list_own_last; 01455 lex->sroutines_list.elements= lex->sroutines_list_own_elements; 01456 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 489 of file sp.cc.
References String::append(), bzero, Field::charset(), sp_head::create_result_field(), charset_info_st::csname, Field::has_charset(), Field::sql_type(), and STRING_WITH_LEN.
Referenced by db_create_routine(), and sp_find_routine().
00490 { 00491 TABLE table; 00492 TABLE_SHARE share; 00493 Field *field; 00494 bzero((char*) &table, sizeof(table)); 00495 bzero((char*) &share, sizeof(share)); 00496 table.in_use= thd; 00497 table.s = &share; 00498 field= sp->create_result_field(0, 0, &table); 00499 field->sql_type(result); 00500 00501 if (field->has_charset()) 00502 { 00503 result.append(STRING_WITH_LEN(" CHARSET ")); 00504 result.append(field->charset()->csname); 00505 } 00506 00507 delete field; 00508 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int sp_routine_exists_in_table | ( | THD * | thd, | |
| int | type, | |||
| sp_name * | name | |||
| ) |
Definition at line 1119 of file sp.cc.
References close_proc_table(), db_find_routine_aux(), name, open_proc_table_for_read(), SP_KEY_NOT_FOUND, SP_OK, and SP_OPEN_TABLE_FAILED.
Referenced by mysql_execute_command().
01120 { 01121 TABLE *table; 01122 int ret; 01123 Open_tables_state open_tables_state_backup; 01124 01125 if (!(table= open_proc_table_for_read(thd, &open_tables_state_backup))) 01126 ret= SP_OPEN_TABLE_FAILED; 01127 else 01128 { 01129 if ((ret= db_find_routine_aux(thd, type, name, table)) != SP_OK) 01130 ret= SP_KEY_NOT_FOUND; 01131 close_proc_table(thd, &open_tables_state_backup); 01132 } 01133 return ret; 01134 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int sp_show_create_function | ( | THD * | thd, | |
| sp_name * | name | |||
| ) |
Definition at line 1249 of file sp.cc.
References DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, FALSE, name, sp_head::show_create_function(), sp_find_routine(), SP_KEY_NOT_FOUND, and TYPE_ENUM_FUNCTION.
Referenced by mysql_execute_command().
01250 { 01251 sp_head *sp; 01252 DBUG_ENTER("sp_show_create_function"); 01253 DBUG_PRINT("enter", ("name: %.*s", name->m_name.length, name->m_name.str)); 01254 01255 if ((sp= sp_find_routine(thd, TYPE_ENUM_FUNCTION, name, 01256 &thd->sp_func_cache, FALSE))) 01257 { 01258 int ret= sp->show_create_function(thd); 01259 01260 DBUG_RETURN(ret); 01261 } 01262 DBUG_RETURN(SP_KEY_NOT_FOUND); 01263 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int sp_show_create_procedure | ( | THD * | thd, | |
| sp_name * | name | |||
| ) |
Definition at line 1178 of file sp.cc.
References DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, FALSE, name, sp_head::show_create_procedure(), sp_find_routine(), SP_KEY_NOT_FOUND, and TYPE_ENUM_PROCEDURE.
Referenced by mysql_execute_command().
01179 { 01180 int ret= SP_KEY_NOT_FOUND; 01181 sp_head *sp; 01182 DBUG_ENTER("sp_show_create_procedure"); 01183 DBUG_PRINT("enter", ("name: %.*s", name->m_name.length, name->m_name.str)); 01184 01185 if ((sp= sp_find_routine(thd, TYPE_ENUM_PROCEDURE, name, 01186 &thd->sp_proc_cache, FALSE))) 01187 ret= sp->show_create_procedure(thd); 01188 01189 DBUG_RETURN(ret); 01190 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int sp_show_status_function | ( | THD * | thd, | |
| const char * | wild | |||
| ) |
Definition at line 1267 of file sp.cc.
References db_show_routine_status(), DBUG_ENTER, DBUG_RETURN, and TYPE_ENUM_FUNCTION.
Referenced by mysql_execute_command().
01268 { 01269 int ret; 01270 DBUG_ENTER("sp_show_status_function"); 01271 ret= db_show_routine_status(thd, TYPE_ENUM_FUNCTION, wild); 01272 DBUG_RETURN(ret); 01273 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int sp_show_status_procedure | ( | THD * | thd, | |
| const char * | wild | |||
| ) |
Definition at line 1194 of file sp.cc.
References db_show_routine_status(), DBUG_ENTER, DBUG_RETURN, and TYPE_ENUM_PROCEDURE.
Referenced by mysql_execute_command().
01195 { 01196 int ret; 01197 DBUG_ENTER("sp_show_status_procedure"); 01198 01199 ret= db_show_routine_status(thd, TYPE_ENUM_PROCEDURE, wild); 01200 DBUG_RETURN(ret); 01201 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1300 of file sp.cc.
References Sroutine_hash_entry::key, LEX_STRING::length, and LEX_STRING::str.
Referenced by sp_head::sp_head().
01301 { 01302 Sroutine_hash_entry *rn= (Sroutine_hash_entry *)ptr; 01303 *plen= rn->key.length; 01304 return (byte *)rn->key.str; 01305 }
Here is the caller graph for this function:

| int sp_update_function | ( | THD * | thd, | |
| sp_name * | name, | |||
| st_sp_chistics * | chistics | |||
| ) |
Definition at line 1235 of file sp.cc.
References db_update_routine(), DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, name, sp_cache_invalidate(), and TYPE_ENUM_FUNCTION.
Referenced by mysql_execute_command().
01236 { 01237 int ret; 01238 DBUG_ENTER("sp_update_procedure"); 01239 DBUG_PRINT("enter", ("name: %.*s", name->m_name.length, name->m_name.str)); 01240 01241 ret= db_update_routine(thd, TYPE_ENUM_FUNCTION, name, chistics); 01242 if (!ret) 01243 sp_cache_invalidate(); 01244 DBUG_RETURN(ret); 01245 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int sp_update_procedure | ( | THD * | thd, | |
| sp_name * | name, | |||
| st_sp_chistics * | chistics | |||
| ) |
Definition at line 1164 of file sp.cc.
References db_update_routine(), DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, name, sp_cache_invalidate(), and TYPE_ENUM_PROCEDURE.
Referenced by mysql_execute_command().
01165 { 01166 int ret; 01167 DBUG_ENTER("sp_update_procedure"); 01168 DBUG_PRINT("enter", ("name: %.*s", name->m_name.length, name->m_name.str)); 01169 01170 ret= db_update_routine(thd, TYPE_ENUM_PROCEDURE, name, chistics); 01171 if (!ret) 01172 sp_cache_invalidate(); 01173 DBUG_RETURN(ret); 01174 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1477 of file sp.cc.
References hash_element(), hash_search(), my_hash_insert(), and st_hash::records.
Referenced by sp_head::restore_lex().
01478 { 01479 for (uint i=0 ; i < src->records ; i++) 01480 { 01481 Sroutine_hash_entry *rt= (Sroutine_hash_entry *)hash_element(src, i); 01482 if (!hash_search(dst, (byte *)rt->key.str, rt->key.length)) 01483 my_hash_insert(dst, (byte *)rt); 01484 } 01485 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void sp_update_stmt_used_routines | ( | THD * | thd, | |
| LEX * | lex, | |||
| SQL_LIST * | src, | |||
| TABLE_LIST * | belong_to_view | |||
| ) | [static] |
Definition at line 1530 of file sp.cc.
References add_used_routine(), and st_sql_list::first.
01532 { 01533 for (Sroutine_hash_entry *rt= (Sroutine_hash_entry *)src->first; 01534 rt; rt= rt->next) 01535 (void)add_used_routine(lex, thd->stmt_arena, &rt->key, belong_to_view); 01536 }
Here is the call graph for this function:

| static void sp_update_stmt_used_routines | ( | THD * | thd, | |
| LEX * | lex, | |||
| HASH * | src, | |||
| TABLE_LIST * | belong_to_view | |||
| ) | [static] |
Definition at line 1504 of file sp.cc.
References add_used_routine(), hash_element(), and st_hash::records.
Referenced by sp_cache_routines_and_add_tables_aux(), sp_cache_routines_and_add_tables_for_triggers(), and sp_cache_routines_and_add_tables_for_view().
01506 { 01507 for (uint i=0 ; i < src->records ; i++) 01508 { 01509 Sroutine_hash_entry *rt= (Sroutine_hash_entry *)hash_element(src, i); 01510 (void)add_used_routine(lex, thd->stmt_arena, &rt->key, belong_to_view); 01511 } 01512 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int sp_use_new_db | ( | THD * | thd, | |
| LEX_STRING | new_db, | |||
| LEX_STRING * | old_db, | |||
| bool | no_access_check, | |||
| bool * | dbchangedp | |||
| ) |
Definition at line 1853 of file sp.cc.
References DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, empty_c_string, FALSE, LEX_STRING::length, my_strcasecmp, mysql_change_db(), NULL, LEX_STRING::str, strmake(), and system_charset_info.
Referenced by db_create_event(), db_create_routine(), db_load_routine(), and sp_head::execute().
01855 { 01856 int ret; 01857 DBUG_ENTER("sp_use_new_db"); 01858 DBUG_PRINT("enter", ("newdb: %s", new_db.str)); 01859 01860 /* 01861 Set new_db to an empty string if it's NULL, because mysql_change_db 01862 requires a non-NULL argument. 01863 new_db.str can be NULL only if we're restoring the old database after 01864 execution of a stored procedure and there were no current database 01865 selected. The stored procedure itself must always have its database 01866 initialized. 01867 */ 01868 if (new_db.str == NULL) 01869 new_db.str= empty_c_string; 01870 01871 if (thd->db) 01872 { 01873 old_db->length= (strmake(old_db->str, thd->db, old_db->length) - 01874 old_db->str); 01875 } 01876 else 01877 { 01878 old_db->str[0]= '\0'; 01879 old_db->length= 0; 01880 } 01881 01882 /* Don't change the database if the new name is the same as the old one. */ 01883 if (my_strcasecmp(system_charset_info, old_db->str, new_db.str) == 0) 01884 { 01885 *dbchangedp= FALSE; 01886 DBUG_RETURN(0); 01887 } 01888 01889 ret= mysql_change_db(thd, new_db.str, no_access_check); 01890 01891 *dbchangedp= ret == 0; 01892 DBUG_RETURN(ret); 01893 }
Here is the call graph for this function:

Here is the caller graph for this function:

struct st_used_field init_fields[] [static] |
Initial value:
{
{ "Db", NAME_LEN, MYSQL_TYPE_STRING, 0},
{ "Name", NAME_LEN, MYSQL_TYPE_STRING, 0},
{ "Type", 9, MYSQL_TYPE_STRING, 0},
{ "Definer", 77, MYSQL_TYPE_STRING, 0},
{ "Modified", 0, MYSQL_TYPE_TIMESTAMP, 0},
{ "Created", 0, MYSQL_TYPE_TIMESTAMP, 0},
{ "Security_type", 1, MYSQL_TYPE_STRING, 0},
{ "Comment", NAME_LEN, MYSQL_TYPE_STRING, 0},
{ 0, 0, MYSQL_TYPE_STRING, 0}
}
Definition at line 721 of file sp.cc.
Referenced by db_show_routine_status(), and mysqld_help().
Definition at line 68 of file sp.cc.
Referenced by acl_load(), open_proc_table_for_read(), open_proc_table_for_update(), and sp_cache_routines_and_add_tables_aux().
1.4.7

