mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
MDEV-11952 Oracle-style packages: stage#5
- CREATE PACKAGE [BODY] statements are now entirely written to mysql.proc with type='PACKAGE' and type='PACKAGE BODY'. - CREATE PACKAGE BODY now supports IF NOT EXISTS - DROP PACKAGE BODY now supports IF EXISTS - CREATE OR REPLACE PACKAGE [BODY] is now supported - CREATE PACKAGE [BODY] now support the DEFINER clause: CREATE DEFINER user@host PACKAGE pkg ... END; CREATE DEFINER user@host PACKAGE BODY pkg ... END; - CREATE PACKAGE [BODY] now supports SQL SECURITY and COMMENT clauses, e.g.: CREATE PACKAGE p1 SQL SECURITY INVOKER COMMENT "comment" AS ... END; - Package routines are now created from the package CREATE PACKAGE BODY statement and don't produce individual records in mysql.proc. - CREATE PACKAGE BODY now supports package-wide variables. Package variables can be read and set inside package routines. Package variables are stored in a separate sp_rcontext, which is cached in THD on the first packate routine call. - CREATE PACKAGE BODY now supports the initialization section. - All public routines (i.e. declared in CREATE PACKAGE) must have implementations in CREATE PACKAGE BODY - Only public package routines are available outside of the package - {CREATE|DROP} PACKAGE [BODY] now respects CREATE ROUTINE and ALTER ROUTINE privileges - "GRANT EXECUTE ON PACKAGE BODY pkg" is now supported - SHOW CREATE PACKAGE [BODY] is now supported - SHOW PACKAGE [BODY] STATUS is now supported - CREATE and DROP for PACKAGE [BODY] now works for non-current databases - mysqldump now supports packages - "SHOW {PROCEDURE|FUNCTION) CODE pkg.routine" now works for package routines - "SHOW PACKAGE BODY CODE pkg" now works (the package initialization section) - A new package body level MDL was added - Recursive calls for package procedures are now possible - Routine forward declarations in CREATE PACKATE BODY are now supported. - Package body variables now work as SP OUT parameters - Package body variables now work as SELECT INTO targets - Package body variables now support ROW, %ROWTYPE, %TYPE
This commit is contained in:
@ -2343,6 +2343,19 @@ public:
|
||||
return m_cpp_ptr;
|
||||
}
|
||||
|
||||
/**
|
||||
Get the current stream pointer, in the pre-processed buffer,
|
||||
with traling spaces removed.
|
||||
*/
|
||||
const char *get_cpp_ptr_rtrim()
|
||||
{
|
||||
const char *p;
|
||||
for (p= m_cpp_ptr;
|
||||
p > m_cpp_buf && my_isspace(system_charset_info, p[-1]);
|
||||
p--)
|
||||
{ }
|
||||
return p;
|
||||
}
|
||||
/** Get the utf8-body string. */
|
||||
const char *get_body_utf8_str()
|
||||
{
|
||||
@ -3212,15 +3225,10 @@ public:
|
||||
sp_name *make_sp_name(THD *thd, const LEX_CSTRING *name);
|
||||
sp_name *make_sp_name(THD *thd, const LEX_CSTRING *name1,
|
||||
const LEX_CSTRING *name2);
|
||||
sp_name *make_sp_name_package_routine(THD *thd, const LEX_CSTRING *name);
|
||||
sp_head *make_sp_head(THD *thd, const sp_name *name, const Sp_handler *sph);
|
||||
sp_head *make_sp_head_no_recursive(THD *thd, const sp_name *name,
|
||||
const Sp_handler *sph)
|
||||
{
|
||||
if (!sphead)
|
||||
return make_sp_head(thd, name, sph);
|
||||
my_error(ER_SP_NO_RECURSIVE_CREATE, MYF(0), sph->type_str());
|
||||
return NULL;
|
||||
}
|
||||
const Sp_handler *sph);
|
||||
sp_head *make_sp_head_no_recursive(THD *thd,
|
||||
DDL_options_st options, sp_name *name,
|
||||
const Sp_handler *sph)
|
||||
@ -3231,10 +3239,29 @@ public:
|
||||
}
|
||||
bool sp_body_finalize_function(THD *);
|
||||
bool sp_body_finalize_procedure(THD *);
|
||||
sp_package *create_package_start(THD *thd,
|
||||
enum_sql_command command,
|
||||
const Sp_handler *sph,
|
||||
const sp_name *name,
|
||||
DDL_options_st options);
|
||||
bool create_package_finalize(THD *thd,
|
||||
const sp_name *name,
|
||||
const sp_name *name2,
|
||||
const char *body_start,
|
||||
const char *body_end);
|
||||
bool call_statement_start(THD *thd, sp_name *name);
|
||||
bool call_statement_start(THD *thd, const LEX_CSTRING *name);
|
||||
bool call_statement_start(THD *thd, const LEX_CSTRING *name1,
|
||||
const LEX_CSTRING *name2);
|
||||
sp_variable *find_variable(const LEX_CSTRING *name,
|
||||
sp_pcontext **ctx,
|
||||
const Sp_rcontext_handler **rh) const;
|
||||
sp_variable *find_variable(const LEX_CSTRING *name,
|
||||
const Sp_rcontext_handler **rh) const
|
||||
{
|
||||
sp_pcontext *not_used_ctx;
|
||||
return find_variable(name, ¬_used_ctx, rh);
|
||||
}
|
||||
bool init_internal_variable(struct sys_var_with_base *variable,
|
||||
const LEX_CSTRING *name);
|
||||
bool init_internal_variable(struct sys_var_with_base *variable,
|
||||
@ -3318,6 +3345,7 @@ public:
|
||||
/*
|
||||
Create an Item corresponding to a ROW field valiable: var.field
|
||||
@param THD - THD, for mem_root
|
||||
@param rh [OUT] - the rcontext handler (local vs package variables)
|
||||
@param var - the ROW variable name
|
||||
@param field - the ROW variable field name
|
||||
@param spvar - the variable that was previously found by name
|
||||
@ -3326,6 +3354,7 @@ public:
|
||||
@param end - end in the query (for binary log)
|
||||
*/
|
||||
Item_splocal *create_item_spvar_row_field(THD *thd,
|
||||
const Sp_rcontext_handler *rh,
|
||||
const LEX_CSTRING *var,
|
||||
const LEX_CSTRING *field,
|
||||
sp_variable *spvar,
|
||||
@ -3419,6 +3448,8 @@ public:
|
||||
Item *make_item_func_replace(THD *thd, Item *org, Item *find, Item *replace);
|
||||
Item *make_item_func_substr(THD *thd, Item *a, Item *b, Item *c);
|
||||
Item *make_item_func_substr(THD *thd, Item *a, Item *b);
|
||||
my_var *create_outvar(THD *thd, const LEX_CSTRING *name);
|
||||
|
||||
/*
|
||||
Create a my_var instance for a ROW field variable that was used
|
||||
as an OUT SP parameter: CALL p1(var.field);
|
||||
@ -3479,6 +3510,7 @@ public:
|
||||
bool sp_block_with_exceptions_finalize_exceptions(THD *thd,
|
||||
uint executable_section_ip,
|
||||
uint exception_count);
|
||||
bool sp_block_with_exceptions_add_empty(THD *thd);
|
||||
bool sp_exit_statement(THD *thd, Item *when);
|
||||
bool sp_exit_statement(THD *thd, const LEX_CSTRING *label_name, Item *item);
|
||||
bool sp_leave_statement(THD *thd, const LEX_CSTRING *label_name);
|
||||
@ -3728,6 +3760,7 @@ public:
|
||||
{
|
||||
return create_info.vers_info;
|
||||
}
|
||||
sp_package *get_sp_package() const;
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user