diff options
author | unknown <pem@mysql.com> | 2006-04-18 11:07:34 +0200 |
---|---|---|
committer | unknown <pem@mysql.com> | 2006-04-18 11:07:34 +0200 |
commit | 661165ee1002751c9f58fe71aa629dac7f5f7d90 (patch) | |
tree | 2a15be5d9efaec8002a29111e29209f9a5111925 | |
parent | aadfa648b3e568667198d349e93f44d82873cc01 (diff) | |
download | mariadb-git-661165ee1002751c9f58fe71aa629dac7f5f7d90.tar.gz |
Fixed BUG#18949: Test case sp-goto is disabled
Removed sp-goto.test, sp-goto.result and all (disabled) GOTO code.
Also removed some related code that's not needed any more (no possible
unresolved label references any more, so no need to check for them).
NB: Keeping the ER_SP_GOTO_IN_HNDLR in errmsg.txt; it might become useful
in the future, and removing it (and thus re-enumerating error codes)
might upset things. (Anything referring to explicit error codes.)
BitKeeper/deleted/.del-sp-goto.result~f343103c63f64b7a:
Delete: mysql-test/r/sp-goto.result
BitKeeper/deleted/.del-sp-goto.test~5054d3f729692d3d:
Delete: mysql-test/t/sp-goto.test
mysql-test/t/disabled.def:
sp-goto.test no longer exists.
sql/lex.h:
Removed (disabled) GOTO definitions.
sql/sp_head.cc:
Removed sp_head::check_backpatch() and simplified sp_head::backpatch().
Without GOTO, unresolved label references are not possible, so no need
to check for them.
sql/sp_head.h:
Removed sp_head::check_backpatch(). (Not needed with no GOTO)
sql/sp_pcontext.cc:
SP_LAB_GOTO was renamed to SP_LAB_IMPL
sql/sp_pcontext.h:
Removed SP_LAB_REF (no longer needed) and renamed SP_LAB_GOTO
to SP_LAB_IMPL, since it's only used for implicit labels now.
sql/sql_yacc.yy:
Removed GOTO symbols and (disabled) code, and the no longer needed
sp_head::check_backpatch() calls.
-rw-r--r-- | mysql-test/r/sp-goto.result | 205 | ||||
-rw-r--r-- | mysql-test/t/disabled.def | 1 | ||||
-rw-r--r-- | mysql-test/t/sp-goto.test | 238 | ||||
-rw-r--r-- | sql/lex.h | 7 | ||||
-rw-r--r-- | sql/sp_head.cc | 37 | ||||
-rw-r--r-- | sql/sp_head.h | 7 | ||||
-rw-r--r-- | sql/sp_pcontext.cc | 2 | ||||
-rw-r--r-- | sql/sp_pcontext.h | 7 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 90 |
9 files changed, 6 insertions, 588 deletions
diff --git a/mysql-test/r/sp-goto.result b/mysql-test/r/sp-goto.result deleted file mode 100644 index ca560f62318..00000000000 --- a/mysql-test/r/sp-goto.result +++ /dev/null @@ -1,205 +0,0 @@ -drop table if exists t1; -create table t1 ( -id char(16) not null default '', -data int not null -); -drop procedure if exists goto1// -create procedure goto1() -begin -declare y int; -label a; -select * from t1; -select count(*) into y from t1; -if y > 2 then -goto b; -end if; -insert into t1 values ("j", y); -goto a; -label b; -end// -call goto1()// -id data -id data -j 0 -id data -j 0 -j 1 -id data -j 0 -j 1 -j 2 -drop procedure goto1// -drop procedure if exists goto2// -create procedure goto2(a int) -begin -declare x int default 0; -declare continue handler for sqlstate '42S98' set x = 1; -label a; -select * from t1; -b: -while x < 2 do -begin -declare continue handler for sqlstate '42S99' set x = 2; -if a = 0 then -set x = x + 1; -iterate b; -elseif a = 1 then -leave b; -elseif a = 2 then -set a = 1; -goto a; -end if; -end; -end while b; -select * from t1; -end// -call goto2(0)// -id data -j 0 -j 1 -j 2 -id data -j 0 -j 1 -j 2 -call goto2(1)// -id data -j 0 -j 1 -j 2 -id data -j 0 -j 1 -j 2 -call goto2(2)// -id data -j 0 -j 1 -j 2 -id data -j 0 -j 1 -j 2 -id data -j 0 -j 1 -j 2 -drop procedure goto2// -delete from t1// -drop procedure if exists goto3// -create procedure goto3() -begin -label L1; -begin -end; -goto L1; -end// -drop procedure goto3// -drop procedure if exists goto4// -create procedure goto4() -begin -begin -label lab1; -begin -goto lab1; -end; -end; -end// -drop procedure goto4// -drop procedure if exists goto5// -create procedure goto5() -begin -begin -begin -goto lab1; -end; -label lab1; -end; -end// -drop procedure goto5// -drop procedure if exists goto6// -create procedure goto6() -begin -label L1; -goto L5; -begin -label L2; -goto L1; -goto L5; -begin -label L3; -goto L1; -goto L2; -goto L3; -goto L4; -goto L5; -end; -goto L2; -goto L4; -label L4; -end; -label L5; -goto L1; -end// -drop procedure goto6// -create procedure foo() -begin -goto foo; -end// -ERROR 42000: GOTO with no matching label: foo -create procedure foo() -begin -begin -label foo; -end; -goto foo; -end// -ERROR 42000: GOTO with no matching label: foo -create procedure foo() -begin -goto foo; -begin -label foo; -end; -end// -ERROR 42000: GOTO with no matching label: foo -create procedure foo() -begin -begin -goto foo; -end; -begin -label foo; -end; -end// -ERROR 42000: GOTO with no matching label: foo -create procedure foo() -begin -begin -label foo; -end; -begin -goto foo; -end; -end// -ERROR 42000: GOTO with no matching label: foo -create procedure p() -begin -declare continue handler for sqlexception -begin -goto L1; -end; -select field from t1; -label L1; -end// -ERROR HY000: GOTO is not allowed in a stored procedure handler -drop procedure if exists bug6898// -create procedure bug6898() -begin -goto label1; -label label1; -begin end; -goto label1; -end// -drop procedure bug6898// -drop table t1; diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index a836b1a2897..37ba97851aa 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -10,6 +10,5 @@ # ############################################################################## -sp-goto : GOTO is currently is disabled - will be fixed in the future ndb_load : Bug#17233 udf : Bug#18564 (Permission by Brian) diff --git a/mysql-test/t/sp-goto.test b/mysql-test/t/sp-goto.test deleted file mode 100644 index e770dd285ff..00000000000 --- a/mysql-test/t/sp-goto.test +++ /dev/null @@ -1,238 +0,0 @@ -# -# The non-standard GOTO, for compatibility -# -# QQQ The "label" syntax is temporary, it will (hopefully) -# change to the more common "L:" syntax soon. -# For the time being, this feature is disabled, until -# the syntax (and some other known bugs) can be fixed. -# -# Test cases for bugs are added at the end. See template there. -# - ---disable_warnings -drop table if exists t1; ---enable_warnings -create table t1 ( - id char(16) not null default '', - data int not null -); - -delimiter //; - ---disable_warnings -drop procedure if exists goto1// ---enable_warnings -create procedure goto1() -begin - declare y int; - -label a; - select * from t1; - select count(*) into y from t1; - if y > 2 then - goto b; - end if; - insert into t1 values ("j", y); - goto a; -label b; -end// - -call goto1()// -drop procedure goto1// - -# With dummy handlers, just to test restore of contexts with jumps ---disable_warnings -drop procedure if exists goto2// ---enable_warnings -create procedure goto2(a int) -begin - declare x int default 0; - declare continue handler for sqlstate '42S98' set x = 1; - -label a; - select * from t1; -b: - while x < 2 do - begin - declare continue handler for sqlstate '42S99' set x = 2; - - if a = 0 then - set x = x + 1; - iterate b; - elseif a = 1 then - leave b; - elseif a = 2 then - set a = 1; - goto a; - end if; - end; - end while b; - - select * from t1; -end// - -call goto2(0)// -call goto2(1)// -call goto2(2)// - -drop procedure goto2// -delete from t1// - -# Check label visibility for some more cases. We don't call these. ---disable_warnings -drop procedure if exists goto3// ---enable_warnings -create procedure goto3() -begin - label L1; - begin - end; - goto L1; -end// -drop procedure goto3// - ---disable_warnings -drop procedure if exists goto4// ---enable_warnings -create procedure goto4() -begin - begin - label lab1; - begin - goto lab1; - end; - end; -end// -drop procedure goto4// - ---disable_warnings -drop procedure if exists goto5// ---enable_warnings -create procedure goto5() -begin - begin - begin - goto lab1; - end; - label lab1; - end; -end// -drop procedure goto5// - ---disable_warnings -drop procedure if exists goto6// ---enable_warnings -create procedure goto6() -begin - label L1; - goto L5; - begin - label L2; - goto L1; - goto L5; - begin - label L3; - goto L1; - goto L2; - goto L3; - goto L4; - goto L5; - end; - goto L2; - goto L4; - label L4; - end; - label L5; - goto L1; -end// -drop procedure goto6// - -# Mismatching labels ---error 1308 -create procedure foo() -begin - goto foo; -end// ---error 1308 -create procedure foo() -begin - begin - label foo; - end; - goto foo; -end// ---error 1308 -create procedure foo() -begin - goto foo; - begin - label foo; - end; -end// ---error 1308 -create procedure foo() -begin - begin - goto foo; - end; - begin - label foo; - end; -end// ---error 1308 -create procedure foo() -begin - begin - label foo; - end; - begin - goto foo; - end; -end// - -# No goto in a handler ---error 1358 -create procedure p() -begin - declare continue handler for sqlexception - begin - goto L1; - end; - - select field from t1; - label L1; -end// - - -# -# Test cases for old bugs -# - -# -# BUG#6898: Stored procedure crash if GOTO statements exist -# ---disable_warnings -drop procedure if exists bug6898// ---enable_warnings -create procedure bug6898() -begin - goto label1; - label label1; - begin end; - goto label1; -end// -drop procedure bug6898// - -# -# BUG#NNNN: New bug synopsis -# -#--disable_warnings -#drop procedure if exists bugNNNN// -#--enable_warnings -#create procedure bugNNNN... - - -# Add bugs above this line. Use existing tables t1 and t2 when -# practical, or create table t3, t4 etc temporarily (and drop them). -delimiter ;// -drop table t1; diff --git a/sql/lex.h b/sql/lex.h index 1acfbaac211..68f34d8de93 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -215,9 +215,6 @@ static SYMBOL symbols[] = { { "GEOMETRYCOLLECTION",SYM(GEOMETRYCOLLECTION)}, { "GET_FORMAT", SYM(GET_FORMAT)}, { "GLOBAL", SYM(GLOBAL_SYM)}, -#ifdef SP_GOTO - { "GOTO", SYM(GOTO_SYM)}, -#endif { "GRANT", SYM(GRANT)}, { "GRANTS", SYM(GRANTS)}, { "GROUP", SYM(GROUP)}, @@ -265,10 +262,6 @@ static SYMBOL symbols[] = { { "KEY", SYM(KEY_SYM)}, { "KEYS", SYM(KEYS)}, { "KILL", SYM(KILL_SYM)}, -#ifdef SP_GOTO - /* QQ This will go away when the GOTO label syntax is fixed */ - { "LABEL", SYM(LABEL_SYM)}, -#endif { "LANGUAGE", SYM(LANGUAGE_SYM)}, { "LAST", SYM(LAST_SYM)}, { "LEADING", SYM(LEADING)}, diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 15d621b1d6d..6b7cdb1ea98 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -1670,44 +1670,11 @@ sp_head::backpatch(sp_label_t *lab) while ((bp= li++)) { - if (bp->lab == lab || - (bp->lab->type == SP_LAB_REF && - my_strcasecmp(system_charset_info, bp->lab->name, lab->name) == 0)) - { - if (bp->lab->type != SP_LAB_REF) - bp->instr->backpatch(dest, lab->ctx); - else - { - sp_label_t *dstlab= bp->lab->ctx->find_label(lab->name); - - if (dstlab) - { - bp->lab= lab; - bp->instr->backpatch(dest, dstlab->ctx); - } - } - } - } -} - -int -sp_head::check_backpatch(THD *thd) -{ - bp_t *bp; - List_iterator_fast<bp_t> li(m_backpatch); - - while ((bp= li++)) - { - if (bp->lab->type == SP_LAB_REF) - { - my_error(ER_SP_LILABEL_MISMATCH, MYF(0), "GOTO", bp->lab->name); - return -1; - } + if (bp->lab == lab) + bp->instr->backpatch(dest, lab->ctx); } - return 0; } - /* Prepare an instance of create_field for field creation (fill all necessary attributes). diff --git a/sql/sp_head.h b/sql/sp_head.h index 17a5d1ae528..3ad81542ce7 100644 --- a/sql/sp_head.h +++ b/sql/sp_head.h @@ -263,13 +263,6 @@ public: void backpatch(struct sp_label *); - // Check that no unresolved references exist. - // If none found, 0 is returned, otherwise errors have been issued - // and -1 is returned. - // This is called by the parser at the end of a create procedure/function. - int - check_backpatch(THD *thd); - // Start a new cont. backpatch level. If 'i' is NULL, the level is just incr. void new_cont_backpatch(sp_instr_opt_meta *i); diff --git a/sql/sp_pcontext.cc b/sql/sp_pcontext.cc index 448df908a32..b0b65d5313b 100644 --- a/sql/sp_pcontext.cc +++ b/sql/sp_pcontext.cc @@ -241,7 +241,7 @@ sp_pcontext::push_label(char *name, uint ip) { lab->name= name; lab->ip= ip; - lab->type= SP_LAB_GOTO; + lab->type= SP_LAB_IMPL; lab->ctx= this; m_label.push_front(lab); } diff --git a/sql/sp_pcontext.h b/sql/sp_pcontext.h index e61057537da..2ee77696efb 100644 --- a/sql/sp_pcontext.h +++ b/sql/sp_pcontext.h @@ -48,10 +48,9 @@ typedef struct sp_variable } sp_variable_t; -#define SP_LAB_REF 0 // Unresolved reference (for goto) -#define SP_LAB_GOTO 1 // Free goto label -#define SP_LAB_BEGIN 2 // Label at BEGIN -#define SP_LAB_ITER 3 // Label at iteration control +#define SP_LAB_IMPL 0 // Implicit label generated by parser +#define SP_LAB_BEGIN 1 // Label at BEGIN +#define SP_LAB_ITER 2 // Label at iteration control /* An SQL/PSM label. Can refer to the identifier used with the diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 37f72c351e5..0681ac31923 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -301,7 +301,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token GEOMFROMWKB %token GET_FORMAT %token GLOBAL_SYM -%token GOTO_SYM %token GRANT %token GRANTS %token GREATEST_SYM @@ -1332,8 +1331,6 @@ create_function_tail: if (sp->is_not_allowed_in_function("function")) YYABORT; - if (sp->check_backpatch(YYTHD)) - YYABORT; lex->sql_command= SQLCOM_CREATE_SPFUNCTION; sp->init_strings(YYTHD, lex, lex->spname); if (!(sp->m_flags & sp_head::HAS_RETURN)) @@ -2054,91 +2051,6 @@ sp_proc_stmt: sp->add_instr(i); } } - | LABEL_SYM IDENT - { -#ifdef SP_GOTO - LEX *lex= Lex; - sp_head *sp= lex->sphead; - sp_pcontext *ctx= lex->spcont; - sp_label_t *lab= ctx->find_label($2.str); - - if (lab) - { - my_error(ER_SP_LABEL_REDEFINE, MYF(0), $2.str); - YYABORT; - } - else - { - lab= ctx->push_label($2.str, sp->instructions()); - lab->type= SP_LAB_GOTO; - lab->ctx= ctx; - sp->backpatch(lab); - } -#else - yyerror(ER(ER_SYNTAX_ERROR)); - YYABORT; -#endif - } - | GOTO_SYM IDENT - { -#ifdef SP_GOTO - LEX *lex= Lex; - sp_head *sp= lex->sphead; - sp_pcontext *ctx= lex->spcont; - uint ip= lex->sphead->instructions(); - sp_label_t *lab; - sp_instr_jump *i; - sp_instr_hpop *ih; - sp_instr_cpop *ic; - - if (sp->m_in_handler) - { - my_message(ER_SP_GOTO_IN_HNDLR, ER(ER_SP_GOTO_IN_HNDLR), MYF(0)); - YYABORT; - } - lab= ctx->find_label($2.str); - if (! lab) - { - lab= (sp_label_t *)YYTHD->alloc(sizeof(sp_label_t)); - lab->name= $2.str; - lab->ip= 0; - lab->type= SP_LAB_REF; - lab->ctx= ctx; - - ih= new sp_instr_hpop(ip++, ctx, 0); - sp->push_backpatch(ih, lab); - sp->add_instr(ih); - ic= new sp_instr_cpop(ip++, ctx, 0); - sp->add_instr(ic); - sp->push_backpatch(ic, lab); - i= new sp_instr_jump(ip, ctx); - sp->push_backpatch(i, lab); /* Jumping forward */ - sp->add_instr(i); - } - else - { - uint n; - - n= ctx->diff_handlers(lab->ctx); - if (n) - { - ih= new sp_instr_hpop(ip++, ctx, n); - sp->add_instr(ih); - } - n= ctx->diff_cursors(lab->ctx); - if (n) - { - ic= new sp_instr_cpop(ip++, ctx, n); - sp->add_instr(ic); - } - i= new sp_instr_jump(ip, ctx, lab->ip); /* Jump back */ - sp->add_instr(i); - } -#else - yyerror(ER(ER_SYNTAX_ERROR)); - YYABORT; -#endif - } | OPEN_SYM ident { LEX *lex= Lex; @@ -9228,8 +9140,6 @@ sp_tail: LEX *lex= Lex; sp_head *sp= lex->sphead; - if (sp->check_backpatch(YYTHD)) - YYABORT; sp->init_strings(YYTHD, lex, $3); lex->sql_command= SQLCOM_CREATE_PROCEDURE; /* Restore flag if it was cleared above */ |