summaryrefslogtreecommitdiff
path: root/sql/sp_rcontext.cc
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2017-09-28 17:48:33 +0400
committerAlexander Barkov <bar@mariadb.org>2017-09-28 17:48:33 +0400
commit139441d0a0e7964898f33659429c22e33bd20dda (patch)
treebeb715db10722c6d52adb838d85ae185f1b4bd91 /sql/sp_rcontext.cc
parent596baeb1bfb812ad9b458eba0f6ea7d9bcdf4671 (diff)
downloadmariadb-git-139441d0a0e7964898f33659429c22e33bd20dda.tar.gz
A cleanup for MDEV-13919 sql_mode=ORACLE: Derive length of VARCHAR SP param...
The intent of this patch is to avoid copying arguments from a pair "Item **args, uint arg_count" to List<Item> in sp_head::execute_function(). If the number of a stored function parameters is huge, such copying can affect performance. Change: 1. Adding a new method Row_definition_list::adjust_formal_params_to_actual_params, which accepts a pair of "Item **, uint". 2. Modifying the code to use the new method: - the calls for sp_rcontext::retrieve_field_definitions() and Row_definition_list::adjust_formal_params_to_actual_params() have been moved from sp_rcontext::create() to sp_head::rcontext_create(), to handle different argument notations easier (Item** vs List<Item>). - sp_rcontext::create() now assumes that the passed Row_definition_list is already adjusted to the actual SP parameters, and all "TYPE OF" and "ROWTYPE OF" references are resolved. 3. Removing creation of List<Item> in sp_head::execute_procedure(), using the code with "Item**, uint" notation instead. 4. Improvement of the code for MDEV-10577: As a good side effect, this patch gets rid of double security context switch inside sp_head::execute_trigger(): sp_rcontext is created when the context is already switched, so the second context switch inside sp_head::rcontext_create() was redundant. This is solved by adding a "bool switch_secutiry_ctx" parameter to rcontext_create(), so now execute_function() and execute_procedure() pass "true", while execute_trigger() passes "false".
Diffstat (limited to 'sql/sp_rcontext.cc')
-rw-r--r--sql/sp_rcontext.cc28
1 files changed, 17 insertions, 11 deletions
diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc
index e82947835f0..43a42b579bd 100644
--- a/sql/sp_rcontext.cc
+++ b/sql/sp_rcontext.cc
@@ -63,25 +63,15 @@ sp_rcontext::~sp_rcontext()
sp_rcontext *sp_rcontext::create(THD *thd,
const sp_pcontext *root_parsing_ctx,
Field *return_value_fld,
- bool resolve_type_refs,
- List<Item> *args)
+ Row_definition_list &field_def_lst)
{
sp_rcontext *ctx= new (thd->mem_root) sp_rcontext(root_parsing_ctx,
return_value_fld,
thd->in_sub_stmt);
-
if (!ctx)
return NULL;
- Row_definition_list field_def_lst;
- ctx->m_root_parsing_ctx->retrieve_field_definitions(&field_def_lst);
-
- if (args &&
- field_def_lst.adjust_formal_params_to_actual_params(thd, args))
- return NULL;
-
if (ctx->alloc_arrays(thd) ||
- (resolve_type_refs && field_def_lst.resolve_type_refs(thd)) ||
ctx->init_var_table(thd, field_def_lst) ||
ctx->init_var_items(thd, field_def_lst))
{
@@ -110,6 +100,22 @@ bool Row_definition_list::
}
+bool Row_definition_list::
+ adjust_formal_params_to_actual_params(THD *thd,
+ Item **args, uint arg_count)
+{
+ List_iterator<Spvar_definition> it(*this);
+ DBUG_ASSERT(elements >= arg_count );
+ Spvar_definition *def;
+ for (uint i= 0; (def= it++) && (i < arg_count) ; i++)
+ {
+ if (def->type_handler()->adjust_spparam_type(def, args[i]))
+ return true;
+ }
+ return false;
+}
+
+
bool sp_rcontext::alloc_arrays(THD *thd)
{
{