List:Commits« Previous MessageNext Message »
From:marc.alff Date:April 14 2008 6:08pm
Subject:bk commit into 6.0 tree (malff:1.2627) BUG#11661 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-04-14 12:07:57-06:00, malff@stripped. +14 -0
  WL#2110 (Stored Procedures: Implement SIGNAL)
  WL#2265 (Stored Procedures: Implement RESIGNAL)
  WL#2111 (Stored Procedures: Implement GET DIAGNOSTICS)
  Bug#11661 (Raising Exceptions from within stored procedures: Support for
    SIGNAL statement)
  
  Part I: Syntax
  
  This patch implements syntax parsing for the following statements:
  - SIGNAL
  - RESIGNAL
  - GET DIAGNOSTICS
  
  Runtime execution of these statements is not implemented in this patch,
  and will be posted separately.

  libmysqld/Makefile.am@stripped, 2008-04-14 12:07:51-06:00, malff@stripped. +2 -1
    SIGNAL / RESIGNAL / GET DIAGNOSTICS

  mysql-test/r/signal.result@stripped, 2008-04-14 12:07:52-06:00, malff@stripped. +1076 -0
    SIGNAL / RESIGNAL / GET DIAGNOSTICS
    

  mysql-test/r/signal.result@stripped, 2008-04-14 12:07:52-06:00, malff@stripped. +0 -0

  mysql-test/r/signal_code.result@stripped, 2008-04-14 12:07:52-06:00, malff@stripped. +51 -0
    SIGNAL / RESIGNAL / GET DIAGNOSTICS
    

  mysql-test/r/signal_code.result@stripped, 2008-04-14 12:07:52-06:00, malff@stripped. +0 -0

  mysql-test/t/signal.test@stripped, 2008-04-14 12:07:52-06:00, malff@stripped. +1292 -0
    SIGNAL / RESIGNAL / GET DIAGNOSTICS
    

  mysql-test/t/signal.test@stripped, 2008-04-14 12:07:52-06:00, malff@stripped. +0 -0

  mysql-test/t/signal_code.test@stripped, 2008-04-14 12:07:53-06:00, malff@stripped. +63 -0
    SIGNAL / RESIGNAL / GET DIAGNOSTICS
    

  mysql-test/t/signal_code.test@stripped, 2008-04-14 12:07:53-06:00, malff@stripped. +0 -0

  sql/Makefile.am@stripped, 2008-04-14 12:07:51-06:00, malff@stripped. +3 -2
    SIGNAL / RESIGNAL / GET DIAGNOSTICS

  sql/item_create.cc@stripped, 2008-04-14 12:07:52-06:00, malff@stripped. +0 -25
    SIGNAL / RESIGNAL / GET DIAGNOSTICS

  sql/lex.h@stripped, 2008-04-14 12:07:52-06:00, malff@stripped. +45 -0
    SIGNAL / RESIGNAL / GET DIAGNOSTICS

  sql/sql_class.cc@stripped, 2008-04-14 12:07:52-06:00, malff@stripped. +1 -0
    SIGNAL / RESIGNAL / GET DIAGNOSTICS

  sql/sql_class.h@stripped, 2008-04-14 12:07:52-06:00, malff@stripped. +136 -0
    SIGNAL / RESIGNAL / GET DIAGNOSTICS

  sql/sql_parse.cc@stripped, 2008-04-14 12:07:52-06:00, malff@stripped. +5 -0
    SIGNAL / RESIGNAL / GET DIAGNOSTICS

  sql/sql_signal.cc@stripped, 2008-04-14 12:07:52-06:00, malff@stripped. +103 -0
    SIGNAL / RESIGNAL / GET DIAGNOSTICS
    

  sql/sql_signal.cc@stripped, 2008-04-14 12:07:52-06:00, malff@stripped. +0 -0

  sql/sql_signal.h@stripped, 2008-04-14 12:07:52-06:00, malff@stripped. +129 -0
    SIGNAL / RESIGNAL / GET DIAGNOSTICS
    

  sql/sql_signal.h@stripped, 2008-04-14 12:07:52-06:00, malff@stripped. +0 -0

  sql/sql_yacc.yy@stripped, 2008-04-14 12:07:52-06:00, malff@stripped. +510 -2
    SIGNAL / RESIGNAL / GET DIAGNOSTICS

diff -Nrup a/libmysqld/Makefile.am b/libmysqld/Makefile.am
--- a/libmysqld/Makefile.am	2008-03-27 16:40:58 -06:00
+++ b/libmysqld/Makefile.am	2008-04-14 12:07:51 -06:00
@@ -82,7 +82,8 @@ sqlsources = derror.cc field.cc field_co
 	rpl_filter.cc sql_partition.cc sql_builtin.cc sql_plugin.cc \
 	sql_tablespace.cc \
 	rpl_injector.cc my_user.c partition_info.cc \
-	sql_servers.cc ddl_blocker.cc si_objects.cc sql_audit.cc
+	sql_servers.cc ddl_blocker.cc si_objects.cc sql_audit.cc \
+	sql_signal.cc
 
 libmysqld_int_a_SOURCES= $(libmysqld_sources)
 nodist_libmysqld_int_a_SOURCES= $(libmysqlsources) $(sqlsources)
diff -Nrup a/mysql-test/r/signal.result b/mysql-test/r/signal.result
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/mysql-test/r/signal.result	2008-04-14 12:07:52 -06:00
@@ -0,0 +1,1076 @@
+drop table if exists signal_non_reserved;
+create table signal_non_reserved (
+class_origin int,
+subclass_origin int,
+constraint_catalog int,
+constraint_schema int,
+constraint_name int,
+catalog_name int,
+schema_name int,
+table_name int,
+column_name int,
+cursor_name int,
+message_text int 
+);
+drop table signal_non_reserved;
+drop table if exists diag_non_reserved;
+create table diag_non_reserved (
+diagnostics int,
+current int,
+stacked int,
+exception int,
+condition int
+);
+drop table diag_non_reserved;
+drop table if exists diag_cond_non_reserved;
+create table diag_cond_non_reserved (
+condition_identifier int,
+condition_number int,
+condition_name int,
+connection_name int,
+message_length int,
+message_octet_length int,
+parameter_mode int,
+parameter_name int,
+parameter_ordinal_position int,
+returned_sqlstate int,
+routine_catalog int,
+routine_name int,
+routine_schema int,
+server_name int,
+specific_name int,
+trigger_catalog int,
+trigger_name int,
+trigger_schema int
+);
+drop table diag_cond_non_reserved;
+drop table if exists diag_stmt_non_reserved;
+create table diag_stmt_non_reserved (
+number int,
+more int,
+command_function int,
+command_function_code int,
+dynamic_function int,
+dynamic_function_code int,
+row_count int,
+transactions_committed int,
+transactions_rolled_back int,
+transaction_active int
+);
+drop table diag_stmt_non_reserved;
+drop table if exists test_reserved;
+create table test_reserved (signal int);
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'signal int)' at line 1
+create table test_reserved (resignal int);
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'resignal int)' at line 1
+create table test_reserved (get int);
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'get int)' at line 1
+SIGNAL foo;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SIGNAL foo' at line 1
+SIGNAL SQLSTATE '23000';
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SIGNAL SQLSTATE '23000'' at line 1
+SIGNAL SQLSTATE VALUE '23000';
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SIGNAL SQLSTATE VALUE '23000'' at line 1
+drop procedure if exists test_invalid;
+drop procedure if exists test_signal;
+create procedure test_invalid()
+begin
+SIGNAL;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ';
+end' at line 3
+create procedure test_invalid()
+begin
+SIGNAL foo;
+end $$
+ERROR 42000: Undefined CONDITION: foo
+create procedure test_signal_syntax()
+begin
+DECLARE foo CONDITION FOR 1234;
+SIGNAL foo;
+end $$
+drop procedure test_signal_syntax $$
+create procedure test_signal_syntax()
+begin
+SIGNAL SQLSTATE '23000';
+end $$
+drop procedure test_signal_syntax $$
+create procedure test_signal_syntax()
+begin
+SIGNAL SQLSTATE VALUE '23000';
+end $$
+drop procedure test_signal_syntax $$
+create procedure test_signal_syntax()
+begin
+DECLARE foo CONDITION FOR 1234;
+SIGNAL foo SET CLASS_ORIGIN = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+create procedure test_signal_syntax()
+begin
+DECLARE foo CONDITION FOR 1234;
+SIGNAL foo SET SUBCLASS_ORIGIN = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+create procedure test_signal_syntax()
+begin
+DECLARE foo CONDITION FOR 1234;
+SIGNAL foo SET CONSTRAINT_CATALOG = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+create procedure test_signal_syntax()
+begin
+DECLARE foo CONDITION FOR 1234;
+SIGNAL foo SET CONSTRAINT_SCHEMA = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+create procedure test_signal_syntax()
+begin
+DECLARE foo CONDITION FOR 1234;
+SIGNAL foo SET CONSTRAINT_NAME = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+create procedure test_signal_syntax()
+begin
+DECLARE foo CONDITION FOR 1234;
+SIGNAL foo SET CATALOG_NAME = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+create procedure test_signal_syntax()
+begin
+DECLARE foo CONDITION FOR 1234;
+SIGNAL foo SET SCHEMA_NAME = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+create procedure test_signal_syntax()
+begin
+DECLARE foo CONDITION FOR 1234;
+SIGNAL foo SET TABLE_NAME = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+create procedure test_signal_syntax()
+begin
+DECLARE foo CONDITION FOR 1234;
+SIGNAL foo SET COLUMN_NAME = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+create procedure test_signal_syntax()
+begin
+DECLARE foo CONDITION FOR 1234;
+SIGNAL foo SET CURSOR_NAME = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+create procedure test_signal_syntax()
+begin
+DECLARE foo CONDITION FOR 1234;
+SIGNAL foo SET MESSAGE_TEXT = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+create procedure test_invalid()
+begin
+DECLARE foo CONDITION FOR 1234;
+SIGNAL foo SET MESSAGE_TEXT = 'foo', MESSAGE_TEXT = 'bar';
+end $$
+ERROR HY000: Incorrect usage of SIGNAL/RESIGNAL and SET
+create procedure test_signal_syntax()
+begin
+DECLARE foo CONDITION FOR 1234;
+SIGNAL foo SET
+CLASS_ORIGIN = 'foo',
+SUBCLASS_ORIGIN = 'foo',
+CONSTRAINT_CATALOG = 'foo',
+CONSTRAINT_SCHEMA = 'foo',
+CONSTRAINT_NAME = 'foo',
+CATALOG_NAME = 'foo',
+SCHEMA_NAME = 'foo',
+TABLE_NAME = 'foo',
+COLUMN_NAME = 'foo',
+CURSOR_NAME = 'foo',
+MESSAGE_TEXT = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+create procedure test_invalid()
+begin
+SIGNAL SQLSTATE '00000';
+end $$
+ERROR 42000: Bad SQLSTATE: '00000'
+create procedure test_invalid()
+begin
+SIGNAL SQLSTATE '12345' SET bla_bla = 'foo';
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'bla_bla = 'foo';
+end' at line 3
+create procedure test_invalid()
+begin
+SIGNAL SQLSTATE '12345' SET CONDITION_IDENTIFIER = 'foo';
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CONDITION_IDENTIFIER = 'foo';
+end' at line 3
+create procedure test_invalid()
+begin
+SIGNAL SQLSTATE '12345' SET CONDITION_NUMBER = 'foo';
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CONDITION_NUMBER = 'foo';
+end' at line 3
+create procedure test_invalid()
+begin
+SIGNAL SQLSTATE '12345' SET CONNECTION_NAME = 'foo';
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CONNECTION_NAME = 'foo';
+end' at line 3
+create procedure test_invalid()
+begin
+SIGNAL SQLSTATE '12345' SET MESSAGE_LENGTH = 'foo';
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MESSAGE_LENGTH = 'foo';
+end' at line 3
+create procedure test_invalid()
+begin
+SIGNAL SQLSTATE '12345' SET MESSAGE_OCTET_LENGTH = 'foo';
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MESSAGE_OCTET_LENGTH = 'foo';
+end' at line 3
+create procedure test_invalid()
+begin
+SIGNAL SQLSTATE '12345' SET PARAMETER_MODE = 'foo';
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PARAMETER_MODE = 'foo';
+end' at line 3
+create procedure test_invalid()
+begin
+SIGNAL SQLSTATE '12345' SET PARAMETER_NAME = 'foo';
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PARAMETER_NAME = 'foo';
+end' at line 3
+create procedure test_invalid()
+begin
+SIGNAL SQLSTATE '12345' SET PARAMETER_ORDINAL_POSITION = 'foo';
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PARAMETER_ORDINAL_POSITION = 'foo';
+end' at line 3
+create procedure test_invalid()
+begin
+SIGNAL SQLSTATE '12345' SET RETURNED_SQLSTATE = 'foo';
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RETURNED_SQLSTATE = 'foo';
+end' at line 3
+create procedure test_invalid()
+begin
+SIGNAL SQLSTATE '12345' SET ROUTINE_CATALOG = 'foo';
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ROUTINE_CATALOG = 'foo';
+end' at line 3
+create procedure test_invalid()
+begin
+SIGNAL SQLSTATE '12345' SET ROUTINE_NAME = 'foo';
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ROUTINE_NAME = 'foo';
+end' at line 3
+create procedure test_invalid()
+begin
+SIGNAL SQLSTATE '12345' SET ROUTINE_SCHEMA = 'foo';
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ROUTINE_SCHEMA = 'foo';
+end' at line 3
+create procedure test_invalid()
+begin
+SIGNAL SQLSTATE '12345' SET SERVER_NAME = 'foo';
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SERVER_NAME = 'foo';
+end' at line 3
+create procedure test_invalid()
+begin
+SIGNAL SQLSTATE '12345' SET SPECIFIC_NAME = 'foo';
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SPECIFIC_NAME = 'foo';
+end' at line 3
+create procedure test_invalid()
+begin
+SIGNAL SQLSTATE '12345' SET TRIGGER_CATALOG = 'foo';
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TRIGGER_CATALOG = 'foo';
+end' at line 3
+create procedure test_invalid()
+begin
+SIGNAL SQLSTATE '12345' SET TRIGGER_NAME = 'foo';
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TRIGGER_NAME = 'foo';
+end' at line 3
+create procedure test_invalid()
+begin
+SIGNAL SQLSTATE '12345' SET TRIGGER_SCHEMA = 'foo';
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TRIGGER_SCHEMA = 'foo';
+end' at line 3
+RESIGNAL;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RESIGNAL' at line 1
+RESIGNAL foo;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RESIGNAL foo' at line 1
+RESIGNAL SQLSTATE '12345';
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RESIGNAL SQLSTATE '12345'' at line 1
+RESIGNAL SQLSTATE VALUE '12345';
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RESIGNAL SQLSTATE VALUE '12345'' at line 1
+drop procedure if exists test_invalid;
+drop procedure if exists test_resignal_syntax;
+create procedure test_invalid()
+begin
+RESIGNAL foo;
+end $$
+ERROR 42000: Undefined CONDITION: foo
+create procedure test_resignal_syntax()
+begin
+RESIGNAL;
+end $$
+drop procedure test_resignal_syntax $$
+create procedure test_resignal_syntax()
+begin
+DECLARE foo CONDITION FOR 1234;
+RESIGNAL foo;
+end $$
+drop procedure test_resignal_syntax $$
+create procedure test_resignal_syntax()
+begin
+RESIGNAL SQLSTATE '23000';
+end $$
+drop procedure test_resignal_syntax $$
+create procedure test_resignal_syntax()
+begin
+RESIGNAL SQLSTATE VALUE '23000';
+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
+DECLARE foo CONDITION FOR 1234;
+RESIGNAL foo SET SUBCLASS_ORIGIN = '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
+DECLARE foo CONDITION FOR 1234;
+RESIGNAL foo 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_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
+DECLARE foo CONDITION FOR 1234;
+RESIGNAL foo SET SCHEMA_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
+DECLARE foo CONDITION FOR 1234;
+RESIGNAL foo SET COLUMN_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
+DECLARE foo CONDITION FOR 1234;
+RESIGNAL foo SET MESSAGE_TEXT = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+create procedure test_invalid()
+begin
+DECLARE foo CONDITION FOR 1234;
+RESIGNAL foo SET MESSAGE_TEXT = 'foo', MESSAGE_TEXT = 'bar';
+end $$
+ERROR HY000: Incorrect usage of SIGNAL/RESIGNAL and SET
+create procedure test_resignal_syntax()
+begin
+DECLARE foo CONDITION FOR 1234;
+RESIGNAL foo SET
+CLASS_ORIGIN = 'foo',
+SUBCLASS_ORIGIN = 'foo',
+CONSTRAINT_CATALOG = 'foo',
+CONSTRAINT_SCHEMA = 'foo',
+CONSTRAINT_NAME = 'foo',
+CATALOG_NAME = 'foo',
+SCHEMA_NAME = 'foo',
+TABLE_NAME = 'foo',
+COLUMN_NAME = 'foo',
+CURSOR_NAME = 'foo',
+MESSAGE_TEXT = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+create procedure test_invalid()
+begin
+RESIGNAL SQLSTATE '00000';
+end $$
+ERROR 42000: Bad SQLSTATE: '00000'
+GET DIAGNOSTICS @foo = NUMBER;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GET DIAGNOSTICS @foo = NUMBER' at line 1
+GET CURRENT DIAGNOSTICS @foo = NUMBER;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GET CURRENT DIAGNOSTICS @foo = NUMBER' at line 1
+GET STACKED DIAGNOSTICS @foo = NUMBER;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GET STACKED DIAGNOSTICS @foo = NUMBER' at line 1
+drop procedure if exists test_invalid;
+drop procedure if exists test_diag_syntax;
+create procedure test_invalid()
+begin
+GET DIAGNOSTICS foo = NUMBER;
+end $$
+ERROR 42000: Undeclared variable: foo
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = NUMBER;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax(OUT foo integer)
+begin
+GET DIAGNOSTICS foo = NUMBER;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+GET DIAGNOSTICS @foo = NUMBER;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET CURRENT DIAGNOSTICS foo = NUMBER;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET STACKED DIAGNOSTICS foo = NUMBER;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = MORE;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = COMMAND_FUNCTION;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = COMMAND_FUNCTION_CODE;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = DYNAMIC_FUNCTION;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = DYNAMIC_FUNCTION_CODE;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = ROW_COUNT;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = TRANSACTIONS_COMMITTED;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = TRANSACTIONS_ROLLED_BACK;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = TRANSACTION_ACTIVE;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo1 integer;
+DECLARE foo2 integer;
+DECLARE foo3 integer;
+DECLARE foo4 integer;
+DECLARE foo5 integer;
+DECLARE foo6 integer;
+DECLARE foo7 integer;
+DECLARE foo8 integer;
+DECLARE foo9 integer;
+DECLARE foo10 integer;
+GET DIAGNOSTICS
+foo1 = NUMBER,
+foo2 = MORE,
+foo3 = COMMAND_FUNCTION,
+foo4 = COMMAND_FUNCTION_CODE,
+foo5 = DYNAMIC_FUNCTION,
+foo6 = DYNAMIC_FUNCTION_CODE,
+foo7 = ROW_COUNT,
+foo8 = TRANSACTIONS_COMMITTED,
+foo9 = TRANSACTIONS_ROLLED_BACK,
+foo10 = TRANSACTION_ACTIVE;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = abcdef;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'abcdef;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = CLASS_ORIGIN;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CLASS_ORIGIN;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = SUBCLASS_ORIGIN;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SUBCLASS_ORIGIN;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = CONSTRAINT_CATALOG;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CONSTRAINT_CATALOG;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = CONSTRAINT_SCHEMA;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CONSTRAINT_SCHEMA;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = CONSTRAINT_NAME;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CONSTRAINT_NAME;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = CATALOG_NAME;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CATALOG_NAME;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = SCHEMA_NAME;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SCHEMA_NAME;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = TABLE_NAME;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TABLE_NAME;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = COLUMN_NAME;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'COLUMN_NAME;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = CURSOR_NAME;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CURSOR_NAME;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = MESSAGE_TEXT;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MESSAGE_TEXT;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = CONDITION_IDENTIFIER;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CONDITION_IDENTIFIER;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = CONDITION_NUMBER;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CONDITION_NUMBER;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = CONNECTION_NAME;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CONNECTION_NAME;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = MESSAGE_LENGTH;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MESSAGE_LENGTH;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = MESSAGE_OCTET_LENGTH;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MESSAGE_OCTET_LENGTH;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = PARAMETER_MODE;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PARAMETER_MODE;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = PARAMETER_NAME;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PARAMETER_NAME;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = PARAMETER_ORDINAL_POSITION;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PARAMETER_ORDINAL_POSITION;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = RETURNED_SQLSTATE;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RETURNED_SQLSTATE;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = ROUTINE_CATALOG;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ROUTINE_CATALOG;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = ROUTINE_NAME;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ROUTINE_NAME;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = ROUTINE_SCHEMA;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ROUTINE_SCHEMA;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = SERVER_NAME;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SERVER_NAME;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = SPECIFIC_NAME;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SPECIFIC_NAME;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = TRIGGER_CATALOG;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TRIGGER_CATALOG;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = TRIGGER_NAME;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TRIGGER_NAME;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS foo = TRIGGER_SCHEMA;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TRIGGER_SCHEMA;
+end' at line 4
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS EXCEPTION 0 foo = CLASS_ORIGIN;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = CLASS_ORIGIN;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = SUBCLASS_ORIGIN;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = CONSTRAINT_CATALOG;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = CONSTRAINT_SCHEMA;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = CONSTRAINT_NAME;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = CATALOG_NAME;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = SCHEMA_NAME;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = TABLE_NAME;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = COLUMN_NAME;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = CURSOR_NAME;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = MESSAGE_TEXT;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = CONDITION_IDENTIFIER;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = CONDITION_NUMBER;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = CONNECTION_NAME;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = MESSAGE_LENGTH;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = MESSAGE_OCTET_LENGTH;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = PARAMETER_MODE;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = PARAMETER_NAME;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = PARAMETER_ORDINAL_POSITION;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = RETURNED_SQLSTATE;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = ROUTINE_CATALOG;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = ROUTINE_NAME;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = ROUTINE_SCHEMA;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = SERVER_NAME;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = SPECIFIC_NAME;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = TRIGGER_CATALOG;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = TRIGGER_NAME;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = TRIGGER_SCHEMA;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_diag_syntax()
+begin
+DECLARE foo1 integer;
+DECLARE foo2 integer;
+DECLARE foo3 integer;
+DECLARE foo4 integer;
+DECLARE foo5 integer;
+DECLARE foo6 integer;
+DECLARE foo7 integer;
+DECLARE foo8 integer;
+DECLARE foo9 integer;
+DECLARE foo10 integer;
+DECLARE foo11 integer;
+DECLARE foo12 integer;
+DECLARE foo13 integer;
+DECLARE foo14 integer;
+DECLARE foo15 integer;
+DECLARE foo16 integer;
+DECLARE foo17 integer;
+DECLARE foo18 integer;
+DECLARE foo19 integer;
+DECLARE foo20 integer;
+DECLARE foo21 integer;
+DECLARE foo22 integer;
+DECLARE foo23 integer;
+DECLARE foo24 integer;
+DECLARE foo25 integer;
+DECLARE foo26 integer;
+DECLARE foo27 integer;
+DECLARE foo28 integer;
+DECLARE foo29 integer;
+GET DIAGNOSTICS CONDITION 0
+foo1 = CLASS_ORIGIN,
+foo2 = SUBCLASS_ORIGIN,
+foo3 = CONSTRAINT_CATALOG,
+foo4 = CONSTRAINT_SCHEMA,
+foo5 = CONSTRAINT_NAME,
+foo6 = CATALOG_NAME,
+foo7 = SCHEMA_NAME,
+foo8 = TABLE_NAME,
+foo9 = COLUMN_NAME,
+foo10 = CURSOR_NAME,
+foo11 = MESSAGE_TEXT,
+foo12 = CONDITION_IDENTIFIER,
+foo13 = CONDITION_NUMBER,
+foo14 = CONNECTION_NAME,
+foo15 = MESSAGE_LENGTH,
+foo16 = MESSAGE_OCTET_LENGTH,
+foo17 = PARAMETER_MODE,
+foo18 = PARAMETER_NAME,
+foo19 = PARAMETER_ORDINAL_POSITION,
+foo20 = RETURNED_SQLSTATE,
+foo21 = ROUTINE_CATALOG,
+foo22 = ROUTINE_NAME,
+foo23 = ROUTINE_SCHEMA,
+foo24 = SERVER_NAME,
+foo25 = SPECIFIC_NAME,
+foo26 = TRIGGER_CATALOG,
+foo27 = TRIGGER_NAME,
+foo28 = TRIGGER_SCHEMA;
+end $$
+drop procedure test_diag_syntax $$
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = abcdef;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'abcdef;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = NUMBER;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NUMBER;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = MORE;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MORE;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = COMMAND_FUNCTION;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'COMMAND_FUNCTION;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = COMMAND_FUNCTION_CODE;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'COMMAND_FUNCTION_CODE;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = DYNAMIC_FUNCTION;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DYNAMIC_FUNCTION;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = DYNAMIC_FUNCTION_CODE;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DYNAMIC_FUNCTION_CODE;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = ROW_COUNT;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ROW_COUNT;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = TRANSACTIONS_COMMITTED;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TRANSACTIONS_COMMITTED;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = TRANSACTIONS_ROLLED_BACK;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TRANSACTIONS_ROLLED_BACK;
+end' at line 4
+create procedure test_invalid()
+begin
+DECLARE foo integer;
+GET DIAGNOSTICS CONDITION 0 foo = TRANSACTION_ACTIVE;
+end $$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TRANSACTION_ACTIVE;
+end' at line 4
+prepare stmt from 'SIGNAL SQLSTATE \'23000\'';
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SIGNAL SQLSTATE '23000'' at line 1
+prepare stmt from 'RESIGNAL SQLSTATE \'23000\'';
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RESIGNAL SQLSTATE '23000'' at line 1
+prepare stmt from 'GET DIAGNOSTICS foo = NUMBER';
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GET DIAGNOSTICS foo = NUMBER' at line 1
diff -Nrup a/mysql-test/r/signal_code.result b/mysql-test/r/signal_code.result
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/mysql-test/r/signal_code.result	2008-04-14 12:07:52 -06:00
@@ -0,0 +1,51 @@
+use test;
+drop procedure if exists signal_proc;
+drop function if exists signal_func;
+create procedure signal_proc()
+begin
+DECLARE v, v1, v2 integer;
+DECLARE foo CONDITION FOR 1234;
+SIGNAL foo;
+SIGNAL foo SET MESSAGE_TEXT = "This is an error message";
+RESIGNAL foo;
+RESIGNAL foo SET MESSAGE_TEXT = "This is an error message";
+GET DIAGNOSTICS v = NUMBER;
+GET CURRENT DIAGNOSTICS v1 = NUMBER, v2 = MORE;
+end $$
+create function signal_func() returns int
+begin
+DECLARE v, v1, v2 integer;
+DECLARE foo CONDITION FOR 1234;
+SIGNAL foo;
+SIGNAL foo SET MESSAGE_TEXT = "This is an error message";
+RESIGNAL foo;
+RESIGNAL foo SET MESSAGE_TEXT = "This is an error message";
+GET DIAGNOSTICS v = NUMBER;
+GET CURRENT DIAGNOSTICS v1 = NUMBER, v2 = MORE;
+return 0;
+end $$
+show procedure code signal_proc;
+Pos	Instruction
+0	set v@0 NULL
+1	set v1@1 NULL
+2	set v2@2 NULL
+3	SIGNAL foo;
+4	SIGNAL foo SET MESSAGE_TEXT = "This i...
+5	RESIGNAL foo;
+6	RESIGNAL foo SET MESSAGE_TEXT = "This...
+7	GET DIAGNOSTICS v = NUMBER;
+8	GET CURRENT DIAGNOSTICS v1 = NUMBER, ...
+drop procedure signal_proc;
+show function code signal_func;
+Pos	Instruction
+0	set v@0 NULL
+1	set v1@1 NULL
+2	set v2@2 NULL
+3	SIGNAL foo;
+4	SIGNAL foo SET MESSAGE_TEXT = "This i...
+5	RESIGNAL foo;
+6	RESIGNAL foo SET MESSAGE_TEXT = "This...
+7	GET DIAGNOSTICS v = NUMBER;
+8	GET CURRENT DIAGNOSTICS v1 = NUMBER, ...
+9	freturn 3 0
+drop function signal_func;
diff -Nrup a/mysql-test/t/signal.test b/mysql-test/t/signal.test
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/mysql-test/t/signal.test	2008-04-14 12:07:52 -06:00
@@ -0,0 +1,1292 @@
+# Copyright (C) 2008 Sun Microsystems, Inc
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+# Tests for SIGNAL, RESIGNAL and GET DIAGNOSTICS
+
+#
+# PART 1: syntax
+#
+
+#
+# Test every new reserved and non reserved keywords
+#
+
+--disable_warnings
+drop table if exists signal_non_reserved;
+--enable_warnings
+
+create table signal_non_reserved (
+  class_origin int,
+  subclass_origin int,
+  constraint_catalog int,
+  constraint_schema int,
+  constraint_name int,
+  catalog_name int,
+  schema_name int,
+  table_name int,
+  column_name int,
+  cursor_name int,
+  message_text int 
+);
+
+drop table signal_non_reserved;
+
+--disable_warnings
+drop table if exists diag_non_reserved;
+--enable_warnings
+
+create table diag_non_reserved (
+  diagnostics int,
+  current int,
+  stacked int,
+  exception int,
+  condition int
+);
+
+drop table diag_non_reserved;
+
+--disable_warnings
+drop table if exists diag_cond_non_reserved;
+--enable_warnings
+
+create table diag_cond_non_reserved (
+  condition_identifier int,
+  condition_number int,
+  condition_name int,
+  connection_name int,
+  message_length int,
+  message_octet_length int,
+  parameter_mode int,
+  parameter_name int,
+  parameter_ordinal_position int,
+  returned_sqlstate int,
+  routine_catalog int,
+  routine_name int,
+  routine_schema int,
+  server_name int,
+  specific_name int,
+  trigger_catalog int,
+  trigger_name int,
+  trigger_schema int
+);
+
+drop table diag_cond_non_reserved;
+
+--disable_warnings
+drop table if exists diag_stmt_non_reserved;
+--enable_warnings
+
+create table diag_stmt_non_reserved (
+  number int,
+  more int,
+  command_function int,
+  command_function_code int,
+  dynamic_function int,
+  dynamic_function_code int,
+  row_count int,
+  transactions_committed int,
+  transactions_rolled_back int,
+  transaction_active int
+);
+
+drop table diag_stmt_non_reserved;
+
+--disable_warnings
+drop table if exists test_reserved;
+--enable_warnings
+
+--error ER_PARSE_ERROR
+create table test_reserved (signal int);
+
+--error ER_PARSE_ERROR
+create table test_reserved (resignal int);
+
+--error ER_PARSE_ERROR
+create table test_reserved (get int);
+
+#
+# SIGNAL can only appear inside a stored program
+#
+
+--error ER_PARSE_ERROR
+SIGNAL foo;
+
+--error ER_PARSE_ERROR
+SIGNAL SQLSTATE '23000';
+
+--error ER_PARSE_ERROR
+SIGNAL SQLSTATE VALUE '23000';
+
+#
+# Test the SIGNAL syntax
+#
+
+--disable_warnings
+drop procedure if exists test_invalid;
+drop procedure if exists test_signal;
+--enable_warnings
+
+delimiter $$;
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  SIGNAL;
+end $$
+
+--error ER_SP_COND_MISMATCH
+create procedure test_invalid()
+begin
+  SIGNAL foo;
+end $$
+
+create procedure test_signal_syntax()
+begin
+  DECLARE foo CONDITION FOR 1234;
+  SIGNAL foo;
+end $$
+drop procedure test_signal_syntax $$
+
+create procedure test_signal_syntax()
+begin
+  SIGNAL SQLSTATE '23000';
+end $$
+drop procedure test_signal_syntax $$
+
+create procedure test_signal_syntax()
+begin
+  SIGNAL SQLSTATE VALUE '23000';
+end $$
+drop procedure test_signal_syntax $$
+
+create procedure test_signal_syntax()
+begin
+  DECLARE foo CONDITION FOR 1234;
+  SIGNAL foo SET CLASS_ORIGIN = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+
+create procedure test_signal_syntax()
+begin
+  DECLARE foo CONDITION FOR 1234;
+  SIGNAL foo SET SUBCLASS_ORIGIN = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+
+create procedure test_signal_syntax()
+begin
+  DECLARE foo CONDITION FOR 1234;
+  SIGNAL foo SET CONSTRAINT_CATALOG = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+
+create procedure test_signal_syntax()
+begin
+  DECLARE foo CONDITION FOR 1234;
+  SIGNAL foo SET CONSTRAINT_SCHEMA = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+
+create procedure test_signal_syntax()
+begin
+  DECLARE foo CONDITION FOR 1234;
+  SIGNAL foo SET CONSTRAINT_NAME = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+
+create procedure test_signal_syntax()
+begin
+  DECLARE foo CONDITION FOR 1234;
+  SIGNAL foo SET CATALOG_NAME = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+
+create procedure test_signal_syntax()
+begin
+  DECLARE foo CONDITION FOR 1234;
+  SIGNAL foo SET SCHEMA_NAME = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+
+create procedure test_signal_syntax()
+begin
+  DECLARE foo CONDITION FOR 1234;
+  SIGNAL foo SET TABLE_NAME = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+
+create procedure test_signal_syntax()
+begin
+  DECLARE foo CONDITION FOR 1234;
+  SIGNAL foo SET COLUMN_NAME = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+
+create procedure test_signal_syntax()
+begin
+  DECLARE foo CONDITION FOR 1234;
+  SIGNAL foo SET CURSOR_NAME = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+
+create procedure test_signal_syntax()
+begin
+  DECLARE foo CONDITION FOR 1234;
+  SIGNAL foo SET MESSAGE_TEXT = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+
+--error ER_WRONG_USAGE
+create procedure test_invalid()
+begin
+  DECLARE foo CONDITION FOR 1234;
+  SIGNAL foo SET MESSAGE_TEXT = 'foo', MESSAGE_TEXT = 'bar';
+end $$
+
+create procedure test_signal_syntax()
+begin
+  DECLARE foo CONDITION FOR 1234;
+  SIGNAL foo SET
+    CLASS_ORIGIN = 'foo',
+    SUBCLASS_ORIGIN = 'foo',
+    CONSTRAINT_CATALOG = 'foo',
+    CONSTRAINT_SCHEMA = 'foo',
+    CONSTRAINT_NAME = 'foo',
+    CATALOG_NAME = 'foo',
+    SCHEMA_NAME = 'foo',
+    TABLE_NAME = 'foo',
+    COLUMN_NAME = 'foo',
+    CURSOR_NAME = 'foo',
+    MESSAGE_TEXT = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+
+--error ER_SP_BAD_SQLSTATE
+create procedure test_invalid()
+begin
+  SIGNAL SQLSTATE '00000';
+end $$
+
+#
+# Test conditions information that SIGNAL can not set
+#
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  SIGNAL SQLSTATE '12345' SET bla_bla = 'foo';
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  SIGNAL SQLSTATE '12345' SET CONDITION_IDENTIFIER = 'foo';
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  SIGNAL SQLSTATE '12345' SET CONDITION_NUMBER = 'foo';
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  SIGNAL SQLSTATE '12345' SET CONNECTION_NAME = 'foo';
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  SIGNAL SQLSTATE '12345' SET MESSAGE_LENGTH = 'foo';
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  SIGNAL SQLSTATE '12345' SET MESSAGE_OCTET_LENGTH = 'foo';
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  SIGNAL SQLSTATE '12345' SET PARAMETER_MODE = 'foo';
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  SIGNAL SQLSTATE '12345' SET PARAMETER_NAME = 'foo';
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  SIGNAL SQLSTATE '12345' SET PARAMETER_ORDINAL_POSITION = 'foo';
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  SIGNAL SQLSTATE '12345' SET RETURNED_SQLSTATE = 'foo';
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  SIGNAL SQLSTATE '12345' SET ROUTINE_CATALOG = 'foo';
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  SIGNAL SQLSTATE '12345' SET ROUTINE_NAME = 'foo';
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  SIGNAL SQLSTATE '12345' SET ROUTINE_SCHEMA = 'foo';
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  SIGNAL SQLSTATE '12345' SET SERVER_NAME = 'foo';
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  SIGNAL SQLSTATE '12345' SET SPECIFIC_NAME = 'foo';
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  SIGNAL SQLSTATE '12345' SET TRIGGER_CATALOG = 'foo';
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  SIGNAL SQLSTATE '12345' SET TRIGGER_NAME = 'foo';
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  SIGNAL SQLSTATE '12345' SET TRIGGER_SCHEMA = 'foo';
+end $$
+
+delimiter ;$$
+
+#
+# RESIGNAL can only appear inside a stored program
+#
+
+--error ER_PARSE_ERROR
+RESIGNAL;
+
+--error ER_PARSE_ERROR
+RESIGNAL foo;
+
+--error ER_PARSE_ERROR
+RESIGNAL SQLSTATE '12345';
+
+--error ER_PARSE_ERROR
+RESIGNAL SQLSTATE VALUE '12345';
+
+#
+# Test the RESIGNAL syntax
+#
+
+--disable_warnings
+drop procedure if exists test_invalid;
+drop procedure if exists test_resignal_syntax;
+--enable_warnings
+
+delimiter $$;
+
+--error ER_SP_COND_MISMATCH
+create procedure test_invalid()
+begin
+  RESIGNAL foo;
+end $$
+
+create procedure test_resignal_syntax()
+begin
+  RESIGNAL;
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
+  DECLARE foo CONDITION FOR 1234;
+  RESIGNAL foo;
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
+  RESIGNAL SQLSTATE '23000';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
+  RESIGNAL SQLSTATE VALUE '23000';
+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
+  DECLARE foo CONDITION FOR 1234;
+  RESIGNAL foo SET SUBCLASS_ORIGIN = '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
+  DECLARE foo CONDITION FOR 1234;
+  RESIGNAL foo 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_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
+  DECLARE foo CONDITION FOR 1234;
+  RESIGNAL foo SET SCHEMA_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
+  DECLARE foo CONDITION FOR 1234;
+  RESIGNAL foo SET COLUMN_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
+  DECLARE foo CONDITION FOR 1234;
+  RESIGNAL foo SET MESSAGE_TEXT = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+--error ER_WRONG_USAGE
+create procedure test_invalid()
+begin
+  DECLARE foo CONDITION FOR 1234;
+  RESIGNAL foo SET MESSAGE_TEXT = 'foo', MESSAGE_TEXT = 'bar';
+end $$
+
+create procedure test_resignal_syntax()
+begin
+  DECLARE foo CONDITION FOR 1234;
+  RESIGNAL foo SET
+    CLASS_ORIGIN = 'foo',
+    SUBCLASS_ORIGIN = 'foo',
+    CONSTRAINT_CATALOG = 'foo',
+    CONSTRAINT_SCHEMA = 'foo',
+    CONSTRAINT_NAME = 'foo',
+    CATALOG_NAME = 'foo',
+    SCHEMA_NAME = 'foo',
+    TABLE_NAME = 'foo',
+    COLUMN_NAME = 'foo',
+    CURSOR_NAME = 'foo',
+    MESSAGE_TEXT = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+--error ER_SP_BAD_SQLSTATE
+create procedure test_invalid()
+begin
+  RESIGNAL SQLSTATE '00000';
+end $$
+
+delimiter ;$$
+
+#
+# GET DIAGNOSTICS can only appear inside a stored program
+#
+
+--error ER_PARSE_ERROR
+GET DIAGNOSTICS @foo = NUMBER;
+
+--error ER_PARSE_ERROR
+GET CURRENT DIAGNOSTICS @foo = NUMBER;
+
+--error ER_PARSE_ERROR
+GET STACKED DIAGNOSTICS @foo = NUMBER;
+
+#
+# Test the GET DIAGNOSTICS syntax
+#
+
+--disable_warnings
+drop procedure if exists test_invalid;
+drop procedure if exists test_diag_syntax;
+--enable_warnings
+
+delimiter $$;
+
+--error ER_SP_UNDECLARED_VAR
+create procedure test_invalid()
+begin
+  GET DIAGNOSTICS foo = NUMBER;
+end $$
+
+#
+# Get diagnostics, statement information
+#
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = NUMBER;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax(OUT foo integer)
+begin
+  GET DIAGNOSTICS foo = NUMBER;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  GET DIAGNOSTICS @foo = NUMBER;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET CURRENT DIAGNOSTICS foo = NUMBER;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET STACKED DIAGNOSTICS foo = NUMBER;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = MORE;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = COMMAND_FUNCTION;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = COMMAND_FUNCTION_CODE;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = DYNAMIC_FUNCTION;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = DYNAMIC_FUNCTION_CODE;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = ROW_COUNT;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = TRANSACTIONS_COMMITTED;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = TRANSACTIONS_ROLLED_BACK;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = TRANSACTION_ACTIVE;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo1 integer;
+  DECLARE foo2 integer;
+  DECLARE foo3 integer;
+  DECLARE foo4 integer;
+  DECLARE foo5 integer;
+  DECLARE foo6 integer;
+  DECLARE foo7 integer;
+  DECLARE foo8 integer;
+  DECLARE foo9 integer;
+  DECLARE foo10 integer;
+  GET DIAGNOSTICS
+    foo1 = NUMBER,
+    foo2 = MORE,
+    foo3 = COMMAND_FUNCTION,
+    foo4 = COMMAND_FUNCTION_CODE,
+    foo5 = DYNAMIC_FUNCTION,
+    foo6 = DYNAMIC_FUNCTION_CODE,
+    foo7 = ROW_COUNT,
+    foo8 = TRANSACTIONS_COMMITTED,
+    foo9 = TRANSACTIONS_ROLLED_BACK,
+    foo10 = TRANSACTION_ACTIVE;
+end $$
+drop procedure test_diag_syntax $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = abcdef;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = CLASS_ORIGIN;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = SUBCLASS_ORIGIN;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = CONSTRAINT_CATALOG;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = CONSTRAINT_SCHEMA;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = CONSTRAINT_NAME;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = CATALOG_NAME;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = SCHEMA_NAME;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = TABLE_NAME;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = COLUMN_NAME;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = CURSOR_NAME;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = MESSAGE_TEXT;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = CONDITION_IDENTIFIER;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = CONDITION_NUMBER;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = CONNECTION_NAME;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = MESSAGE_LENGTH;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = MESSAGE_OCTET_LENGTH;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = PARAMETER_MODE;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = PARAMETER_NAME;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = PARAMETER_ORDINAL_POSITION;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = RETURNED_SQLSTATE;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = ROUTINE_CATALOG;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = ROUTINE_NAME;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = ROUTINE_SCHEMA;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = SERVER_NAME;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = SPECIFIC_NAME;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = TRIGGER_CATALOG;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = TRIGGER_NAME;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS foo = TRIGGER_SCHEMA;
+end $$
+
+#
+# Get diagnostics, condition information
+#
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS EXCEPTION 0 foo = CLASS_ORIGIN;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = CLASS_ORIGIN;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = SUBCLASS_ORIGIN;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = CONSTRAINT_CATALOG;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = CONSTRAINT_SCHEMA;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = CONSTRAINT_NAME;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = CATALOG_NAME;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = SCHEMA_NAME;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = TABLE_NAME;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = COLUMN_NAME;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = CURSOR_NAME;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = MESSAGE_TEXT;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = CONDITION_IDENTIFIER;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = CONDITION_NUMBER;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = CONNECTION_NAME;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = MESSAGE_LENGTH;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = MESSAGE_OCTET_LENGTH;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = PARAMETER_MODE;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = PARAMETER_NAME;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = PARAMETER_ORDINAL_POSITION;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = RETURNED_SQLSTATE;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = ROUTINE_CATALOG;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = ROUTINE_NAME;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = ROUTINE_SCHEMA;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = SERVER_NAME;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = SPECIFIC_NAME;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = TRIGGER_CATALOG;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = TRIGGER_NAME;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = TRIGGER_SCHEMA;
+end $$
+drop procedure test_diag_syntax $$
+
+create procedure test_diag_syntax()
+begin
+  DECLARE foo1 integer;
+  DECLARE foo2 integer;
+  DECLARE foo3 integer;
+  DECLARE foo4 integer;
+  DECLARE foo5 integer;
+  DECLARE foo6 integer;
+  DECLARE foo7 integer;
+  DECLARE foo8 integer;
+  DECLARE foo9 integer;
+  DECLARE foo10 integer;
+  DECLARE foo11 integer;
+  DECLARE foo12 integer;
+  DECLARE foo13 integer;
+  DECLARE foo14 integer;
+  DECLARE foo15 integer;
+  DECLARE foo16 integer;
+  DECLARE foo17 integer;
+  DECLARE foo18 integer;
+  DECLARE foo19 integer;
+  DECLARE foo20 integer;
+  DECLARE foo21 integer;
+  DECLARE foo22 integer;
+  DECLARE foo23 integer;
+  DECLARE foo24 integer;
+  DECLARE foo25 integer;
+  DECLARE foo26 integer;
+  DECLARE foo27 integer;
+  DECLARE foo28 integer;
+  DECLARE foo29 integer;
+
+  GET DIAGNOSTICS CONDITION 0
+    foo1 = CLASS_ORIGIN,
+    foo2 = SUBCLASS_ORIGIN,
+    foo3 = CONSTRAINT_CATALOG,
+    foo4 = CONSTRAINT_SCHEMA,
+    foo5 = CONSTRAINT_NAME,
+    foo6 = CATALOG_NAME,
+    foo7 = SCHEMA_NAME,
+    foo8 = TABLE_NAME,
+    foo9 = COLUMN_NAME,
+    foo10 = CURSOR_NAME,
+    foo11 = MESSAGE_TEXT,
+
+    foo12 = CONDITION_IDENTIFIER,
+    foo13 = CONDITION_NUMBER,
+    foo14 = CONNECTION_NAME,
+    foo15 = MESSAGE_LENGTH,
+    foo16 = MESSAGE_OCTET_LENGTH,
+    foo17 = PARAMETER_MODE,
+    foo18 = PARAMETER_NAME,
+    foo19 = PARAMETER_ORDINAL_POSITION,
+    foo20 = RETURNED_SQLSTATE,
+    foo21 = ROUTINE_CATALOG,
+    foo22 = ROUTINE_NAME,
+    foo23 = ROUTINE_SCHEMA,
+    foo24 = SERVER_NAME,
+    foo25 = SPECIFIC_NAME,
+    foo26 = TRIGGER_CATALOG,
+    foo27 = TRIGGER_NAME,
+    foo28 = TRIGGER_SCHEMA;
+
+end $$
+drop procedure test_diag_syntax $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = abcdef;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = NUMBER;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = MORE;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = COMMAND_FUNCTION;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = COMMAND_FUNCTION_CODE;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = DYNAMIC_FUNCTION;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = DYNAMIC_FUNCTION_CODE;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = ROW_COUNT;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = TRANSACTIONS_COMMITTED;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = TRANSACTIONS_ROLLED_BACK;
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+  DECLARE foo integer;
+  GET DIAGNOSTICS CONDITION 0 foo = TRANSACTION_ACTIVE;
+end $$
+
+delimiter ;$$
+
+#
+# PART 2: non preparable statements
+#
+
+--error ER_PARSE_ERROR
+prepare stmt from 'SIGNAL SQLSTATE \'23000\'';
+
+--error ER_PARSE_ERROR
+prepare stmt from 'RESIGNAL SQLSTATE \'23000\'';
+
+--error ER_PARSE_ERROR
+prepare stmt from 'GET DIAGNOSTICS foo = NUMBER';
+
+#
+# PART 3: runtime execution
+#
+
+
diff -Nrup a/mysql-test/t/signal_code.test b/mysql-test/t/signal_code.test
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/mysql-test/t/signal_code.test	2008-04-14 12:07:53 -06:00
@@ -0,0 +1,63 @@
+# Copyright (C) 2008 Sun Microsystems, Inc
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+# Tests for SIGNAL, RESIGNAL and GET DIAGNOSTICS
+
+-- source include/have_debug.inc
+
+use test;
+
+--disable_warnings
+drop procedure if exists signal_proc;
+drop function if exists signal_func;
+--enable_warnings
+
+delimiter $$;
+
+create procedure signal_proc()
+begin
+  DECLARE v, v1, v2 integer;
+  DECLARE foo CONDITION FOR 1234;
+
+  SIGNAL foo;
+  SIGNAL foo SET MESSAGE_TEXT = "This is an error message";
+  RESIGNAL foo;
+  RESIGNAL foo SET MESSAGE_TEXT = "This is an error message";
+  GET DIAGNOSTICS v = NUMBER;
+  GET CURRENT DIAGNOSTICS v1 = NUMBER, v2 = MORE;
+end $$
+
+create function signal_func() returns int
+begin
+  DECLARE v, v1, v2 integer;
+  DECLARE foo CONDITION FOR 1234;
+
+  SIGNAL foo;
+  SIGNAL foo SET MESSAGE_TEXT = "This is an error message";
+  RESIGNAL foo;
+  RESIGNAL foo SET MESSAGE_TEXT = "This is an error message";
+  GET DIAGNOSTICS v = NUMBER;
+  GET CURRENT DIAGNOSTICS v1 = NUMBER, v2 = MORE;
+  return 0;
+end $$
+
+delimiter ;$$
+
+show procedure code signal_proc;
+drop procedure signal_proc;
+
+show function code signal_func;
+drop function signal_func;
+
diff -Nrup a/sql/Makefile.am b/sql/Makefile.am
--- a/sql/Makefile.am	2008-03-27 16:40:59 -06:00
+++ b/sql/Makefile.am	2008-04-14 12:07:51 -06:00
@@ -88,7 +88,8 @@ noinst_HEADERS =	item.h item_func.h item
 			event_data_objects.h event_scheduler.h \
 			sql_partition.h partition_info.h partition_element.h \
 			probes.h sql_audit.h \
-			contributors.h sql_servers.h ddl_blocker.h si_objects.h
+			contributors.h sql_servers.h ddl_blocker.h \
+			si_objects.h sql_signal.h
 
 mysqld_SOURCES =	sql_lex.cc sql_handler.cc sql_partition.cc \
 			item.cc item_sum.cc item_buff.cc item_func.cc \
@@ -133,7 +134,7 @@ mysqld_SOURCES =	sql_lex.cc sql_handler.
 			sql_plugin.cc sql_binlog.cc \
 			sql_builtin.cc sql_tablespace.cc partition_info.cc \
 			sql_servers.cc sql_audit.cc sha2.cc \
-			ddl_blocker.cc si_objects.cc
+			ddl_blocker.cc si_objects.cc sql_signal.cc
 
 if HAVE_DTRACE
   mysqld_SOURCES += probes.d
diff -Nrup a/sql/item_create.cc b/sql/item_create.cc
--- a/sql/item_create.cc	2008-03-07 10:24:59 -07:00
+++ b/sql/item_create.cc	2008-04-14 12:07:52 -06:00
@@ -1750,19 +1750,6 @@ protected:
 };
 
 
-class Create_func_row_count : public Create_func_arg0
-{
-public:
-  virtual Item *create(THD *thd);
-
-  static Create_func_row_count s_singleton;
-
-protected:
-  Create_func_row_count() {}
-  virtual ~Create_func_row_count() {}
-};
-
-
 class Create_func_rpad : public Create_func_arg3
 {
 public:
@@ -4245,17 +4232,6 @@ Create_func_round::create_native(THD *th
 }
 
 
-Create_func_row_count Create_func_row_count::s_singleton;
-
-Item*
-Create_func_row_count::create(THD *thd)
-{
-  thd->lex->set_stmt_unsafe();
-  thd->lex->safe_to_cache_query= 0;
-  return new (thd->mem_root) Item_func_row_count();
-}
-
-
 Create_func_rpad Create_func_rpad::s_singleton;
 
 Item*
@@ -4891,7 +4867,6 @@ static Native_func_registry func_array[]
   { { C_STRING_WITH_LEN("RAND") }, BUILDER(Create_func_rand)},
   { { C_STRING_WITH_LEN("RELEASE_LOCK") }, BUILDER(Create_func_release_lock)},
   { { C_STRING_WITH_LEN("ROUND") }, BUILDER(Create_func_round)},
-  { { C_STRING_WITH_LEN("ROW_COUNT") }, BUILDER(Create_func_row_count)},
   { { C_STRING_WITH_LEN("RPAD") }, BUILDER(Create_func_rpad)},
   { { C_STRING_WITH_LEN("RTRIM") }, BUILDER(Create_func_rtrim)},
   { { C_STRING_WITH_LEN("SEC_TO_TIME") }, BUILDER(Create_func_sec_to_time)},
diff -Nrup a/sql/lex.h b/sql/lex.h
--- a/sql/lex.h	2008-04-01 07:44:52 -06:00
+++ b/sql/lex.h	2008-04-14 12:07:52 -06:00
@@ -96,6 +96,7 @@ static SYMBOL symbols[] = {
   { "CASCADE",		SYM(CASCADE)},
   { "CASCADED",         SYM(CASCADED)},
   { "CASE",		SYM(CASE_SYM)},
+  { "CATALOG_NAME",     SYM(CATALOG_NAME_SYM)},
   { "CHAIN",		SYM(CHAIN_SYM)},
   { "CHANGE",		SYM(CHANGE)},
   { "CHANGED",		SYM(CHANGED)},
@@ -105,6 +106,7 @@ static SYMBOL symbols[] = {
   { "CHECK",		SYM(CHECK_SYM)},
   { "CHECKSUM",		SYM(CHECKSUM_SYM)},
   { "CIPHER",		SYM(CIPHER_SYM)},
+  { "CLASS_ORIGIN",     SYM(CLASS_ORIGIN_SYM)},
   { "CLIENT",		SYM(CLIENT_SYM)},
   { "CLOSE",		SYM(CLOSE_SYM)},
   { "COALESCE",		SYM(COALESCE)},
@@ -112,7 +114,10 @@ static SYMBOL symbols[] = {
   { "COLLATE",		SYM(COLLATE_SYM)},
   { "COLLATION",	SYM(COLLATION_SYM)},
   { "COLUMN",		SYM(COLUMN_SYM)},
+  { "COLUMN_NAME",      SYM(COLUMN_NAME_SYM)},
   { "COLUMNS",		SYM(COLUMNS)},
+  { "COMMAND_FUNCTION", SYM(COMMAND_FUNCTION_SYM)},
+  { "COMMAND_FUNCTION_CODE", SYM(COMMAND_FUNCTION_CODE_SYM)},
   { "COMMENT",		SYM(COMMENT_SYM)},
   { "COMMIT",		SYM(COMMIT_SYM)},
   { "COMMITTED",	SYM(COMMITTED_SYM)},
@@ -121,9 +126,15 @@ static SYMBOL symbols[] = {
   { "COMPRESSED",	SYM(COMPRESSED_SYM)},
   { "CONCURRENT",	SYM(CONCURRENT)},
   { "CONDITION",        SYM(CONDITION_SYM)},
+  { "CONDITION_NUMBER", SYM(CONDITION_NUMBER_SYM)},
+  { "CONDITION_IDENTIFIER", SYM(CONDITION_IDENTIFIER_SYM)},
   { "CONNECTION",       SYM(CONNECTION_SYM)},
+  { "CONNECTION_NAME",  SYM(CONNECTION_NAME_SYM)},
   { "CONSISTENT",	SYM(CONSISTENT_SYM)},
   { "CONSTRAINT",	SYM(CONSTRAINT)},
+  { "CONSTRAINT_CATALOG", SYM(CONSTRAINT_CATALOG_SYM)},
+  { "CONSTRAINT_NAME",  SYM(CONSTRAINT_NAME_SYM)},
+  { "CONSTRAINT_SCHEMA", SYM(CONSTRAINT_SCHEMA_SYM)},
   { "CONTAINS",         SYM(CONTAINS_SYM)},
   { "CONTEXT",    SYM(CONTEXT_SYM)},
   { "CONTINUE",         SYM(CONTINUE_SYM)},
@@ -133,11 +144,13 @@ static SYMBOL symbols[] = {
   { "CREATE",		SYM(CREATE)},
   { "CROSS",		SYM(CROSS)},
   { "CUBE",		SYM(CUBE_SYM)},
+  { "CURRENT",          SYM(CURRENT_SYM)},
   { "CURRENT_DATE",	SYM(CURDATE)},
   { "CURRENT_TIME",	SYM(CURTIME)},
   { "CURRENT_TIMESTAMP", SYM(NOW_SYM)},
   { "CURRENT_USER",	SYM(CURRENT_USER)},
   { "CURSOR",           SYM(CURSOR_SYM)},
+  { "CURSOR_NAME",      SYM(CURSOR_NAME_SYM)},
   { "DATA",		SYM(DATA_SYM)},
   { "DATABASE",		SYM(DATABASE)},
   { "DATABASES",	SYM(DATABASES)},
@@ -162,6 +175,7 @@ static SYMBOL symbols[] = {
   { "DESCRIBE",		SYM(DESCRIBE)},
   { "DES_KEY_FILE",	SYM(DES_KEY_FILE)},
   { "DETERMINISTIC",    SYM(DETERMINISTIC_SYM)},
+  { "DIAGNOSTICS",	SYM(DIAGNOSTICS_SYM)},
   { "DIRECTORY",	SYM(DIRECTORY_SYM)},
   { "DISABLE",		SYM(DISABLE_SYM)},
   { "DISCARD",		SYM(DISCARD)},
@@ -176,6 +190,8 @@ static SYMBOL symbols[] = {
   { "DUMPFILE",		SYM(DUMPFILE)},
   { "DUPLICATE",	SYM(DUPLICATE_SYM)},
   { "DYNAMIC",		SYM(DYNAMIC_SYM)},
+  { "DYNAMIC_FUNCTION", SYM(DYNAMIC_FUNCTION_SYM)},
+  { "DYNAMIC_FUNCTION_CODE", SYM(DYNAMIC_FUNCTION_CODE_SYM)},
   { "EACH",             SYM(EACH_SYM)},
   { "ELSE",             SYM(ELSE)},
   { "ELSEIF",           SYM(ELSEIF_SYM)},
@@ -192,6 +208,7 @@ static SYMBOL symbols[] = {
   { "EVENT",		SYM(EVENT_SYM)},
   { "EVENTS",		SYM(EVENTS_SYM)},
   { "EVERY",		SYM(EVERY_SYM)},
+  { "EXCEPTION",        SYM(EXCEPTION_SYM)},
   { "EXCLUSIVE",        SYM(EXCLUSIVE_SYM)},
   { "EXECUTE",		SYM(EXECUTE_SYM)},
   { "EXISTS",		SYM(EXISTS)},
@@ -224,6 +241,7 @@ static SYMBOL symbols[] = {
   { "FUNCTION",		SYM(FUNCTION_SYM)},
   { "GEOMETRY",		SYM(GEOMETRY_SYM)},
   { "GEOMETRYCOLLECTION",SYM(GEOMETRYCOLLECTION)},
+  { "GET",              SYM(GET_SYM)},
   { "GET_FORMAT",       SYM(GET_FORMAT)},
   { "GLOBAL",		SYM(GLOBAL_SYM)},
   { "GRANT",		SYM(GRANT)},
@@ -335,6 +353,9 @@ static SYMBOL symbols[] = {
   { "MEDIUMTEXT",	SYM(MEDIUMTEXT)},
   { "MEMORY",		SYM(MEMORY_SYM)},
   { "MERGE",		SYM(MERGE_SYM)},
+  { "MESSAGE_LENGTH",   SYM(MESSAGE_LENGTH_SYM)},
+  { "MESSAGE_OCTET_LENGTH", SYM(MESSAGE_OCTET_LENGTH_SYM)},
+  { "MESSAGE_TEXT",     SYM(MESSAGE_TEXT_SYM)},
   { "MICROSECOND",	SYM(MICROSECOND_SYM)},
   { "MIDDLEINT",	SYM(MEDIUMINT)},	/* For powerbuilder */
   { "MIGRATE",          SYM(MIGRATE_SYM)},
@@ -347,6 +368,7 @@ static SYMBOL symbols[] = {
   { "MODIFIES",		SYM(MODIFIES_SYM)},
   { "MODIFY",		SYM(MODIFY_SYM)},
   { "MONTH",		SYM(MONTH_SYM)},
+  { "MORE",             SYM(MORE_SYM)},
   { "MULTILINESTRING",	SYM(MULTILINESTRING)},
   { "MULTIPOINT",	SYM(MULTIPOINT)},
   { "MULTIPOLYGON",	SYM(MULTIPOLYGON)},
@@ -368,6 +390,7 @@ static SYMBOL symbols[] = {
   { "NOWAIT",           SYM(NOWAIT_SYM)},
   { "NO_WRITE_TO_BINLOG",  SYM(NO_WRITE_TO_BINLOG)},
   { "NULL",		SYM(NULL_SYM)},
+  { "NUMBER",		SYM(NUMBER_SYM)},
   { "NUMERIC",		SYM(NUMERIC_SYM)},
   { "NVARCHAR",		SYM(NVARCHAR_SYM)},
   { "OFFLINE",		SYM(OFFLINE_SYM)},
@@ -389,6 +412,9 @@ static SYMBOL symbols[] = {
   { "OUTFILE",		SYM(OUTFILE)},
   { "OWNER",		SYM(OWNER_SYM)},
   { "PACK_KEYS",	SYM(PACK_KEYS_SYM)},
+  { "PARAMETER_MODE",   SYM(PARAMETER_MODE_SYM)},
+  { "PARAMETER_NAME",   SYM(PARAMETER_NAME_SYM)},
+  { "PARAMETER_ORDINAL_POSITION", SYM(PARAMETER_ORDINAL_POSITION_SYM)},
   { "PARSER",           SYM(PARSER_SYM)},
   { "PAGE",	        SYM(PAGE_SYM)},
   { "PAGE_CHECKSUM",        SYM(PAGE_CHECKSUM_SYM)},
@@ -446,10 +472,12 @@ static SYMBOL symbols[] = {
   { "REPEAT",           SYM(REPEAT_SYM)},
   { "REQUIRE",	        SYM(REQUIRE_SYM)},
   { "RESET",		SYM(RESET_SYM)},
+  { "RESIGNAL",         SYM(RESIGNAL_SYM)},
   { "RESTORE",		SYM(RESTORE_SYM)},
   { "RESTRICT",		SYM(RESTRICT)},
   { "RESUME",           SYM(RESUME_SYM)},
   { "RETURN",           SYM(RETURN_SYM)},
+  { "RETURNED_SQLSTATE", SYM(RETURNED_SQLSTATE_SYM)},
   { "RETURNS",		SYM(RETURNS_SYM)},
   { "REVERSE",		SYM(REVERSE_SYM)},
   { "REVOKE",		SYM(REVOKE)},
@@ -458,13 +486,18 @@ static SYMBOL symbols[] = {
   { "ROLLBACK",		SYM(ROLLBACK_SYM)},
   { "ROLLUP",		SYM(ROLLUP_SYM)},
   { "ROUTINE",		SYM(ROUTINE_SYM)},
+  { "ROUTINE_CATALOG",  SYM(ROUTINE_CATALOG_SYM)},
+  { "ROUTINE_NAME",     SYM(ROUTINE_NAME_SYM)},
+  { "ROUTINE_SCHEMA",   SYM(ROUTINE_SCHEMA_SYM)},
   { "ROW",		SYM(ROW_SYM)},
   { "ROWS",		SYM(ROWS_SYM)},
+  { "ROW_COUNT",        SYM(ROW_COUNT_SYM)},
   { "ROW_FORMAT",	SYM(ROW_FORMAT_SYM)},
   { "RTREE",		SYM(RTREE_SYM)},
   { "SAVEPOINT",	SYM(SAVEPOINT_SYM)},
   { "SCHEDULE",		SYM(SCHEDULE_SYM)},
   { "SCHEMA",		SYM(DATABASE)},
+  { "SCHEMA_NAME",      SYM(SCHEMA_NAME_SYM)},
   { "SCHEMAS",          SYM(DATABASES)},
   { "SECOND",		SYM(SECOND_SYM)},
   { "SECOND_MICROSECOND", SYM(SECOND_MICROSECOND_SYM)},
@@ -476,10 +509,12 @@ static SYMBOL symbols[] = {
   { "SERIALIZABLE",	SYM(SERIALIZABLE_SYM)},
   { "SESSION",		SYM(SESSION_SYM)},
   { "SERVER",           SYM(SERVER_SYM)},
+  { "SERVER_NAME",      SYM(SERVER_NAME_SYM)},
   { "SET",		SYM(SET)},
   { "SHARE",		SYM(SHARE_SYM)},
   { "SHOW",		SYM(SHOW)},
   { "SHUTDOWN",		SYM(SHUTDOWN)},
+  { "SIGNAL",		SYM(SIGNAL_SYM)},
   { "SIGNED",		SYM(SIGNED_SYM)},
   { "SIMPLE",		SYM(SIMPLE_SYM)},
   { "SLAVE",            SYM(SLAVE)},
@@ -492,6 +527,7 @@ static SYMBOL symbols[] = {
   { "SOURCE",   SYM(SOURCE_SYM)},
   { "SPATIAL",		SYM(SPATIAL_SYM)},
   { "SPECIFIC",         SYM(SPECIFIC_SYM)},
+  { "SPECIFIC_NAME",    SYM(SPECIFIC_NAME_SYM)},
   { "SQL",              SYM(SQL_SYM)},
   { "SQLEXCEPTION",     SYM(SQLEXCEPTION_SYM)},
   { "SQLSTATE",         SYM(SQLSTATE_SYM)},
@@ -513,6 +549,7 @@ static SYMBOL symbols[] = {
   { "SQL_TSI_QUARTER",  SYM(QUARTER_SYM)},
   { "SQL_TSI_YEAR",     SYM(YEAR_SYM)},
   { "SSL",		SYM(SSL_SYM)},
+  { "STACKED",          SYM(STACKED_SYM)},
   { "START",		SYM(START_SYM)},
   { "STARTING",		SYM(STARTING)},
   { "STARTS",		SYM(STARTS_SYM)},
@@ -521,6 +558,7 @@ static SYMBOL symbols[] = {
   { "STORAGE",		SYM(STORAGE_SYM)},
   { "STRAIGHT_JOIN",	SYM(STRAIGHT_JOIN)},
   { "STRING",		SYM(STRING_SYM)},
+  { "SUBCLASS_ORIGIN",  SYM(SUBCLASS_ORIGIN_SYM)},
   { "SUBJECT",		SYM(SUBJECT_SYM)},
   { "SUBPARTITION",     SYM(SUBPARTITION_SYM)},
   { "SUBPARTITIONS",    SYM(SUBPARTITIONS_SYM)},
@@ -529,6 +567,7 @@ static SYMBOL symbols[] = {
   { "SWAPS",      SYM(SWAPS_SYM)},
   { "SWITCHES",   SYM(SWITCHES_SYM)},
   { "TABLE",		SYM(TABLE_SYM)},
+  { "TABLE_NAME",       SYM(TABLE_NAME_SYM)},
   { "TABLES",		SYM(TABLES)},
   { "TABLESPACE",	        SYM(TABLESPACE)},
   { "TABLE_CHECKSUM",	SYM(TABLE_CHECKSUM_SYM)},
@@ -548,8 +587,14 @@ static SYMBOL symbols[] = {
   { "TO",		SYM(TO_SYM)},
   { "TRAILING",		SYM(TRAILING)},
   { "TRANSACTION",	SYM(TRANSACTION_SYM)},
+  { "TRANSACTION_ACTIVE", SYM(TRANSACTION_ACTIVE_SYM)},
   { "TRANSACTIONAL",	SYM(TRANSACTIONAL_SYM)},
+  { "TRANSACTIONS_COMMITTED", SYM(TRANSACTIONS_COMMITTED_SYM)},
+  { "TRANSACTIONS_ROLLED_BACK", SYM(TRANSACTIONS_ROLLED_BACK_SYM)},
   { "TRIGGER",          SYM(TRIGGER_SYM)},
+  { "TRIGGER_CATALOG",  SYM(TRIGGER_CATALOG_SYM)},
+  { "TRIGGER_NAME",     SYM(TRIGGER_NAME_SYM)},
+  { "TRIGGER_SCHEMA",   SYM(TRIGGER_SCHEMA_SYM)},
   { "TRIGGERS",         SYM(TRIGGERS_SYM)},
   { "TRUE",		SYM(TRUE_SYM)},
   { "TRUNCATE",		SYM(TRUNCATE_SYM)},
diff -Nrup a/sql/sql_class.cc b/sql/sql_class.cc
--- a/sql/sql_class.cc	2008-04-01 07:44:53 -06:00
+++ b/sql/sql_class.cc	2008-04-14 12:07:52 -06:00
@@ -518,6 +518,7 @@ THD::THD()
    derived_tables_processing(FALSE),
    spcont(NULL),
    m_lip(NULL),
+   m_tmp_syn(NULL),
   /*
     @todo The following is a work around for online backup and the DDL blocker.
           It should be removed when the generalized solution is in place.
diff -Nrup a/sql/sql_class.h b/sql/sql_class.h
--- a/sql/sql_class.h	2008-04-01 07:44:53 -06:00
+++ b/sql/sql_class.h	2008-04-14 12:07:52 -06:00
@@ -32,6 +32,7 @@ class Slave_log_event;
 class sp_rcontext;
 class sp_cache;
 class Lex_input_stream;
+class Tmp_syn;
 class Rows_log_event;
 
 enum enum_enable_or_disable { LEAVE_AS_IS, ENABLE, DISABLE };
@@ -243,6 +244,135 @@ struct Query_cache_tls
   Query_cache_tls() :first_query_block(NULL) {}
 };
 
+/* SIGNAL / RESIGNAL / GET DIAGNOSTICS */
+
+#define FIRST_DIAG_SET_PROPERTY 0
+#define LAST_DIAG_SET_PROPERTY 10
+
+#define FIRST_DIAG_PROPERTY 0
+#define LAST_DIAG_PROPERTY 27
+
+typedef enum enum_diag_condition_item_name
+{
+  DIAG_CLASS_ORIGIN= 0,
+  DIAG_SUBCLASS_ORIGIN= 1,
+  DIAG_CONSTRAINT_CATALOG= 2,
+  DIAG_CONSTRAINT_SCHEMA= 3,
+  DIAG_CONSTRAINT_NAME= 4,
+  DIAG_CATALOG_NAME= 5,
+  DIAG_SCHEMA_NAME= 6,
+  DIAG_TABLE_NAME= 7,
+  DIAG_COLUMN_NAME= 8,
+  DIAG_CURSOR_NAME= 9,
+  DIAG_MESSAGE_TEXT= 10,
+
+  DIAG_CONDITION_IDENTIFIER= 11,
+  DIAG_CONDITION_NUMBER= 12,
+  DIAG_CONNECTION_NAME= 13,
+  DIAG_MESSAGE_LENGTH= 14,
+  DIAG_MESSAGE_OCTET_LENGTH= 15,
+  DIAG_PARAMETER_MODE= 16,
+  DIAG_PARAMETER_NAME= 17,
+  DIAG_PARAMETER_ORDINAL_POSITION= 18,
+  DIAG_RETURNED_SQLSTATE= 19,
+  DIAG_ROUTINE_CATALOG= 20,
+  DIAG_ROUTINE_NAME= 21,
+  DIAG_ROUTINE_SCHEMA= 22,
+  DIAG_SERVER_NAME= 23,
+  DIAG_SPECIFIC_NAME= 24,
+  DIAG_TRIGGER_CATALOG= 25,
+  DIAG_TRIGGER_NAME= 26,
+  DIAG_TRIGGER_SCHEMA= 27,
+} Diag_condition_item_name;
+
+typedef enum enum_diag_statement_item_name
+{
+  DIAG_NUMBER= 0,
+  DIAG_MORE= 1,
+  DIAG_COMMAND_FUNCTION= 2,
+  DIAG_COMMAND_FUNCTION_CODE= 3,
+  DIAG_DYNAMIC_FUNCTION= 4,
+  DIAG_DYNAMIC_FUNCTION_CODE= 5,
+  DIAG_ROW_COUNT= 6,
+  DIAG_TRANSACTIONS_COMMITTED= 7,
+  DIAG_TRANSACTIONS_ROLLED_BACK= 8,
+  DIAG_TRANSACTION_ACTIVE= 9
+} Diag_statement_item_name;
+
+
+class Set_signal_information
+{
+public:
+  Set_signal_information();
+  Set_signal_information(const Set_signal_information& set);
+
+  ~Set_signal_information()
+  {}
+
+  void clear();
+
+  Item *m_item[LAST_DIAG_SET_PROPERTY+1];
+};
+
+
+enum diagnostic_area_type
+{
+  CURRENT_AREA,
+  STACKED_AREA
+};
+
+
+class Diag_condition_property : public Sql_alloc
+{
+public:
+  Diag_condition_property(Item *target, Diag_condition_item_name item_name)
+    : m_target(target),
+      m_item_name(item_name)
+  {}
+
+  ~Diag_condition_property()
+  {}
+
+private:
+  Item *m_target;
+  Diag_condition_item_name m_item_name;
+};
+
+
+class Diag_statement_property : public Sql_alloc
+{
+public:
+  Diag_statement_property(Item *target, Diag_statement_item_name item_name)
+    : m_target(target),
+      m_item_name(item_name)
+  {}
+
+  ~Diag_statement_property()
+  {}
+
+private:
+  Item *m_target;
+  Diag_statement_item_name m_item_name;
+};
+
+
+/**
+  Parser temporary internal state, used during syntax analysis.
+*/
+/* FIXME: can't move to sql_lex.h due to the header dependencies */
+class Tmp_syn
+{
+public:
+  Tmp_syn()
+    : m_set_signal_info()
+  {}
+
+  ~Tmp_syn()
+  {}
+
+  Set_signal_information m_set_signal_info;
+};
+
 #include "sql_lex.h"				/* Must be here */
 
 class Delayed_insert;
@@ -1771,6 +1901,12 @@ public:
           when the DDL blocker is engaged.
   */
   my_bool DDL_exception; // Allow some DDL if there is an exception
+
+  /**
+    Parser internal temporary state, used during syntax parsing.
+    This member is only valid during parsing.
+  */
+  Tmp_syn *m_tmp_syn;
 
 #ifdef WITH_PARTITION_STORAGE_ENGINE
   partition_info *work_part_info;
diff -Nrup a/sql/sql_parse.cc b/sql/sql_parse.cc
--- a/sql/sql_parse.cc	2008-04-01 07:44:54 -06:00
+++ b/sql/sql_parse.cc	2008-04-14 12:07:52 -06:00
@@ -7487,7 +7487,10 @@ bool parse_sql(THD *thd,
                Lex_input_stream *lip,
                Object_creation_ctx *creation_ctx)
 {
+  Tmp_syn tmp_syn;
+
   DBUG_ASSERT(thd->m_lip == NULL);
+  DBUG_ASSERT(thd->m_tmp_syn == NULL);
 
   /* Backup creation context. */
 
@@ -7499,6 +7502,7 @@ bool parse_sql(THD *thd,
   /* Set Lex_input_stream. */
 
   thd->m_lip= lip;
+  thd->m_tmp_syn= & tmp_syn;
 
   /* Parse the query. */
 
@@ -7511,6 +7515,7 @@ bool parse_sql(THD *thd,
   /* Reset Lex_input_stream. */
 
   thd->m_lip= NULL;
+  thd->m_tmp_syn= NULL;
 
   /* Restore creation context. */
 
diff -Nrup a/sql/sql_signal.cc b/sql/sql_signal.cc
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/sql/sql_signal.cc	2008-04-14 12:07:52 -06:00
@@ -0,0 +1,103 @@
+/* Copyright (C) 2008 Sun Microsystems, Inc
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+#include "mysql_priv.h"
+#include "sp_head.h"
+#include "sp_pcontext.h"
+#include "sp_rcontext.h"
+#include "sql_signal.h"
+
+Set_signal_information::Set_signal_information()
+{
+  int i;
+  for (i= FIRST_DIAG_SET_PROPERTY;
+       i <= LAST_DIAG_SET_PROPERTY;
+       i++)
+  {
+    m_item[i]= NULL;
+  }
+}
+
+Set_signal_information::Set_signal_information(
+  const Set_signal_information& set)
+{
+  int i;
+  for (i= FIRST_DIAG_SET_PROPERTY;
+       i <= LAST_DIAG_SET_PROPERTY;
+       i++)
+  {
+    m_item[i]= set.m_item[i];
+  }
+}
+
+void Set_signal_information::clear()
+{
+  int i;
+  for (i= FIRST_DIAG_SET_PROPERTY;
+       i <= LAST_DIAG_SET_PROPERTY;
+       i++)
+  {
+    m_item[i]= NULL;
+  }
+}
+
+Sp_printable_instr::Sp_printable_instr(uint ip, sp_pcontext *ctx,
+                                       LEX *lex, const LEX_STRING *query)
+  : sp_instr(ip, ctx),
+    m_lex_keeper(lex, FALSE)
+{
+  size_t len= sizeof(m_query_buffer);
+  if (query->length > len)
+  {
+    memcpy(m_query_buffer, query->str, len - 3);
+    memcpy(m_query_buffer + len - 3, "...", 3);
+    m_query_length= len;
+  }
+  else
+  {
+    memcpy(m_query_buffer, query->str, query->length);
+    m_query_length= query->length;
+  }
+}
+
+void Sp_printable_instr::print(String *str)
+{
+  str->reserve(m_query_length);
+  str->qs_append(m_query_buffer, m_query_length);
+}
+
+int Sp_printable_instr::execute(THD *thd, uint *nextp)
+{
+  return m_lex_keeper.reset_lex_and_exec_core(thd, nextp, TRUE, this);
+}
+
+int Sp_instr_signal::exec_core(THD *thd, uint *nextp)
+{
+  my_error(ER_NOT_SUPPORTED_YET, MYF(0), "SIGNAL");
+  return 1;
+}
+
+int Sp_instr_resignal::exec_core(THD *thd, uint *nextp)
+{
+  my_error(ER_NOT_SUPPORTED_YET, MYF(0), "RESIGNAL");
+  return 1;
+}
+
+int Sp_instr_get_diag::exec_core(THD *thd, uint *nextp)
+{
+  my_error(ER_NOT_SUPPORTED_YET, MYF(0), "GET DIAGNOSTICS");
+  return 1;
+}
+
diff -Nrup a/sql/sql_signal.h b/sql/sql_signal.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/sql/sql_signal.h	2008-04-14 12:07:52 -06:00
@@ -0,0 +1,129 @@
+/* Copyright (C) 2008 Sun Microsystems, Inc
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+#ifndef SQL_SIGNAL_H
+#define SQL_SIGNAL_H
+
+class Sp_printable_instr : public sp_instr
+{
+public:
+  virtual void print(String *str);
+  virtual int execute(THD *thd, uint *nextp);
+
+protected:
+  Sp_printable_instr(uint ip, sp_pcontext *ctx,
+                     LEX *lex, const LEX_STRING *query);
+
+  virtual ~Sp_printable_instr()
+  {}
+
+private:
+  char m_query_buffer[40];
+  int m_query_length;
+  sp_lex_keeper m_lex_keeper;
+};
+
+class Abstract_signal : public Sp_printable_instr
+{
+protected:
+  Abstract_signal(uint ip, sp_pcontext *ctx, LEX *lex,
+                  const LEX_STRING *query,
+                  const sp_cond_type_t *cond,
+                  const Set_signal_information& set)
+    : Sp_printable_instr(ip, ctx, lex, query),
+      m_cond(cond),
+      m_set_signal_information(set)
+  {}
+
+  virtual ~Abstract_signal()
+  {}
+
+  const sp_cond_type_t *m_cond;
+  Set_signal_information m_set_signal_information;
+};
+
+class Sp_instr_signal : public Abstract_signal
+{
+public:
+  Sp_instr_signal(uint ip, sp_pcontext *ctx, LEX *lex,
+                  const LEX_STRING *query,
+                  const sp_cond_type_t *cond,
+                  const Set_signal_information& set)
+    : Abstract_signal(ip, ctx, lex, query, cond, set)
+  {}
+
+  virtual ~Sp_instr_signal()
+  {}
+
+  virtual int exec_core(THD *thd, uint *nextp);
+};
+
+class Sp_instr_resignal : public Abstract_signal
+{
+public:
+  Sp_instr_resignal(uint ip, sp_pcontext *ctx, LEX *lex,
+                    const LEX_STRING *query,
+                    const sp_cond_type_t *cond,
+                    const Set_signal_information& set)
+    : Abstract_signal(ip, ctx, lex, query, cond, set)
+  {}
+
+  virtual ~Sp_instr_resignal()
+  {}
+
+  virtual int exec_core(THD *thd, uint *nextp);
+};
+
+
+class Sp_instr_get_diag : public Sp_printable_instr
+{
+public:
+  Sp_instr_get_diag(uint ip, sp_pcontext *ctx, LEX *lex,
+                    const LEX_STRING *query,
+                    diagnostic_area_type area_type,
+                    List<Diag_statement_property> *statement_property_list)
+    : Sp_printable_instr(ip, ctx, lex, query),
+      m_area_type(area_type),
+      m_cond_expr(NULL),
+      m_condition_property_list(NULL),
+      m_statement_property_list(statement_property_list)
+  {}
+
+  Sp_instr_get_diag(uint ip, sp_pcontext *ctx, LEX *lex,
+                    const LEX_STRING *query,
+                    diagnostic_area_type area_type,
+                    Item *condition_expr,
+                    List<Diag_condition_property> *condition_property_list)
+    : Sp_printable_instr(ip, ctx, lex, query),
+      m_area_type(area_type),
+      m_cond_expr(condition_expr),
+      m_condition_property_list(condition_property_list),
+      m_statement_property_list(NULL)
+  {}
+
+  virtual ~Sp_instr_get_diag()
+  {}
+
+  virtual int exec_core(THD *thd, uint *nextp);
+
+private:
+  diagnostic_area_type m_area_type;
+  Item *m_cond_expr;
+  List<Diag_condition_property> *m_condition_property_list;
+  List<Diag_statement_property> *m_statement_property_list;
+};
+
+#endif
+
diff -Nrup a/sql/sql_yacc.yy b/sql/sql_yacc.yy
--- a/sql/sql_yacc.yy	2008-04-01 09:13:54 -06:00
+++ b/sql/sql_yacc.yy	2008-04-14 12:07:52 -06:00
@@ -42,6 +42,7 @@
 #include "sp_pcontext.h"
 #include "sp_rcontext.h"
 #include "sp.h"
+#include "sql_signal.h"
 #include "event_data_objects.h"
 #include <myisam.h>
 #include <myisammrg.h>
@@ -583,6 +584,13 @@ bool setup_select_in_parentheses(LEX *le
   enum enum_filetype filetype;
   enum ha_build_method build_method;
   enum Foreign_key::fk_option m_fk_option;
+  Diag_condition_item_name diag_condition_item_name;
+  Diag_statement_item_name diag_statement_item_name;
+  Diag_condition_property *diag_condition;
+  Diag_statement_property *diag_statement;
+  List<Diag_condition_property> *condition_information_list;
+  List<Diag_statement_property> *statement_information_list;
+  enum diagnostic_area_type diag_area; 
 }
 
 %{
@@ -664,6 +672,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  CASCADED                      /* SQL-2003-R */
 %token  CASE_SYM                      /* SQL-2003-R */
 %token  CAST_SYM                      /* SQL-2003-R */
+%token  CATALOG_NAME_SYM              /* SQL-2003-N */
 %token  CHAIN_SYM                     /* SQL-2003-N */
 %token  CHANGE
 %token  CHANGED
@@ -672,6 +681,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  CHECKSUM_SYM
 %token  CHECK_SYM                     /* SQL-2003-R */
 %token  CIPHER_SYM
+%token  CLASS_ORIGIN_SYM              /* SQL-2003-N */
 %token  CLIENT_SYM
 %token  CLOSE_SYM                     /* SQL-2003-R */
 %token  COALESCE                      /* SQL-2003-N */
@@ -680,6 +690,9 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  COLLATION_SYM                 /* SQL-2003-N */
 %token  COLUMNS
 %token  COLUMN_SYM                    /* SQL-2003-R */
+%token  COLUMN_NAME_SYM               /* SQL-2003-N */
+%token  COMMAND_FUNCTION_SYM          /* SQL-2003-N */
+%token  COMMAND_FUNCTION_CODE_SYM     /* SQL-2003-N */
 %token  COMMENT_SYM
 %token  COMMITTED_SYM                 /* SQL-2003-N */
 %token  COMMIT_SYM                    /* SQL-2003-R */
@@ -687,10 +700,16 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  COMPLETION_SYM
 %token  COMPRESSED_SYM
 %token  CONCURRENT
+%token  CONDITION_NUMBER_SYM          /* SQL-2003-N */
 %token  CONDITION_SYM                 /* SQL-2003-N */
+%token  CONDITION_IDENTIFIER_SYM      /* SQL-2003-N */
 %token  CONNECTION_SYM
+%token  CONNECTION_NAME_SYM           /* SQL-2003-N */
 %token  CONSISTENT_SYM
 %token  CONSTRAINT                    /* SQL-2003-R */
+%token  CONSTRAINT_CATALOG_SYM        /* SQL-2003-N */
+%token  CONSTRAINT_NAME_SYM           /* SQL-2003-N */
+%token  CONSTRAINT_SCHEMA_SYM         /* SQL-2003-N */
 %token  CONTAINS_SYM                  /* SQL-2003-N */
 %token  CONTEXT_SYM
 %token  CONTINUE_SYM                  /* SQL-2003-R */
@@ -702,8 +721,10 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  CROSS                         /* SQL-2003-R */
 %token  CUBE_SYM                      /* SQL-2003-R */
 %token  CURDATE                       /* MYSQL-FUNC */
+%token  CURRENT_SYM                   /* SQL-2003-N */
 %token  CURRENT_USER                  /* SQL-2003-R */
 %token  CURSOR_SYM                    /* SQL-2003-R */
+%token  CURSOR_NAME_SYM               /* SQL-2003-N */
 %token  CURTIME                       /* MYSQL-FUNC */
 %token  DATABASE
 %token  DATABASES
@@ -731,6 +752,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  DESCRIBE                      /* SQL-2003-R */
 %token  DES_KEY_FILE
 %token  DETERMINISTIC_SYM             /* SQL-2003-R */
+%token  DIAGNOSTICS_SYM               /* SQL-2003-N */
 %token  DIRECTORY_SYM
 %token  DISABLE_SYM
 %token  DISCARD
@@ -744,6 +766,8 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  DUMPFILE
 %token  DUPLICATE_SYM
 %token  DYNAMIC_SYM                   /* SQL-2003-R */
+%token  DYNAMIC_FUNCTION_SYM          /* SQL-2003-N */
+%token  DYNAMIC_FUNCTION_CODE_SYM     /* SQL-2003-N */
 %token  EACH_SYM                      /* SQL-2003-R */
 %token  ELSE                          /* SQL-2003-R */
 %token  ELSEIF_SYM
@@ -763,6 +787,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  EVENTS_SYM
 %token  EVENT_SYM
 %token  EVERY_SYM                     /* SQL-2003-N */
+%token  EXCEPTION_SYM                 /* SQL-2003-N */
 %token  EXCLUSIVE_SYM
 %token  EXECUTE_SYM                   /* SQL-2003-R */
 %token  EXISTS                        /* SQL-2003-R */
@@ -794,6 +819,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  GE
 %token  GEOMETRYCOLLECTION
 %token  GEOMETRY_SYM
+%token  GET_SYM                       /* SQL-2003-R */
 %token  GET_FORMAT                    /* MYSQL-FUNC */
 %token  GLOBAL_SYM                    /* SQL-2003-R */
 %token  GRANT                         /* SQL-2003-R */
@@ -907,6 +933,9 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  MEDIUM_SYM
 %token  MEMORY_SYM
 %token  MERGE_SYM                     /* SQL-2003-R */
+%token  MESSAGE_LENGTH_SYM            /* SQL-2003-N */
+%token  MESSAGE_OCTET_LENGTH_SYM      /* SQL-2003-N */
+%token  MESSAGE_TEXT_SYM              /* SQL-2003-N */
 %token  MICROSECOND_SYM               /* MYSQL-FUNC */
 %token  MIGRATE_SYM
 %token  MINUTE_MICROSECOND_SYM
@@ -919,6 +948,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  MODIFY_SYM
 %token  MOD_SYM                       /* SQL-2003-N */
 %token  MONTH_SYM                     /* SQL-2003-R */
+%token  MORE_SYM                      /* SQL-2003-N */
 %token  MULTILINESTRING
 %token  MULTIPOINT
 %token  MULTIPOLYGON
@@ -945,6 +975,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  NO_WRITE_TO_BINLOG
 %token  NULL_SYM                      /* SQL-2003-R */
 %token  NUM
+%token  NUMBER_SYM                    /* SQL-2003-N */
 %token  NUMERIC_SYM                   /* SQL-2003-R */
 %token  NVARCHAR_SYM
 %token  OFFLINE_SYM
@@ -971,6 +1002,9 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  PAGE_SYM
 %token  PAGE_CHECKSUM_SYM
 %token  PARAM_MARKER
+%token  PARAMETER_MODE_SYM            /* SQL-2003-N */
+%token  PARAMETER_NAME_SYM            /* SQL-2003-N */
+%token  PARAMETER_ORDINAL_POSITION_SYM /* SQL-2003-N */
 %token  PARSER_SYM
 %token  PARTIAL                       /* SQL-2003-N */
 %token  PARTITIONING_SYM
@@ -1027,10 +1061,12 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  REPLICATION
 %token  REQUIRE_SYM
 %token  RESET_SYM
+%token  RESIGNAL_SYM                  /* SQL-2003-R */
 %token  RESOURCES
 %token  RESTORE_SYM
 %token  RESTRICT
 %token  RESUME_SYM
+%token  RETURNED_SQLSTATE_SYM         /* SQL-2003-N */
 %token  RETURNS_SYM                   /* SQL-2003-R */
 %token  RETURN_SYM                    /* SQL-2003-R */
 %token  REVERSE_SYM
@@ -1039,12 +1075,17 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  ROLLBACK_SYM                  /* SQL-2003-R */
 %token  ROLLUP_SYM                    /* SQL-2003-R */
 %token  ROUTINE_SYM                   /* SQL-2003-N */
+%token  ROUTINE_CATALOG_SYM           /* SQL-2003-N */
+%token  ROUTINE_NAME_SYM              /* SQL-2003-N */
+%token  ROUTINE_SCHEMA_SYM            /* SQL-2003-N */
 %token  ROWS_SYM                      /* SQL-2003-R */
+%token  ROW_COUNT_SYM                 /* SQL-2003-N */
 %token  ROW_FORMAT_SYM
 %token  ROW_SYM                       /* SQL-2003-R */
 %token  RTREE_SYM
 %token  SAVEPOINT_SYM                 /* SQL-2003-R */
 %token  SCHEDULE_SYM
+%token  SCHEMA_NAME_SYM               /* SQL-2003-N */
 %token  SECOND_MICROSECOND_SYM
 %token  SECOND_SYM                    /* SQL-2003-R */
 %token  SECURITY_SYM                  /* SQL-2003-N */
@@ -1055,6 +1096,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  SERIAL_SYM
 %token  SESSION_SYM                   /* SQL-2003-N */
 %token  SERVER_SYM
+%token  SERVER_NAME_SYM               /* SQL-2003-N */
 %token  SERVER_OPTIONS
 %token  SET                           /* SQL-2003-R */
 %token  SET_VAR
@@ -1063,6 +1105,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  SHIFT_RIGHT                   /* OPERATOR */
 %token  SHOW
 %token  SHUTDOWN
+%token  SIGNAL_SYM                    /* SQL-2003-R */
 %token  SIGNED_SYM
 %token  SIMPLE_SYM                    /* SQL-2003-N */
 %token  SLAVE
@@ -1074,6 +1117,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  SOURCE_SYM
 %token  SPATIAL_SYM
 %token  SPECIFIC_SYM                  /* SQL-2003-R */
+%token  SPECIFIC_NAME_SYM             /* SQL-2003-N */
 %token  SQLEXCEPTION_SYM              /* SQL-2003-R */
 %token  SQLSTATE_SYM                  /* SQL-2003-R */
 %token  SQLWARNING_SYM                /* SQL-2003-R */
@@ -1086,6 +1130,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  SQL_SYM                       /* SQL-2003-R */
 %token  SQL_THREAD
 %token  SSL_SYM
+%token  STACKED_SYM                   /* SQL-2003-N */
 %token  STARTING
 %token  STARTS_SYM
 %token  START_SYM                     /* SQL-2003-R */
@@ -1096,6 +1141,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  STORAGE_SYM
 %token  STRAIGHT_JOIN
 %token  STRING_SYM
+%token  SUBCLASS_ORIGIN_SYM           /* SQL-2003-N */
 %token  SUBDATE_SYM
 %token  SUBJECT_SYM
 %token  SUBPARTITIONS_SYM
@@ -1112,6 +1158,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  TABLE_REF_PRIORITY
 %token  TABLE_SYM                     /* SQL-2003-R */
 %token  TABLE_CHECKSUM_SYM
+%token  TABLE_NAME_SYM                /* SQL-2003-N */
 %token  TEMPORARY                     /* SQL-2003-N */
 %token  TEMPTABLE_SYM
 %token  TERMINATED
@@ -1129,9 +1176,15 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  TO_SYM                        /* SQL-2003-R */
 %token  TRAILING                      /* SQL-2003-R */
 %token  TRANSACTION_SYM
+%token  TRANSACTION_ACTIVE_SYM        /* SQL-2003-N */
+%token  TRANSACTIONS_COMMITTED_SYM    /* SQL-2003-N */
 %token  TRANSACTIONAL_SYM
+%token  TRANSACTIONS_ROLLED_BACK_SYM  /* SQL-2003-N */
 %token  TRIGGERS_SYM
 %token  TRIGGER_SYM                   /* SQL-2003-R */
+%token  TRIGGER_CATALOG_SYM           /* SQL-2003-N */
+%token  TRIGGER_NAME_SYM              /* SQL-2003-N */
+%token  TRIGGER_SCHEMA_SYM            /* SQL-2003-N */
 %token  TRIM                          /* SQL-2003-N */
 %token  TRUE_SYM                      /* SQL-2003-R */
 %token  TRUNCATE_SYM
@@ -1422,7 +1475,7 @@ END_OF_INPUT
 %type <NONE> case_stmt_specification simple_case_stmt searched_case_stmt
 
 %type <num>  sp_decl_idents sp_opt_inout sp_handler_type sp_hcond_list
-%type <spcondtype> sp_cond sp_hcond
+%type <spcondtype> sp_cond sp_hcond sqlstate signal_value opt_signal_value
 %type <spblock> sp_decls sp_decl
 %type <lex> sp_cursor_stmt
 %type <spname> sp_name
@@ -1430,6 +1483,17 @@ END_OF_INPUT
 %type <num> index_hint_clause
 %type <filetype> data_or_xml
 
+%type <NONE> signal_stmt resignal_stmt get_diagnostics_stmt
+%type <diag_condition_item_name> signal_condition_information_item_name
+%type <diag_condition_item_name> condition_information_item_name
+%type <diag_statement_item_name> statement_information_item_name
+%type <diag_condition> condition_information_item
+%type <diag_statement> statement_information_item
+%type <diag_area> opt_which_area
+%type <item> simple_target_specification
+%type <condition_information_list> condition_information_list
+%type <statement_information_list> statement_information
+
 %type <NONE>
         '-' '+' '*' '/' '%' '(' ')'
         ',' '!' '{' '}' '&' '|' AND_SYM OR_SYM OR_OR_SYM BETWEEN_SYM CASE_SYM
@@ -2128,6 +2192,9 @@ ev_sql_stmt_inner:
         | sp_proc_stmt_open
         | sp_proc_stmt_fetch
         | sp_proc_stmt_close
+        | signal_stmt
+        | resignal_stmt
+        | get_diagnostics_stmt
         ;
 
 clear_privileges:
@@ -2602,7 +2669,11 @@ sp_cond:
             $$->type= sp_cond_type_t::number;
             $$->mysqlerr= $1;
           }
-        | SQLSTATE_SYM opt_value TEXT_STRING_literal
+        | sqlstate
+        ;
+
+sqlstate:
+          SQLSTATE_SYM opt_value TEXT_STRING_literal
           { /* SQLSTATE */
             if (!sp_cond_check(&$3))
             {
@@ -2652,6 +2723,391 @@ sp_hcond:
           }
         ;
 
+signal_stmt:
+          SIGNAL_SYM
+          {
+            THD *thd= YYTHD;
+            LEX *lex= thd->lex;
+            Lex_input_stream *lip= thd->m_lip;
+            sp_head *sp= lex->sphead;
+
+            sp->reset_lex(thd);
+            sp->m_tmp_query= lip->get_tok_start();
+          }
+          signal_value
+          opt_set_signal_information
+          {
+            THD *thd= YYTHD;
+            LEX *lex= thd->lex;
+            Lex_input_stream *lip= thd->m_lip;
+            Tmp_syn *tmp_syn= thd->m_tmp_syn;
+            sp_head *sp= lex->sphead;
+            sp_instr *i;
+
+            LEX_STRING query;
+            query.length= lip->get_ptr() - sp->m_tmp_query;
+            query.str= (char*) sp->m_tmp_query;
+
+            i= new (thd->mem_root) Sp_instr_signal(sp->instructions(),
+                                                   lex->spcont,
+                                                   lex,
+                                                   & query,
+                                                   $3,
+                                                   tmp_syn->m_set_signal_info);
+            sp->add_instr(i);
+
+            sp->restore_lex(thd);
+          }
+        ;
+
+signal_value:
+          ident
+          {
+            $$= Lex->spcont->find_cond(&$1);
+            if ($$ == NULL)
+            {
+              my_error(ER_SP_COND_MISMATCH, MYF(0), $1.str);
+              MYSQL_YYABORT;
+            }
+          }
+        | sqlstate
+          { $$= $1; }
+        ;
+
+opt_signal_value:
+          /* empty */
+          { $$= NULL; }
+        | signal_value
+          { $$= $1; }
+        ;
+
+opt_set_signal_information:
+          /* empty */
+          {
+            YYTHD->m_tmp_syn->m_set_signal_info.clear();
+          }
+        | SET signal_information_item_list
+        ;
+
+signal_information_item_list:
+          signal_condition_information_item_name EQ expr
+          {
+            Set_signal_information *info= & YYTHD->m_tmp_syn->m_set_signal_info;
+            int index= (int) $1;
+            info->clear();
+            info->m_item[index]= $3;
+          }
+        | signal_information_item_list ','
+          signal_condition_information_item_name EQ expr
+          {
+            Set_signal_information *info= & YYTHD->m_tmp_syn->m_set_signal_info;
+            int index= (int) $3;
+            if (info->m_item[index] != NULL)
+            {
+              my_error(ER_WRONG_USAGE, MYF(0), "SIGNAL/RESIGNAL", "SET");
+              MYSQL_YYABORT;
+            }
+            info->m_item[index]= $5;
+          }
+        ;
+
+/*
+  REFERENCE:
+  - ISO/IEC 9075-2:2003 (E), section 22.1
+  - ISO/IEC 9075-4:2003 (E), section 16.1
+*/
+
+/* conditions that can be set in signal / resignal */
+signal_condition_information_item_name:
+          CLASS_ORIGIN_SYM
+          { $$= DIAG_CLASS_ORIGIN; }
+        | SUBCLASS_ORIGIN_SYM
+          { $$= DIAG_SUBCLASS_ORIGIN; }
+        | CONSTRAINT_CATALOG_SYM
+          { $$= DIAG_CONSTRAINT_CATALOG; }
+        | CONSTRAINT_SCHEMA_SYM
+          { $$= DIAG_CONSTRAINT_SCHEMA; }
+        | CONSTRAINT_NAME_SYM
+          { $$= DIAG_CONSTRAINT_NAME; }
+        | CATALOG_NAME_SYM
+          { $$= DIAG_CATALOG_NAME; }
+        | SCHEMA_NAME_SYM
+          { $$= DIAG_SCHEMA_NAME; }
+        | TABLE_NAME_SYM
+          { $$= DIAG_TABLE_NAME; }
+        | COLUMN_NAME_SYM
+          { $$= DIAG_COLUMN_NAME; }
+        | CURSOR_NAME_SYM
+          { $$= DIAG_CURSOR_NAME; }
+        | MESSAGE_TEXT_SYM
+          { $$= DIAG_MESSAGE_TEXT; }
+        ;
+
+/* conditions that can be read in get diagnostics */
+condition_information_item_name:
+          signal_condition_information_item_name
+          { $$= $1; }
+        | CONDITION_IDENTIFIER_SYM
+          { $$= DIAG_CONDITION_IDENTIFIER; }
+        | CONDITION_NUMBER_SYM
+          { $$= DIAG_CONDITION_NUMBER; }
+        | CONNECTION_NAME_SYM
+          { $$= DIAG_CONNECTION_NAME; }
+        | MESSAGE_LENGTH_SYM
+          { $$= DIAG_MESSAGE_LENGTH; }
+        | MESSAGE_OCTET_LENGTH_SYM
+          { $$= DIAG_MESSAGE_OCTET_LENGTH; }
+        | PARAMETER_MODE_SYM
+          { $$= DIAG_PARAMETER_MODE; }
+        | PARAMETER_NAME_SYM
+          { $$= DIAG_PARAMETER_NAME; }
+        | PARAMETER_ORDINAL_POSITION_SYM
+          { $$= DIAG_PARAMETER_ORDINAL_POSITION; }
+        | RETURNED_SQLSTATE_SYM
+          { $$= DIAG_RETURNED_SQLSTATE; }
+        | ROUTINE_CATALOG_SYM
+          { $$= DIAG_ROUTINE_CATALOG; }
+        | ROUTINE_NAME_SYM
+          { $$= DIAG_ROUTINE_NAME; }
+        | ROUTINE_SCHEMA_SYM
+          { $$= DIAG_ROUTINE_SCHEMA; }
+        | SERVER_NAME_SYM
+          { $$= DIAG_SERVER_NAME; }
+        | SPECIFIC_NAME_SYM
+          { $$= DIAG_SPECIFIC_NAME; }
+        | TRIGGER_CATALOG_SYM
+          { $$= DIAG_TRIGGER_CATALOG; }
+        | TRIGGER_NAME_SYM
+          { $$= DIAG_TRIGGER_NAME; }
+        | TRIGGER_SCHEMA_SYM
+          { $$= DIAG_TRIGGER_SCHEMA; }
+        ;
+
+resignal_stmt:
+          RESIGNAL_SYM
+          {
+            THD *thd= YYTHD;
+            LEX *lex= thd->lex;
+            Lex_input_stream *lip= thd->m_lip;
+            sp_head *sp= lex->sphead;
+
+            sp->reset_lex(thd);
+            sp->m_tmp_query= lip->get_tok_start();
+          }
+          opt_signal_value
+          opt_set_signal_information
+          {
+            THD *thd= YYTHD;
+            LEX *lex= thd->lex;
+            Lex_input_stream *lip= thd->m_lip;
+            Tmp_syn *tmp_syn= thd->m_tmp_syn;
+            sp_head *sp= lex->sphead;
+            sp_instr *i;
+
+            LEX_STRING query;
+            query.length= lip->get_ptr() - sp->m_tmp_query;
+            query.str= (char*) sp->m_tmp_query;
+
+            i= new (thd->mem_root) Sp_instr_resignal(sp->instructions(),
+                                                     lex->spcont,
+                                                     lex,
+                                                     & query,
+                                                     $3,
+                                                     tmp_syn->m_set_signal_info);
+            sp->add_instr(i);
+
+            sp->restore_lex(thd);
+          }
+        ;
+
+init_get_diagnostics:
+          /* empty */
+          {
+            THD *thd= YYTHD;
+            LEX *lex= thd->lex;
+            Lex_input_stream *lip= thd->m_lip;
+            sp_head *sp= lex->sphead;
+
+            sp->reset_lex(thd);
+            sp->m_tmp_query= lip->get_tok_start();
+          }
+        ;
+
+get_diagnostics_stmt:
+          GET_SYM /* $1 */
+          init_get_diagnostics /* $2 */
+          opt_which_area /* $3 */
+          DIAGNOSTICS_SYM /* $4 */
+          statement_information /* $5 */
+          {
+            THD *thd= YYTHD;
+            LEX *lex= thd->lex;
+            Lex_input_stream *lip= thd->m_lip;
+            sp_head *sp= lex->sphead;
+            sp_instr *i;
+
+            LEX_STRING query;
+            query.length= lip->get_ptr() - sp->m_tmp_query;
+            query.str= (char*) sp->m_tmp_query;
+
+            i= new (thd->mem_root) Sp_instr_get_diag(sp->instructions(),
+                                                     lex->spcont,
+                                                     lex,
+                                                     & query,
+                                                     $3,
+                                                     $5);
+            sp->add_instr(i);
+
+            sp->restore_lex(thd);
+          }
+        | GET_SYM /* $1 */
+          init_get_diagnostics /* $2 */
+          opt_which_area /* $3 */
+          DIAGNOSTICS_SYM /* $4 */
+          exception_or_condition /* $5 */
+          expr /* $6 */
+          condition_information_list /* $7 */
+          {
+            THD *thd= YYTHD;
+            LEX *lex= thd->lex;
+            Lex_input_stream *lip= thd->m_lip;
+            sp_head *sp= lex->sphead;
+            sp_instr *i;
+
+            LEX_STRING query;
+            query.length= lip->get_ptr() - sp->m_tmp_query;
+            query.str= (char*) sp->m_tmp_query;
+
+            i= new (thd->mem_root) Sp_instr_get_diag(sp->instructions(),
+                                                     lex->spcont,
+                                                     lex,
+                                                     & query,
+                                                     $3,
+                                                     $6,
+                                                     $7);
+            sp->add_instr(i);
+
+            sp->restore_lex(thd);
+          }
+        ;
+
+opt_which_area:
+          /* empty */
+          { $$= CURRENT_AREA; }
+        | CURRENT_SYM
+          { $$= CURRENT_AREA; }
+        | STACKED_SYM
+          { $$= STACKED_AREA; }
+        ;
+
+statement_information:
+          statement_information_item
+          {
+            $$= new (YYTHD->mem_root) List<Diag_statement_property>;
+            $$->push_back($1);
+          }
+        | statement_information ',' statement_information_item
+          {
+            $1->push_back($3);
+            $$= $1;
+          }
+        ;
+
+statement_information_item:
+          simple_target_specification EQ statement_information_item_name
+          {
+            $$= new (YYTHD->mem_root) Diag_statement_property($1, $3);
+            if ($$ == NULL)
+              MYSQL_YYABORT;
+          }
+        ;
+
+statement_information_item_name:
+          NUMBER_SYM
+          { $$= DIAG_NUMBER; }
+        | MORE_SYM
+          { $$= DIAG_MORE; }
+        | COMMAND_FUNCTION_SYM
+          { $$= DIAG_COMMAND_FUNCTION; }
+        | COMMAND_FUNCTION_CODE_SYM
+          { $$= DIAG_COMMAND_FUNCTION_CODE; }
+        | DYNAMIC_FUNCTION_SYM
+          { $$= DIAG_DYNAMIC_FUNCTION; }
+        | DYNAMIC_FUNCTION_CODE_SYM
+          { $$= DIAG_DYNAMIC_FUNCTION_CODE; }
+        | ROW_COUNT_SYM
+          { $$= DIAG_ROW_COUNT; }
+        | TRANSACTIONS_COMMITTED_SYM
+          { $$= DIAG_TRANSACTIONS_COMMITTED; }
+        | TRANSACTIONS_ROLLED_BACK_SYM
+          { $$= DIAG_TRANSACTIONS_ROLLED_BACK; }
+        | TRANSACTION_ACTIVE_SYM
+          { $$= DIAG_TRANSACTION_ACTIVE; }
+        ;
+
+simple_target_specification:
+          ident
+          {
+            THD *thd= YYTHD;
+            LEX *lex= thd->lex;
+            Lex_input_stream *lip= thd->m_lip;
+            sp_pcontext *spc= thd->lex->spcont;
+            sp_variable_t *spv;
+            Item_splocal *splocal;
+            uint pos_in_q;
+            uint len_in_q;
+            
+            DBUG_ASSERT(spc);
+            spv = spc->find_variable(&$1);
+            if (spv == NULL)
+            {
+              my_error(ER_SP_UNDECLARED_VAR, MYF(0), $1.str);
+              MYSQL_YYABORT;
+            }
+
+            pos_in_q= lip->get_tok_start_prev() - lex->sphead->m_tmp_query;
+            len_in_q= lip->get_tok_end() - lip->get_tok_start_prev();
+            splocal= new (thd->mem_root) Item_splocal($1,
+                                                      spv->offset, spv->type,
+                                                      pos_in_q, len_in_q);
+#ifndef DBUG_OFF
+            if (splocal)
+              splocal->m_sp= lex->sphead;
+#endif
+            $$ = splocal;
+          }
+        | '@' ident_or_text
+          {
+            $$= new (YYTHD->mem_root) Item_user_var_as_out_param($2);
+          }
+        ;
+
+exception_or_condition:
+          EXCEPTION_SYM
+        | CONDITION_SYM
+        ;
+
+condition_information_list:
+          condition_information_item
+          {
+            $$= new (YYTHD->mem_root) List<Diag_condition_property>;
+            $$->push_back($1);
+          }
+        | condition_information_list ',' condition_information_item
+          {
+            $1->push_back($3);
+            $$= $1;
+          }
+        ;
+
+condition_information_item:
+          simple_target_specification EQ condition_information_item_name
+          {
+            $$= new (YYTHD->mem_root) Diag_condition_property($1, $3);
+          }
+        ;
+
+
 sp_decl_idents:
           ident
           {
@@ -2704,6 +3160,9 @@ sp_proc_stmt:
         | sp_proc_stmt_open
         | sp_proc_stmt_fetch
         | sp_proc_stmt_close
+        | signal_stmt
+        | resignal_stmt
+        | get_diagnostics_stmt
         ;
 
 sp_proc_stmt_if:
@@ -7426,6 +7885,12 @@ function_call_conflict:
           { $$= new (YYTHD->mem_root) Item_func_replace($3,$5,$7); }
         | REVERSE_SYM '(' expr ')'
           { $$= new (YYTHD->mem_root) Item_func_reverse($3); }
+        | ROW_COUNT_SYM '(' ')'
+          {
+            Lex->set_stmt_unsafe();
+            Lex->safe_to_cache_query= 0;
+            $$= new (YYTHD->mem_root) Item_func_row_count();
+          }
         | TRUNCATE_SYM '(' expr ',' expr ')'
           { $$= new (YYTHD->mem_root) Item_func_round($3,$5,1); }
         | WEEK_SYM '(' expr ')'
@@ -10922,26 +11387,40 @@ keyword_sp:
         | BOOLEAN_SYM              {}
         | BTREE_SYM                {}
         | CASCADED                 {}
+        | CATALOG_NAME_SYM         {}
         | CHAIN_SYM                {}
         | CHANGED                  {}
         | CIPHER_SYM               {}
         | CLIENT_SYM               {}
+        | CLASS_ORIGIN_SYM         {}
         | COALESCE                 {}
         | CODE_SYM                 {}
         | COLLATION_SYM            {}
         | COLUMN_FORMAT_SYM        {}
+        | COLUMN_NAME_SYM          {}
         | COLUMNS                  {}
+        | COMMAND_FUNCTION_SYM     {}
+        | COMMAND_FUNCTION_CODE_SYM {}
         | COMMITTED_SYM            {}
         | COMPACT_SYM              {}
         | COMPLETION_SYM           {}
         | COMPRESSED_SYM           {}
         | CONCURRENT               {}
+        | CONDITION_SYM            {}
+        | CONDITION_IDENTIFIER_SYM {}
+        | CONDITION_NUMBER_SYM     {}
         | CONNECTION_SYM           {}
+        | CONNECTION_NAME_SYM      {}
         | CONSISTENT_SYM           {}
+        | CONSTRAINT_CATALOG_SYM   {}
+        | CONSTRAINT_SCHEMA_SYM    {}
+        | CONSTRAINT_NAME_SYM      {}
         | CONTEXT_SYM              {}
         | CONTRIBUTORS_SYM         {}
         | CPU_SYM                  {}
         | CUBE_SYM                 {}
+        | CURRENT_SYM              {}
+        | CURSOR_NAME_SYM          {}
         | DATA_SYM                 {}
         | DATAFILE_SYM             {}
         | DATETIME                 {}
@@ -10950,6 +11429,7 @@ keyword_sp:
         | DEFINER_SYM              {}
         | DELAY_KEY_WRITE_SYM      {}
         | DES_KEY_FILE             {}
+        | DIAGNOSTICS_SYM          {}
         | DIRECTORY_SYM            {}
         | DISABLE_SYM              {}
         | DISCARD                  {}
@@ -10957,6 +11437,8 @@ keyword_sp:
         | DUMPFILE                 {}
         | DUPLICATE_SYM            {}
         | DYNAMIC_SYM              {}
+        | DYNAMIC_FUNCTION_SYM     {}
+        | DYNAMIC_FUNCTION_CODE_SYM {}
         | ENDS_SYM                 {}
         | ENUM                     {}
         | ENGINE_SYM               {}
@@ -10966,6 +11448,7 @@ keyword_sp:
         | EVENT_SYM                {}
         | EVENTS_SYM               {}
         | EVERY_SYM                {}
+        | EXCEPTION_SYM            {}
         | EXCLUSIVE_SYM            {}
         | EXPANSION_SYM            {}
         | EXTENDED_SYM             {}
@@ -11033,6 +11516,9 @@ keyword_sp:
         | MEDIUM_SYM               {}
         | MEMORY_SYM               {}
         | MERGE_SYM                {}
+        | MESSAGE_LENGTH_SYM       {}
+        | MESSAGE_OCTET_LENGTH_SYM {}
+        | MESSAGE_TEXT_SYM         {}
         | MICROSECOND_SYM          {}
         | MIGRATE_SYM              {}
         | MINUTE_SYM               {}
@@ -11040,6 +11526,7 @@ keyword_sp:
         | MODIFY_SYM               {}
         | MODE_SYM                 {}
         | MONTH_SYM                {}
+        | MORE_SYM                 {}
         | MULTILINESTRING          {}
         | MULTIPOINT               {}
         | MULTIPOLYGON             {}
@@ -11055,6 +11542,7 @@ keyword_sp:
         | NODEGROUP_SYM            {}
         | NONE_SYM                 {}
         | NOWAIT_SYM               {}
+        | NUMBER_SYM               {}
         | NVARCHAR_SYM             {}
         | OFFLINE_SYM              {}
         | OFFSET_SYM               {}
@@ -11065,6 +11553,9 @@ keyword_sp:
         | PACK_KEYS_SYM            {}
         | PAGE_SYM                 {}
         | PAGE_CHECKSUM_SYM	   {}
+        | PARAMETER_MODE_SYM       {}
+        | PARAMETER_NAME_SYM       {}
+        | PARAMETER_ORDINAL_POSITION_SYM {}
         | PARTIAL                  {}
         | PARTITIONING_SYM         {}
         | PARTITIONS_SYM           {}
@@ -11099,18 +11590,25 @@ keyword_sp:
         | REPLICATION              {}
         | RESOURCES                {}
         | RESUME_SYM               {}
+        | RETURNED_SQLSTATE_SYM    {}
         | RETURNS_SYM              {}
         | REVERSE_SYM              {}
         | ROLLUP_SYM               {}
         | ROUTINE_SYM              {}
+        | ROUTINE_CATALOG_SYM      {}
+        | ROUTINE_NAME_SYM         {}
+        | ROUTINE_SCHEMA_SYM       {}
         | ROWS_SYM                 {}
+        | ROW_COUNT_SYM            {}
         | ROW_FORMAT_SYM           {}
         | ROW_SYM                  {}
         | RTREE_SYM                {}
         | SCHEDULE_SYM             {}
+        | SCHEMA_NAME_SYM          {}
         | SECOND_SYM               {}
         | SERIAL_SYM               {}
         | SERIALIZABLE_SYM         {}
+        | SERVER_NAME_SYM          {}
         | SESSION_SYM              {}
         | SIMPLE_SYM               {}
         | SHARE_SYM                {}
@@ -11118,14 +11616,17 @@ keyword_sp:
         | SNAPSHOT_SYM             {}
         | SOUNDS_SYM               {}
         | SOURCE_SYM               {}
+        | SPECIFIC_NAME_SYM        {}
         | SQL_CACHE_SYM            {}
         | SQL_BUFFER_RESULT        {}
         | SQL_NO_CACHE_SYM         {}
         | SQL_THREAD               {}
+        | STACKED_SYM              {}
         | STARTS_SYM               {}
         | STATUS_SYM               {}
         | STORAGE_SYM              {}
         | STRING_SYM               {}
+        | SUBCLASS_ORIGIN_SYM      {}
         | SUBDATE_SYM              {}
         | SUBJECT_SYM              {}
         | SUBPARTITION_SYM         {}
@@ -11134,6 +11635,7 @@ keyword_sp:
         | SUSPEND_SYM              {}
         | SWAPS_SYM                {}
         | SWITCHES_SYM             {}
+        | TABLE_NAME_SYM           {}
         | TABLES                   {}
         | TABLE_CHECKSUM_SYM       {}
         | TABLESPACE               {}
@@ -11142,7 +11644,13 @@ keyword_sp:
         | TEXT_SYM                 {}
         | THAN_SYM                 {}
         | TRANSACTION_SYM          {}
+        | TRANSACTION_ACTIVE_SYM   {}
         | TRANSACTIONAL_SYM        {}
+        | TRANSACTIONS_COMMITTED_SYM {}
+        | TRANSACTIONS_ROLLED_BACK_SYM {}
+        | TRIGGER_CATALOG_SYM      {}
+        | TRIGGER_NAME_SYM         {}
+        | TRIGGER_SCHEMA_SYM       {}
         | TRIGGERS_SYM             {}
         | TIMESTAMP                {}
         | TIMESTAMP_ADD            {}
Thread
bk commit into 6.0 tree (malff:1.2627) BUG#11661 WL#2110marc.alff14 Apr