mirror of
https://github.com/MariaDB/server.git
synced 2025-09-02 09:41:40 +03:00
Major rehacking and cleanup of sp_pcontext.
This finishes (almost) WL#2002: Implement stored procedure GOTO. Only the syntax issue for free labels remains ("label L;" vs "L:").
This commit is contained in:
@@ -68,6 +68,42 @@ 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;
|
||||
@@ -288,6 +324,16 @@ 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
|
||||
create procedure bug1965()
|
||||
begin
|
||||
declare c cursor for select val from t1 order by valname;
|
||||
|
@@ -1,4 +1,3 @@
|
||||
reset master;
|
||||
use test;
|
||||
drop table if exists t1;
|
||||
drop table if exists t2;
|
||||
@@ -398,7 +397,7 @@ id data
|
||||
i 3
|
||||
delete from t1|
|
||||
drop procedure i|
|
||||
create procedure j()
|
||||
create procedure goto1()
|
||||
begin
|
||||
declare y int;
|
||||
label a;
|
||||
@@ -411,7 +410,7 @@ insert into t1 values ("j", y);
|
||||
goto a;
|
||||
label b;
|
||||
end|
|
||||
call j()|
|
||||
call goto1()|
|
||||
id data
|
||||
id data
|
||||
j 0
|
||||
@@ -422,8 +421,8 @@ id data
|
||||
j 0
|
||||
j 1
|
||||
j 2
|
||||
drop procedure j|
|
||||
create procedure k(a int)
|
||||
drop procedure goto1|
|
||||
create procedure goto2(a int)
|
||||
begin
|
||||
declare x int default 0;
|
||||
declare continue handler for sqlstate '42S98' set x = 1;
|
||||
@@ -446,7 +445,7 @@ end;
|
||||
end while b;
|
||||
select * from t1;
|
||||
end|
|
||||
call k(0)|
|
||||
call goto2(0)|
|
||||
id data
|
||||
j 0
|
||||
j 1
|
||||
@@ -455,7 +454,7 @@ id data
|
||||
j 0
|
||||
j 1
|
||||
j 2
|
||||
call k(1)|
|
||||
call goto2(1)|
|
||||
id data
|
||||
j 0
|
||||
j 1
|
||||
@@ -464,7 +463,7 @@ id data
|
||||
j 0
|
||||
j 1
|
||||
j 2
|
||||
call k(2)|
|
||||
call goto2(2)|
|
||||
id data
|
||||
j 0
|
||||
j 1
|
||||
@@ -477,8 +476,60 @@ id data
|
||||
j 0
|
||||
j 1
|
||||
j 2
|
||||
drop procedure k|
|
||||
drop procedure goto2|
|
||||
delete from t1|
|
||||
create procedure goto3()
|
||||
begin
|
||||
label L1;
|
||||
begin
|
||||
end;
|
||||
goto L1;
|
||||
end|
|
||||
drop procedure goto3|
|
||||
create procedure goto4()
|
||||
begin
|
||||
begin
|
||||
label lab1;
|
||||
begin
|
||||
goto lab1;
|
||||
end;
|
||||
end;
|
||||
end|
|
||||
drop procedure goto4|
|
||||
create procedure goto5()
|
||||
begin
|
||||
begin
|
||||
begin
|
||||
goto lab1;
|
||||
end;
|
||||
label lab1;
|
||||
end;
|
||||
end|
|
||||
drop procedure goto5|
|
||||
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)|
|
||||
create procedure sel1()
|
||||
@@ -1536,11 +1587,8 @@ show errors;
|
||||
show columns from t1;
|
||||
show grants for 'root'@'localhost';
|
||||
show keys from t1;
|
||||
show master status;
|
||||
show open tables like 'foo';
|
||||
show privileges;
|
||||
show slave hosts;
|
||||
show slave status;
|
||||
show status like 'foo';
|
||||
show tables like 'foo';
|
||||
show variables like 'foo';
|
||||
@@ -1567,8 +1615,6 @@ data int(11) 0
|
||||
Grants for root@localhost
|
||||
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
File Position Binlog_Do_DB Binlog_Ignore_DB
|
||||
master-bin.000001 22451
|
||||
Database Table In_use Name_locked
|
||||
Privilege Context Comment
|
||||
Alter Tables To alter the table
|
||||
@@ -1594,8 +1640,6 @@ Shutdown Server Admin To shut down the server
|
||||
Super Server Admin To use KILL thread, SET GLOBAL, CHANGE MASTER, etc.
|
||||
Update Tables To update existing rows
|
||||
Usage Server Admin No privileges - allow connect only
|
||||
Server_id Host Port Rpl_recovery_rank Master_id
|
||||
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
|
||||
Variable_name Value
|
||||
Tables_in_test (foo) table_type
|
||||
Variable_name Value
|
||||
@@ -1621,8 +1665,6 @@ data int(11) 0
|
||||
Grants for root@localhost
|
||||
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
File Position Binlog_Do_DB Binlog_Ignore_DB
|
||||
master-bin.000001 22451
|
||||
Database Table In_use Name_locked
|
||||
Privilege Context Comment
|
||||
Alter Tables To alter the table
|
||||
@@ -1648,8 +1690,6 @@ Shutdown Server Admin To shut down the server
|
||||
Super Server Admin To use KILL thread, SET GLOBAL, CHANGE MASTER, etc.
|
||||
Update Tables To update existing rows
|
||||
Usage Server Admin No privileges - allow connect only
|
||||
Server_id Host Port Rpl_recovery_rank Master_id
|
||||
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
|
||||
Variable_name Value
|
||||
Tables_in_test (foo) table_type
|
||||
Variable_name Value
|
||||
|
@@ -103,6 +103,42 @@ create procedure foo()
|
||||
begin
|
||||
goto foo;
|
||||
end|
|
||||
--error 1307
|
||||
create procedure foo()
|
||||
begin
|
||||
begin
|
||||
label foo;
|
||||
end;
|
||||
goto foo;
|
||||
end|
|
||||
--error 1307
|
||||
create procedure foo()
|
||||
begin
|
||||
goto foo;
|
||||
begin
|
||||
label foo;
|
||||
end;
|
||||
end|
|
||||
--error 1307
|
||||
create procedure foo()
|
||||
begin
|
||||
begin
|
||||
goto foo;
|
||||
end;
|
||||
begin
|
||||
label foo;
|
||||
end;
|
||||
end|
|
||||
--error 1307
|
||||
create procedure foo()
|
||||
begin
|
||||
begin
|
||||
label foo;
|
||||
end;
|
||||
begin
|
||||
goto foo;
|
||||
end;
|
||||
end|
|
||||
|
||||
# Redefining label
|
||||
--error 1308
|
||||
@@ -380,6 +416,18 @@ begin
|
||||
declare c cursor for select * from t1;
|
||||
end|
|
||||
|
||||
--error 1357
|
||||
create procedure p()
|
||||
begin
|
||||
declare continue handler for sqlexception
|
||||
begin
|
||||
goto L1;
|
||||
end;
|
||||
|
||||
select field from t1;
|
||||
label L1;
|
||||
end|
|
||||
|
||||
#
|
||||
# BUG#1965
|
||||
#
|
||||
|
@@ -1,11 +1,9 @@
|
||||
#
|
||||
# Basic stored PROCEDURE tests
|
||||
#
|
||||
#
|
||||
|
||||
# Let us reset binary logs in order to make show master status
|
||||
# in test for bug 4902 repeatable.
|
||||
reset master;
|
||||
# Please keep this file free of --error cases and other
|
||||
# things that will not run in a single debugged mysqld
|
||||
# process (e.g. master-slave things).
|
||||
|
||||
use test;
|
||||
|
||||
@@ -470,10 +468,10 @@ drop procedure i|
|
||||
|
||||
# The non-standard GOTO, for compatibility
|
||||
#
|
||||
# QQQ The "label" syntax is temporary.
|
||||
# QQQ This is no nearly enough, more tests are needed
|
||||
# QQQ The "label" syntax is temporary, it will (hopefully)
|
||||
# change to the more common "L:" syntax soon.
|
||||
#
|
||||
create procedure j()
|
||||
create procedure goto1()
|
||||
begin
|
||||
declare y int;
|
||||
|
||||
@@ -488,12 +486,11 @@ label a;
|
||||
label b;
|
||||
end|
|
||||
|
||||
call j()|
|
||||
|
||||
drop procedure j|
|
||||
call goto1()|
|
||||
drop procedure goto1|
|
||||
|
||||
# With dummy handlers, just to test restore of contexts with jumps
|
||||
create procedure k(a int)
|
||||
create procedure goto2(a int)
|
||||
begin
|
||||
declare x int default 0;
|
||||
declare continue handler for sqlstate '42S98' set x = 1;
|
||||
@@ -520,13 +517,70 @@ b:
|
||||
select * from t1;
|
||||
end|
|
||||
|
||||
call k(0)|
|
||||
call k(1)|
|
||||
call k(2)|
|
||||
call goto2(0)|
|
||||
call goto2(1)|
|
||||
call goto2(2)|
|
||||
|
||||
drop procedure k|
|
||||
drop procedure goto2|
|
||||
delete from t1|
|
||||
|
||||
# Check label visibility for some more cases. We don't call these.
|
||||
create procedure goto3()
|
||||
begin
|
||||
label L1;
|
||||
begin
|
||||
end;
|
||||
goto L1;
|
||||
end|
|
||||
drop procedure goto3|
|
||||
|
||||
create procedure goto4()
|
||||
begin
|
||||
begin
|
||||
label lab1;
|
||||
begin
|
||||
goto lab1;
|
||||
end;
|
||||
end;
|
||||
end|
|
||||
drop procedure goto4|
|
||||
|
||||
create procedure goto5()
|
||||
begin
|
||||
begin
|
||||
begin
|
||||
goto lab1;
|
||||
end;
|
||||
label lab1;
|
||||
end;
|
||||
end|
|
||||
drop procedure goto5|
|
||||
|
||||
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)|
|
||||
@@ -1761,11 +1815,8 @@ begin
|
||||
show columns from t1;
|
||||
show grants for 'root'@'localhost';
|
||||
show keys from t1;
|
||||
show master status;
|
||||
show open tables like 'foo';
|
||||
show privileges;
|
||||
show slave hosts;
|
||||
show slave status;
|
||||
show status like 'foo';
|
||||
show tables like 'foo';
|
||||
show variables like 'foo';
|
||||
@@ -1773,6 +1824,9 @@ begin
|
||||
end|
|
||||
#show binlog events;
|
||||
#show storage engines;
|
||||
#show master status;
|
||||
#show slave hosts;
|
||||
#show slave status;
|
||||
|
||||
call bug4902()|
|
||||
call bug4902()|
|
||||
|
Reference in New Issue
Block a user