List:Commits« Previous MessageNext Message »
From:marc.alff Date:May 8 2008 2:50am
Subject:bk commit into 6.0 tree (malff:1.2641) WL#2110
View as plain text  
Below is the list of changes that have just been committed into a local
6.0 repository of malff.  When malff does a push these changes
will be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2008-05-07 20:50:46-06:00, malff@stripped. +11 -0
  WL#2110 (Stored Procedures: Implement SIGNAL)
  WL#2265 (Stored Procedures: Implement RESIGNAL)
  WL#2111 (Stored Procedures: Implement GET DIAGNOSTICS)
  
  RESIGNAL runtime

  mysql-test/r/signal.result@stripped, 2008-05-07 20:50:41-06:00, malff@stripped. +717 -3
    SIGNAL / RESIGNAL / GET DIAGNOSTICS

  mysql-test/t/signal.test@stripped, 2008-05-07 20:50:41-06:00, malff@stripped. +715 -3
    SIGNAL / RESIGNAL / GET DIAGNOSTICS

  sql/item.cc@stripped, 2008-05-07 20:50:41-06:00, malff@stripped. +6 -6
    SIGNAL / RESIGNAL / GET DIAGNOSTICS

  sql/sp_head.cc@stripped, 2008-05-07 20:50:41-06:00, malff@stripped. +4 -18
    SIGNAL / RESIGNAL / GET DIAGNOSTICS

  sql/sp_head.h@stripped, 2008-05-07 20:50:41-06:00, malff@stripped. +2 -1
    SIGNAL / RESIGNAL / GET DIAGNOSTICS

  sql/sp_rcontext.cc@stripped, 2008-05-07 20:50:41-06:00, malff@stripped. +38 -2
    SIGNAL / RESIGNAL / GET DIAGNOSTICS

  sql/sp_rcontext.h@stripped, 2008-05-07 20:50:41-06:00, malff@stripped. +9 -9
    SIGNAL / RESIGNAL / GET DIAGNOSTICS

  sql/sql_class.cc@stripped, 2008-05-07 20:50:42-06:00, malff@stripped. +11 -2
    SIGNAL / RESIGNAL / GET DIAGNOSTICS

  sql/sql_class.h@stripped, 2008-05-07 20:50:42-06:00, malff@stripped. +7 -1
    SIGNAL / RESIGNAL / GET DIAGNOSTICS

  sql/sql_signal.cc@stripped, 2008-05-07 20:50:42-06:00, malff@stripped. +119 -34
    SIGNAL / RESIGNAL / GET DIAGNOSTICS

  sql/sql_signal.h@stripped, 2008-05-07 20:50:42-06:00, malff@stripped. +2 -0
    SIGNAL / RESIGNAL / GET DIAGNOSTICS

diff -Nrup a/mysql-test/r/signal.result b/mysql-test/r/signal.result
--- a/mysql-test/r/signal.result	2008-05-06 17:05:32 -06:00
+++ b/mysql-test/r/signal.result	2008-05-07 20:50:41 -06:00
@@ -347,72 +347,132 @@ end $$
 drop procedure test_resignal_syntax $$
 create procedure test_resignal_syntax()
 begin
+RESIGNAL SET CLASS_ORIGIN = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+create procedure test_resignal_syntax()
+begin
 DECLARE foo CONDITION FOR 1234;
 RESIGNAL foo SET CLASS_ORIGIN = 'foo';
 end $$
 drop procedure test_resignal_syntax $$
 create procedure test_resignal_syntax()
 begin
+RESIGNAL SET SUBCLASS_ORIGIN = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+create procedure test_resignal_syntax()
+begin
 DECLARE foo CONDITION FOR 1234;
 RESIGNAL foo SET SUBCLASS_ORIGIN = 'foo';
 end $$
 drop procedure test_resignal_syntax $$
 create procedure test_resignal_syntax()
 begin
+RESIGNAL SET CONSTRAINT_CATALOG = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+create procedure test_resignal_syntax()
+begin
 DECLARE foo CONDITION FOR 1234;
 RESIGNAL foo SET CONSTRAINT_CATALOG = 'foo';
 end $$
 drop procedure test_resignal_syntax $$
 create procedure test_resignal_syntax()
 begin
+RESIGNAL SET CONSTRAINT_SCHEMA = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+create procedure test_resignal_syntax()
+begin
 DECLARE foo CONDITION FOR 1234;
 RESIGNAL foo SET CONSTRAINT_SCHEMA = 'foo';
 end $$
 drop procedure test_resignal_syntax $$
 create procedure test_resignal_syntax()
 begin
+RESIGNAL SET CONSTRAINT_NAME = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+create procedure test_resignal_syntax()
+begin
 DECLARE foo CONDITION FOR 1234;
 RESIGNAL foo SET CONSTRAINT_NAME = 'foo';
 end $$
 drop procedure test_resignal_syntax $$
 create procedure test_resignal_syntax()
 begin
+RESIGNAL SET CATALOG_NAME = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+create procedure test_resignal_syntax()
+begin
 DECLARE foo CONDITION FOR 1234;
 RESIGNAL foo SET CATALOG_NAME = 'foo';
 end $$
 drop procedure test_resignal_syntax $$
 create procedure test_resignal_syntax()
 begin
+RESIGNAL SET SCHEMA_NAME = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+create procedure test_resignal_syntax()
+begin
 DECLARE foo CONDITION FOR 1234;
 RESIGNAL foo SET SCHEMA_NAME = 'foo';
 end $$
 drop procedure test_resignal_syntax $$
 create procedure test_resignal_syntax()
 begin
+RESIGNAL SET TABLE_NAME = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+create procedure test_resignal_syntax()
+begin
 DECLARE foo CONDITION FOR 1234;
 RESIGNAL foo SET TABLE_NAME = 'foo';
 end $$
 drop procedure test_resignal_syntax $$
 create procedure test_resignal_syntax()
 begin
+RESIGNAL SET COLUMN_NAME = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+create procedure test_resignal_syntax()
+begin
 DECLARE foo CONDITION FOR 1234;
 RESIGNAL foo SET COLUMN_NAME = 'foo';
 end $$
 drop procedure test_resignal_syntax $$
 create procedure test_resignal_syntax()
 begin
+RESIGNAL SET CURSOR_NAME = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+create procedure test_resignal_syntax()
+begin
 DECLARE foo CONDITION FOR 1234;
 RESIGNAL foo SET CURSOR_NAME = 'foo';
 end $$
 drop procedure test_resignal_syntax $$
 create procedure test_resignal_syntax()
 begin
+RESIGNAL SET MESSAGE_TEXT = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+create procedure test_resignal_syntax()
+begin
 DECLARE foo CONDITION FOR 1234;
 RESIGNAL foo SET MESSAGE_TEXT = 'foo';
 end $$
 drop procedure test_resignal_syntax $$
 create procedure test_resignal_syntax()
 begin
+RESIGNAL SET SQLCODE = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+create procedure test_resignal_syntax()
+begin
 DECLARE foo CONDITION FOR 1234;
 RESIGNAL foo SET SQLCODE = 'foo';
 end $$
@@ -1107,6 +1167,11 @@ ERROR HY000: This command is not support
 prepare stmt from 'GET DIAGNOSTICS @foo = NUMBER';
 ERROR HY000: This command is not supported in the prepared statement protocol yet
 drop procedure if exists test_signal;
+drop procedure if exists test_resignal;
+drop table if exists t_warn;
+drop table if exists t_cursor;
+create table t_warn(a integer(2));
+create table t_cursor(a integer);
 SIGNAL foo;
 ERROR 42000: Undefined CONDITION: foo
 SIGNAL SQLSTATE '01000';
@@ -1131,13 +1196,13 @@ ERROR 42000: Variable 'SQLCODE' can't be
 SIGNAL SQLSTATE 'HY000' SET SQLCODE = 65535;
 ERROR HY000: Unhandled user-defined exception
 RESIGNAL;
-ERROR 42000: This version of MySQL doesn't yet support 'RESIGNAL'
+ERROR 0K000: RESIGNAL when handler not active
 RESIGNAL foo;
 ERROR 42000: Undefined CONDITION: foo
 RESIGNAL SQLSTATE '12345';
-ERROR 42000: This version of MySQL doesn't yet support 'RESIGNAL'
+ERROR 0K000: RESIGNAL when handler not active
 RESIGNAL SQLSTATE VALUE '12345';
-ERROR 42000: This version of MySQL doesn't yet support 'RESIGNAL'
+ERROR 0K000: RESIGNAL when handler not active
 GET DIAGNOSTICS @foo = NUMBER;
 ERROR 42000: This version of MySQL doesn't yet support 'GET DIAGNOSTICS'
 GET CURRENT DIAGNOSTICS @foo = NUMBER;
@@ -1813,3 +1878,652 @@ caught cursor is not open
 drop table t1 $$
 drop procedure p1 $$
 drop function f1 $$
+create procedure test_resignal()
+begin
+DECLARE warn CONDITION FOR SQLSTATE "01234";
+DECLARE CONTINUE HANDLER for 1012
+begin
+select "before RESIGNAL";
+RESIGNAL;
+select "after RESIGNAL";
+end;
+SIGNAL warn SET
+MESSAGE_TEXT = "Raising a warning",
+SQLCODE = 1012;
+end $$
+call test_resignal() $$
+before RESIGNAL
+before RESIGNAL
+after RESIGNAL
+after RESIGNAL
+Warnings:
+Warning	1012	Raising a warning
+drop procedure test_resignal $$
+create procedure test_resignal()
+begin
+DECLARE not_found CONDITION FOR SQLSTATE "02222";
+DECLARE CONTINUE HANDLER for 1012
+begin
+select "before RESIGNAL";
+RESIGNAL;
+select "after RESIGNAL";
+end;
+SIGNAL not_found SET
+MESSAGE_TEXT = "Raising a not found",
+SQLCODE = 1012;
+end $$
+call test_resignal() $$
+before RESIGNAL
+before RESIGNAL
+ERROR 02222: Raising a not found
+drop procedure test_resignal $$
+create procedure test_resignal()
+begin
+DECLARE error CONDITION FOR SQLSTATE "55555";
+DECLARE CONTINUE HANDLER for 1012
+begin
+select "before RESIGNAL";
+RESIGNAL;
+select "after RESIGNAL";
+end;
+SIGNAL error SET
+MESSAGE_TEXT = "Raising an error",
+SQLCODE = 1012;
+end $$
+call test_resignal() $$
+before RESIGNAL
+before RESIGNAL
+ERROR 55555: Raising an error
+drop procedure test_resignal $$
+create procedure test_resignal()
+begin
+DECLARE CONTINUE HANDLER for sqlwarning
+begin
+select "before RESIGNAL";
+RESIGNAL;
+select "after RESIGNAL";
+end;
+insert into t_warn set a= 9999999999999999;
+end $$
+call test_resignal() $$
+before RESIGNAL
+before RESIGNAL
+after RESIGNAL
+after RESIGNAL
+Warnings:
+Warning	1264	Out of range value for column 'a' at row 1
+drop procedure test_resignal $$
+create procedure test_resignal()
+begin
+DECLARE x integer;
+DECLARE c cursor for select * from t_cursor;
+DECLARE CONTINUE HANDLER for not found
+begin
+select "before RESIGNAL";
+RESIGNAL;
+select "after RESIGNAL";
+end;
+open c;
+fetch c into x;
+close c;
+end $$
+call test_resignal() $$
+before RESIGNAL
+before RESIGNAL
+ERROR 02000: No data - zero rows fetched, selected, or processed
+drop procedure test_resignal $$
+create procedure test_resignal()
+begin
+DECLARE CONTINUE HANDLER for sqlexception
+begin
+select "before RESIGNAL";
+RESIGNAL;
+select "after RESIGNAL";
+end;
+drop table no_such_table;
+end $$
+call test_resignal() $$
+before RESIGNAL
+before RESIGNAL
+ERROR 42S02: Unknown table 'no_such_table'
+drop procedure test_resignal $$
+create procedure test_resignal()
+begin
+DECLARE warn CONDITION FOR SQLSTATE "01234";
+DECLARE CONTINUE HANDLER for 1012
+begin
+select "before RESIGNAL";
+RESIGNAL SET
+MESSAGE_TEXT = "RESIGNAL of a warning",
+SQLCODE = 5555 ;
+select "after RESIGNAL";
+end;
+SIGNAL warn SET
+MESSAGE_TEXT = "Raising a warning",
+SQLCODE = 1012;
+end $$
+call test_resignal() $$
+before RESIGNAL
+before RESIGNAL
+after RESIGNAL
+after RESIGNAL
+Warnings:
+Warning	5555	RESIGNAL of a warning
+drop procedure test_resignal $$
+create procedure test_resignal()
+begin
+DECLARE not_found CONDITION FOR SQLSTATE "02111";
+DECLARE CONTINUE HANDLER for 1012
+begin
+select "before RESIGNAL";
+RESIGNAL SET
+MESSAGE_TEXT = "RESIGNAL of a not found",
+SQLCODE = 5555 ;
+select "after RESIGNAL";
+end;
+SIGNAL not_found SET
+MESSAGE_TEXT = "Raising a not found",
+SQLCODE = 1012;
+end $$
+call test_resignal() $$
+before RESIGNAL
+before RESIGNAL
+ERROR 02111: RESIGNAL of a not found
+drop procedure test_resignal $$
+create procedure test_resignal()
+begin
+DECLARE error CONDITION FOR SQLSTATE "33333";
+DECLARE CONTINUE HANDLER for 1012
+begin
+select "before RESIGNAL";
+RESIGNAL SET
+MESSAGE_TEXT = "RESIGNAL of an error",
+SQLCODE = 5555 ;
+select "after RESIGNAL";
+end;
+SIGNAL error SET
+MESSAGE_TEXT = "Raising an error",
+SQLCODE = 1012;
+end $$
+call test_resignal() $$
+before RESIGNAL
+before RESIGNAL
+ERROR 33333: RESIGNAL of an error
+drop procedure test_resignal $$
+create procedure test_resignal()
+begin
+DECLARE CONTINUE HANDLER for sqlwarning
+begin
+select "before RESIGNAL";
+RESIGNAL SET
+MESSAGE_TEXT = "RESIGNAL of a warning",
+SQLCODE = 5555 ;
+select "after RESIGNAL";
+end;
+insert into t_warn set a= 9999999999999999;
+end $$
+call test_resignal() $$
+before RESIGNAL
+before RESIGNAL
+after RESIGNAL
+after RESIGNAL
+Warnings:
+Warning	5555	RESIGNAL of a warning
+drop procedure test_resignal $$
+create procedure test_resignal()
+begin
+DECLARE x integer;
+DECLARE c cursor for select * from t_cursor;
+DECLARE CONTINUE HANDLER for not found
+begin
+select "before RESIGNAL";
+RESIGNAL SET
+MESSAGE_TEXT = "RESIGNAL of not found",
+SQLCODE = 5555 ;
+select "after RESIGNAL";
+end;
+open c;
+fetch c into x;
+close c;
+end $$
+call test_resignal() $$
+before RESIGNAL
+before RESIGNAL
+ERROR 02000: RESIGNAL of not found
+drop procedure test_resignal $$
+create procedure test_resignal()
+begin
+DECLARE CONTINUE HANDLER for sqlexception
+begin
+select "before RESIGNAL";
+RESIGNAL SET
+MESSAGE_TEXT = "RESIGNAL of an error",
+SQLCODE = 5555 ;
+select "after RESIGNAL";
+end;
+drop table no_such_table;
+end $$
+call test_resignal() $$
+before RESIGNAL
+before RESIGNAL
+ERROR 42S02: RESIGNAL of an error
+drop procedure test_resignal $$
+create procedure test_resignal()
+begin
+DECLARE warn CONDITION FOR SQLSTATE "01111";
+DECLARE CONTINUE HANDLER for 1012
+begin
+select "before RESIGNAL";
+RESIGNAL SQLSTATE "01222" SET
+MESSAGE_TEXT = "RESIGNAL to warning",
+SQLCODE = 5555 ;
+select "after RESIGNAL";
+end;
+SIGNAL warn SET
+MESSAGE_TEXT = "Raising a warning",
+SQLCODE = 1012;
+end $$
+call test_resignal() $$
+before RESIGNAL
+before RESIGNAL
+after RESIGNAL
+after RESIGNAL
+Warnings:
+Warning	1012	Raising a warning
+Warning	5555	RESIGNAL to warning
+drop procedure test_resignal $$
+create procedure test_resignal()
+begin
+DECLARE warn CONDITION FOR SQLSTATE "01111";
+DECLARE CONTINUE HANDLER for 1012
+begin
+select "before RESIGNAL";
+RESIGNAL SQLSTATE "02222" SET
+MESSAGE_TEXT = "RESIGNAL to not found",
+SQLCODE = 5555 ;
+select "after RESIGNAL";
+end;
+SIGNAL warn SET
+MESSAGE_TEXT = "Raising a warning",
+SQLCODE = 1012;
+end $$
+call test_resignal() $$
+before RESIGNAL
+before RESIGNAL
+ERROR 02222: RESIGNAL to not found
+show warnings $$
+Level	Code	Message
+Warning	1012	Raising a warning
+Error	5555	RESIGNAL to not found
+drop procedure test_resignal $$
+create procedure test_resignal()
+begin
+DECLARE warn CONDITION FOR SQLSTATE "01111";
+DECLARE CONTINUE HANDLER for 1012
+begin
+select "before RESIGNAL";
+RESIGNAL SQLSTATE "33333" SET
+MESSAGE_TEXT = "RESIGNAL to error",
+SQLCODE = 5555 ;
+select "after RESIGNAL";
+end;
+SIGNAL warn SET
+MESSAGE_TEXT = "Raising a warning",
+SQLCODE = 1012;
+end $$
+call test_resignal() $$
+before RESIGNAL
+before RESIGNAL
+ERROR 33333: RESIGNAL to error
+show warnings $$
+Level	Code	Message
+Warning	1012	Raising a warning
+Error	5555	RESIGNAL to error
+drop procedure test_resignal $$
+create procedure test_resignal()
+begin
+DECLARE not_found CONDITION FOR SQLSTATE "02ABC";
+DECLARE CONTINUE HANDLER for 1012
+begin
+select "before RESIGNAL";
+RESIGNAL SQLSTATE "01222" SET
+MESSAGE_TEXT = "RESIGNAL to warning",
+SQLCODE = 5555 ;
+select "after RESIGNAL";
+end;
+SIGNAL not_found SET
+MESSAGE_TEXT = "Raising a not found",
+SQLCODE = 1012;
+end $$
+call test_resignal() $$
+before RESIGNAL
+before RESIGNAL
+after RESIGNAL
+after RESIGNAL
+Warnings:
+Error	1012	Raising a not found
+Warning	5555	RESIGNAL to warning
+drop procedure test_resignal $$
+create procedure test_resignal()
+begin
+DECLARE not_found CONDITION FOR SQLSTATE "02ABC";
+DECLARE CONTINUE HANDLER for 1012
+begin
+select "before RESIGNAL";
+RESIGNAL SQLSTATE "02222" SET
+MESSAGE_TEXT = "RESIGNAL to not found",
+SQLCODE = 5555 ;
+select "after RESIGNAL";
+end;
+SIGNAL not_found SET
+MESSAGE_TEXT = "Raising a not found",
+SQLCODE = 1012;
+end $$
+call test_resignal() $$
+before RESIGNAL
+before RESIGNAL
+ERROR 02222: RESIGNAL to not found
+show warnings $$
+Level	Code	Message
+Error	1012	Raising a not found
+Error	5555	RESIGNAL to not found
+drop procedure test_resignal $$
+create procedure test_resignal()
+begin
+DECLARE not_found CONDITION FOR SQLSTATE "02ABC";
+DECLARE CONTINUE HANDLER for 1012
+begin
+select "before RESIGNAL";
+RESIGNAL SQLSTATE "33333" SET
+MESSAGE_TEXT = "RESIGNAL to error",
+SQLCODE = 5555 ;
+select "after RESIGNAL";
+end;
+SIGNAL not_found SET
+MESSAGE_TEXT = "Raising a not found",
+SQLCODE = 1012;
+end $$
+call test_resignal() $$
+before RESIGNAL
+before RESIGNAL
+ERROR 33333: RESIGNAL to error
+show warnings $$
+Level	Code	Message
+Error	1012	Raising a not found
+Error	5555	RESIGNAL to error
+drop procedure test_resignal $$
+create procedure test_resignal()
+begin
+DECLARE error CONDITION FOR SQLSTATE "AAAAA";
+DECLARE CONTINUE HANDLER for 1012
+begin
+select "before RESIGNAL";
+RESIGNAL SQLSTATE "01222" SET
+MESSAGE_TEXT = "RESIGNAL to warning",
+SQLCODE = 5555 ;
+select "after RESIGNAL";
+end;
+SIGNAL error SET
+MESSAGE_TEXT = "Raising an error",
+SQLCODE = 1012;
+end $$
+call test_resignal() $$
+before RESIGNAL
+before RESIGNAL
+after RESIGNAL
+after RESIGNAL
+Warnings:
+Error	1012	Raising an error
+Warning	5555	RESIGNAL to warning
+drop procedure test_resignal $$
+create procedure test_resignal()
+begin
+DECLARE error CONDITION FOR SQLSTATE "AAAAA";
+DECLARE CONTINUE HANDLER for 1012
+begin
+select "before RESIGNAL";
+RESIGNAL SQLSTATE "02222" SET
+MESSAGE_TEXT = "RESIGNAL to not found",
+SQLCODE = 5555 ;
+select "after RESIGNAL";
+end;
+SIGNAL error SET
+MESSAGE_TEXT = "Raising an error",
+SQLCODE = 1012;
+end $$
+call test_resignal() $$
+before RESIGNAL
+before RESIGNAL
+ERROR 02222: RESIGNAL to not found
+show warnings $$
+Level	Code	Message
+Error	1012	Raising an error
+Error	5555	RESIGNAL to not found
+drop procedure test_resignal $$
+create procedure test_resignal()
+begin
+DECLARE error CONDITION FOR SQLSTATE "AAAAA";
+DECLARE CONTINUE HANDLER for 1012
+begin
+select "before RESIGNAL";
+RESIGNAL SQLSTATE "33333" SET
+MESSAGE_TEXT = "RESIGNAL to error",
+SQLCODE = 5555 ;
+select "after RESIGNAL";
+end;
+SIGNAL error SET
+MESSAGE_TEXT = "Raising an error",
+SQLCODE = 1012;
+end $$
+call test_resignal() $$
+before RESIGNAL
+before RESIGNAL
+ERROR 33333: RESIGNAL to error
+show warnings $$
+Level	Code	Message
+Error	1012	Raising an error
+Error	5555	RESIGNAL to error
+drop procedure test_resignal $$
+create procedure test_resignal()
+begin
+DECLARE CONTINUE HANDLER for sqlwarning
+begin
+select "before RESIGNAL";
+RESIGNAL SQLSTATE "01111" SET
+MESSAGE_TEXT = "RESIGNAL to a warning",
+SQLCODE = 5555 ;
+select "after RESIGNAL";
+end;
+insert into t_warn set a= 9999999999999999;
+end $$
+call test_resignal() $$
+before RESIGNAL
+before RESIGNAL
+after RESIGNAL
+after RESIGNAL
+Warnings:
+Warning	1264	Out of range value for column 'a' at row 1
+Warning	5555	RESIGNAL to a warning
+drop procedure test_resignal $$
+create procedure test_resignal()
+begin
+DECLARE CONTINUE HANDLER for sqlwarning
+begin
+select "before RESIGNAL";
+RESIGNAL SQLSTATE "02444" SET
+MESSAGE_TEXT = "RESIGNAL to a not found",
+SQLCODE = 5555 ;
+select "after RESIGNAL";
+end;
+insert into t_warn set a= 9999999999999999;
+end $$
+call test_resignal() $$
+before RESIGNAL
+before RESIGNAL
+ERROR 02444: RESIGNAL to a not found
+show warnings $$
+Level	Code	Message
+Warning	1264	Out of range value for column 'a' at row 1
+Error	5555	RESIGNAL to a not found
+drop procedure test_resignal $$
+create procedure test_resignal()
+begin
+DECLARE CONTINUE HANDLER for sqlwarning
+begin
+select "before RESIGNAL";
+RESIGNAL SQLSTATE "44444" SET
+MESSAGE_TEXT = "RESIGNAL to an error",
+SQLCODE = 5555 ;
+select "after RESIGNAL";
+end;
+insert into t_warn set a= 9999999999999999;
+end $$
+call test_resignal() $$
+before RESIGNAL
+before RESIGNAL
+ERROR 44444: RESIGNAL to an error
+show warnings $$
+Level	Code	Message
+Warning	1264	Out of range value for column 'a' at row 1
+Error	5555	RESIGNAL to an error
+drop procedure test_resignal $$
+create procedure test_resignal()
+begin
+DECLARE x integer;
+DECLARE c cursor for select * from t_cursor;
+DECLARE CONTINUE HANDLER for not found
+begin
+select "before RESIGNAL";
+RESIGNAL SQLSTATE "01111" SET
+MESSAGE_TEXT = "RESIGNAL to a warning",
+SQLCODE = 5555 ;
+select "after RESIGNAL";
+end;
+open c;
+fetch c into x;
+close c;
+end $$
+call test_resignal() $$
+before RESIGNAL
+before RESIGNAL
+after RESIGNAL
+after RESIGNAL
+Warnings:
+Error	1329	No data - zero rows fetched, selected, or processed
+Warning	5555	RESIGNAL to a warning
+drop procedure test_resignal $$
+create procedure test_resignal()
+begin
+DECLARE x integer;
+DECLARE c cursor for select * from t_cursor;
+DECLARE CONTINUE HANDLER for not found
+begin
+select "before RESIGNAL";
+RESIGNAL SQLSTATE "02444" SET
+MESSAGE_TEXT = "RESIGNAL to a not found",
+SQLCODE = 5555 ;
+select "after RESIGNAL";
+end;
+open c;
+fetch c into x;
+close c;
+end $$
+call test_resignal() $$
+before RESIGNAL
+before RESIGNAL
+ERROR 02444: RESIGNAL to a not found
+show warnings $$
+Level	Code	Message
+Error	1329	No data - zero rows fetched, selected, or processed
+Error	5555	RESIGNAL to a not found
+drop procedure test_resignal $$
+create procedure test_resignal()
+begin
+DECLARE x integer;
+DECLARE c cursor for select * from t_cursor;
+DECLARE CONTINUE HANDLER for not found
+begin
+select "before RESIGNAL";
+RESIGNAL SQLSTATE "44444" SET
+MESSAGE_TEXT = "RESIGNAL to an error",
+SQLCODE = 5555 ;
+select "after RESIGNAL";
+end;
+open c;
+fetch c into x;
+close c;
+end $$
+call test_resignal() $$
+before RESIGNAL
+before RESIGNAL
+ERROR 44444: RESIGNAL to an error
+show warnings $$
+Level	Code	Message
+Error	1329	No data - zero rows fetched, selected, or processed
+Error	5555	RESIGNAL to an error
+drop procedure test_resignal $$
+create procedure test_resignal()
+begin
+DECLARE CONTINUE HANDLER for sqlexception
+begin
+select "before RESIGNAL";
+RESIGNAL SQLSTATE "01111" SET
+MESSAGE_TEXT = "RESIGNAL to a warning",
+SQLCODE = 5555 ;
+select "after RESIGNAL";
+end;
+drop table no_such_table;
+end $$
+call test_resignal() $$
+before RESIGNAL
+before RESIGNAL
+after RESIGNAL
+after RESIGNAL
+Warnings:
+Error	1051	Unknown table 'no_such_table'
+Warning	5555	RESIGNAL to a warning
+drop procedure test_resignal $$
+create procedure test_resignal()
+begin
+DECLARE CONTINUE HANDLER for sqlexception
+begin
+select "before RESIGNAL";
+RESIGNAL SQLSTATE "02444" SET
+MESSAGE_TEXT = "RESIGNAL to a not found",
+SQLCODE = 5555 ;
+select "after RESIGNAL";
+end;
+drop table no_such_table;
+end $$
+call test_resignal() $$
+before RESIGNAL
+before RESIGNAL
+ERROR 02444: RESIGNAL to a not found
+show warnings $$
+Level	Code	Message
+Error	1051	Unknown table 'no_such_table'
+Error	5555	RESIGNAL to a not found
+drop procedure test_resignal $$
+create procedure test_resignal()
+begin
+DECLARE CONTINUE HANDLER for sqlexception
+begin
+select "before RESIGNAL";
+RESIGNAL SQLSTATE "44444" SET
+MESSAGE_TEXT = "RESIGNAL to an error",
+SQLCODE = 5555 ;
+select "after RESIGNAL";
+end;
+drop table no_such_table;
+end $$
+call test_resignal() $$
+before RESIGNAL
+before RESIGNAL
+ERROR 44444: RESIGNAL to an error
+show warnings $$
+Level	Code	Message
+Error	1051	Unknown table 'no_such_table'
+Error	5555	RESIGNAL to an error
+drop procedure test_resignal $$
+drop table t_warn;
+drop table t_cursor;
diff -Nrup a/mysql-test/t/signal.test b/mysql-test/t/signal.test
--- a/mysql-test/t/signal.test	2008-05-06 17:05:32 -06:00
+++ b/mysql-test/t/signal.test	2008-05-07 20:50:41 -06:00
@@ -448,6 +448,12 @@ drop procedure test_resignal_syntax $$
 
 create procedure test_resignal_syntax()
 begin
+  RESIGNAL SET CLASS_ORIGIN = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
   DECLARE foo CONDITION FOR 1234;
   RESIGNAL foo SET CLASS_ORIGIN = 'foo';
 end $$
@@ -455,6 +461,12 @@ drop procedure test_resignal_syntax $$
 
 create procedure test_resignal_syntax()
 begin
+  RESIGNAL SET SUBCLASS_ORIGIN = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
   DECLARE foo CONDITION FOR 1234;
   RESIGNAL foo SET SUBCLASS_ORIGIN = 'foo';
 end $$
@@ -462,6 +474,12 @@ drop procedure test_resignal_syntax $$
 
 create procedure test_resignal_syntax()
 begin
+  RESIGNAL SET CONSTRAINT_CATALOG = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
   DECLARE foo CONDITION FOR 1234;
   RESIGNAL foo SET CONSTRAINT_CATALOG = 'foo';
 end $$
@@ -469,6 +487,12 @@ drop procedure test_resignal_syntax $$
 
 create procedure test_resignal_syntax()
 begin
+  RESIGNAL SET CONSTRAINT_SCHEMA = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
   DECLARE foo CONDITION FOR 1234;
   RESIGNAL foo SET CONSTRAINT_SCHEMA = 'foo';
 end $$
@@ -476,6 +500,12 @@ drop procedure test_resignal_syntax $$
 
 create procedure test_resignal_syntax()
 begin
+  RESIGNAL SET CONSTRAINT_NAME = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
   DECLARE foo CONDITION FOR 1234;
   RESIGNAL foo SET CONSTRAINT_NAME = 'foo';
 end $$
@@ -483,6 +513,12 @@ drop procedure test_resignal_syntax $$
 
 create procedure test_resignal_syntax()
 begin
+  RESIGNAL SET CATALOG_NAME = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
   DECLARE foo CONDITION FOR 1234;
   RESIGNAL foo SET CATALOG_NAME = 'foo';
 end $$
@@ -490,6 +526,12 @@ drop procedure test_resignal_syntax $$
 
 create procedure test_resignal_syntax()
 begin
+  RESIGNAL SET SCHEMA_NAME = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
   DECLARE foo CONDITION FOR 1234;
   RESIGNAL foo SET SCHEMA_NAME = 'foo';
 end $$
@@ -497,6 +539,12 @@ drop procedure test_resignal_syntax $$
 
 create procedure test_resignal_syntax()
 begin
+  RESIGNAL SET TABLE_NAME = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
   DECLARE foo CONDITION FOR 1234;
   RESIGNAL foo SET TABLE_NAME = 'foo';
 end $$
@@ -504,6 +552,12 @@ drop procedure test_resignal_syntax $$
 
 create procedure test_resignal_syntax()
 begin
+  RESIGNAL SET COLUMN_NAME = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
   DECLARE foo CONDITION FOR 1234;
   RESIGNAL foo SET COLUMN_NAME = 'foo';
 end $$
@@ -511,6 +565,12 @@ drop procedure test_resignal_syntax $$
 
 create procedure test_resignal_syntax()
 begin
+  RESIGNAL SET CURSOR_NAME = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
   DECLARE foo CONDITION FOR 1234;
   RESIGNAL foo SET CURSOR_NAME = 'foo';
 end $$
@@ -518,6 +578,12 @@ drop procedure test_resignal_syntax $$
 
 create procedure test_resignal_syntax()
 begin
+  RESIGNAL SET MESSAGE_TEXT = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
   DECLARE foo CONDITION FOR 1234;
   RESIGNAL foo SET MESSAGE_TEXT = 'foo';
 end $$
@@ -525,6 +591,12 @@ drop procedure test_resignal_syntax $$
 
 create procedure test_resignal_syntax()
 begin
+  RESIGNAL SET SQLCODE = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
   DECLARE foo CONDITION FOR 1234;
   RESIGNAL foo SET SQLCODE = 'foo';
 end $$
@@ -1308,8 +1380,15 @@ prepare stmt from 'GET DIAGNOSTICS @foo 
 
 --disable_warnings
 drop procedure if exists test_signal;
+drop procedure if exists test_resignal;
+drop table if exists t_warn;
+drop table if exists t_cursor;
 --enable_warnings
 
+# Helper tables
+create table t_warn(a integer(2));
+create table t_cursor(a integer);
+
 #
 # SIGNAL can also appear in a query
 #
@@ -1350,16 +1429,16 @@ SIGNAL SQLSTATE 'HY000' SET SQLCODE = 65
 # RESIGNAL can also appear in a query
 #
 
---error ER_NOT_SUPPORTED_YET
+--error ER_RESIGNAL_NO_HANDLER
 RESIGNAL;
 
 --error ER_SP_COND_MISMATCH
 RESIGNAL foo;
 
---error ER_NOT_SUPPORTED_YET
+--error ER_RESIGNAL_NO_HANDLER
 RESIGNAL SQLSTATE '12345';
 
---error ER_NOT_SUPPORTED_YET
+--error ER_RESIGNAL_NO_HANDLER
 RESIGNAL SQLSTATE VALUE '12345';
 
 #
@@ -2166,8 +2245,641 @@ drop table t1 $$
 drop procedure p1 $$
 drop function f1 $$
 
+#########################################################
+# Test the RESIGNAL runtime
+#########################################################
+
+# 6 tests:
+# {Signaled warning, Signaled Not Found, Signaled Error,
+# warning, not found, error} --> RESIGNAL
+
+create procedure test_resignal()
+begin
+  DECLARE warn CONDITION FOR SQLSTATE "01234";
+  DECLARE CONTINUE HANDLER for 1012
+  begin
+    select "before RESIGNAL";
+    RESIGNAL;
+    select "after RESIGNAL";
+  end;
+
+  SIGNAL warn SET
+    MESSAGE_TEXT = "Raising a warning",
+    SQLCODE = 1012;
+end $$
+
+call test_resignal() $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+  DECLARE not_found CONDITION FOR SQLSTATE "02222";
+  DECLARE CONTINUE HANDLER for 1012
+  begin
+    select "before RESIGNAL";
+    RESIGNAL;
+    select "after RESIGNAL";
+  end;
+
+  SIGNAL not_found SET
+    MESSAGE_TEXT = "Raising a not found",
+    SQLCODE = 1012;
+end $$
+
+--error 1012
+call test_resignal() $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+  DECLARE error CONDITION FOR SQLSTATE "55555";
+  DECLARE CONTINUE HANDLER for 1012
+  begin
+    select "before RESIGNAL";
+    RESIGNAL;
+    select "after RESIGNAL";
+  end;
+
+  SIGNAL error SET
+    MESSAGE_TEXT = "Raising an error",
+    SQLCODE = 1012;
+end $$
+
+--error 1012
+call test_resignal() $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+  DECLARE CONTINUE HANDLER for sqlwarning
+  begin
+    select "before RESIGNAL";
+    RESIGNAL;
+    select "after RESIGNAL";
+  end;
+
+  insert into t_warn set a= 9999999999999999;
+end $$
+
+call test_resignal() $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+  DECLARE x integer;
+  DECLARE c cursor for select * from t_cursor;
+  DECLARE CONTINUE HANDLER for not found
+  begin
+    select "before RESIGNAL";
+    RESIGNAL;
+    select "after RESIGNAL";
+  end;
+
+  open c;
+  fetch c into x;
+  close c;
+end $$
+
+--error ER_SP_FETCH_NO_DATA
+call test_resignal() $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+  DECLARE CONTINUE HANDLER for sqlexception
+  begin
+    select "before RESIGNAL";
+    RESIGNAL;
+    select "after RESIGNAL";
+  end;
+
+  drop table no_such_table;
+end $$
+
+--error ER_BAD_TABLE_ERROR
+call test_resignal() $$
+drop procedure test_resignal $$
+
+# 6 tests:
+# {Signaled warning, Signaled Not Found, Signaled Error,
+# warning, not found, error} --> RESIGNAL SET ...
+
+create procedure test_resignal()
+begin
+  DECLARE warn CONDITION FOR SQLSTATE "01234";
+  DECLARE CONTINUE HANDLER for 1012
+  begin
+    select "before RESIGNAL";
+    RESIGNAL SET
+      MESSAGE_TEXT = "RESIGNAL of a warning",
+      SQLCODE = 5555 ;
+    select "after RESIGNAL";
+  end;
+
+  SIGNAL warn SET
+    MESSAGE_TEXT = "Raising a warning",
+    SQLCODE = 1012;
+end $$
+
+call test_resignal() $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+  DECLARE not_found CONDITION FOR SQLSTATE "02111";
+  DECLARE CONTINUE HANDLER for 1012
+  begin
+    select "before RESIGNAL";
+    RESIGNAL SET
+      MESSAGE_TEXT = "RESIGNAL of a not found",
+      SQLCODE = 5555 ;
+    select "after RESIGNAL";
+  end;
+
+  SIGNAL not_found SET
+    MESSAGE_TEXT = "Raising a not found",
+    SQLCODE = 1012;
+end $$
+
+--error 5555
+call test_resignal() $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+  DECLARE error CONDITION FOR SQLSTATE "33333";
+  DECLARE CONTINUE HANDLER for 1012
+  begin
+    select "before RESIGNAL";
+    RESIGNAL SET
+      MESSAGE_TEXT = "RESIGNAL of an error",
+      SQLCODE = 5555 ;
+    select "after RESIGNAL";
+  end;
+
+  SIGNAL error SET
+    MESSAGE_TEXT = "Raising an error",
+    SQLCODE = 1012;
+end $$
+
+--error 5555
+call test_resignal() $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+  DECLARE CONTINUE HANDLER for sqlwarning
+  begin
+    select "before RESIGNAL";
+    RESIGNAL SET
+      MESSAGE_TEXT = "RESIGNAL of a warning",
+      SQLCODE = 5555 ;
+    select "after RESIGNAL";
+  end;
+
+  insert into t_warn set a= 9999999999999999;
+end $$
+
+call test_resignal() $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+  DECLARE x integer;
+  DECLARE c cursor for select * from t_cursor;
+  DECLARE CONTINUE HANDLER for not found
+  begin
+    select "before RESIGNAL";
+    RESIGNAL SET
+      MESSAGE_TEXT = "RESIGNAL of not found",
+      SQLCODE = 5555 ;
+    select "after RESIGNAL";
+  end;
+
+  open c;
+  fetch c into x;
+  close c;
+end $$
+
+--error 5555
+call test_resignal() $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+  DECLARE CONTINUE HANDLER for sqlexception
+  begin
+    select "before RESIGNAL";
+    RESIGNAL SET
+      MESSAGE_TEXT = "RESIGNAL of an error",
+      SQLCODE = 5555 ;
+    select "after RESIGNAL";
+  end;
+
+  drop table no_such_table;
+end $$
+
+--error 5555
+call test_resignal() $$
+drop procedure test_resignal $$
+
+#########################################################
+
+# 3 tests:
+# {Signaled warning}
+# --> RESIGNAL SQLSTATE {warning, not found, error} SET ...
+
+create procedure test_resignal()
+begin
+  DECLARE warn CONDITION FOR SQLSTATE "01111";
+  DECLARE CONTINUE HANDLER for 1012
+  begin
+    select "before RESIGNAL";
+    RESIGNAL SQLSTATE "01222" SET
+      MESSAGE_TEXT = "RESIGNAL to warning",
+      SQLCODE = 5555 ;
+    select "after RESIGNAL";
+  end;
+
+  SIGNAL warn SET
+    MESSAGE_TEXT = "Raising a warning",
+    SQLCODE = 1012;
+end $$
+
+call test_resignal() $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+  DECLARE warn CONDITION FOR SQLSTATE "01111";
+  DECLARE CONTINUE HANDLER for 1012
+  begin
+    select "before RESIGNAL";
+    RESIGNAL SQLSTATE "02222" SET
+      MESSAGE_TEXT = "RESIGNAL to not found",
+      SQLCODE = 5555 ;
+    select "after RESIGNAL";
+  end;
+
+  SIGNAL warn SET
+    MESSAGE_TEXT = "Raising a warning",
+    SQLCODE = 1012;
+end $$
+
+--error 5555
+call test_resignal() $$
+show warnings $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+  DECLARE warn CONDITION FOR SQLSTATE "01111";
+  DECLARE CONTINUE HANDLER for 1012
+  begin
+    select "before RESIGNAL";
+    RESIGNAL SQLSTATE "33333" SET
+      MESSAGE_TEXT = "RESIGNAL to error",
+      SQLCODE = 5555 ;
+    select "after RESIGNAL";
+  end;
+
+  SIGNAL warn SET
+    MESSAGE_TEXT = "Raising a warning",
+    SQLCODE = 1012;
+end $$
+
+--error 5555
+call test_resignal() $$
+show warnings $$
+drop procedure test_resignal $$
+
+# 3 tests:
+# {Signaled not found}
+# --> RESIGNAL SQLSTATE {warning, not found, error} SET ...
+
+create procedure test_resignal()
+begin
+  DECLARE not_found CONDITION FOR SQLSTATE "02ABC";
+  DECLARE CONTINUE HANDLER for 1012
+  begin
+    select "before RESIGNAL";
+    RESIGNAL SQLSTATE "01222" SET
+      MESSAGE_TEXT = "RESIGNAL to warning",
+      SQLCODE = 5555 ;
+    select "after RESIGNAL";
+  end;
+
+  SIGNAL not_found SET
+    MESSAGE_TEXT = "Raising a not found",
+    SQLCODE = 1012;
+end $$
+
+call test_resignal() $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+  DECLARE not_found CONDITION FOR SQLSTATE "02ABC";
+  DECLARE CONTINUE HANDLER for 1012
+  begin
+    select "before RESIGNAL";
+    RESIGNAL SQLSTATE "02222" SET
+      MESSAGE_TEXT = "RESIGNAL to not found",
+      SQLCODE = 5555 ;
+    select "after RESIGNAL";
+  end;
+
+  SIGNAL not_found SET
+    MESSAGE_TEXT = "Raising a not found",
+    SQLCODE = 1012;
+end $$
+
+--error 5555
+call test_resignal() $$
+show warnings $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+  DECLARE not_found CONDITION FOR SQLSTATE "02ABC";
+  DECLARE CONTINUE HANDLER for 1012
+  begin
+    select "before RESIGNAL";
+    RESIGNAL SQLSTATE "33333" SET
+      MESSAGE_TEXT = "RESIGNAL to error",
+      SQLCODE = 5555 ;
+    select "after RESIGNAL";
+  end;
+
+  SIGNAL not_found SET
+    MESSAGE_TEXT = "Raising a not found",
+    SQLCODE = 1012;
+end $$
+
+--error 5555
+call test_resignal() $$
+show warnings $$
+drop procedure test_resignal $$
+
+# 3 tests:
+# {Signaled error}
+# --> RESIGNAL SQLSTATE {warning, not found, error} SET ...
+
+create procedure test_resignal()
+begin
+  DECLARE error CONDITION FOR SQLSTATE "AAAAA";
+  DECLARE CONTINUE HANDLER for 1012
+  begin
+    select "before RESIGNAL";
+    RESIGNAL SQLSTATE "01222" SET
+      MESSAGE_TEXT = "RESIGNAL to warning",
+      SQLCODE = 5555 ;
+    select "after RESIGNAL";
+  end;
+
+  SIGNAL error SET
+    MESSAGE_TEXT = "Raising an error",
+    SQLCODE = 1012;
+end $$
+
+call test_resignal() $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+  DECLARE error CONDITION FOR SQLSTATE "AAAAA";
+  DECLARE CONTINUE HANDLER for 1012
+  begin
+    select "before RESIGNAL";
+    RESIGNAL SQLSTATE "02222" SET
+      MESSAGE_TEXT = "RESIGNAL to not found",
+      SQLCODE = 5555 ;
+    select "after RESIGNAL";
+  end;
+
+  SIGNAL error SET
+    MESSAGE_TEXT = "Raising an error",
+    SQLCODE = 1012;
+end $$
+
+--error 5555
+call test_resignal() $$
+show warnings $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+  DECLARE error CONDITION FOR SQLSTATE "AAAAA";
+  DECLARE CONTINUE HANDLER for 1012
+  begin
+    select "before RESIGNAL";
+    RESIGNAL SQLSTATE "33333" SET
+      MESSAGE_TEXT = "RESIGNAL to error",
+      SQLCODE = 5555 ;
+    select "after RESIGNAL";
+  end;
+
+  SIGNAL error SET
+    MESSAGE_TEXT = "Raising an error",
+    SQLCODE = 1012;
+end $$
+
+--error 5555
+call test_resignal() $$
+show warnings $$
+drop procedure test_resignal $$
+
+# 3 tests:
+# {warning}
+# --> RESIGNAL SQLSTATE {warning, not found, error} SET ...
+
+create procedure test_resignal()
+begin
+  DECLARE CONTINUE HANDLER for sqlwarning
+  begin
+    select "before RESIGNAL";
+    RESIGNAL SQLSTATE "01111" SET
+      MESSAGE_TEXT = "RESIGNAL to a warning",
+      SQLCODE = 5555 ;
+    select "after RESIGNAL";
+  end;
+
+  insert into t_warn set a= 9999999999999999;
+end $$
+
+call test_resignal() $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+  DECLARE CONTINUE HANDLER for sqlwarning
+  begin
+    select "before RESIGNAL";
+    RESIGNAL SQLSTATE "02444" SET
+      MESSAGE_TEXT = "RESIGNAL to a not found",
+      SQLCODE = 5555 ;
+    select "after RESIGNAL";
+  end;
+
+  insert into t_warn set a= 9999999999999999;
+end $$
+
+--error 5555
+call test_resignal() $$
+show warnings $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+  DECLARE CONTINUE HANDLER for sqlwarning
+  begin
+    select "before RESIGNAL";
+    RESIGNAL SQLSTATE "44444" SET
+      MESSAGE_TEXT = "RESIGNAL to an error",
+      SQLCODE = 5555 ;
+    select "after RESIGNAL";
+  end;
+
+  insert into t_warn set a= 9999999999999999;
+end $$
+
+--error 5555
+call test_resignal() $$
+show warnings $$
+drop procedure test_resignal $$
+
+# 3 tests:
+# {not found}
+# --> RESIGNAL SQLSTATE {warning, not found, error} SET ...
+
+create procedure test_resignal()
+begin
+  DECLARE x integer;
+  DECLARE c cursor for select * from t_cursor;
+  DECLARE CONTINUE HANDLER for not found
+  begin
+    select "before RESIGNAL";
+    RESIGNAL SQLSTATE "01111" SET
+      MESSAGE_TEXT = "RESIGNAL to a warning",
+      SQLCODE = 5555 ;
+    select "after RESIGNAL";
+  end;
+
+  open c;
+  fetch c into x;
+  close c;
+end $$
+
+call test_resignal() $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+  DECLARE x integer;
+  DECLARE c cursor for select * from t_cursor;
+  DECLARE CONTINUE HANDLER for not found
+  begin
+    select "before RESIGNAL";
+    RESIGNAL SQLSTATE "02444" SET
+      MESSAGE_TEXT = "RESIGNAL to a not found",
+      SQLCODE = 5555 ;
+    select "after RESIGNAL";
+  end;
+
+  open c;
+  fetch c into x;
+  close c;
+end $$
+
+--error 5555
+call test_resignal() $$
+show warnings $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+  DECLARE x integer;
+  DECLARE c cursor for select * from t_cursor;
+  DECLARE CONTINUE HANDLER for not found
+  begin
+    select "before RESIGNAL";
+    RESIGNAL SQLSTATE "44444" SET
+      MESSAGE_TEXT = "RESIGNAL to an error",
+      SQLCODE = 5555 ;
+    select "after RESIGNAL";
+  end;
+
+  open c;
+  fetch c into x;
+  close c;
+end $$
+
+--error 5555
+call test_resignal() $$
+show warnings $$
+drop procedure test_resignal $$
+
+# 3 tests:
+# {error}
+# --> RESIGNAL SQLSTATE {warning, not found, error} SET ...
+
+create procedure test_resignal()
+begin
+  DECLARE CONTINUE HANDLER for sqlexception
+  begin
+    select "before RESIGNAL";
+    RESIGNAL SQLSTATE "01111" SET
+      MESSAGE_TEXT = "RESIGNAL to a warning",
+      SQLCODE = 5555 ;
+    select "after RESIGNAL";
+  end;
+
+  drop table no_such_table;
+end $$
+
+call test_resignal() $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+  DECLARE CONTINUE HANDLER for sqlexception
+  begin
+    select "before RESIGNAL";
+    RESIGNAL SQLSTATE "02444" SET
+      MESSAGE_TEXT = "RESIGNAL to a not found",
+      SQLCODE = 5555 ;
+    select "after RESIGNAL";
+  end;
+
+  drop table no_such_table;
+end $$
+
+--error 5555
+call test_resignal() $$
+show warnings $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+  DECLARE CONTINUE HANDLER for sqlexception
+  begin
+    select "before RESIGNAL";
+    RESIGNAL SQLSTATE "44444" SET
+      MESSAGE_TEXT = "RESIGNAL to an error",
+      SQLCODE = 5555 ;
+    select "after RESIGNAL";
+  end;
+
+  drop table no_such_table;
+end $$
 
+--error 5555
+call test_resignal() $$
+show warnings $$
+drop procedure test_resignal $$
 
 delimiter ;$$
 
+drop table t_warn;
+drop table t_cursor;
 
diff -Nrup a/sql/item.cc b/sql/item.cc
--- a/sql/item.cc	2008-04-14 04:09:58 -06:00
+++ b/sql/item.cc	2008-05-07 20:50:41 -06:00
@@ -1108,7 +1108,7 @@ Item_splocal::Item_splocal(const LEX_STR
 Item *
 Item_splocal::this_item()
 {
-  DBUG_ASSERT(m_sp == m_thd->spcont->sp);
+  DBUG_ASSERT(m_sp == m_thd->spcont->m_sp);
 
   return m_thd->spcont->get_item(m_var_idx);
 }
@@ -1116,7 +1116,7 @@ Item_splocal::this_item()
 const Item *
 Item_splocal::this_item() const
 {
-  DBUG_ASSERT(m_sp == m_thd->spcont->sp);
+  DBUG_ASSERT(m_sp == m_thd->spcont->m_sp);
 
   return m_thd->spcont->get_item(m_var_idx);
 }
@@ -1125,7 +1125,7 @@ Item_splocal::this_item() const
 Item **
 Item_splocal::this_item_addr(THD *thd, Item **)
 {
-  DBUG_ASSERT(m_sp == thd->spcont->sp);
+  DBUG_ASSERT(m_sp == thd->spcont->m_sp);
 
   return thd->spcont->get_item_addr(m_var_idx);
 }
@@ -1160,7 +1160,7 @@ Item_case_expr::Item_case_expr(uint case
 Item *
 Item_case_expr::this_item()
 {
-  DBUG_ASSERT(m_sp == m_thd->spcont->sp);
+  DBUG_ASSERT(m_sp == m_thd->spcont->m_sp);
 
   return m_thd->spcont->get_case_expr(m_case_expr_id);
 }
@@ -1170,7 +1170,7 @@ Item_case_expr::this_item()
 const Item *
 Item_case_expr::this_item() const
 {
-  DBUG_ASSERT(m_sp == m_thd->spcont->sp);
+  DBUG_ASSERT(m_sp == m_thd->spcont->m_sp);
 
   return m_thd->spcont->get_case_expr(m_case_expr_id);
 }
@@ -1179,7 +1179,7 @@ Item_case_expr::this_item() const
 Item **
 Item_case_expr::this_item_addr(THD *thd, Item **)
 {
-  DBUG_ASSERT(m_sp == thd->spcont->sp);
+  DBUG_ASSERT(m_sp == thd->spcont->m_sp);
 
   return thd->spcont->get_case_expr_addr(m_case_expr_id);
 }
diff -Nrup a/sql/sp_head.cc b/sql/sp_head.cc
--- a/sql/sp_head.cc	2008-04-29 17:34:13 -06:00
+++ b/sql/sp_head.cc	2008-05-07 20:50:41 -06:00
@@ -1505,17 +1505,13 @@ sp_head::execute_trigger(THD *thd,
   init_sql_alloc(&call_mem_root, MEM_ROOT_BLOCK_SIZE, 0);
   thd->set_n_backup_active_arena(&call_arena, &backup_arena);
 
-  if (!(nctx= new sp_rcontext(m_pcont, 0, octx)) ||
+  if (!(nctx= new sp_rcontext(this, m_pcont, 0, octx)) ||
       nctx->init(thd))
   {
     err_status= TRUE;
     goto err_with_cleanup;
   }
 
-#ifndef DBUG_OFF
-  nctx->sp= this;
-#endif
-
   thd->spcont= nctx;
 
   err_status= execute(thd);
@@ -1622,7 +1618,7 @@ sp_head::execute_function(THD *thd, Item
   init_sql_alloc(&call_mem_root, MEM_ROOT_BLOCK_SIZE, 0);
   thd->set_n_backup_active_arena(&call_arena, &backup_arena);
 
-  if (!(nctx= new sp_rcontext(m_pcont, return_value_fld, octx)) ||
+  if (!(nctx= new sp_rcontext(this, m_pcont, return_value_fld, octx)) ||
       nctx->init(thd))
   {
     thd->restore_active_arena(&call_arena, &backup_arena);
@@ -1638,10 +1634,6 @@ sp_head::execute_function(THD *thd, Item
   */
   thd->restore_active_arena(&call_arena, &backup_arena);
 
-#ifndef DBUG_OFF
-  nctx->sp= this;
-#endif
-
   /* Pass arguments. */
   for (arg_no= 0; arg_no < argcount; arg_no++)
   {
@@ -1826,32 +1818,26 @@ sp_head::execute_procedure(THD *thd, Lis
   save_spcont= octx= thd->spcont;
   if (! octx)
   {				// Create a temporary old context
-    if (!(octx= new sp_rcontext(m_pcont, NULL, octx)) ||
+    if (!(octx= new sp_rcontext(this, m_pcont, NULL, octx)) ||
         octx->init(thd))
     {
       delete octx; /* Delete octx if it was init() that failed. */
       DBUG_RETURN(TRUE);
     }
 
-#ifndef DBUG_OFF
-    octx->sp= 0;
-#endif
     thd->spcont= octx;
 
     /* set callers_arena to thd, for upper-level function to work */
     thd->spcont->callers_arena= thd;
   }
 
-  if (!(nctx= new sp_rcontext(m_pcont, NULL, octx)) ||
+  if (!(nctx= new sp_rcontext(this, m_pcont, NULL, octx)) ||
       nctx->init(thd))
   {
     delete nctx; /* Delete nctx if it was init() that failed. */
     thd->spcont= save_spcont;
     DBUG_RETURN(TRUE);
   }
-#ifndef DBUG_OFF
-  nctx->sp= this;
-#endif
 
   if (params > 0)
   {
diff -Nrup a/sql/sp_head.h b/sql/sp_head.h
--- a/sql/sp_head.h	2008-01-25 13:27:10 -07:00
+++ b/sql/sp_head.h	2008-05-07 20:50:41 -06:00
@@ -152,8 +152,9 @@ class sp_head :private Query_arena
   sp_head(const sp_head &);	/**< Prevent use of these */
   void operator=(sp_head &);
 
-  MEM_ROOT main_mem_root;
 public:
+  MEM_ROOT main_mem_root;
+
   /** Possible values of m_flags */
   enum {
     HAS_RETURN= 1,              // For FUNCTIONs only: is set if has RETURN
diff -Nrup a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc
--- a/sql/sp_rcontext.cc	2008-04-29 17:34:13 -06:00
+++ b/sql/sp_rcontext.cc	2008-05-07 20:50:41 -06:00
@@ -29,10 +29,11 @@
 #include "sp_pcontext.h"
 
 
-sp_rcontext::sp_rcontext(sp_pcontext *root_parsing_ctx,
+sp_rcontext::sp_rcontext(sp_head *sp, sp_pcontext *root_parsing_ctx,
                          Field *return_value_fld,
                          sp_rcontext *prev_runtime_ctx)
-  :m_root_parsing_ctx(root_parsing_ctx),
+  :m_sp(sp),
+   m_root_parsing_ctx(root_parsing_ctx),
    m_var_table(0),
    m_var_items(0),
    m_return_value_fld(return_value_fld),
@@ -77,6 +78,9 @@ bool sp_rcontext::init(THD *thd)
     !(m_handler=
       (sp_handler_t*)thd->alloc(m_root_parsing_ctx->max_handler_index() *
                                 sizeof(sp_handler_t))) ||
+    !(m_raised_conditions=
+      (SQL_condition**)thd->alloc(m_root_parsing_ctx->max_handler_index() *
+                                  sizeof(SQL_condition*))) ||
     !(m_hstack=
       (uint*)thd->alloc(m_root_parsing_ctx->max_handler_index() *
                         sizeof(uint))) ||
@@ -269,7 +273,17 @@ sp_rcontext::find_handler(THD *thd, cons
       return m_prev_runtime_ctx->find_handler(thd, cond);
     return FALSE;
   }
+
   m_hfound= found;
+
+  /* FIXME: Fix class String to not use thd->mem_root */
+  MEM_ROOT *save_root= thd->mem_root;
+  thd->mem_root= & m_sp->main_mem_root;
+  SQL_condition *raised= new (thd->mem_root) SQL_condition();
+  raised->deep_copy(*cond);
+  m_raised_conditions[m_hfound]= raised;
+  thd->mem_root= save_root;
+
   return TRUE;
 }
 
@@ -401,6 +415,28 @@ sp_rcontext::exit_handler()
   m_ihsp-= 1;
   DBUG_PRINT("info", ("m_ihsp: %d", m_ihsp));
   DBUG_VOID_RETURN;
+}
+
+SQL_condition*
+sp_rcontext::raised_condition() const
+{
+  if (m_ihsp > 0)
+  {
+    uint hid= m_in_handler[m_ihsp - 1];
+    uint index;
+    for (index= 0 ; index < m_root_parsing_ctx->max_handler_index() ; index ++)
+    {
+      /* Resolve the handler instruction pointer (hip) to it's index */
+      if (m_handler[index].handler == hid)
+        return m_raised_conditions[index];
+    }
+    DBUG_ASSERT(FALSE);
+  }
+
+  if (m_prev_runtime_ctx)
+    return m_prev_runtime_ctx->raised_condition();
+
+  return NULL;
 }
 
 
diff -Nrup a/sql/sp_rcontext.h b/sql/sp_rcontext.h
--- a/sql/sp_rcontext.h	2008-04-29 17:34:13 -06:00
+++ b/sql/sp_rcontext.h	2008-05-07 20:50:41 -06:00
@@ -75,16 +75,10 @@ class sp_rcontext : public Sql_alloc
   */
   Query_arena *callers_arena;
 
-#ifndef DBUG_OFF
-  /*
-    The routine for which this runtime context is created. Used for checking
-    if correct runtime context is used for variable handling.
-  */
-  sp_head *sp;
-#endif
+  sp_head *m_sp;
 
-  sp_rcontext(sp_pcontext *root_parsing_ctx, Field *return_value_fld,
-              sp_rcontext *prev_runtime_ctx);
+  sp_rcontext(sp_head *sp, sp_pcontext *root_parsing_ctx,
+              Field *return_value_fld, sp_rcontext *prev_runtime_ctx);
   bool init(THD *thd);
 
   ~sp_rcontext();
@@ -130,6 +124,8 @@ class sp_rcontext : public Sql_alloc
     return m_handler[m_hfound].type;
   }
 
+  SQL_condition* raised_condition() const;
+
   // Returns true if we found a handler in this context
   inline bool
   found_handler_here()
@@ -212,6 +208,10 @@ private:
   bool in_sub_stmt;
 
   sp_handler_t *m_handler;      // Visible handlers
+
+  /** SQL condition stack caught by a handler */
+  SQL_condition ** m_raised_conditions;
+
   uint m_hcount;                // Stack pointer for m_handler
   uint *m_hstack;               // Return stack for continue handlers
   uint m_hsp;                   // Stack pointer for m_hstack
diff -Nrup a/sql/sql_class.cc b/sql/sql_class.cc
--- a/sql/sql_class.cc	2008-04-29 17:34:13 -06:00
+++ b/sql/sql_class.cc	2008-05-07 20:50:42 -06:00
@@ -778,7 +778,6 @@ void THD::raise_note_printf(uint code, c
 
 void THD::raise_condition(const SQL_condition *cond)
 {
-  MYSQL_ERROR *err;
   const char* msg= cond->get_message_text();
 
   DBUG_ENTER("THD::raise_condition");
@@ -834,6 +833,17 @@ void THD::raise_condition(const SQL_cond
 
   /* Un-handled conditions */
 
+  raise_condition_no_handler(cond);
+  DBUG_VOID_RETURN;
+}
+
+void THD::raise_condition_no_handler(const SQL_condition *cond)
+{
+  MYSQL_ERROR *err;
+  const char* msg= cond->get_message_text();
+
+  DBUG_ENTER("THD::raise_condition_no_handler");
+
   query_cache_abort(& query_cache_tls);
 
   if (warn_list.elements < variables.max_error_count)
@@ -847,7 +857,6 @@ void THD::raise_condition(const SQL_cond
   total_warn_count++;
   DBUG_VOID_RETURN;
 }
-
 
 extern "C"
 void *thd_alloc(MYSQL_THD thd, unsigned int size)
diff -Nrup a/sql/sql_class.h b/sql/sql_class.h
--- a/sql/sql_class.h	2008-05-06 17:05:32 -06:00
+++ b/sql/sql_class.h	2008-05-07 20:50:42 -06:00
@@ -1136,17 +1136,22 @@ public:
 
   void set_string(THD *thd, String *value);
 
+  void deep_copy(const UTF8String64& str);
+
 private:
   String m_value;
 };
 
-class SQL_condition
+class SQL_condition : public Sql_alloc
 {
 public:
   SQL_condition();
+
   ~SQL_condition()
   {}
 
+  void deep_copy(const SQL_condition& cond);
+
   void set(uint code, const char *str,
            MYSQL_ERROR::enum_warning_level level, myf MyFlags);
 
@@ -2441,6 +2446,7 @@ public:
   void raise_note_printf(uint code, const char *format, ...);
 
   void raise_condition(const SQL_condition *cond);
+  void raise_condition_no_handler(const SQL_condition *cond);
 
 private:
   /** The current internal error handler for this thread, or NULL. */
diff -Nrup a/sql/sql_signal.cc b/sql/sql_signal.cc
--- a/sql/sql_signal.cc	2008-05-06 17:05:32 -06:00
+++ b/sql/sql_signal.cc	2008-05-07 20:50:42 -06:00
@@ -99,8 +99,17 @@ void UTF8String64::set_string(THD *thd, 
   (void) m_value.c_ptr_safe();
 }
 
+void
+UTF8String64::deep_copy(const UTF8String64& str)
+{
+  m_value.length(0);
+  m_value.append(str.m_value);
+  (void) m_value.c_ptr_safe();
+}
+
 SQL_condition::SQL_condition()
- : m_class_origin(),
+ : Sql_alloc(),
+   m_class_origin(),
    m_subclass_origin(),
    m_constraint_catalog(),
    m_constraint_schema(),
@@ -137,6 +146,47 @@ SQL_condition::SQL_condition()
 }
 
 void
+SQL_condition::deep_copy(const SQL_condition& cond)
+{
+  memcpy(m_returned_sqlstate, cond.m_returned_sqlstate,
+         sizeof(m_returned_sqlstate));
+
+  m_message_text.set_charset(& my_charset_utf8_bin);
+  m_message_text.length(0);
+  m_message_text.append(cond.m_message_text);
+
+  m_class_origin.deep_copy(cond.m_class_origin);
+  m_subclass_origin.deep_copy(cond.m_subclass_origin);
+  m_constraint_catalog.deep_copy(cond.m_constraint_catalog);
+  m_constraint_schema.deep_copy(cond.m_constraint_schema);
+  m_constraint_name.deep_copy(cond.m_constraint_name);
+  m_catalog_name.deep_copy(cond.m_catalog_name);
+  m_schema_name.deep_copy(cond.m_schema_name);
+  m_table_name.deep_copy(cond.m_table_name);
+  m_column_name.deep_copy(cond.m_column_name);
+  m_cursor_name.deep_copy(cond.m_cursor_name);
+  m_sqlcode= cond.m_sqlcode;
+  m_condition_identifier.deep_copy(cond.m_condition_identifier);
+  condition_number= cond.condition_number;
+  m_connection_name.deep_copy(cond.m_connection_name);
+  m_message_length= cond.m_message_length;
+  m_message_octet_length= cond.m_message_octet_length;
+  m_parameter_mode.deep_copy(cond.m_parameter_mode);
+  m_parameter_name.deep_copy(cond.m_parameter_name);
+  m_parameter_ordinal_position= cond.m_parameter_ordinal_position;
+  m_routine_catalog.deep_copy(cond.m_routine_catalog);
+  m_routine_name.deep_copy(cond.m_routine_name);
+  m_routine_schema.deep_copy(cond.m_routine_schema);
+  m_server_name.deep_copy(cond.m_server_name);
+  m_specific_name.deep_copy(cond.m_specific_name);
+  m_trigger_catalog.deep_copy(cond.m_trigger_catalog);
+  m_trigger_name.deep_copy(cond.m_trigger_name);
+  m_trigger_schema.deep_copy(cond.m_trigger_schema);
+  m_level= cond.m_level;
+  m_flags= cond.m_flags;
+}
+
+void
 SQL_condition::set(uint code, const char *str,
                    MYSQL_ERROR::enum_warning_level level, myf flags)
 {
@@ -256,22 +306,21 @@ int SQLCOM_statement::open_and_lock_all_
 
 int Abstract_signal::eval_sqlcode_sqlstate(THD *thd, SQL_condition *cond)
 {
-  if (m_cond != NULL)
+  DBUG_ASSERT(m_cond);
+
+  switch(m_cond->type)
   {
-    switch(m_cond->type)
-    {
-      case sp_cond_type::number:
-        cond->m_sqlcode= m_cond->mysqlerr;
-        cond->set_sqlstate(mysql_errno_to_sqlstate(cond->m_sqlcode));
-        break;
-      case sp_cond_type::state:
-        cond->m_sqlcode= 0;
-        cond->set_sqlstate(m_cond->sqlstate);
-        break;
-      default:
-        DBUG_ASSERT(FALSE);
-        break;
-    }
+    case sp_cond_type::number:
+      cond->m_sqlcode= m_cond->mysqlerr;
+      cond->set_sqlstate(mysql_errno_to_sqlstate(cond->m_sqlcode));
+      break;
+    case sp_cond_type::state:
+      cond->m_sqlcode= 0;
+      cond->set_sqlstate(m_cond->sqlstate);
+      break;
+    default:
+      DBUG_ASSERT(FALSE);
+      break;
   }
 
   return 0;
@@ -435,16 +484,11 @@ int Abstract_signal::eval_signal_informa
   DBUG_RETURN(0);
 }
 
-int SQLCOM_signal::execute(THD *thd)
+int Abstract_signal::raise_condition(THD *thd, SQL_condition *cond)
 {
   int result= 1;
-  SQL_condition cond;
 
-  DBUG_ENTER("SQLCOM_signal::execute");
-
-  thd->main_da.reset_diagnostics_area();
-  thd->row_count_func= 0;
-  mysql_reset_errors(thd, TRUE);
+  DBUG_ENTER("Abstract_signal::raise_condition");
 
   if (check_all_tables_access(thd, SELECT_ACL))
     DBUG_RETURN(result);
@@ -452,22 +496,25 @@ int SQLCOM_signal::execute(THD *thd)
   if (open_and_lock_all_tables(thd))
     DBUG_RETURN(result);
 
-  if (eval_sqlcode_sqlstate(thd, & cond))
-    DBUG_RETURN(result);
+  if (m_cond != NULL)
+  {
+    if (eval_sqlcode_sqlstate(thd, cond))
+      DBUG_RETURN(result);
 
-  if (eval_defaults(thd, & cond))
-    DBUG_RETURN(result);
+    if (eval_defaults(thd, cond))
+      DBUG_RETURN(result);
+  }
 
-  if (eval_signal_informations(thd, & cond))
+  if (eval_signal_informations(thd, cond))
     DBUG_RETURN(result);
 
   /* SIGNAL should not signal WARN_LEVEL_NOTE */
-  DBUG_ASSERT((cond.m_level == MYSQL_ERROR::WARN_LEVEL_WARN) ||
-              (cond.m_level == MYSQL_ERROR::WARN_LEVEL_ERROR));
+  DBUG_ASSERT((cond->m_level == MYSQL_ERROR::WARN_LEVEL_WARN) ||
+              (cond->m_level == MYSQL_ERROR::WARN_LEVEL_ERROR));
 
-  thd->raise_condition(& cond);
+  thd->raise_condition(cond);
 
-  if (cond.m_level == MYSQL_ERROR::WARN_LEVEL_WARN)
+  if (cond->m_level == MYSQL_ERROR::WARN_LEVEL_WARN)
   {
     my_ok(thd);
     result= 0;
@@ -476,11 +523,49 @@ int SQLCOM_signal::execute(THD *thd)
   DBUG_RETURN(result);
 }
 
+int SQLCOM_signal::execute(THD *thd)
+{
+  int result= 1;
+  SQL_condition cond;
+
+  DBUG_ENTER("SQLCOM_signal::execute");
+
+  thd->main_da.reset_diagnostics_area();
+  thd->row_count_func= 0;
+  mysql_reset_errors(thd, TRUE);
+
+  result= raise_condition(thd, &cond);
+
+  DBUG_RETURN(result);
+}
+
+
 int SQLCOM_resignal::execute(THD *thd)
 {
+  SQL_condition *signaled;
+  int result= 1;
+
   DBUG_ENTER("SQLCOM_resignal::execute");
-  my_error(ER_NOT_SUPPORTED_YET, MYF(0), "RESIGNAL");
-  DBUG_RETURN(1);
+
+  if (! thd->spcont || ! (signaled= thd->spcont->raised_condition()))
+  {
+    my_error(ER_RESIGNAL_NO_HANDLER, MYF(0));
+    DBUG_RETURN(result);
+  }
+
+  if (m_cond == NULL)
+  {
+    /* RESIGNAL without signal_value */
+    result= raise_condition(thd, signaled);
+    DBUG_RETURN(result);
+  }
+
+  /* RESIGNAL with signal_value */
+  thd->raise_condition_no_handler(signaled);
+
+  SQL_condition new_cond;
+  result= raise_condition(thd, & new_cond);
+  DBUG_RETURN(result);
 }
 
 int SQLCOM_get_diag::execute(THD *thd)
diff -Nrup a/sql/sql_signal.h b/sql/sql_signal.h
--- a/sql/sql_signal.h	2008-05-02 17:08:24 -06:00
+++ b/sql/sql_signal.h	2008-05-07 20:50:42 -06:00
@@ -34,6 +34,8 @@ protected:
   int eval_defaults(THD *thd, SQL_condition *cond);
   int eval_signal_informations(THD *thd, SQL_condition *cond);
 
+  int raise_condition(THD *thd, SQL_condition *cond);
+
   const sp_cond_type_t *m_cond;
   Set_signal_information m_set_signal_information;
 };
Thread
bk commit into 6.0 tree (malff:1.2641) WL#2110marc.alff8 May