diff options
author | Alexander Barkov <bar@mariadb.org> | 2016-08-09 14:58:20 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2017-04-05 15:02:40 +0400 |
commit | 365e0b3178f5377529d9c6579118212e544552dc (patch) | |
tree | c66f28d3a042638fb91a578d9401ab4db96d98c2 /sql/sp_pcontext.h | |
parent | 36b80caed12cd629c7b067eb9e3273832fe6a4d0 (diff) | |
download | mariadb-git-365e0b3178f5377529d9c6579118212e544552dc.tar.gz |
sql_lex.yy / sql_yacc_ora.yy refactoring for MDEV-10411.
1. Adding const qualifiers into a few method parameters.
2. Adding methods:
- sp_label::block_label_declare()
- LEX::sp_block_init()
- LEX::sp_block_finalize()
to share more code between the files sql_yacc.yy and sql_yacc_ora.yy,
as well as between the rules sp_labeled_block, sp_unlabeled_block,
sp_unlabeled_block_not_atomic.
3. sql_yacc.yy, sql_yacc_ora.yy changes:
- Removing sp_block_content
- Reorganizing the grammar so the rules sp_labeled_block,
sp_unlabeled_block, sp_unlabeled_block_not_atomic now
contain both BEGIN_SYM and END keywords. Previously,
BEGIN_SYM and END resided in different rules.
This change makes the grammar easier to read,
as well as simplifies adding Oracle-style DECLARE section (coming soon):
DECLARE
..
BEGIN
..
END;
Good side effects:
- SP block related grammar does not use Lex->name any more.
- The "splabel" member was removed from %union
Diffstat (limited to 'sql/sp_pcontext.h')
-rw-r--r-- | sql/sp_pcontext.h | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/sql/sp_pcontext.h b/sql/sp_pcontext.h index 1ef99219e8e..cbebc157dbb 100644 --- a/sql/sp_pcontext.h +++ b/sql/sp_pcontext.h @@ -108,7 +108,8 @@ public: class sp_pcontext *ctx; public: - sp_label(LEX_STRING _name, uint _ip, enum_type _type, sp_pcontext *_ctx) + sp_label(const LEX_STRING _name, + uint _ip, enum_type _type, sp_pcontext *_ctx) :Sql_alloc(), name(_name), ip(_ip), @@ -401,9 +402,9 @@ public: // Labels. ///////////////////////////////////////////////////////////////////////// - sp_label *push_label(THD *thd, LEX_STRING name, uint ip); + sp_label *push_label(THD *thd, const LEX_STRING name, uint ip); - sp_label *find_label(LEX_STRING name); + sp_label *find_label(const LEX_STRING name); sp_label *last_label() { @@ -418,6 +419,17 @@ public: sp_label *pop_label() { return m_labels.pop(); } + bool block_label_declare(LEX_STRING label) + { + sp_label *lab= find_label(label); + if (lab) + { + my_error(ER_SP_LABEL_REDEFINE, MYF(0), label.str); + return true; + } + return false; + } + ///////////////////////////////////////////////////////////////////////// // Conditions. ///////////////////////////////////////////////////////////////////////// |