summaryrefslogtreecommitdiff
path: root/sql/sql_lex.cc
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2016-08-15 16:25:27 +0400
committerAlexander Barkov <bar@mariadb.org>2017-04-05 15:02:42 +0400
commit81ba971d0334dee5dce880ea848300cc5ed45ccb (patch)
tree6b14af9f914e55609960479b7501d41bb2220770 /sql/sql_lex.cc
parent0040b0f38060724e95137aa5564feca3da11bc02 (diff)
downloadmariadb-git-81ba971d0334dee5dce880ea848300cc5ed45ccb.tar.gz
MDEV-10411 Providing compatibility for basic PL/SQL constructs
- Part 9: EXCEPTION handlers The top-most stored routine blocks now support EXCEPTION clause in its correct place: AS [ declarations ] BEGIN statements [ EXCEPTION exceptions ] END Inner block will be done in a separate commit. - Part 14: IN OUT instead of INOUT (in SP parameter declarations)
Diffstat (limited to 'sql/sql_lex.cc')
-rw-r--r--sql/sql_lex.cc49
1 files changed, 49 insertions, 0 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 076f389f3a3..9c66aea04d9 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -5386,8 +5386,57 @@ sp_head *LEX::make_sp_head(THD *thd, sp_name *name,
}
+bool LEX::sp_block_with_exceptions_finalize_declarations(THD *thd)
+{
+ /*
+ [ DECLARE declarations ]
+ BEGIN executable_section
+ [ EXCEPTION exceptions ]
+ END
+
+ We are now at the "BEGIN" keyword.
+ We have collected all declarations, including DECLARE HANDLER directives.
+ But there will be possibly more handlers in the EXCEPTION section.
+
+ Generate a forward jump from the end of the DECLARE section to the
+ beginning of the EXCEPTION section, over the executable section.
+ */
+ return sphead->add_instr_jump(thd, spcont);
+}
+bool
+LEX::sp_block_with_exceptions_finalize_executable_section(THD *thd,
+ uint executable_section_ip)
+{
+ /*
+ We're now at the end of "executable_section" of the block,
+ near the "EXCEPTION" or the "END" keyword.
+ Generate a jump to the END of the block over the EXCEPTION section.
+ */
+ if (sphead->add_instr_jump_forward_with_backpatch(thd, spcont))
+ return true;
+ /*
+ Set the destination for the jump that we added in
+ sp_block_with_exceptions_finalize_declarations().
+ */
+ sp_instr *instr= sphead->get_instr(executable_section_ip - 1);
+ instr->backpatch(sphead->instructions(), spcont);
+ return false;
+}
+
+
+bool
+LEX::sp_block_with_exceptions_finalize_exceptions(THD *thd,
+ uint executable_section_ip)
+{
+ /*
+ Generate a jump from the end of the EXCEPTION code
+ to the executable section.
+ */
+ return sphead->add_instr_jump(thd, spcont, executable_section_ip);
+}
+
#ifdef MYSQL_SERVER
uint binlog_unsafe_map[256];