mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +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:
@ -913,6 +913,8 @@ THD::THD(my_thread_id id, bool is_wsrep_applier, bool skip_global_sys_var_lock)
|
||||
|
||||
sp_proc_cache= NULL;
|
||||
sp_func_cache= NULL;
|
||||
sp_package_spec_cache= NULL;
|
||||
sp_package_body_cache= NULL;
|
||||
|
||||
/* For user vars replication*/
|
||||
if (opt_bin_log)
|
||||
@ -1478,6 +1480,8 @@ void THD::change_user(void)
|
||||
(my_hash_free_key) free_sequence_last, HASH_THREAD_SPECIFIC);
|
||||
sp_cache_clear(&sp_proc_cache);
|
||||
sp_cache_clear(&sp_func_cache);
|
||||
sp_cache_clear(&sp_package_spec_cache);
|
||||
sp_cache_clear(&sp_package_body_cache);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1604,6 +1608,8 @@ void THD::cleanup(void)
|
||||
my_hash_free(&sequences);
|
||||
sp_cache_clear(&sp_proc_cache);
|
||||
sp_cache_clear(&sp_func_cache);
|
||||
sp_cache_clear(&sp_package_spec_cache);
|
||||
sp_cache_clear(&sp_package_body_cache);
|
||||
auto_inc_intervals_forced.empty();
|
||||
auto_inc_intervals_in_cur_stmt_for_binlog.empty();
|
||||
|
||||
@ -3732,7 +3738,8 @@ int select_dumpvar::prepare(List<Item> &list, SELECT_LEX_UNIT *u)
|
||||
mvsp->type_handler() == &type_handler_row)
|
||||
{
|
||||
// SELECT INTO row_type_sp_variable
|
||||
if (thd->spcont->get_variable(mvsp->offset)->cols() != list.elements)
|
||||
if (mvsp->get_rcontext(thd->spcont)->get_variable(mvsp->offset)->cols() !=
|
||||
list.elements)
|
||||
goto error;
|
||||
m_var_sp_row= mvsp;
|
||||
return 0;
|
||||
@ -4076,14 +4083,22 @@ bool my_var_user::set(THD *thd, Item *item)
|
||||
return suv->fix_fields(thd, 0) || suv->update();
|
||||
}
|
||||
|
||||
|
||||
sp_rcontext *my_var_sp::get_rcontext(sp_rcontext *local_ctx) const
|
||||
{
|
||||
return m_rcontext_handler->get_rcontext(local_ctx);
|
||||
}
|
||||
|
||||
|
||||
bool my_var_sp::set(THD *thd, Item *item)
|
||||
{
|
||||
return thd->spcont->set_variable(thd, offset, &item);
|
||||
return get_rcontext(thd->spcont)->set_variable(thd, offset, &item);
|
||||
}
|
||||
|
||||
bool my_var_sp_row_field::set(THD *thd, Item *item)
|
||||
{
|
||||
return thd->spcont->set_variable_row_field(thd, offset, m_field_offset, &item);
|
||||
return get_rcontext(thd->spcont)->
|
||||
set_variable_row_field(thd, offset, m_field_offset, &item);
|
||||
}
|
||||
|
||||
|
||||
@ -4118,7 +4133,8 @@ int select_dumpvar::send_data(List<Item> &items)
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
if (m_var_sp_row ?
|
||||
thd->spcont->set_variable_row(thd, m_var_sp_row->offset, items) :
|
||||
m_var_sp_row->get_rcontext(thd->spcont)->
|
||||
set_variable_row(thd, m_var_sp_row->offset, items) :
|
||||
send_data_to_var_list(items))
|
||||
DBUG_RETURN(1);
|
||||
|
||||
|
Reference in New Issue
Block a user