MCPcopy Create free account
hub / github.com/MariaDB/server / create_package_start

Method create_package_start

sql/sql_lex.cc:10627–10683  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10625
10626
10627sp_package *LEX::create_package_start(THD *thd,
10628 const Sp_handler *sph,
10629 const sp_name *name_arg,
10630 DDL_options_st options,
10631 const st_sp_chistics &chistics)
10632{
10633 sp_package *pkg;
10634
10635 if (unlikely(sphead))
10636 {
10637 my_error(ER_SP_NO_RECURSIVE_CREATE, MYF(0), sph->type_str());
10638 return NULL;
10639 }
10640 if (unlikely(set_command_with_check(sph->sqlcom_create(), options)))
10641 return NULL;
10642 if (sph->type() == SP_TYPE_PACKAGE_BODY)
10643 {
10644 /*
10645 If we start parsing a "CREATE PACKAGE BODY", we need to load
10646 the corresponding "CREATE PACKAGE", for the following reasons:
10647 1. "CREATE PACKAGE BODY" is allowed only if "CREATE PACKAGE"
10648 was done earlier for the same package name.
10649 So if "CREATE PACKAGE" does not exist, we throw an error here.
10650 2. When parsing "CREATE PACKAGE BODY", we need to know all package
10651 public and private routine names, to translate procedure and
10652 function calls correctly.
10653 For example, this statement inside a package routine:
10654 CALL p;
10655 can be translated to:
10656 CALL db.pkg.p; -- p is a known (public or private) package routine
10657 CALL db.p; -- p is not a known package routine
10658 */
10659 sp_head *spec;
10660 int ret= sp_handler_package_spec.
10661 sp_cache_routine_reentrant(thd, name_arg, &spec);
10662 if (unlikely(!spec))
10663 {
10664 if (!ret)
10665 my_error(ER_SP_DOES_NOT_EXIST, MYF(0),
10666 "PACKAGE", ErrConvDQName(name_arg).ptr());
10667 return 0;
10668 }
10669 }
10670 if (unlikely(!(pkg= sp_package::create(this, name_arg, sph,
10671 thd->variables.sql_mode,
10672 thd->variables.path,
10673 sp_mem_root_ptr))))
10674 return NULL;
10675 pkg->reset_thd_mem_root(thd);
10676 pkg->init(this);
10677 if (!(pkg->m_qname= pkg->to_identifier_chain2().
10678 make_qname_casedn_part1(pkg->get_main_mem_root())).str)
10679 return NULL;
10680 pkg->set_c_chistics(chistics);
10681 sphead= pkg;
10682 return pkg;
10683}
10684

Callers

nothing calls this directly

Calls 14

my_errorFunction · 0.85
ErrConvDQNameClass · 0.85
createFunction · 0.85
type_strMethod · 0.80
reset_thd_mem_rootMethod · 0.80
to_identifier_chain2Method · 0.80
get_main_mem_rootMethod · 0.80
set_c_chisticsMethod · 0.80
sqlcom_createMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected