mirror of
				https://github.com/MariaDB/server.git
				synced 2025-11-03 14:33:32 +03:00 
			
		
		
		
	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).
		
	
		
			
				
	
	
		
			206 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			206 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
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;
 |