diff options
author | Alexander Barkov <bar@mariadb.org> | 2017-03-22 18:10:33 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2017-04-05 15:03:00 +0400 |
commit | ec19e48021e408edac2e875cfeeef8f496a04d22 (patch) | |
tree | 2e0e035a36bb4ccaf5bb3918dc9a5362afc4e42b /sql/sp_head.h | |
parent | e0451941ccb6adc11490099cdb7b1564af62ee68 (diff) | |
download | mariadb-git-ec19e48021e408edac2e875cfeeef8f496a04d22.tar.gz |
MDEV-12314 Implicit cursor FOR LOOP for cursors with parameters
Diffstat (limited to 'sql/sp_head.h')
-rw-r--r-- | sql/sp_head.h | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/sql/sp_head.h b/sql/sp_head.h index d8709feb084..3dbed697f75 100644 --- a/sql/sp_head.h +++ b/sql/sp_head.h @@ -363,8 +363,20 @@ public: } Item *adjust_assignment_source(THD *thd, Item *val, Item *val2); + /** + @param thd - the current thd + @param spcont - the current parse context + @param spv - the SP variable + @param val - the value to be assigned to the variable + @param lex - the LEX that was used to create "val" + @param responsible_to_free_lex - if the generated sp_instr_set should + free "lex". + @retval true - on error + @retval false - on success + */ bool set_local_variable(THD *thd, sp_pcontext *spcont, - sp_variable *spv, Item *val, LEX *lex); + sp_variable *spv, Item *val, LEX *lex, + bool responsible_to_free_lex); bool set_local_variable_row_field(THD *thd, sp_pcontext *spcont, sp_variable *spv, uint field_idx, Item *val, LEX *lex); @@ -394,7 +406,7 @@ private: */ DBUG_ASSERT(m_thd->free_list == NULL); m_thd->free_list= prm->get_free_list(); - if (set_local_variable(thd, param_spcont, spvar, prm->get_item(), prm)) + if (set_local_variable(thd, param_spcont, spvar, prm->get_item(), prm, true)) return true; /* Safety: @@ -429,6 +441,15 @@ private: return false; } + /** + Generate a code to set all cursor parameter variables for a FOR LOOP, e.g.: + FOR index IN cursor(1,2,3) + @param + */ + bool add_set_for_loop_cursor_param_variables(THD *thd, + sp_pcontext *param_spcont, + sp_assignment_lex *param_lex, + Item_args *parameters); public: /** @@ -451,9 +472,11 @@ public: /** Generate an initiation code for a CURSOR FOR LOOP, e.g.: - FOR index IN cursor + FOR index IN cursor -- cursor without parameters + FOR index IN cursor(1,2,3) -- cursor with parameters The code generated by this method does the following during SP run-time: + - Sets all cursor parameter vartiables from "parameters" - Initializes the index ROW-type variable from the cursor (the structure is copied from the cursor to the index variable) - The cursor gets opened @@ -464,13 +487,16 @@ public: @param index - the loop "index" ROW-type variable @param pcursor - the cursor @param coffset - the cursor offset + @param param_lex - the LEX that owns Items in "parameters" + @param parameters - the cursor parameters Item array @retval true - on error (EOM) @retval false - on success */ bool add_for_loop_open_cursor(THD *thd, sp_pcontext *spcont, sp_variable *index, - const sp_pcursor *pcursor, uint coffset); - + const sp_pcursor *pcursor, uint coffset, + sp_assignment_lex *param_lex, + Item_args *parameters); /** Returns true if any substatement in the routine directly (not through another routine) modifies data/changes table. |