summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <pem@mysql.com>2005-07-01 15:25:51 +0200
committerunknown <pem@mysql.com>2005-07-01 15:25:51 +0200
commit1ff4a0ebf17959d242b7822ecc0438b7078a4acd (patch)
tree2b81457b3223f96449285b78748c31bb3a0fd9c6
parent6c8d397588722dece2803370409d4776d5ffb461 (diff)
downloadmariadb-git-1ff4a0ebf17959d242b7822ecc0438b7078a4acd.tar.gz
Disabled the GOTO feature. (It's non-standard and undocumented.)
We want to have the defacto standard syntax for labels ("L:" instead of "label L;"), and fix some known bugs, before we enable this again. The code is left intact (#ifdef'ed SP_GOTO) and the test cases are kept in sp-goto.test, for the future... mysql-test/r/sp-error.result: Moved all goto tests to sp-goto.test. mysql-test/r/sp.result: Moved all goto tests to sp-goto.test. mysql-test/t/disabled.def: Disabled GOTO/LABEL (until the label syntax and some bugs can be fixed). We keep the tests in sp-goto.test for the future, but disable for now. mysql-test/t/sp-error.test: Moved all goto tests to sp-goto.test. mysql-test/t/sp.test: Moved all goto tests to sp-goto.test. sql/lex.h: Disabled GOTO/LABEL (until the label syntax and some bugs can be fixed). sql/sql_yacc.yy: Disabled GOTO/LABEL (until the label syntax and some bugs can be fixed).
-rw-r--r--mysql-test/r/sp-error.result51
-rw-r--r--mysql-test/r/sp-goto.result205
-rw-r--r--mysql-test/r/sp.result148
-rw-r--r--mysql-test/t/disabled.def1
-rw-r--r--mysql-test/t/sp-error.test55
-rw-r--r--mysql-test/t/sp-goto.test238
-rw-r--r--mysql-test/t/sp.test150
-rw-r--r--sql/lex.h5
-rw-r--r--sql/sql_yacc.yy11
9 files changed, 461 insertions, 403 deletions
diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result
index b6ba737a8ba..bfbfb87ac43 100644
--- a/mysql-test/r/sp-error.result
+++ b/mysql-test/r/sp-error.result
@@ -65,47 +65,6 @@ iterate foo;
end|
ERROR 42000: ITERATE with no matching label: foo
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 foo()
foo: loop
foo: loop
set @x=2;
@@ -308,16 +267,6 @@ declare continue handler for sqlstate '42S99' set x = 1;
declare c cursor for select * from t1;
end|
ERROR 42000: Cursor declaration after handler declaration
-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 p|
create procedure p(in x int, inout y int, out z int)
begin
diff --git a/mysql-test/r/sp-goto.result b/mysql-test/r/sp-goto.result
new file mode 100644
index 00000000000..ca560f62318
--- /dev/null
+++ b/mysql-test/r/sp-goto.result
@@ -0,0 +1,205 @@
+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/r/sp.result b/mysql-test/r/sp.result
index 69ae64475d2..7b99a3bacd0 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -438,145 +438,6 @@ id data
i 3
delete from t1|
drop procedure i|
-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|
insert into t1 values ("foo", 3), ("bar", 19)|
insert into t2 values ("x", 9, 4.1), ("y", -1, 19.2), ("z", 3, 2.2)|
drop procedure if exists sel1|
@@ -2971,15 +2832,6 @@ select @x|
set global query_cache_size = @qcs1|
delete from t1|
drop function bug9902|
-drop procedure if exists bug6898|
-create procedure bug6898()
-begin
-goto label1;
-label label1;
-begin end;
-goto label1;
-end|
-drop procedure bug6898|
drop function if exists bug9102|
create function bug9102() returns blob return 'a'|
select bug9102()|
diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def
index 9bfe9567d83..c5f96ec4201 100644
--- a/mysql-test/t/disabled.def
+++ b/mysql-test/t/disabled.def
@@ -10,3 +10,4 @@
#
##############################################################################
+sp-goto:GOTO is currently is disabled - will be fixed in the future
diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test
index faf6d8b4de3..f5a9e53e710 100644
--- a/mysql-test/t/sp-error.test
+++ b/mysql-test/t/sp-error.test
@@ -84,7 +84,7 @@ show create procedure foo|
--error 1305
show create function foo|
-# LEAVE/ITERATE/GOTO with no match
+# LEAVE/ITERATE with no match
--error 1308
create procedure foo()
foo: loop
@@ -100,47 +100,6 @@ create procedure foo()
foo: begin
iterate foo;
end|
---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|
# Redefining label
--error 1309
@@ -398,18 +357,6 @@ begin
declare c cursor for select * from t1;
end|
---error 1358
-create procedure p()
-begin
- declare continue handler for sqlexception
- begin
- goto L1;
- end;
-
- select field from t1;
- label L1;
-end|
-
# Check in and inout arguments.
--disable_warnings
drop procedure if exists p|
diff --git a/mysql-test/t/sp-goto.test b/mysql-test/t/sp-goto.test
new file mode 100644
index 00000000000..e770dd285ff
--- /dev/null
+++ b/mysql-test/t/sp-goto.test
@@ -0,0 +1,238 @@
+#
+# 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/mysql-test/t/sp.test b/mysql-test/t/sp.test
index 314ed58b5a9..7455bc139dc 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -12,6 +12,7 @@
# Tests that check privilege and security issues go to sp-security.test.
# Tests that require multiple connections, except security/privilege tests,
# go to sp-thread.
+# Tests that uses 'goto' to into sp-goto.test (currently disabled)
use test;
@@ -585,139 +586,6 @@ delete from t1|
drop procedure i|
-# The non-standard GOTO, for compatibility
-#
-# QQQ The "label" syntax is temporary, it will (hopefully)
-# change to the more common "L:" syntax soon.
-#
---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|
-
# SELECT with one of more result set sent back to the clinet
insert into t1 values ("foo", 3), ("bar", 19)|
insert into t2 values ("x", 9, 4.1), ("y", -1, 19.2), ("z", 3, 2.2)|
@@ -3635,22 +3503,6 @@ drop function bug9902|
#
-# 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#9102: Stored proccedures: function which returns blob causes crash
#
--disable_warnings
diff --git a/sql/lex.h b/sql/lex.h
index d0dc287775e..aa10328ced0 100644
--- a/sql/lex.h
+++ b/sql/lex.h
@@ -214,7 +214,9 @@ 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)},
@@ -262,7 +264,10 @@ 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/sql_yacc.yy b/sql/sql_yacc.yy
index 7a789cba035..b1438f1c571 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -2113,6 +2113,7 @@ sp_proc_stmt:
}
| LABEL_SYM IDENT
{
+#ifdef SP_GOTO
LEX *lex= Lex;
sp_head *sp= lex->sphead;
sp_pcontext *ctx= lex->spcont;
@@ -2130,9 +2131,14 @@ sp_proc_stmt:
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;
@@ -2185,6 +2191,10 @@ sp_proc_stmt:
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
{
@@ -7437,7 +7447,6 @@ keyword:
| INNOBASE_SYM {}
| INSERT_METHOD {}
| RELAY_THREAD {}
- | LABEL_SYM {}
| LANGUAGE_SYM {}
| LAST_SYM {}
| LEAVES {}