#include <item_func.h>
Inheritance diagram for Item_func_sp:


Definition at line 1423 of file item_func.h.
| Item_func_sp::Item_func_sp | ( | Name_resolution_context * | context_arg, | |
| sp_name * | name | |||
| ) |
Definition at line 4722 of file item_func.cc.
References current_thd, dummy_table, sp_name::init_qname(), m_name, Item::maybe_null, st_table::s, and sql_calloc().
04723 :Item_func(), context(context_arg), m_name(name), m_sp(NULL), 04724 result_field(NULL) 04725 { 04726 maybe_null= 1; 04727 m_name->init_qname(current_thd); 04728 dummy_table= (TABLE*) sql_calloc(sizeof(TABLE)+ sizeof(TABLE_SHARE)); 04729 dummy_table->s= (TABLE_SHARE*) (dummy_table+1); 04730 }
Here is the call graph for this function:

| Item_func_sp::Item_func_sp | ( | Name_resolution_context * | context_arg, | |
| sp_name * | name, | |||
| List< Item > & | list | |||
| ) |
Definition at line 4733 of file item_func.cc.
References current_thd, dummy_table, sp_name::init_qname(), m_name, Item::maybe_null, st_table::s, and sql_calloc().
04735 :Item_func(list), context(context_arg), m_name(name), m_sp(NULL), 04736 result_field(NULL) 04737 { 04738 maybe_null= 1; 04739 m_name->init_qname(current_thd); 04740 dummy_table= (TABLE*) sql_calloc(sizeof(TABLE)+ sizeof(TABLE_SHARE)); 04741 dummy_table->s= (TABLE_SHARE*) (dummy_table+1); 04742 }
Here is the call graph for this function:

| virtual Item_func_sp::~Item_func_sp | ( | ) | [inline, virtual] |
Reimplemented from Item.
Definition at line 1499 of file item_func.h.
References context, and FALSE.
01500 { context= (Name_resolution_context *)cntx; return FALSE; }
| void Item_func_sp::cleanup | ( | ) | [virtual] |
Reimplemented from Item_result_field.
Definition at line 4746 of file item_func.cc.
References Item_result_field::cleanup(), m_sp, NULL, and result_field.
04747 { 04748 if (result_field) 04749 { 04750 delete result_field; 04751 result_field= NULL; 04752 } 04753 m_sp= NULL; 04754 Item_func::cleanup(); 04755 }
Here is the call graph for this function:

Definition at line 4826 of file item_func.cc.
References context, current_thd, execute_impl(), f, Name_resolution_context::process_error(), result_buf, sp_result_field(), sql_alloc(), and TRUE.
Referenced by val_decimal(), val_int(), val_real(), and val_str().
04827 { 04828 THD *thd= current_thd; 04829 Field *f; 04830 04831 /* 04832 Get field in virtual tmp table to store result. Create the field if 04833 invoked first time. 04834 */ 04835 04836 if (!(f= *flp)) 04837 { 04838 if (!(*flp= f= sp_result_field())) 04839 { 04840 /* Error set by sp_result_field() */ 04841 null_value= 1; 04842 return TRUE; 04843 } 04844 04845 f->move_field((f->pack_length() > sizeof(result_buf)) ? 04846 sql_alloc(f->pack_length()) : result_buf); 04847 f->null_ptr= (uchar *)&null_value; 04848 f->null_bit= 1; 04849 } 04850 04851 /* Execute function and store the return value in the field. */ 04852 04853 if (execute_impl(thd, f)) 04854 { 04855 null_value= 1; 04856 context->process_error(thd); 04857 return TRUE; 04858 } 04859 04860 /* Check that the field (the value) is not NULL. */ 04861 04862 null_value= f->is_null(); 04863 04864 return null_value; 04865 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4869 of file item_func.cc.
References Item_func::args, context, DBUG_ENTER, DBUG_RETURN, sp_head::execute_function(), find_and_check_access(), m_sp, Name_resolution_context::security_ctx, and TRUE.
Referenced by execute().
04870 { 04871 bool err_status= TRUE; 04872 Sub_statement_state statement_state; 04873 #ifndef NO_EMBEDDED_ACCESS_CHECKS 04874 Security_context *save_security_ctx= thd->security_ctx; 04875 #endif 04876 04877 DBUG_ENTER("Item_func_sp::execute_impl"); 04878 04879 #ifndef NO_EMBEDDED_ACCESS_CHECKS 04880 if (context->security_ctx) 04881 { 04882 /* Set view definer security context */ 04883 thd->security_ctx= context->security_ctx; 04884 } 04885 #endif 04886 if (find_and_check_access(thd)) 04887 goto error; 04888 04889 /* 04890 Disable the binlogging if this is not a SELECT statement. If this is a 04891 SELECT, leave binlogging on, so execute_function() code writes the 04892 function call into binlog. 04893 */ 04894 thd->reset_sub_statement_state(&statement_state, SUB_STMT_FUNCTION); 04895 err_status= m_sp->execute_function(thd, args, arg_count, return_value_fld); 04896 thd->restore_sub_statement_state(&statement_state); 04897 04898 error: 04899 #ifndef NO_EMBEDDED_ACCESS_CHECKS 04900 thd->security_ctx= save_security_ctx; 04901 #endif 04902 04903 DBUG_RETURN(err_status); 04904 }
Here is the call graph for this function:

Here is the caller graph for this function:

| enum enum_field_types Item_func_sp::field_type | ( | ) | const [virtual] |
Reimplemented from Item.
Definition at line 4924 of file item_func.cc.
References DBUG_ENTER, DBUG_RETURN, MYSQL_TYPE_VARCHAR, result_field, sp_result_field(), and Field::type().
04925 { 04926 Field *field; 04927 DBUG_ENTER("Item_func_sp::field_type"); 04928 04929 if (result_field) 04930 DBUG_RETURN(result_field->type()); 04931 if ((field= sp_result_field())) 04932 { 04933 enum_field_types result= field->type(); 04934 delete field; 04935 DBUG_RETURN(result); 04936 } 04937 DBUG_RETURN(MYSQL_TYPE_VARCHAR); 04938 }
Here is the call graph for this function:

| bool Item_func_sp::find_and_check_access | ( | THD * | thd | ) |
Definition at line 5032 of file item_func.cc.
References check_routine_access(), ER_SP_DOES_NOT_EXIST, EXECUTE_ACL, FALSE, sp_head::m_db, sp_head::m_name, m_name, sp_name::m_qname, m_sp, my_error(), MYF, sp_find_routine(), LEX_STRING::str, TRUE, and TYPE_ENUM_FUNCTION.
Referenced by execute_impl(), and fix_fields().
05033 { 05034 if (! m_sp && ! (m_sp= sp_find_routine(thd, TYPE_ENUM_FUNCTION, m_name, 05035 &thd->sp_func_cache, TRUE))) 05036 { 05037 my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION", m_name->m_qname.str); 05038 return TRUE; 05039 } 05040 05041 #ifndef NO_EMBEDDED_ACCESS_CHECKS 05042 if (check_routine_access(thd, EXECUTE_ACL, 05043 m_sp->m_db.str, m_sp->m_name.str, 0, FALSE)) 05044 return TRUE; 05045 #endif 05046 05047 return FALSE; 05048 }
Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented from Item_func.
Definition at line 5052 of file item_func.cc.
References DBUG_ASSERT, find_and_check_access(), Item_func::fix_fields(), Item::fixed, m_sp, set_routine_security_ctx(), and sp_restore_security_context().
05053 { 05054 bool res; 05055 DBUG_ASSERT(fixed == 0); 05056 res= Item_func::fix_fields(thd, ref); 05057 if (!res && thd->lex->view_prepare_mode) 05058 { 05059 /* 05060 Here we check privileges of the stored routine only during view 05061 creation, in order to validate the view. A runtime check is 05062 perfomed in Item_func_sp::execute(), and this method is not 05063 called during context analysis. Notice, that during view 05064 creation we do not infer into stored routine bodies and do not 05065 check privileges of its statements, which would probably be a 05066 good idea especially if the view has SQL SECURITY DEFINER and 05067 the used stored procedure has SQL SECURITY DEFINER. 05068 */ 05069 res= find_and_check_access(thd); 05070 #ifndef NO_EMBEDDED_ACCESS_CHECKS 05071 Security_context *save_secutiry_ctx; 05072 if (!res && !(res= set_routine_security_ctx(thd, m_sp, false, 05073 &save_secutiry_ctx))) 05074 { 05075 sp_restore_security_context(thd, save_secutiry_ctx); 05076 } 05077 #endif /* ! NO_EMBEDDED_ACCESS_CHECKS */ 05078 } 05079 return res; 05080 }
Here is the call graph for this function:

| void Item_func_sp::fix_length_and_dec | ( | ) | [virtual] |
Implements Item_result_field.
Definition at line 4960 of file item_func.cc.
References Field::charset(), Item::collation, context, current_thd, DBUG_ENTER, DBUG_VOID_RETURN, Field::decimals(), Field::field_length, Item::max_length, Item::maybe_null, Name_resolution_context::process_error(), result_field, DTCollation::set(), and sp_result_field().
04961 { 04962 Field *field; 04963 DBUG_ENTER("Item_func_sp::fix_length_and_dec"); 04964 04965 if (result_field) 04966 { 04967 decimals= result_field->decimals(); 04968 max_length= result_field->field_length; 04969 collation.set(result_field->charset()); 04970 DBUG_VOID_RETURN; 04971 } 04972 04973 if (!(field= sp_result_field())) 04974 { 04975 context->process_error(current_thd); 04976 DBUG_VOID_RETURN; 04977 } 04978 decimals= field->decimals(); 04979 max_length= field->field_length; 04980 collation.set(field->charset()); 04981 maybe_null= 1; 04982 delete field; 04983 DBUG_VOID_RETURN; 04984 }
Here is the call graph for this function:

| const char * Item_func_sp::func_name | ( | ) | const [virtual] |
Implements Item_func.
Definition at line 4758 of file item_func.cc.
References ALIGN_SIZE, alloc_root(), String::append(), append_identifier(), current_thd, String::length(), LEX_STRING::length, sp_name::m_db, sp_name::m_name, m_name, String::ptr(), LEX_STRING::str, and system_charset_info.
04759 { 04760 THD *thd= current_thd; 04761 /* Calculate length to avoid reallocation of string for sure */ 04762 uint len= ((m_name->m_db.length + 04763 m_name->m_name.length)*2 + //characters*quoting 04764 2 + // ` and ` 04765 1 + // . 04766 1 + // end of string 04767 ALIGN_SIZE(1)); // to avoid String reallocation 04768 String qname((char *)alloc_root(thd->mem_root, len), len, 04769 system_charset_info); 04770 04771 qname.length(0); 04772 append_identifier(thd, &qname, m_name->m_db.str, m_name->m_db.length); 04773 qname.append('.'); 04774 append_identifier(thd, &qname, m_name->m_name.str, m_name->m_name.length); 04775 return qname.ptr(); 04776 }
Here is the call graph for this function:

| virtual enum Functype Item_func_sp::functype | ( | ) | const [inline, virtual] |
Reimplemented from Item_func.
Definition at line 1504 of file item_func.h.
References Item_func::FUNC_SP.
01504 { return FUNC_SP; }
| bool Item_func_sp::is_expensive | ( | ) | [inline, virtual] |
| void Item_func_sp::make_field | ( | Send_field * | tmp_field | ) | [virtual] |
Reimplemented from Item.
Definition at line 4908 of file item_func.cc.
References DBUG_ENTER, DBUG_VOID_RETURN, Item::init_make_field(), Field::make_field(), MYSQL_TYPE_VARCHAR, and sp_result_field().
04909 { 04910 Field *field; 04911 DBUG_ENTER("Item_func_sp::make_field"); 04912 if ((field= sp_result_field())) 04913 { 04914 field->make_field(tmp_field); 04915 delete field; 04916 DBUG_VOID_RETURN; 04917 } 04918 init_make_field(tmp_field, MYSQL_TYPE_VARCHAR); 04919 DBUG_VOID_RETURN; 04920 }
Here is the call graph for this function:

| Item_result Item_func_sp::result_type | ( | ) | const [virtual] |
Reimplemented from Item.
Definition at line 4942 of file item_func.cc.
References DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, m_sp, result_field, Field::result_type(), sp_result_field(), and STRING_RESULT.
04943 { 04944 Field *field; 04945 DBUG_ENTER("Item_func_sp::result_type"); 04946 DBUG_PRINT("info", ("m_sp = %p", m_sp)); 04947 04948 if (result_field) 04949 DBUG_RETURN(result_field->result_type()); 04950 if ((field= sp_result_field())) 04951 { 04952 Item_result result= field->result_type(); 04953 delete field; 04954 DBUG_RETURN(result); 04955 } 04956 DBUG_RETURN(STRING_RESULT); 04957 }
Here is the call graph for this function:

| Field * Item_func_sp::sp_result_field | ( | void | ) | const [private] |
Definition at line 4780 of file item_func.cc.
References st_table::alias, st_table::copy_blobs, sp_head::create_result_field(), current_thd, st_table_share::db, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, dummy_table, ER, ER_OUT_OF_RESOURCES, ER_SP_DOES_NOT_EXIST, st_table::in_use, sp_head::m_flags, m_name, sp_name::m_qname, sp_head::m_recursion_level, m_sp, Item::max_length, Item::maybe_null, st_table::maybe_null, my_error(), my_message(), MYF, Item::name, st_table::s, sp_find_routine(), LEX_STRING::str, st_table_share::table_cache_key, st_table_share::table_name, TRUE, and TYPE_ENUM_FUNCTION.
Referenced by execute(), field_type(), fix_length_and_dec(), make_field(), and result_type().
04781 { 04782 Field *field; 04783 DBUG_ENTER("Item_func_sp::sp_result_field"); 04784 DBUG_PRINT("info", ("sp: %s, flags: %x, level: %lu", 04785 (m_sp ? "YES" : "NO"), 04786 (m_sp ? m_sp->m_flags : (uint)0), 04787 (m_sp ? m_sp->m_recursion_level : (ulong)0))); 04788 04789 if (!m_sp) 04790 { 04791 THD *thd= current_thd; 04792 if (!(m_sp= sp_find_routine(thd, TYPE_ENUM_FUNCTION, m_name, 04793 &thd->sp_func_cache, TRUE))) 04794 { 04795 my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION", m_name->m_qname.str); 04796 DBUG_RETURN(0); 04797 } 04798 } 04799 if (!dummy_table->alias) 04800 { 04801 char *empty_name= (char *) ""; 04802 dummy_table->alias= empty_name; 04803 dummy_table->maybe_null= maybe_null; 04804 dummy_table->in_use= current_thd; 04805 dummy_table->copy_blobs= TRUE; 04806 dummy_table->s->table_cache_key.str = empty_name; 04807 dummy_table->s->table_name.str= empty_name; 04808 dummy_table->s->db.str= empty_name; 04809 } 04810 if (!(field= m_sp->create_result_field(max_length, name, dummy_table))) 04811 my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0)); 04812 04813 DBUG_RETURN(field); 04814 }
Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented from Item_func.
Definition at line 4995 of file item_func.cc.
References sp_head::create_result_field(), DBUG_ENTER, DBUG_RETURN, ER, ER_OUT_OF_RESOURCES, m_sp, Item::max_length, my_message(), MYF, Item::name, and Item_func::tmp_table_field().
04996 { 04997 Field *field= 0; 04998 DBUG_ENTER("Item_func_sp::tmp_table_field"); 04999 05000 if (m_sp) 05001 field= m_sp->create_result_field(max_length, (const char*) name, t_arg); 05002 05003 if (!field) 05004 field= Item_func::tmp_table_field(t_arg); 05005 05006 if (!field) 05007 my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0)); 05008 05009 DBUG_RETURN(field); 05010 }
Here is the call graph for this function:

| my_decimal* Item_func_sp::val_decimal | ( | my_decimal * | dec_buf | ) | [inline, virtual] |
Reimplemented from Item_func.
Definition at line 1473 of file item_func.h.
References execute(), NULL, result_field, and Field::val_decimal().
01474 { 01475 if (execute(&result_field)) 01476 return NULL; 01477 return result_field->val_decimal(dec_buf); 01478 }
Here is the call graph for this function:

| longlong Item_func_sp::val_int | ( | void | ) | [inline, virtual] |
Implements Item.
Definition at line 1459 of file item_func.h.
References execute(), result_field, and Field::val_int().
01460 { 01461 if (execute(&result_field)) 01462 return (longlong) 0; 01463 return result_field->val_int(); 01464 }
Here is the call graph for this function:

| double Item_func_sp::val_real | ( | void | ) | [inline, virtual] |
Implements Item.
Definition at line 1466 of file item_func.h.
References execute(), result_field, and Field::val_real().
01467 { 01468 if (execute(&result_field)) 01469 return 0.0; 01470 return result_field->val_real(); 01471 }
Here is the call graph for this function:

Implements Item.
Definition at line 1480 of file item_func.h.
References buf, String::charset(), String::copy(), execute(), NULL, result_field, and Field::val_str().
01481 { 01482 String buf; 01483 char buff[20]; 01484 buf.set(buff, 20, str->charset()); 01485 buf.length(0); 01486 if (execute(&result_field)) 01487 return NULL; 01488 /* 01489 result_field will set buf pointing to internal buffer 01490 of the resul_field. Due to this it will change any time 01491 when SP is executed. In order to prevent occasional 01492 corruption of returned value, we make here a copy. 01493 */ 01494 result_field->val_str(&buf); 01495 str->copy(buf); 01496 return str; 01497 }
Here is the call graph for this function:

Name_resolution_context* Item_func_sp::context [private] |
Definition at line 1426 of file item_func.h.
Referenced by change_context_processor(), execute(), execute_impl(), and fix_length_and_dec().
TABLE* Item_func_sp::dummy_table [private] |
sp_name* Item_func_sp::m_name [private] |
Definition at line 1427 of file item_func.h.
Referenced by find_and_check_access(), func_name(), Item_func_sp(), and sp_result_field().
sp_head* Item_func_sp::m_sp [mutable, private] |
Definition at line 1428 of file item_func.h.
Referenced by cleanup(), execute_impl(), find_and_check_access(), fix_fields(), result_type(), sp_result_field(), and tmp_table_field().
char Item_func_sp::result_buf[64] [private] |
Field* Item_func_sp::result_field [private] |
Reimplemented from Item_result_field.
Definition at line 1430 of file item_func.h.
Referenced by cleanup(), field_type(), fix_length_and_dec(), result_type(), val_decimal(), val_int(), val_real(), and val_str().
1.4.7

