summaryrefslogtreecommitdiff
path: root/sql/sp_head.cc
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2017-03-10 14:11:07 +0400
committerAlexander Barkov <bar@mariadb.org>2017-04-05 15:02:59 +0400
commit84c55a5668db582aa92dd2ccf076fbb783894b12 (patch)
treec6fccd62b326cae532b50965b37889d363111940 /sql/sp_head.cc
parentf429b5a834439e4f0c76e893487e33027d76b74b (diff)
downloadmariadb-git-84c55a5668db582aa92dd2ccf076fbb783894b12.tar.gz
MDEV-10581 sql_mode=ORACLE: Explicit cursor FOR LOOP
MDEV-12098 sql_mode=ORACLE: Implicit cursor FOR loop
Diffstat (limited to 'sql/sp_head.cc')
-rw-r--r--sql/sp_head.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 2b5b1db5ddf..5b7e4f854e7 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -4207,7 +4207,10 @@ void
sp_instr_cursor_copy_struct::print(String *str)
{
sp_variable *var= m_ctx->find_variable(m_var);
+ const LEX_STRING *name= m_lex_keeper.cursor_name();
str->append(STRING_WITH_LEN("cursor_copy_struct "));
+ str->append(name->str, name->length);
+ str->append(' ');
str->append(var->name.str, var->name.length);
str->append('@');
str->append_ulonglong(m_var);
@@ -4665,3 +4668,29 @@ bool sp_head::add_open_cursor(THD *thd, sp_pcontext *spcont, uint offset,
sp_instr_copen(instructions(), spcont, offset);
return i == NULL || add_instr(i);
}
+
+
+bool sp_head::add_for_loop_open_cursor(THD *thd, sp_pcontext *spcont,
+ sp_variable *index,
+ const sp_pcursor *pcursor, uint coffset)
+{
+ sp_instr *instr_copy_struct=
+ new (thd->mem_root) sp_instr_cursor_copy_struct(instructions(),
+ spcont, pcursor->lex(),
+ index->offset);
+ if (instr_copy_struct == NULL || add_instr(instr_copy_struct))
+ return true;
+
+ sp_instr_copen *instr_copen=
+ new (thd->mem_root) sp_instr_copen(instructions(), spcont, coffset);
+ if (instr_copen == NULL || add_instr(instr_copen))
+ return true;
+
+ sp_instr_cfetch *instr_cfetch=
+ new (thd->mem_root) sp_instr_cfetch(instructions(),
+ spcont, coffset);
+ if (instr_cfetch == NULL || add_instr(instr_cfetch))
+ return true;
+ instr_cfetch->add_to_varlist(index);
+ return false;
+}