-
Praveenkumar Hulakund authored
WL6384 provides new DD tables ("Routines" and "Parameters") and new DD APIs to work with the stored routines(Stored function and procedures). This patch mainly uses APIs provided by WL6384 to store, drop, alter routine metadata in New DD tables and read stored routine's metadata from new DD tables("Routines" and "Parameters"). Table mysql.proc creation and usage is avoided with this patch. A) As part of this WL, followings APIs are introduced to operate on new DD tables using DD APIs. These methods are called by the current SP module. a) template <typename T> enum_sp_return_code dd::create_routine(...) Stores metadata information from sp_head object to the DD tables. b) template <typename T> enum_sp_return_code dd::drop_routine(...) Removes metadata information of stored routine from the DD tables. c) template <typename T> enum_sp_return_code dd::alter_routine(...) Alter metadata information of stored routine in the DD tables. d) template <typename T> enum_sp_return_code dd::find_routine(...) Find stored routine in the Data Dictionary table. B) Following methods are introduced in the sp.cc. a) static enum_sp_return_code lock_routine_name(...) Acquire MDL lock MDL_EXCLUSIVE or MDL_SHARED on routine name. b) static bool show_create_routine_from_dd_routine(...) Prepares "SHOW CREATE FUNCTION/PROCEDURE" output using the dd::Routine object. C) Following methods are introduced in the "new" files dd_sp.h & dd.sp.cc a) void prepare_sp_chistics_from_dd_routine(...) Prepares st_sp_chistics object from the dd::Routine object. b) void prepare_return_type_string_from_dd_routine(...) Prepares stored routine return type value in string format from dd::Routine object. c) void prepare_params_string_from_dd_routine(...) Prepares stored routine parameters string from the dd::Routine object. d) bool is_dd_routine_type_functon(...) Method to check whether routine is of stored function or not. Notes: The WL introduces the following user-visible changes: a) The mysql.proc table is now removed. This means that the table can no longer be e.g. queried, updated or locked explicitly by the user. b) A shared metadata lock is now taken when executing stored routine. This lock is held until the transaction terminates. This means that it will no longer be possible to alter or drop a stored routine while it is executing. c) As a consequence of removing mysql.proc, ACL on mysql.proc no longer applies. For now, full access is only given to the definer, any users with global SELECT privilege and users with CREATE ROUTINE, ALTER ROUTINE or EXECUTE ROUTINE privileges. A more long-term solution for allowing backup of stored routines will be implemented in WL#8131/WL#9049. d) Before this WL, creating a stored routine having a definition containing illegal characters only resulted in a warning. With this WL, an error will be raised instead (ER_INVALID_CHARACTER_STRING is still used). This makes stored routines behave similar to e.g. views. The stored routine subsystem has been suitably refactored to make use of new DD table "Routine" and "Parameters" with the new DD APIs provided. Since mysql.proc does not exists after this WL changes, all MTR tests which use mysql.proc are either updated to use INFORMATION_SCHEMA's "Routines" and "Parameters" tables or test cases are removed.
Praveenkumar Hulakund authoredWL6384 provides new DD tables ("Routines" and "Parameters") and new DD APIs to work with the stored routines(Stored function and procedures). This patch mainly uses APIs provided by WL6384 to store, drop, alter routine metadata in New DD tables and read stored routine's metadata from new DD tables("Routines" and "Parameters"). Table mysql.proc creation and usage is avoided with this patch. A) As part of this WL, followings APIs are introduced to operate on new DD tables using DD APIs. These methods are called by the current SP module. a) template <typename T> enum_sp_return_code dd::create_routine(...) Stores metadata information from sp_head object to the DD tables. b) template <typename T> enum_sp_return_code dd::drop_routine(...) Removes metadata information of stored routine from the DD tables. c) template <typename T> enum_sp_return_code dd::alter_routine(...) Alter metadata information of stored routine in the DD tables. d) template <typename T> enum_sp_return_code dd::find_routine(...) Find stored routine in the Data Dictionary table. B) Following methods are introduced in the sp.cc. a) static enum_sp_return_code lock_routine_name(...) Acquire MDL lock MDL_EXCLUSIVE or MDL_SHARED on routine name. b) static bool show_create_routine_from_dd_routine(...) Prepares "SHOW CREATE FUNCTION/PROCEDURE" output using the dd::Routine object. C) Following methods are introduced in the "new" files dd_sp.h & dd.sp.cc a) void prepare_sp_chistics_from_dd_routine(...) Prepares st_sp_chistics object from the dd::Routine object. b) void prepare_return_type_string_from_dd_routine(...) Prepares stored routine return type value in string format from dd::Routine object. c) void prepare_params_string_from_dd_routine(...) Prepares stored routine parameters string from the dd::Routine object. d) bool is_dd_routine_type_functon(...) Method to check whether routine is of stored function or not. Notes: The WL introduces the following user-visible changes: a) The mysql.proc table is now removed. This means that the table can no longer be e.g. queried, updated or locked explicitly by the user. b) A shared metadata lock is now taken when executing stored routine. This lock is held until the transaction terminates. This means that it will no longer be possible to alter or drop a stored routine while it is executing. c) As a consequence of removing mysql.proc, ACL on mysql.proc no longer applies. For now, full access is only given to the definer, any users with global SELECT privilege and users with CREATE ROUTINE, ALTER ROUTINE or EXECUTE ROUTINE privileges. A more long-term solution for allowing backup of stored routines will be implemented in WL#8131/WL#9049. d) Before this WL, creating a stored routine having a definition containing illegal characters only resulted in a warning. With this WL, an error will be raised instead (ER_INVALID_CHARACTER_STRING is still used). This makes stored routines behave similar to e.g. views. The stored routine subsystem has been suitably refactored to make use of new DD table "Routine" and "Parameters" with the new DD APIs provided. Since mysql.proc does not exists after this WL changes, all MTR tests which use mysql.proc are either updated to use INFORMATION_SCHEMA's "Routines" and "Parameters" tables or test cases are removed.
Loading