@@ -953,7 +953,8 @@ static bool sp_create_assignment_instr(THD *thd, bool no_lookahead)
953
953
chooser_compare_func_creator boolfunc2creator;
954
954
class sp_condition_value *spcondvalue;
955
955
struct { int vars, conds, hndlrs, curs; } spblock;
956
- sp_name *spname;
956
+ class sp_name *spname;
957
+ class sp_label *splabel;
957
958
LEX *lex;
958
959
class my_var *myvar;
959
960
sp_head *sphead;
@@ -1911,6 +1912,7 @@ END_OF_INPUT
1911
1912
%type <spblock> sp_decls sp_decl
1912
1913
%type <lex> sp_cursor_stmt
1913
1914
%type <spname> sp_name
1915
+ %type <splabel> sp_block_content
1914
1916
%type <index_hint> index_hint_type
1915
1917
%type <num> index_hint_clause normal_join inner_join
1916
1918
%type <filetype> data_or_xml
@@ -3743,7 +3745,7 @@ sp_proc_stmt_return:
3743
3745
;
3744
3746
3745
3747
sp_unlabeled_control:
3746
- { /* Unlabeled controls get a secret label. */
3748
+ { /* Unlabeled controls get an empty label. */
3747
3749
LEX *lex= Lex;
3748
3750
3749
3751
lex->spcont ->push_label (thd, empty_lex_str,
@@ -4170,7 +4172,7 @@ sp_opt_label:
4170
4172
;
4171
4173
4172
4174
sp_labeled_block:
4173
- label_ident ' :'
4175
+ label_ident ' :' BEGIN_SYM
4174
4176
{
4175
4177
LEX *lex= Lex;
4176
4178
sp_pcontext *ctx= lex->spcont ;
@@ -4181,46 +4183,39 @@ sp_labeled_block:
4181
4183
my_error (ER_SP_LABEL_REDEFINE, MYF (0 ), $1 .str );
4182
4184
MYSQL_YYABORT;
4183
4185
}
4184
-
4185
- lab= lex->spcont ->push_label (thd, $1 , lex->sphead ->instructions ());
4186
- lab->type = sp_label::BEGIN;
4186
+ lex->name = $1 ;
4187
4187
}
4188
4188
sp_block_content sp_opt_label
4189
4189
{
4190
- LEX *lex= Lex;
4191
- sp_label *lab= lex->spcont ->pop_label ();
4192
-
4193
- if ($5 .str )
4190
+ if ($6 .str )
4194
4191
{
4195
- if (my_strcasecmp (system_charset_info, $5 .str , lab ->name .str ) != 0 )
4192
+ if (my_strcasecmp (system_charset_info, $6 .str , $ 5 ->name .str ) != 0 )
4196
4193
{
4197
- my_error (ER_SP_LABEL_MISMATCH, MYF (0 ), $5 .str );
4194
+ my_error (ER_SP_LABEL_MISMATCH, MYF (0 ), $6 .str );
4198
4195
MYSQL_YYABORT;
4199
4196
}
4200
4197
}
4201
4198
}
4202
4199
;
4203
4200
4201
+ /* QQ This is just a dummy for grouping declarations and statements
4202
+ together. No [[NOT] ATOMIC] yet, and we need to figure out how
4203
+ make it coexist with the existing BEGIN COMMIT/ROLLBACK. */
4204
4204
sp_unlabeled_block:
4205
- { /* Unlabeled blocks get a secret label. */
4206
- LEX *lex= Lex;
4207
- uint ip= lex->sphead ->instructions ();
4208
- sp_label *lab= lex->spcont ->push_label (thd, empty_lex_str, ip);
4209
- lab->type = sp_label::BEGIN;
4210
- }
4211
- sp_block_content
4205
+ BEGIN_SYM
4212
4206
{
4213
- LEX *lex= Lex;
4214
- lex->spcont ->pop_label ();
4207
+ Lex->name = empty_lex_str; // Unlabeled blocks get an empty label
4215
4208
}
4209
+ sp_block_content
4210
+ { }
4216
4211
;
4217
4212
4218
4213
sp_block_content:
4219
- BEGIN_SYM
4220
- { /* QQ This is just a dummy for grouping declarations and statements
4221
- together. No [[NOT] ATOMIC] yet, and we need to figure out how
4222
- make it coexist with the existing BEGIN COMMIT/ROLLBACK. */
4214
+ {
4223
4215
LEX *lex= Lex;
4216
+ sp_label *lab= lex->spcont ->push_label (thd, lex->name ,
4217
+ lex->sphead ->instructions ());
4218
+ lab->type = sp_label::BEGIN;
4224
4219
lex->spcont = lex->spcont ->push_context (thd,
4225
4220
sp_pcontext::REGULAR_SCOPE);
4226
4221
}
@@ -4234,21 +4229,22 @@ sp_block_content:
4234
4229
sp_instr *i;
4235
4230
4236
4231
sp->backpatch (ctx->last_label ()); /* We always have a label */
4237
- if ($3 .hndlrs )
4232
+ if ($2 .hndlrs )
4238
4233
{
4239
- i= new sp_instr_hpop (sp->instructions (), ctx, $3 .hndlrs );
4234
+ i= new sp_instr_hpop (sp->instructions (), ctx, $2 .hndlrs );
4240
4235
if (i == NULL ||
4241
4236
sp->add_instr (i))
4242
4237
MYSQL_YYABORT;
4243
4238
}
4244
- if ($3 .curs )
4239
+ if ($2 .curs )
4245
4240
{
4246
- i= new sp_instr_cpop (sp->instructions (), ctx, $3 .curs );
4241
+ i= new sp_instr_cpop (sp->instructions (), ctx, $2 .curs );
4247
4242
if (i == NULL ||
4248
4243
sp->add_instr (i))
4249
4244
MYSQL_YYABORT;
4250
4245
}
4251
4246
lex->spcont = ctx->pop_context ();
4247
+ $$ = lex->spcont ->pop_label ();
4252
4248
}
4253
4249
;
4254
4250
0 commit comments