=== added file 'mysql-test/r/diag.result'
--- a/mysql-test/r/diag.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/diag.result	2008-07-18 01:23:15 +0000
@@ -0,0 +1,1414 @@
+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
+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 = MYSQL_ERRNO;
+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 'MYSQL_ERRNO;
+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 = MYSQL_ERRNO;
+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 'GET DIAGNOSTICS @foo = NUMBER';
+ERROR HY000: This command is not supported in the prepared statement protocol yet
+select "Clear the previous statement diagnostics area";
+Clear the previous statement diagnostics area
+Clear the previous statement diagnostics area
+show warnings;
+Level	Code	Message
+Error	1295	This command is not supported in the prepared statement protocol yet
+GET DIAGNOSTICS @foo = NUMBER;
+show warnings;
+Level	Code	Message
+Error	1295	This command is not supported in the prepared statement protocol yet
+GET CURRENT DIAGNOSTICS @foo = NUMBER;
+show warnings;
+Level	Code	Message
+Error	1295	This command is not supported in the prepared statement protocol yet
+GET STACKED DIAGNOSTICS @foo = NUMBER;
+ERROR 0Z002: STACKED DIAGNOSTICS accessed without active handler
+show warnings;
+Level	Code	Message
+Error	1295	This command is not supported in the prepared statement protocol yet
+select "Populate the previous statement diagnostics area (note)";
+Populate the previous statement diagnostics area (note)
+Populate the previous statement diagnostics area (note)
+drop table if exists `no_such_table_and_this_error_better_stick`;
+Warnings:
+Note	1051	Unknown table 'no_such_table_and_this_error_better_stick'
+show warnings;
+Level	Code	Message
+Note	1051	Unknown table 'no_such_table_and_this_error_better_stick'
+GET DIAGNOSTICS @foo = NUMBER;
+show warnings;
+Level	Code	Message
+Note	1051	Unknown table 'no_such_table_and_this_error_better_stick'
+GET CURRENT DIAGNOSTICS @foo = NUMBER;
+show warnings;
+Level	Code	Message
+Note	1051	Unknown table 'no_such_table_and_this_error_better_stick'
+GET STACKED DIAGNOSTICS @foo = NUMBER;
+ERROR 0Z002: STACKED DIAGNOSTICS accessed without active handler
+show warnings;
+Level	Code	Message
+Note	1051	Unknown table 'no_such_table_and_this_error_better_stick'
+select "Clear the previous statement diagnostics area";
+Clear the previous statement diagnostics area
+Clear the previous statement diagnostics area
+show warnings;
+Level	Code	Message
+Note	1051	Unknown table 'no_such_table_and_this_error_better_stick'
+set @foo=12;
+GET DIAGNOSTICS @foo = NUMBER;
+select @foo;
+@foo
+3
+set @foo=12;
+GET CURRENT DIAGNOSTICS @foo = NUMBER;
+select @foo;
+@foo
+4
+set @foo=12;
+drop table if exists `no_such_table_and_this_note_better_stick`;
+Warnings:
+Note	1051	Unknown table 'no_such_table_and_this_note_better_stick'
+show warnings;
+Level	Code	Message
+Note	1051	Unknown table 'no_such_table_and_this_note_better_stick'
+GET CURRENT DIAGNOSTICS @foo = NUMBER;
+show warnings;
+Level	Code	Message
+Note	1051	Unknown table 'no_such_table_and_this_note_better_stick'
+select @foo;
+@foo
+2
+set @foo=12;
+drop table `no_such_table_and_this_error_better_stick`;
+ERROR 42S02: Unknown table 'no_such_table_and_this_error_better_stick'
+show warnings;
+Level	Code	Message
+GET CURRENT DIAGNOSTICS @foo = NUMBER;
+show warnings;
+Level	Code	Message
+select @foo;
+@foo
+0
+set @foo=12;
+insert into no_such_table value (1);
+ERROR 42S02: Table 'test.no_such_table' doesn't exist
+show warnings;
+Level	Code	Message
+Error	1146	Table 'test.no_such_table' doesn't exist
+GET CURRENT DIAGNOSTICS @foo = NUMBER;
+show warnings;
+Level	Code	Message
+Error	1146	Table 'test.no_such_table' doesn't exist
+select @foo;
+@foo
+1
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="more";
+Warnings:
+Warning	1726	more
+GET CURRENT DIAGNOSTICS @foo = MORE;
+select @foo;
+@foo
+N
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="command_function";
+Warnings:
+Warning	1726	command_function
+GET CURRENT DIAGNOSTICS @foo = COMMAND_FUNCTION;
+select @foo;
+@foo
+SIGNAL
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="command_function_code";
+Warnings:
+Warning	1726	command_function_code
+GET CURRENT DIAGNOSTICS @foo = COMMAND_FUNCTION_CODE;
+select @foo;
+@foo
+92
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="dynamic_function";
+Warnings:
+Warning	1726	dynamic_function
+GET CURRENT DIAGNOSTICS @foo = DYNAMIC_FUNCTION;
+select @foo;
+@foo
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="dynamic_function_code";
+Warnings:
+Warning	1726	dynamic_function_code
+GET CURRENT DIAGNOSTICS @foo = DYNAMIC_FUNCTION_CODE;
+select @foo;
+@foo
+0
+create table t1(a int);
+insert into t1 values (1), (2), (3);
+GET CURRENT DIAGNOSTICS @foo = ROW_COUNT;
+select @foo;
+@foo
+3
+update t1 set a=a*10 where (a <= 2);
+GET CURRENT DIAGNOSTICS @foo = ROW_COUNT;
+select @foo;
+@foo
+2
+delete from t1 where (a = 20);
+GET CURRENT DIAGNOSTICS @foo = ROW_COUNT;
+select @foo;
+@foo
+1
+set @foo="foo";
+insert into no_such_table values (1);
+ERROR 42S02: Table 'test.no_such_table' doesn't exist
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CLASS_ORIGIN;
+select @foo;
+@foo
+
+set @foo="foo";
+insert into no_such_table values (1);
+ERROR 42S02: Table 'test.no_such_table' doesn't exist
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = SUBCLASS_ORIGIN;
+select @foo;
+@foo
+
+set @foo="foo";
+insert into no_such_table values (1);
+ERROR 42S02: Table 'test.no_such_table' doesn't exist
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONSTRAINT_CATALOG;
+select @foo;
+@foo
+
+set @foo="foo";
+insert into no_such_table values (1);
+ERROR 42S02: Table 'test.no_such_table' doesn't exist
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONSTRAINT_SCHEMA;
+select @foo;
+@foo
+
+set @foo="foo";
+insert into no_such_table values (1);
+ERROR 42S02: Table 'test.no_such_table' doesn't exist
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONSTRAINT_NAME;
+select @foo;
+@foo
+
+set @foo="foo";
+insert into no_such_table values (1);
+ERROR 42S02: Table 'test.no_such_table' doesn't exist
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CATALOG_NAME;
+select @foo;
+@foo
+
+set @foo="foo";
+insert into no_such_table values (1);
+ERROR 42S02: Table 'test.no_such_table' doesn't exist
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = SCHEMA_NAME;
+select @foo;
+@foo
+test
+set @foo="foo";
+insert into no_such_table values (1);
+ERROR 42S02: Table 'test.no_such_table' doesn't exist
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = TABLE_NAME;
+select @foo;
+@foo
+no_such_table
+set @foo="foo";
+insert into no_such_table values (1);
+ERROR 42S02: Table 'test.no_such_table' doesn't exist
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = COLUMN_NAME;
+select @foo;
+@foo
+
+set @foo="foo";
+insert into no_such_table values (1);
+ERROR 42S02: Table 'test.no_such_table' doesn't exist
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CURSOR_NAME;
+select @foo;
+@foo
+
+set @foo="foo";
+insert into no_such_table values (1);
+ERROR 42S02: Table 'test.no_such_table' doesn't exist
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = MESSAGE_TEXT;
+select @foo;
+@foo
+Table 'test.no_such_table' doesn't exist
+set @foo="foo";
+insert into no_such_table values (1);
+ERROR 42S02: Table 'test.no_such_table' doesn't exist
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = MYSQL_ERRNO;
+select @foo;
+@foo
+1146
+set @foo="foo";
+insert into no_such_table values (1);
+ERROR 42S02: Table 'test.no_such_table' doesn't exist
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONDITION_IDENTIFIER;
+select @foo;
+@foo
+
+set @foo="foo";
+insert into no_such_table values (1);
+ERROR 42S02: Table 'test.no_such_table' doesn't exist
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONDITION_NUMBER;
+select @foo;
+@foo
+1
+set @foo="foo";
+insert into no_such_table values (1);
+ERROR 42S02: Table 'test.no_such_table' doesn't exist
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONNECTION_NAME;
+select @foo;
+@foo
+
+set @foo="foo";
+insert into no_such_table values (1);
+ERROR 42S02: Table 'test.no_such_table' doesn't exist
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = MESSAGE_LENGTH;
+select @foo;
+@foo
+40
+set @foo="foo";
+insert into no_such_table values (1);
+ERROR 42S02: Table 'test.no_such_table' doesn't exist
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = MESSAGE_OCTET_LENGTH;
+select @foo;
+@foo
+40
+set @foo="foo";
+insert into no_such_table values (1);
+ERROR 42S02: Table 'test.no_such_table' doesn't exist
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = PARAMETER_MODE;
+select @foo;
+@foo
+
+set @foo="foo";
+insert into no_such_table values (1);
+ERROR 42S02: Table 'test.no_such_table' doesn't exist
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = PARAMETER_NAME;
+select @foo;
+@foo
+
+set @foo="foo";
+insert into no_such_table values (1);
+ERROR 42S02: Table 'test.no_such_table' doesn't exist
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = PARAMETER_ORDINAL_POSITION;
+select @foo;
+@foo
+0
+set @foo="foo";
+insert into no_such_table values (1);
+ERROR 42S02: Table 'test.no_such_table' doesn't exist
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = RETURNED_SQLSTATE;
+select @foo;
+@foo
+42S02
+set @foo="foo";
+insert into no_such_table values (1);
+ERROR 42S02: Table 'test.no_such_table' doesn't exist
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = ROUTINE_CATALOG;
+select @foo;
+@foo
+
+set @foo="foo";
+insert into no_such_table values (1);
+ERROR 42S02: Table 'test.no_such_table' doesn't exist
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = ROUTINE_SCHEMA;
+select @foo;
+@foo
+
+set @foo="foo";
+insert into no_such_table values (1);
+ERROR 42S02: Table 'test.no_such_table' doesn't exist
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = SERVER_NAME;
+select @foo;
+@foo
+
+set @foo="foo";
+insert into no_such_table values (1);
+ERROR 42S02: Table 'test.no_such_table' doesn't exist
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = SPECIFIC_NAME;
+select @foo;
+@foo
+
+set @foo="foo";
+insert into no_such_table values (1);
+ERROR 42S02: Table 'test.no_such_table' doesn't exist
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = TRIGGER_CATALOG;
+select @foo;
+@foo
+
+set @foo="foo";
+insert into no_such_table values (1);
+ERROR 42S02: Table 'test.no_such_table' doesn't exist
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = TRIGGER_NAME;
+select @foo;
+@foo
+
+set @foo="foo";
+insert into no_such_table values (1);
+ERROR 42S02: Table 'test.no_such_table' doesn't exist
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = TRIGGER_SCHEMA;
+select @foo;
+@foo
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET CLASS_ORIGIN="class origin";
+Warnings:
+Warning	1726	Unhandled user-defined warning
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CLASS_ORIGIN;
+select @foo;
+@foo
+class origin
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET SUBCLASS_ORIGIN="subclass origin";
+Warnings:
+Warning	1726	Unhandled user-defined warning
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = SUBCLASS_ORIGIN;
+select @foo;
+@foo
+subclass origin
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET CONSTRAINT_CATALOG="constraint catalog";
+Warnings:
+Warning	1726	Unhandled user-defined warning
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CONSTRAINT_CATALOG;
+select @foo;
+@foo
+constraint catalog
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET CONSTRAINT_SCHEMA="constraint schema";
+Warnings:
+Warning	1726	Unhandled user-defined warning
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CONSTRAINT_SCHEMA;
+select @foo;
+@foo
+constraint schema
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET CONSTRAINT_NAME="constraint name";
+Warnings:
+Warning	1726	Unhandled user-defined warning
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CONSTRAINT_NAME;
+select @foo;
+@foo
+constraint name
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET CATALOG_NAME="catalog name";
+Warnings:
+Warning	1726	Unhandled user-defined warning
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CATALOG_NAME;
+select @foo;
+@foo
+catalog name
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET SCHEMA_NAME="schema name";
+Warnings:
+Warning	1726	Unhandled user-defined warning
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = SCHEMA_NAME;
+select @foo;
+@foo
+schema name
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET TABLE_NAME="table name";
+Warnings:
+Warning	1726	Unhandled user-defined warning
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = TABLE_NAME;
+select @foo;
+@foo
+table name
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET COLUMN_NAME="column name";
+Warnings:
+Warning	1726	Unhandled user-defined warning
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = COLUMN_NAME;
+select @foo;
+@foo
+column name
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET CURSOR_NAME="cursor name";
+Warnings:
+Warning	1726	Unhandled user-defined warning
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CURSOR_NAME;
+select @foo;
+@foo
+cursor name
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="message text";
+Warnings:
+Warning	1726	message text
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = MESSAGE_TEXT;
+select @foo;
+@foo
+message text
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MYSQL_ERRNO=1234;
+Warnings:
+Warning	1234	Unhandled user-defined warning
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = MYSQL_ERRNO;
+select @foo;
+@foo
+1234
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
+Warnings:
+Warning	1726	internal
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CONDITION_IDENTIFIER;
+select @foo;
+@foo
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
+Warnings:
+Warning	1726	internal
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CONDITION_NUMBER;
+select @foo;
+@foo
+2
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
+Warnings:
+Warning	1726	internal
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CONNECTION_NAME;
+select @foo;
+@foo
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
+Warnings:
+Warning	1726	internal
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = MESSAGE_LENGTH;
+select @foo;
+@foo
+8
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
+Warnings:
+Warning	1726	internal
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = MESSAGE_OCTET_LENGTH;
+select @foo;
+@foo
+8
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
+Warnings:
+Warning	1726	internal
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = PARAMETER_MODE;
+select @foo;
+@foo
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
+Warnings:
+Warning	1726	internal
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = PARAMETER_NAME;
+select @foo;
+@foo
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
+Warnings:
+Warning	1726	internal
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = PARAMETER_ORDINAL_POSITION;
+select @foo;
+@foo
+0
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
+Warnings:
+Warning	1726	internal
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = RETURNED_SQLSTATE;
+select @foo;
+@foo
+01000
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
+Warnings:
+Warning	1726	internal
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = ROUTINE_CATALOG;
+select @foo;
+@foo
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
+Warnings:
+Warning	1726	internal
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = ROUTINE_SCHEMA;
+select @foo;
+@foo
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
+Warnings:
+Warning	1726	internal
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = SERVER_NAME;
+select @foo;
+@foo
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
+Warnings:
+Warning	1726	internal
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = SPECIFIC_NAME;
+select @foo;
+@foo
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
+Warnings:
+Warning	1726	internal
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = TRIGGER_CATALOG;
+select @foo;
+@foo
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
+Warnings:
+Warning	1726	internal
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = TRIGGER_NAME;
+select @foo;
+@foo
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
+Warnings:
+Warning	1726	internal
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = TRIGGER_SCHEMA;
+select @foo;
+@foo
+
+set @foo="foo";
+SIGNAL SQLSTATE '03000' SET CLASS_ORIGIN="class origin";
+ERROR 03000: Unhandled user-defined exception
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CLASS_ORIGIN;
+select @foo;
+@foo
+class origin
+set @foo="foo";
+SIGNAL SQLSTATE '03000' SET SUBCLASS_ORIGIN="subclass origin";
+ERROR 03000: Unhandled user-defined exception
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = SUBCLASS_ORIGIN;
+select @foo;
+@foo
+subclass origin
+set @foo="foo";
+SIGNAL SQLSTATE '03000' SET CONSTRAINT_CATALOG="constraint catalog";
+ERROR 03000: Unhandled user-defined exception
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONSTRAINT_CATALOG;
+select @foo;
+@foo
+constraint catalog
+set @foo="foo";
+SIGNAL SQLSTATE '03000' SET CONSTRAINT_SCHEMA="constraint schema";
+ERROR 03000: Unhandled user-defined exception
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONSTRAINT_SCHEMA;
+select @foo;
+@foo
+constraint schema
+set @foo="foo";
+SIGNAL SQLSTATE '03000' SET CONSTRAINT_NAME="constraint name";
+ERROR 03000: Unhandled user-defined exception
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONSTRAINT_NAME;
+select @foo;
+@foo
+constraint name
+set @foo="foo";
+SIGNAL SQLSTATE '03000' SET CATALOG_NAME="catalog name";
+ERROR 03000: Unhandled user-defined exception
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CATALOG_NAME;
+select @foo;
+@foo
+catalog name
+set @foo="foo";
+SIGNAL SQLSTATE '03000' SET SCHEMA_NAME="schema name";
+ERROR 03000: Unhandled user-defined exception
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = SCHEMA_NAME;
+select @foo;
+@foo
+schema name
+set @foo="foo";
+SIGNAL SQLSTATE '03000' SET TABLE_NAME="table name";
+ERROR 03000: Unhandled user-defined exception
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = TABLE_NAME;
+select @foo;
+@foo
+table name
+set @foo="foo";
+SIGNAL SQLSTATE '03000' SET COLUMN_NAME="column name";
+ERROR 03000: Unhandled user-defined exception
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = COLUMN_NAME;
+select @foo;
+@foo
+column name
+set @foo="foo";
+SIGNAL SQLSTATE '03000' SET CURSOR_NAME="cursor name";
+ERROR 03000: Unhandled user-defined exception
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CURSOR_NAME;
+select @foo;
+@foo
+cursor name
+set @foo="foo";
+SIGNAL SQLSTATE '03000' SET MESSAGE_TEXT="message text";
+ERROR 03000: message text
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = MESSAGE_TEXT;
+select @foo;
+@foo
+message text
+set @foo="foo";
+SIGNAL SQLSTATE '03000' SET MYSQL_ERRNO=1234;
+ERROR 03000: Unhandled user-defined exception
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = MYSQL_ERRNO;
+select @foo;
+@foo
+1234
+set @foo="foo";
+SIGNAL SQLSTATE '03000' SET MESSAGE_TEXT="internal";
+ERROR 03000: internal
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONDITION_IDENTIFIER;
+select @foo;
+@foo
+
+set @foo="foo";
+SIGNAL SQLSTATE '03000' SET MESSAGE_TEXT="internal";
+ERROR 03000: internal
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONDITION_NUMBER;
+select @foo;
+@foo
+1
+set @foo="foo";
+SIGNAL SQLSTATE '03000' SET MESSAGE_TEXT="internal";
+ERROR 03000: internal
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONNECTION_NAME;
+select @foo;
+@foo
+
+set @foo="foo";
+SIGNAL SQLSTATE '03000' SET MESSAGE_TEXT="internal";
+ERROR 03000: internal
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = MESSAGE_LENGTH;
+select @foo;
+@foo
+8
+set @foo="foo";
+SIGNAL SQLSTATE '03000' SET MESSAGE_TEXT="internal";
+ERROR 03000: internal
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = MESSAGE_OCTET_LENGTH;
+select @foo;
+@foo
+8
+set @foo="foo";
+SIGNAL SQLSTATE '03000' SET MESSAGE_TEXT="internal";
+ERROR 03000: internal
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = PARAMETER_MODE;
+select @foo;
+@foo
+
+set @foo="foo";
+SIGNAL SQLSTATE '03000' SET MESSAGE_TEXT="internal";
+ERROR 03000: internal
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = PARAMETER_NAME;
+select @foo;
+@foo
+
+set @foo="foo";
+SIGNAL SQLSTATE '03000' SET MESSAGE_TEXT="internal";
+ERROR 03000: internal
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = PARAMETER_ORDINAL_POSITION;
+select @foo;
+@foo
+0
+set @foo="foo";
+SIGNAL SQLSTATE '03000' SET MESSAGE_TEXT="internal";
+ERROR 03000: internal
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = RETURNED_SQLSTATE;
+select @foo;
+@foo
+03000
+set @foo="foo";
+SIGNAL SQLSTATE '03000' SET MESSAGE_TEXT="internal";
+ERROR 03000: internal
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = ROUTINE_CATALOG;
+select @foo;
+@foo
+
+set @foo="foo";
+SIGNAL SQLSTATE '03000' SET MESSAGE_TEXT="internal";
+ERROR 03000: internal
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = ROUTINE_SCHEMA;
+select @foo;
+@foo
+
+set @foo="foo";
+SIGNAL SQLSTATE '03000' SET MESSAGE_TEXT="internal";
+ERROR 03000: internal
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = SERVER_NAME;
+select @foo;
+@foo
+
+set @foo="foo";
+SIGNAL SQLSTATE '03000' SET MESSAGE_TEXT="internal";
+ERROR 03000: internal
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = SPECIFIC_NAME;
+select @foo;
+@foo
+
+set @foo="foo";
+SIGNAL SQLSTATE '03000' SET MESSAGE_TEXT="internal";
+ERROR 03000: internal
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = TRIGGER_CATALOG;
+select @foo;
+@foo
+
+set @foo="foo";
+SIGNAL SQLSTATE '03000' SET MESSAGE_TEXT="internal";
+ERROR 03000: internal
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = TRIGGER_NAME;
+select @foo;
+@foo
+
+set @foo="foo";
+SIGNAL SQLSTATE '03000' SET MESSAGE_TEXT="internal";
+ERROR 03000: internal
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = TRIGGER_SCHEMA;
+select @foo;
+@foo
+

=== added file 'mysql-test/r/diag_code.result'
--- a/mysql-test/r/diag_code.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/diag_code.result	2008-07-18 01:23:15 +0000
@@ -0,0 +1,33 @@
+use test;
+drop procedure if exists diag_proc;
+drop function if exists diag_func;
+create procedure diag_proc()
+begin
+DECLARE v, v1, v2 integer;
+GET DIAGNOSTICS v = NUMBER;
+GET CURRENT DIAGNOSTICS v1 = NUMBER, v2 = MORE;
+end $$
+create function diag_func() returns int
+begin
+DECLARE v, v1, v2 integer;
+GET DIAGNOSTICS v = NUMBER;
+GET CURRENT DIAGNOSTICS v1 = NUMBER, v2 = MORE;
+return 0;
+end $$
+show procedure code diag_proc;
+Pos	Instruction
+0	set v@0 NULL
+1	set v1@1 NULL
+2	set v2@2 NULL
+3	stmt 135 "GET DIAGNOSTICS v = NUMBER"
+4	stmt 135 "GET CURRENT DIAGNOSTICS v1 = NUMBER, ..."
+drop procedure diag_proc;
+show function code diag_func;
+Pos	Instruction
+0	set v@0 NULL
+1	set v1@1 NULL
+2	set v2@2 NULL
+3	stmt 135 "GET DIAGNOSTICS v = NUMBER"
+4	stmt 135 "GET CURRENT DIAGNOSTICS v1 = NUMBER, ..."
+5	freturn 3 0
+drop function diag_func;

=== added file 'mysql-test/r/diag_tx.result'
--- a/mysql-test/r/diag_tx.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/diag_tx.result	2008-07-18 01:23:15 +0000
@@ -0,0 +1,64 @@
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="transactions_committed";
+Warnings:
+Warning	1726	transactions_committed
+GET CURRENT DIAGNOSTICS @foo = TRANSACTIONS_COMMITTED;
+select @foo;
+@foo
+0
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="transactions_rolled_back";
+Warnings:
+Warning	1726	transactions_rolled_back
+GET CURRENT DIAGNOSTICS @foo = TRANSACTIONS_ROLLED_BACK;
+select @foo;
+@foo
+0
+drop table if exists t1;
+create table t1 (a integer) engine=falcon;
+set autocommit=0;
+GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
+select @foo;
+@foo
+0
+BEGIN;
+GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
+select @foo;
+@foo
+1
+insert into t1 value (1);
+GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
+select @foo;
+@foo
+1
+COMMIT;
+GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
+select @foo;
+@foo
+0
+BEGIN;
+GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
+select @foo;
+@foo
+1
+insert into t1 value (2);
+GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
+select @foo;
+@foo
+1
+ROLLBACK;
+GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
+select @foo;
+@foo
+0
+set autocommit=1;
+GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
+select @foo;
+@foo
+0
+insert into t1 value (3);
+GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
+select @foo;
+@foo
+0
+drop table t1;

=== modified file 'mysql-test/r/signal.result'
--- a/mysql-test/r/signal.result	2008-07-17 17:36:22 +0000
+++ b/mysql-test/r/signal.result	2008-07-18 01:21:18 +0000
@@ -539,655 +539,10 @@
 RESIGNAL SQLSTATE '00000';
 end $$
 ERROR 42000: Bad SQLSTATE: '00000'
-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 = MYSQL_ERRNO;
-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 'MYSQL_ERRNO;
-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 = MYSQL_ERRNO;
-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 HY000: This command is not supported in the prepared statement protocol yet
 prepare stmt from 'RESIGNAL SQLSTATE \'23000\'';
 ERROR HY000: This command is not supported in the prepared statement protocol yet
-prepare stmt from 'GET DIAGNOSTICS @foo = NUMBER';
-ERROR HY000: This command is not supported in the prepared statement protocol yet
 drop procedure if exists test_signal;
 drop procedure if exists test_resignal;
 drop table if exists t_warn;

=== modified file 'mysql-test/r/signal_code.result'
--- a/mysql-test/r/signal_code.result	2008-07-17 17:36:22 +0000
+++ b/mysql-test/r/signal_code.result	2008-07-18 01:21:18 +0000
@@ -3,49 +3,33 @@
 drop function if exists signal_func;
 create procedure signal_proc()
 begin
-DECLARE v, v1, v2 integer;
 DECLARE foo CONDITION FOR SQLSTATE '12345';
 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 SQLSTATE '12345';
 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	stmt 133 "SIGNAL foo"
-4	stmt 133 "SIGNAL foo SET MESSAGE_TEXT = "This i..."
-5	stmt 134 "RESIGNAL foo"
-6	stmt 134 "RESIGNAL foo SET MESSAGE_TEXT = "This..."
-7	stmt 135 "GET DIAGNOSTICS v = NUMBER"
-8	stmt 135 "GET CURRENT DIAGNOSTICS v1 = NUMBER, ..."
+0	stmt 133 "SIGNAL foo"
+1	stmt 133 "SIGNAL foo SET MESSAGE_TEXT = "This i..."
+2	stmt 134 "RESIGNAL foo"
+3	stmt 134 "RESIGNAL foo SET MESSAGE_TEXT = "This..."
 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	stmt 133 "SIGNAL foo"
-4	stmt 133 "SIGNAL foo SET MESSAGE_TEXT = "This i..."
-5	stmt 134 "RESIGNAL foo"
-6	stmt 134 "RESIGNAL foo SET MESSAGE_TEXT = "This..."
-7	stmt 135 "GET DIAGNOSTICS v = NUMBER"
-8	stmt 135 "GET CURRENT DIAGNOSTICS v1 = NUMBER, ..."
-9	freturn 3 0
+0	stmt 133 "SIGNAL foo"
+1	stmt 133 "SIGNAL foo SET MESSAGE_TEXT = "This i..."
+2	stmt 134 "RESIGNAL foo"
+3	stmt 134 "RESIGNAL foo SET MESSAGE_TEXT = "This..."
+4	freturn 3 0
 drop function signal_func;

=== modified file 'mysql-test/r/signal_demo1.result'
--- a/mysql-test/r/signal_demo1.result	2008-06-24 23:41:24 +0000
+++ b/mysql-test/r/signal_demo1.result	2008-07-18 01:21:18 +0000
@@ -44,7 +44,7 @@
 if (x != 1)
 then
 set msg= concat('No such physical person, PK:', id);
-SIGNAL SQLSTATE 'XX001' SET
+SIGNAL SQLSTATE '45000' SET
 MESSAGE_TEXT = msg,
 MYSQL_ERRNO = 10000;
 end if;
@@ -57,7 +57,7 @@
 if (x != 1)
 then
 set msg= concat('No such moral person, PK:', id);
-SIGNAL SQLSTATE 'XX001' SET
+SIGNAL SQLSTATE '45000' SET
 MESSAGE_TEXT = msg,
 MYSQL_ERRNO = 10000;
 end if;
@@ -65,7 +65,7 @@
 else
 begin
 set msg= concat('No such person type:', person_type);
-SIGNAL SQLSTATE 'XX002' SET
+SIGNAL SQLSTATE '45000' SET
 MESSAGE_TEXT = msg,
 MYSQL_ERRNO = 20000;
 end;
@@ -83,7 +83,7 @@
 then
 set msg= concat('Failed integrity constraint, table in_inventory, PK:',
 id);
-SIGNAL SQLSTATE 'XX001' SET
+SIGNAL SQLSTATE '45000' SET
 MESSAGE_TEXT = msg,
 MYSQL_ERRNO = 10000;
 end if;
@@ -99,7 +99,7 @@
 if (x != 1)
 then
 set msg= concat('Failed integrity constraint, table po_order, PK:', id);
-SIGNAL SQLSTATE 'XX001' SET
+SIGNAL SQLSTATE '45000' SET
 MESSAGE_TEXT = msg,
 MYSQL_ERRNO = 10000;
 end if;
@@ -198,22 +198,22 @@
 Entering bad data in an order
 Entering bad data in an order
 call po_add_order_line (@my_po, 1, 999, 1);
-ERROR XX001: Failed integrity constraint, table in_inventory, PK:999
+ERROR 45000: Failed integrity constraint, table in_inventory, PK:999
 select "Entering bad data in an unknown order";
 Entering bad data in an unknown order
 Entering bad data in an unknown order
 call po_add_order_line (99, 1, 100, 1);
-ERROR XX001: Failed integrity constraint, table po_order, PK:99
+ERROR 45000: Failed integrity constraint, table po_order, PK:99
 select "Entering an order for an unknown company";
 Entering an order for an unknown company
 Entering an order for an unknown company
 call po_create_order("M", 7, @my_po);
-ERROR XX001: No such moral person, PK:7
+ERROR 45000: No such moral person, PK:7
 select "Entering an order for an unknown person type";
 Entering an order for an unknown person type
 Entering an order for an unknown person type
 call po_create_order("X", 1, @my_po);
-ERROR XX002: No such person type:X
+ERROR 45000: No such person type:X
 /* The local school wants 10 class tables and 20 chairs */
 call po_create_order("M", 4, @my_po);
 call po_add_order_line (@my_po, 1, 300, 10);

=== modified file 'mysql-test/r/signal_demo3.result'
--- a/mysql-test/r/signal_demo3.result	2008-07-17 17:36:22 +0000
+++ b/mysql-test/r/signal_demo3.result	2008-07-18 01:21:18 +0000
@@ -12,69 +12,69 @@
 create procedure proc_1()
 begin
 declare exit handler for sqlexception
-resignal sqlstate '55555' set message_text='Oops in proc_1';
+resignal sqlstate '45000' set message_text='Oops in proc_1';
 call proc_2();
 end
 $$
 create procedure proc_2()
 begin
 declare exit handler for sqlexception
-resignal sqlstate '55555' set message_text='Oops in proc_2';
+resignal sqlstate '45000' set message_text='Oops in proc_2';
 call proc_3();
 end
 $$
 create procedure proc_3()
 begin
 declare exit handler for sqlexception
-resignal sqlstate '55555' set message_text='Oops in proc_3';
+resignal sqlstate '45000' set message_text='Oops in proc_3';
 call proc_4();
 end
 $$
 create procedure proc_4()
 begin
 declare exit handler for sqlexception
-resignal sqlstate '55555' set message_text='Oops in proc_4';
+resignal sqlstate '45000' set message_text='Oops in proc_4';
 call proc_5();
 end
 $$
 create procedure proc_5()
 begin
 declare exit handler for sqlexception
-resignal sqlstate '55555' set message_text='Oops in proc_5';
+resignal sqlstate '45000' set message_text='Oops in proc_5';
 call proc_6();
 end
 $$
 create procedure proc_6()
 begin
 declare exit handler for sqlexception
-resignal sqlstate '55555' set message_text='Oops in proc_6';
+resignal sqlstate '45000' set message_text='Oops in proc_6';
 call proc_7();
 end
 $$
 create procedure proc_7()
 begin
 declare exit handler for sqlexception
-resignal sqlstate '55555' set message_text='Oops in proc_7';
+resignal sqlstate '45000' set message_text='Oops in proc_7';
 call proc_8();
 end
 $$
 create procedure proc_8()
 begin
 declare exit handler for sqlexception
-resignal sqlstate '55555' set message_text='Oops in proc_8';
+resignal sqlstate '45000' set message_text='Oops in proc_8';
 call proc_9();
 end
 $$
 create procedure proc_9()
 begin
 declare exit handler for sqlexception
-resignal sqlstate '55555' set message_text='Oops in proc_9';
+resignal sqlstate '45000' set message_text='Oops in proc_9';
 ## Do something that fails, to see how errors are reported
 drop table oops_it_is_not_here;
 end
 $$
 call proc_1();
-ERROR 55555: Oops in proc_1
+ERROR 45000: Oops in proc_1
 show warnings;
 Level	Code	Message
 Error	1051	Unknown table 'oops_it_is_not_here'
@@ -92,7 +92,7 @@
 @@session.max_error_count
 5
 call proc_1();
-ERROR 55555: Oops in proc_1
+ERROR 45000: Oops in proc_1
 show warnings;
 Level	Code	Message
 Error	1728	Oops in proc_5
@@ -105,7 +105,7 @@
 @@session.max_error_count
 7
 call proc_1();
-ERROR 55555: Oops in proc_1
+ERROR 45000: Oops in proc_1
 show warnings;
 Level	Code	Message
 Error	1728	Oops in proc_7
@@ -120,7 +120,7 @@
 @@session.max_error_count
 9
 call proc_1();
-ERROR 55555: Oops in proc_1
+ERROR 45000: Oops in proc_1
 show warnings;
 Level	Code	Message
 Error	1728	Oops in proc_9

=== removed file 'mysql-test/r/signal_diag.result'
--- a/mysql-test/r/signal_diag.result	2008-07-17 17:36:22 +0000
+++ b/mysql-test/r/signal_diag.result	1970-01-01 00:00:00 +0000
@@ -1,567 +0,0 @@
-select "Clear the previous statement diagnostics area";
-Clear the previous statement diagnostics area
-Clear the previous statement diagnostics area
-show warnings;
-Level	Code	Message
-GET DIAGNOSTICS @foo = NUMBER;
-show warnings;
-Level	Code	Message
-GET CURRENT DIAGNOSTICS @foo = NUMBER;
-show warnings;
-Level	Code	Message
-GET STACKED DIAGNOSTICS @foo = NUMBER;
-ERROR 0Z002: STACKED DIAGNOSTICS accessed without active handler
-show warnings;
-Level	Code	Message
-select "Populate the previous statement diagnostics area (note)";
-Populate the previous statement diagnostics area (note)
-Populate the previous statement diagnostics area (note)
-drop table if exists `no_such_table_and_this_error_better_stick`;
-Warnings:
-Note	1051	Unknown table 'no_such_table_and_this_error_better_stick'
-show warnings;
-Level	Code	Message
-Note	1051	Unknown table 'no_such_table_and_this_error_better_stick'
-GET DIAGNOSTICS @foo = NUMBER;
-show warnings;
-Level	Code	Message
-Note	1051	Unknown table 'no_such_table_and_this_error_better_stick'
-GET CURRENT DIAGNOSTICS @foo = NUMBER;
-show warnings;
-Level	Code	Message
-Note	1051	Unknown table 'no_such_table_and_this_error_better_stick'
-GET STACKED DIAGNOSTICS @foo = NUMBER;
-ERROR 0Z002: STACKED DIAGNOSTICS accessed without active handler
-show warnings;
-Level	Code	Message
-Note	1051	Unknown table 'no_such_table_and_this_error_better_stick'
-select "Clear the previous statement diagnostics area";
-Clear the previous statement diagnostics area
-Clear the previous statement diagnostics area
-show warnings;
-Level	Code	Message
-Note	1051	Unknown table 'no_such_table_and_this_error_better_stick'
-set @foo=12;
-GET DIAGNOSTICS @foo = NUMBER;
-select @foo;
-@foo
-3
-set @foo=12;
-GET CURRENT DIAGNOSTICS @foo = NUMBER;
-select @foo;
-@foo
-4
-set @foo=12;
-drop table if exists `no_such_table_and_this_note_better_stick`;
-Warnings:
-Note	1051	Unknown table 'no_such_table_and_this_note_better_stick'
-show warnings;
-Level	Code	Message
-Note	1051	Unknown table 'no_such_table_and_this_note_better_stick'
-GET CURRENT DIAGNOSTICS @foo = NUMBER;
-show warnings;
-Level	Code	Message
-Note	1051	Unknown table 'no_such_table_and_this_note_better_stick'
-select @foo;
-@foo
-2
-set @foo=12;
-drop table `no_such_table_and_this_error_better_stick`;
-ERROR 42S02: Unknown table 'no_such_table_and_this_error_better_stick'
-show warnings;
-Level	Code	Message
-GET CURRENT DIAGNOSTICS @foo = NUMBER;
-show warnings;
-Level	Code	Message
-select @foo;
-@foo
-0
-set @foo=12;
-insert into no_such_table value (1);
-ERROR 42S02: Table 'test.no_such_table' doesn't exist
-show warnings;
-Level	Code	Message
-Error	1146	Table 'test.no_such_table' doesn't exist
-GET CURRENT DIAGNOSTICS @foo = NUMBER;
-show warnings;
-Level	Code	Message
-Error	1146	Table 'test.no_such_table' doesn't exist
-select @foo;
-@foo
-1
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="more";
-Warnings:
-Warning	1726	more
-GET CURRENT DIAGNOSTICS @foo = MORE;
-select @foo;
-@foo
-N
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="command_function";
-Warnings:
-Warning	1726	command_function
-GET CURRENT DIAGNOSTICS @foo = COMMAND_FUNCTION;
-select @foo;
-@foo
-SIGNAL
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="command_function_code";
-Warnings:
-Warning	1726	command_function_code
-GET CURRENT DIAGNOSTICS @foo = COMMAND_FUNCTION_CODE;
-select @foo;
-@foo
-92
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="dynamic_function";
-Warnings:
-Warning	1726	dynamic_function
-GET CURRENT DIAGNOSTICS @foo = DYNAMIC_FUNCTION;
-select @foo;
-@foo
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="dynamic_function_code";
-Warnings:
-Warning	1726	dynamic_function_code
-GET CURRENT DIAGNOSTICS @foo = DYNAMIC_FUNCTION_CODE;
-select @foo;
-@foo
-0
-create table t1(a int);
-insert into t1 values (1), (2), (3);
-GET CURRENT DIAGNOSTICS @foo = ROW_COUNT;
-select @foo;
-@foo
-3
-update t1 set a=a*10 where (a <= 2);
-GET CURRENT DIAGNOSTICS @foo = ROW_COUNT;
-select @foo;
-@foo
-2
-delete from t1 where (a = 20);
-GET CURRENT DIAGNOSTICS @foo = ROW_COUNT;
-select @foo;
-@foo
-1
-set @foo="foo";
-insert into no_such_table values (1);
-ERROR 42S02: Table 'test.no_such_table' doesn't exist
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CLASS_ORIGIN;
-select @foo;
-@foo
-
-set @foo="foo";
-insert into no_such_table values (1);
-ERROR 42S02: Table 'test.no_such_table' doesn't exist
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = SUBCLASS_ORIGIN;
-select @foo;
-@foo
-
-set @foo="foo";
-insert into no_such_table values (1);
-ERROR 42S02: Table 'test.no_such_table' doesn't exist
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONSTRAINT_CATALOG;
-select @foo;
-@foo
-
-set @foo="foo";
-insert into no_such_table values (1);
-ERROR 42S02: Table 'test.no_such_table' doesn't exist
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONSTRAINT_SCHEMA;
-select @foo;
-@foo
-
-set @foo="foo";
-insert into no_such_table values (1);
-ERROR 42S02: Table 'test.no_such_table' doesn't exist
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONSTRAINT_NAME;
-select @foo;
-@foo
-
-set @foo="foo";
-insert into no_such_table values (1);
-ERROR 42S02: Table 'test.no_such_table' doesn't exist
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CATALOG_NAME;
-select @foo;
-@foo
-
-set @foo="foo";
-insert into no_such_table values (1);
-ERROR 42S02: Table 'test.no_such_table' doesn't exist
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = SCHEMA_NAME;
-select @foo;
-@foo
-test
-set @foo="foo";
-insert into no_such_table values (1);
-ERROR 42S02: Table 'test.no_such_table' doesn't exist
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = TABLE_NAME;
-select @foo;
-@foo
-no_such_table
-set @foo="foo";
-insert into no_such_table values (1);
-ERROR 42S02: Table 'test.no_such_table' doesn't exist
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = COLUMN_NAME;
-select @foo;
-@foo
-
-set @foo="foo";
-insert into no_such_table values (1);
-ERROR 42S02: Table 'test.no_such_table' doesn't exist
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CURSOR_NAME;
-select @foo;
-@foo
-
-set @foo="foo";
-insert into no_such_table values (1);
-ERROR 42S02: Table 'test.no_such_table' doesn't exist
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = MESSAGE_TEXT;
-select @foo;
-@foo
-Table 'test.no_such_table' doesn't exist
-set @foo="foo";
-insert into no_such_table values (1);
-ERROR 42S02: Table 'test.no_such_table' doesn't exist
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = MYSQL_ERRNO;
-select @foo;
-@foo
-1146
-set @foo="foo";
-insert into no_such_table values (1);
-ERROR 42S02: Table 'test.no_such_table' doesn't exist
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONDITION_IDENTIFIER;
-select @foo;
-@foo
-
-set @foo="foo";
-insert into no_such_table values (1);
-ERROR 42S02: Table 'test.no_such_table' doesn't exist
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONDITION_NUMBER;
-select @foo;
-@foo
-1
-set @foo="foo";
-insert into no_such_table values (1);
-ERROR 42S02: Table 'test.no_such_table' doesn't exist
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONNECTION_NAME;
-select @foo;
-@foo
-
-set @foo="foo";
-insert into no_such_table values (1);
-ERROR 42S02: Table 'test.no_such_table' doesn't exist
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = MESSAGE_LENGTH;
-select @foo;
-@foo
-40
-set @foo="foo";
-insert into no_such_table values (1);
-ERROR 42S02: Table 'test.no_such_table' doesn't exist
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = MESSAGE_OCTET_LENGTH;
-select @foo;
-@foo
-40
-set @foo="foo";
-insert into no_such_table values (1);
-ERROR 42S02: Table 'test.no_such_table' doesn't exist
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = PARAMETER_MODE;
-select @foo;
-@foo
-
-set @foo="foo";
-insert into no_such_table values (1);
-ERROR 42S02: Table 'test.no_such_table' doesn't exist
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = PARAMETER_NAME;
-select @foo;
-@foo
-
-set @foo="foo";
-insert into no_such_table values (1);
-ERROR 42S02: Table 'test.no_such_table' doesn't exist
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = PARAMETER_ORDINAL_POSITION;
-select @foo;
-@foo
-0
-set @foo="foo";
-insert into no_such_table values (1);
-ERROR 42S02: Table 'test.no_such_table' doesn't exist
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = RETURNED_SQLSTATE;
-select @foo;
-@foo
-42S02
-set @foo="foo";
-insert into no_such_table values (1);
-ERROR 42S02: Table 'test.no_such_table' doesn't exist
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = ROUTINE_CATALOG;
-select @foo;
-@foo
-
-set @foo="foo";
-insert into no_such_table values (1);
-ERROR 42S02: Table 'test.no_such_table' doesn't exist
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = ROUTINE_SCHEMA;
-select @foo;
-@foo
-
-set @foo="foo";
-insert into no_such_table values (1);
-ERROR 42S02: Table 'test.no_such_table' doesn't exist
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = SERVER_NAME;
-select @foo;
-@foo
-
-set @foo="foo";
-insert into no_such_table values (1);
-ERROR 42S02: Table 'test.no_such_table' doesn't exist
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = SPECIFIC_NAME;
-select @foo;
-@foo
-
-set @foo="foo";
-insert into no_such_table values (1);
-ERROR 42S02: Table 'test.no_such_table' doesn't exist
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = TRIGGER_CATALOG;
-select @foo;
-@foo
-
-set @foo="foo";
-insert into no_such_table values (1);
-ERROR 42S02: Table 'test.no_such_table' doesn't exist
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = TRIGGER_NAME;
-select @foo;
-@foo
-
-set @foo="foo";
-insert into no_such_table values (1);
-ERROR 42S02: Table 'test.no_such_table' doesn't exist
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = TRIGGER_SCHEMA;
-select @foo;
-@foo
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET CLASS_ORIGIN="class origin";
-Warnings:
-Warning	1726	Unhandled user-defined warning
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CLASS_ORIGIN;
-select @foo;
-@foo
-class origin
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET SUBCLASS_ORIGIN="subclass origin";
-Warnings:
-Warning	1726	Unhandled user-defined warning
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = SUBCLASS_ORIGIN;
-select @foo;
-@foo
-subclass origin
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET CONSTRAINT_CATALOG="constraint catalog";
-Warnings:
-Warning	1726	Unhandled user-defined warning
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CONSTRAINT_CATALOG;
-select @foo;
-@foo
-constraint catalog
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET CONSTRAINT_SCHEMA="constraint schema";
-Warnings:
-Warning	1726	Unhandled user-defined warning
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CONSTRAINT_SCHEMA;
-select @foo;
-@foo
-constraint schema
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET CONSTRAINT_NAME="constraint name";
-Warnings:
-Warning	1726	Unhandled user-defined warning
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CONSTRAINT_NAME;
-select @foo;
-@foo
-constraint name
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET CATALOG_NAME="catalog name";
-Warnings:
-Warning	1726	Unhandled user-defined warning
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CATALOG_NAME;
-select @foo;
-@foo
-catalog name
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET SCHEMA_NAME="schema name";
-Warnings:
-Warning	1726	Unhandled user-defined warning
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = SCHEMA_NAME;
-select @foo;
-@foo
-schema name
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET TABLE_NAME="table name";
-Warnings:
-Warning	1726	Unhandled user-defined warning
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = TABLE_NAME;
-select @foo;
-@foo
-table name
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET COLUMN_NAME="column name";
-Warnings:
-Warning	1726	Unhandled user-defined warning
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = COLUMN_NAME;
-select @foo;
-@foo
-column name
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET CURSOR_NAME="cursor name";
-Warnings:
-Warning	1726	Unhandled user-defined warning
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CURSOR_NAME;
-select @foo;
-@foo
-cursor name
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="message text";
-Warnings:
-Warning	1726	message text
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = MESSAGE_TEXT;
-select @foo;
-@foo
-message text
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MYSQL_ERRNO=1234;
-Warnings:
-Warning	1234	Unhandled user-defined warning
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = MYSQL_ERRNO;
-select @foo;
-@foo
-1234
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
-Warnings:
-Warning	1726	internal
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CONDITION_IDENTIFIER;
-select @foo;
-@foo
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
-Warnings:
-Warning	1726	internal
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CONDITION_NUMBER;
-select @foo;
-@foo
-2
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
-Warnings:
-Warning	1726	internal
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CONNECTION_NAME;
-select @foo;
-@foo
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
-Warnings:
-Warning	1726	internal
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = MESSAGE_LENGTH;
-select @foo;
-@foo
-8
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
-Warnings:
-Warning	1726	internal
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = MESSAGE_OCTET_LENGTH;
-select @foo;
-@foo
-8
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
-Warnings:
-Warning	1726	internal
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = PARAMETER_MODE;
-select @foo;
-@foo
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
-Warnings:
-Warning	1726	internal
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = PARAMETER_NAME;
-select @foo;
-@foo
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
-Warnings:
-Warning	1726	internal
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = PARAMETER_ORDINAL_POSITION;
-select @foo;
-@foo
-0
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
-Warnings:
-Warning	1726	internal
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = RETURNED_SQLSTATE;
-select @foo;
-@foo
-01000
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
-Warnings:
-Warning	1726	internal
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = ROUTINE_CATALOG;
-select @foo;
-@foo
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
-Warnings:
-Warning	1726	internal
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = ROUTINE_SCHEMA;
-select @foo;
-@foo
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
-Warnings:
-Warning	1726	internal
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = SERVER_NAME;
-select @foo;
-@foo
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
-Warnings:
-Warning	1726	internal
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = SPECIFIC_NAME;
-select @foo;
-@foo
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
-Warnings:
-Warning	1726	internal
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = TRIGGER_CATALOG;
-select @foo;
-@foo
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
-Warnings:
-Warning	1726	internal
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = TRIGGER_NAME;
-select @foo;
-@foo
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
-Warnings:
-Warning	1726	internal
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = TRIGGER_SCHEMA;
-select @foo;
-@foo
-

=== removed file 'mysql-test/r/signal_diag_tx.result'
--- a/mysql-test/r/signal_diag_tx.result	2008-07-17 17:36:22 +0000
+++ b/mysql-test/r/signal_diag_tx.result	1970-01-01 00:00:00 +0000
@@ -1,64 +0,0 @@
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="transactions_committed";
-Warnings:
-Warning	1726	transactions_committed
-GET CURRENT DIAGNOSTICS @foo = TRANSACTIONS_COMMITTED;
-select @foo;
-@foo
-0
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="transactions_rolled_back";
-Warnings:
-Warning	1726	transactions_rolled_back
-GET CURRENT DIAGNOSTICS @foo = TRANSACTIONS_ROLLED_BACK;
-select @foo;
-@foo
-0
-drop table if exists t1;
-create table t1 (a integer) engine=falcon;
-set autocommit=0;
-GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
-select @foo;
-@foo
-0
-BEGIN;
-GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
-select @foo;
-@foo
-1
-insert into t1 value (1);
-GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
-select @foo;
-@foo
-1
-COMMIT;
-GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
-select @foo;
-@foo
-0
-BEGIN;
-GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
-select @foo;
-@foo
-1
-insert into t1 value (2);
-GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
-select @foo;
-@foo
-1
-ROLLBACK;
-GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
-select @foo;
-@foo
-0
-set autocommit=1;
-GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
-select @foo;
-@foo
-0
-insert into t1 value (3);
-GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
-select @foo;
-@foo
-0
-drop table t1;

=== added file 'mysql-test/t/diag.test'
--- a/mysql-test/t/diag.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/diag.test	2008-07-18 01:23:15 +0000
@@ -0,0 +1,1339 @@
+# 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 GET DIAGNOSTICS
+
+#
+# PART 1: syntax
+#
+
+--error ER_PARSE_ERROR
+create table test_reserved (get int);
+
+#
+# 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 = MYSQL_ERRNO;
+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 = MYSQL_ERRNO;
+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_UNSUPPORTED_PS
+prepare stmt from 'GET DIAGNOSTICS @foo = NUMBER';
+
+#
+# PART 3: Runtime execution
+#
+
+#
+# GET DIAGNOSTICS can also appear in a query
+#
+
+# Test that GET DIAGNOSTICS does not write to the condition area
+
+select "Clear the previous statement diagnostics area";
+show warnings;
+
+GET DIAGNOSTICS @foo = NUMBER;
+show warnings;
+GET CURRENT DIAGNOSTICS @foo = NUMBER;
+show warnings;
+--error ER_STACKED_DIAG_NO_HANDLER
+GET STACKED DIAGNOSTICS @foo = NUMBER;
+show warnings;
+
+select "Populate the previous statement diagnostics area (note)";
+drop table if exists `no_such_table_and_this_error_better_stick`;
+show warnings;
+
+GET DIAGNOSTICS @foo = NUMBER;
+show warnings;
+GET CURRENT DIAGNOSTICS @foo = NUMBER;
+show warnings;
+--error ER_STACKED_DIAG_NO_HANDLER
+GET STACKED DIAGNOSTICS @foo = NUMBER;
+show warnings;
+
+select "Clear the previous statement diagnostics area";
+show warnings;
+
+set @foo=12;
+GET DIAGNOSTICS @foo = NUMBER;
+select @foo;
+
+set @foo=12;
+GET CURRENT DIAGNOSTICS @foo = NUMBER;
+select @foo;
+
+set @foo=12;
+# Note + completion : 2 conditions
+drop table if exists `no_such_table_and_this_note_better_stick`;
+show warnings;
+GET CURRENT DIAGNOSTICS @foo = NUMBER;
+show warnings;
+select @foo;
+
+set @foo=12;
+# Error : 1 condition
+--error ER_BAD_TABLE_ERROR
+drop table `no_such_table_and_this_error_better_stick`;
+# Bug#37431: no_warnings_for_error is set in mysql_rm_table_part2(),
+# which silence the error
+show warnings;
+GET CURRENT DIAGNOSTICS @foo = NUMBER;
+show warnings;
+# Expecting 0 given no_warnings_for_error
+select @foo;
+
+set @foo=12;
+# Error : 1 condition
+--error ER_NO_SUCH_TABLE
+insert into no_such_table value (1);
+show warnings;
+GET CURRENT DIAGNOSTICS @foo = NUMBER;
+show warnings;
+select @foo;
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="more";
+GET CURRENT DIAGNOSTICS @foo = MORE;
+select @foo;
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="command_function";
+GET CURRENT DIAGNOSTICS @foo = COMMAND_FUNCTION;
+select @foo;
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="command_function_code";
+GET CURRENT DIAGNOSTICS @foo = COMMAND_FUNCTION_CODE;
+select @foo;
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="dynamic_function";
+GET CURRENT DIAGNOSTICS @foo = DYNAMIC_FUNCTION;
+select @foo;
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="dynamic_function_code";
+GET CURRENT DIAGNOSTICS @foo = DYNAMIC_FUNCTION_CODE;
+select @foo;
+
+create table t1(a int);
+insert into t1 values (1), (2), (3);
+GET CURRENT DIAGNOSTICS @foo = ROW_COUNT;
+select @foo;
+
+update t1 set a=a*10 where (a <= 2);
+GET CURRENT DIAGNOSTICS @foo = ROW_COUNT;
+select @foo;
+
+delete from t1 where (a = 20);
+GET CURRENT DIAGNOSTICS @foo = ROW_COUNT;
+select @foo;
+
+set @foo="foo";
+--error ER_NO_SUCH_TABLE
+insert into no_such_table values (1);
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CLASS_ORIGIN;
+select @foo;
+
+set @foo="foo";
+--error ER_NO_SUCH_TABLE
+insert into no_such_table values (1);
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = SUBCLASS_ORIGIN;
+select @foo;
+
+set @foo="foo";
+--error ER_NO_SUCH_TABLE
+insert into no_such_table values (1);
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONSTRAINT_CATALOG;
+select @foo;
+
+set @foo="foo";
+--error ER_NO_SUCH_TABLE
+insert into no_such_table values (1);
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONSTRAINT_SCHEMA;
+select @foo;
+
+set @foo="foo";
+--error ER_NO_SUCH_TABLE
+insert into no_such_table values (1);
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONSTRAINT_NAME;
+select @foo;
+
+set @foo="foo";
+--error ER_NO_SUCH_TABLE
+insert into no_such_table values (1);
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CATALOG_NAME;
+select @foo;
+
+set @foo="foo";
+--error ER_NO_SUCH_TABLE
+insert into no_such_table values (1);
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = SCHEMA_NAME;
+select @foo;
+
+set @foo="foo";
+--error ER_NO_SUCH_TABLE
+insert into no_such_table values (1);
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = TABLE_NAME;
+select @foo;
+
+set @foo="foo";
+--error ER_NO_SUCH_TABLE
+insert into no_such_table values (1);
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = COLUMN_NAME;
+select @foo;
+
+set @foo="foo";
+--error ER_NO_SUCH_TABLE
+insert into no_such_table values (1);
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CURSOR_NAME;
+select @foo;
+
+set @foo="foo";
+--error ER_NO_SUCH_TABLE
+insert into no_such_table values (1);
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = MESSAGE_TEXT;
+select @foo;
+
+set @foo="foo";
+--error ER_NO_SUCH_TABLE
+insert into no_such_table values (1);
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = MYSQL_ERRNO;
+select @foo;
+
+set @foo="foo";
+--error ER_NO_SUCH_TABLE
+insert into no_such_table values (1);
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONDITION_IDENTIFIER;
+select @foo;
+
+set @foo="foo";
+--error ER_NO_SUCH_TABLE
+insert into no_such_table values (1);
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONDITION_NUMBER;
+select @foo;
+
+set @foo="foo";
+--error ER_NO_SUCH_TABLE
+insert into no_such_table values (1);
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONNECTION_NAME;
+select @foo;
+
+set @foo="foo";
+--error ER_NO_SUCH_TABLE
+insert into no_such_table values (1);
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = MESSAGE_LENGTH;
+select @foo;
+
+set @foo="foo";
+--error ER_NO_SUCH_TABLE
+insert into no_such_table values (1);
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = MESSAGE_OCTET_LENGTH;
+select @foo;
+
+set @foo="foo";
+--error ER_NO_SUCH_TABLE
+insert into no_such_table values (1);
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = PARAMETER_MODE;
+select @foo;
+
+set @foo="foo";
+--error ER_NO_SUCH_TABLE
+insert into no_such_table values (1);
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = PARAMETER_NAME;
+select @foo;
+
+set @foo="foo";
+--error ER_NO_SUCH_TABLE
+insert into no_such_table values (1);
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = PARAMETER_ORDINAL_POSITION;
+select @foo;
+
+set @foo="foo";
+--error ER_NO_SUCH_TABLE
+insert into no_such_table values (1);
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = RETURNED_SQLSTATE;
+select @foo;
+
+set @foo="foo";
+--error ER_NO_SUCH_TABLE
+insert into no_such_table values (1);
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = ROUTINE_CATALOG;
+select @foo;
+
+set @foo="foo";
+--error ER_NO_SUCH_TABLE
+insert into no_such_table values (1);
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = ROUTINE_SCHEMA;
+select @foo;
+
+set @foo="foo";
+--error ER_NO_SUCH_TABLE
+insert into no_such_table values (1);
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = SERVER_NAME;
+select @foo;
+
+set @foo="foo";
+--error ER_NO_SUCH_TABLE
+insert into no_such_table values (1);
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = SPECIFIC_NAME;
+select @foo;
+
+set @foo="foo";
+--error ER_NO_SUCH_TABLE
+insert into no_such_table values (1);
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = TRIGGER_CATALOG;
+select @foo;
+
+set @foo="foo";
+--error ER_NO_SUCH_TABLE
+insert into no_such_table values (1);
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = TRIGGER_NAME;
+select @foo;
+
+set @foo="foo";
+--error ER_NO_SUCH_TABLE
+insert into no_such_table values (1);
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = TRIGGER_SCHEMA;
+select @foo;
+
+#
+# Note: the following tests signal a warning, so that:
+# condition #1 = 00000 (succes),
+# condition #2 = warning
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET CLASS_ORIGIN="class origin";
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CLASS_ORIGIN;
+select @foo;
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET SUBCLASS_ORIGIN="subclass origin";
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = SUBCLASS_ORIGIN;
+select @foo;
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET CONSTRAINT_CATALOG="constraint catalog";
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CONSTRAINT_CATALOG;
+select @foo;
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET CONSTRAINT_SCHEMA="constraint schema";
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CONSTRAINT_SCHEMA;
+select @foo;
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET CONSTRAINT_NAME="constraint name";
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CONSTRAINT_NAME;
+select @foo;
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET CATALOG_NAME="catalog name";
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CATALOG_NAME;
+select @foo;
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET SCHEMA_NAME="schema name";
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = SCHEMA_NAME;
+select @foo;
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET TABLE_NAME="table name";
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = TABLE_NAME;
+select @foo;
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET COLUMN_NAME="column name";
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = COLUMN_NAME;
+select @foo;
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET CURSOR_NAME="cursor name";
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CURSOR_NAME;
+select @foo;
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="message text";
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = MESSAGE_TEXT;
+select @foo;
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MYSQL_ERRNO=1234;
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = MYSQL_ERRNO;
+select @foo;
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CONDITION_IDENTIFIER;
+select @foo;
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CONDITION_NUMBER;
+select @foo;
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CONNECTION_NAME;
+select @foo;
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = MESSAGE_LENGTH;
+select @foo;
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = MESSAGE_OCTET_LENGTH;
+select @foo;
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = PARAMETER_MODE;
+select @foo;
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = PARAMETER_NAME;
+select @foo;
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = PARAMETER_ORDINAL_POSITION;
+select @foo;
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = RETURNED_SQLSTATE;
+select @foo;
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = ROUTINE_CATALOG;
+select @foo;
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = ROUTINE_SCHEMA;
+select @foo;
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = SERVER_NAME;
+select @foo;
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = SPECIFIC_NAME;
+select @foo;
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = TRIGGER_CATALOG;
+select @foo;
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = TRIGGER_NAME;
+select @foo;
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
+GET CURRENT DIAGNOSTICS CONDITION 2 @foo = TRIGGER_SCHEMA;
+select @foo;
+
+#
+# Note: the following tests signal an error, so that:
+# condition #1 = error
+
+set @foo="foo";
+--error ER_SIGNAL_EXCEPTION
+SIGNAL SQLSTATE '03000' SET CLASS_ORIGIN="class origin";
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CLASS_ORIGIN;
+select @foo;
+
+set @foo="foo";
+--error ER_SIGNAL_EXCEPTION
+SIGNAL SQLSTATE '03000' SET SUBCLASS_ORIGIN="subclass origin";
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = SUBCLASS_ORIGIN;
+select @foo;
+
+set @foo="foo";
+--error ER_SIGNAL_EXCEPTION
+SIGNAL SQLSTATE '03000' SET CONSTRAINT_CATALOG="constraint catalog";
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONSTRAINT_CATALOG;
+select @foo;
+
+set @foo="foo";
+--error ER_SIGNAL_EXCEPTION
+SIGNAL SQLSTATE '03000' SET CONSTRAINT_SCHEMA="constraint schema";
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONSTRAINT_SCHEMA;
+select @foo;
+
+set @foo="foo";
+--error ER_SIGNAL_EXCEPTION
+SIGNAL SQLSTATE '03000' SET CONSTRAINT_NAME="constraint name";
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONSTRAINT_NAME;
+select @foo;
+
+set @foo="foo";
+--error ER_SIGNAL_EXCEPTION
+SIGNAL SQLSTATE '03000' SET CATALOG_NAME="catalog name";
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CATALOG_NAME;
+select @foo;
+
+set @foo="foo";
+--error ER_SIGNAL_EXCEPTION
+SIGNAL SQLSTATE '03000' SET SCHEMA_NAME="schema name";
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = SCHEMA_NAME;
+select @foo;
+
+set @foo="foo";
+--error ER_SIGNAL_EXCEPTION
+SIGNAL SQLSTATE '03000' SET TABLE_NAME="table name";
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = TABLE_NAME;
+select @foo;
+
+set @foo="foo";
+--error ER_SIGNAL_EXCEPTION
+SIGNAL SQLSTATE '03000' SET COLUMN_NAME="column name";
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = COLUMN_NAME;
+select @foo;
+
+set @foo="foo";
+--error ER_SIGNAL_EXCEPTION
+SIGNAL SQLSTATE '03000' SET CURSOR_NAME="cursor name";
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CURSOR_NAME;
+select @foo;
+
+set @foo="foo";
+--error ER_SIGNAL_EXCEPTION
+SIGNAL SQLSTATE '03000' SET MESSAGE_TEXT="message text";
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = MESSAGE_TEXT;
+select @foo;
+
+set @foo="foo";
+--error 1234
+SIGNAL SQLSTATE '03000' SET MYSQL_ERRNO=1234;
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = MYSQL_ERRNO;
+select @foo;
+
+set @foo="foo";
+--error ER_SIGNAL_EXCEPTION
+SIGNAL SQLSTATE '03000' SET MESSAGE_TEXT="internal";
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONDITION_IDENTIFIER;
+select @foo;
+
+set @foo="foo";
+--error ER_SIGNAL_EXCEPTION
+SIGNAL SQLSTATE '03000' SET MESSAGE_TEXT="internal";
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONDITION_NUMBER;
+select @foo;
+
+set @foo="foo";
+--error ER_SIGNAL_EXCEPTION
+SIGNAL SQLSTATE '03000' SET MESSAGE_TEXT="internal";
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONNECTION_NAME;
+select @foo;
+
+set @foo="foo";
+--error ER_SIGNAL_EXCEPTION
+SIGNAL SQLSTATE '03000' SET MESSAGE_TEXT="internal";
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = MESSAGE_LENGTH;
+select @foo;
+
+set @foo="foo";
+--error ER_SIGNAL_EXCEPTION
+SIGNAL SQLSTATE '03000' SET MESSAGE_TEXT="internal";
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = MESSAGE_OCTET_LENGTH;
+select @foo;
+
+set @foo="foo";
+--error ER_SIGNAL_EXCEPTION
+SIGNAL SQLSTATE '03000' SET MESSAGE_TEXT="internal";
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = PARAMETER_MODE;
+select @foo;
+
+set @foo="foo";
+--error ER_SIGNAL_EXCEPTION
+SIGNAL SQLSTATE '03000' SET MESSAGE_TEXT="internal";
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = PARAMETER_NAME;
+select @foo;
+
+set @foo="foo";
+--error ER_SIGNAL_EXCEPTION
+SIGNAL SQLSTATE '03000' SET MESSAGE_TEXT="internal";
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = PARAMETER_ORDINAL_POSITION;
+select @foo;
+
+set @foo="foo";
+--error ER_SIGNAL_EXCEPTION
+SIGNAL SQLSTATE '03000' SET MESSAGE_TEXT="internal";
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = RETURNED_SQLSTATE;
+select @foo;
+
+set @foo="foo";
+--error ER_SIGNAL_EXCEPTION
+SIGNAL SQLSTATE '03000' SET MESSAGE_TEXT="internal";
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = ROUTINE_CATALOG;
+select @foo;
+
+set @foo="foo";
+--error ER_SIGNAL_EXCEPTION
+SIGNAL SQLSTATE '03000' SET MESSAGE_TEXT="internal";
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = ROUTINE_SCHEMA;
+select @foo;
+
+set @foo="foo";
+--error ER_SIGNAL_EXCEPTION
+SIGNAL SQLSTATE '03000' SET MESSAGE_TEXT="internal";
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = SERVER_NAME;
+select @foo;
+
+set @foo="foo";
+--error ER_SIGNAL_EXCEPTION
+SIGNAL SQLSTATE '03000' SET MESSAGE_TEXT="internal";
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = SPECIFIC_NAME;
+select @foo;
+
+set @foo="foo";
+--error ER_SIGNAL_EXCEPTION
+SIGNAL SQLSTATE '03000' SET MESSAGE_TEXT="internal";
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = TRIGGER_CATALOG;
+select @foo;
+
+set @foo="foo";
+--error ER_SIGNAL_EXCEPTION
+SIGNAL SQLSTATE '03000' SET MESSAGE_TEXT="internal";
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = TRIGGER_NAME;
+select @foo;
+
+set @foo="foo";
+--error ER_SIGNAL_EXCEPTION
+SIGNAL SQLSTATE '03000' SET MESSAGE_TEXT="internal";
+GET CURRENT DIAGNOSTICS CONDITION 1 @foo = TRIGGER_SCHEMA;
+select @foo;
+

=== added file 'mysql-test/t/diag_code.test'
--- a/mysql-test/t/diag_code.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/diag_code.test	2008-07-18 01:23:15 +0000
@@ -0,0 +1,53 @@
+# 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 GET DIAGNOSTICS
+
+-- source include/have_debug.inc
+
+use test;
+
+--disable_warnings
+drop procedure if exists diag_proc;
+drop function if exists diag_func;
+--enable_warnings
+
+delimiter $$;
+
+create procedure diag_proc()
+begin
+  DECLARE v, v1, v2 integer;
+
+  GET DIAGNOSTICS v = NUMBER;
+  GET CURRENT DIAGNOSTICS v1 = NUMBER, v2 = MORE;
+end $$
+
+create function diag_func() returns int
+begin
+  DECLARE v, v1, v2 integer;
+
+  GET DIAGNOSTICS v = NUMBER;
+  GET CURRENT DIAGNOSTICS v1 = NUMBER, v2 = MORE;
+  return 0;
+end $$
+
+delimiter ;$$
+
+show procedure code diag_proc;
+drop procedure diag_proc;
+
+show function code diag_func;
+drop function diag_func;
+

=== added file 'mysql-test/t/diag_tx.test'
--- a/mysql-test/t/diag_tx.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/diag_tx.test	2008-07-18 01:23:15 +0000
@@ -0,0 +1,86 @@
+# 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 GET DIAGNOSTICS
+
+#
+# GET DIAGNOSTICS and transactional items
+#
+
+--source include/have_falcon.inc
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="transactions_committed";
+GET CURRENT DIAGNOSTICS @foo = TRANSACTIONS_COMMITTED;
+select @foo;
+
+set @foo="foo";
+SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="transactions_rolled_back";
+GET CURRENT DIAGNOSTICS @foo = TRANSACTIONS_ROLLED_BACK;
+select @foo;
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1 (a integer) engine=falcon;
+
+set autocommit=0;
+
+GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
+select @foo;
+
+BEGIN;
+
+GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
+select @foo;
+
+insert into t1 value (1);
+
+GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
+select @foo;
+
+COMMIT;
+
+GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
+select @foo;
+
+BEGIN;
+
+GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
+select @foo;
+
+insert into t1 value (2);
+
+GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
+select @foo;
+
+ROLLBACK;
+
+GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
+select @foo;
+
+set autocommit=1;
+
+GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
+select @foo;
+
+insert into t1 value (3);
+
+GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
+select @foo;
+
+drop table t1;
+

=== modified file 'mysql-test/t/signal.test'
--- a/mysql-test/t/signal.test	2008-07-17 16:41:14 +0000
+++ b/mysql-test/t/signal.test	2008-07-18 01:21:18 +0000
@@ -13,7 +13,7 @@
 # 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
+# Tests for SIGNAL and RESIGNAL
 
 #
 # PART 1: syntax
@@ -679,718 +679,6 @@
 delimiter ;$$
 
 #
-# 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 = MYSQL_ERRNO;
-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 = MYSQL_ERRNO;
-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
 #
 
@@ -1400,9 +688,6 @@
 --error ER_UNSUPPORTED_PS
 prepare stmt from 'RESIGNAL SQLSTATE \'23000\'';
 
---error ER_UNSUPPORTED_PS
-prepare stmt from 'GET DIAGNOSTICS @foo = NUMBER';
-
 #
 # PART 3: runtime execution
 #

=== modified file 'mysql-test/t/signal_code.test'
--- a/mysql-test/t/signal_code.test	2008-06-11 22:53:47 +0000
+++ b/mysql-test/t/signal_code.test	2008-07-18 01:21:18 +0000
@@ -13,7 +13,7 @@
 # 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
+# Tests for SIGNAL and RESIGNAL
 
 -- source include/have_debug.inc
 
@@ -28,28 +28,22 @@
 
 create procedure signal_proc()
 begin
-  DECLARE v, v1, v2 integer;
   DECLARE foo CONDITION FOR SQLSTATE '12345';
 
   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 SQLSTATE '12345';
 
   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 $$
 

=== modified file 'mysql-test/t/signal_demo1.test'
--- a/mysql-test/t/signal_demo1.test	2008-06-24 23:41:24 +0000
+++ b/mysql-test/t/signal_demo1.test	2008-07-18 01:21:18 +0000
@@ -102,7 +102,7 @@
       if (x != 1)
       then
         set msg= concat('No such physical person, PK:', id);
-        SIGNAL SQLSTATE 'XX001' SET
+        SIGNAL SQLSTATE '45000' SET
           MESSAGE_TEXT = msg,
           MYSQL_ERRNO = 10000;
       end if;
@@ -117,7 +117,7 @@
       if (x != 1)
       then
         set msg= concat('No such moral person, PK:', id);
-        SIGNAL SQLSTATE 'XX001' SET
+        SIGNAL SQLSTATE '45000' SET
           MESSAGE_TEXT = msg,
           MYSQL_ERRNO = 10000;
       end if;
@@ -126,7 +126,7 @@
     else
     begin
       set msg= concat('No such person type:', person_type);
-      SIGNAL SQLSTATE 'XX002' SET
+      SIGNAL SQLSTATE '45000' SET
         MESSAGE_TEXT = msg,
         MYSQL_ERRNO = 20000;
     end;
@@ -147,7 +147,7 @@
   then
     set msg= concat('Failed integrity constraint, table in_inventory, PK:',
                     id);
-    SIGNAL SQLSTATE 'XX001' SET
+    SIGNAL SQLSTATE '45000' SET
       MESSAGE_TEXT = msg,
       MYSQL_ERRNO = 10000;
   end if;
@@ -166,7 +166,7 @@
   if (x != 1)
   then
     set msg= concat('Failed integrity constraint, table po_order, PK:', id);
-    SIGNAL SQLSTATE 'XX001' SET
+    SIGNAL SQLSTATE '45000' SET
       MESSAGE_TEXT = msg,
       MYSQL_ERRNO = 10000;
   end if;

=== modified file 'mysql-test/t/signal_demo3.test'
--- a/mysql-test/t/signal_demo3.test	2008-06-18 01:09:10 +0000
+++ b/mysql-test/t/signal_demo3.test	2008-07-18 01:21:18 +0000
@@ -37,7 +37,7 @@
 create procedure proc_1()
 begin
   declare exit handler for sqlexception
-    resignal sqlstate '55555' set message_text='Oops in proc_1';
+    resignal sqlstate '45000' set message_text='Oops in proc_1';
 
   call proc_2();
 end
@@ -46,7 +46,7 @@
 create procedure proc_2()
 begin
   declare exit handler for sqlexception
-    resignal sqlstate '55555' set message_text='Oops in proc_2';
+    resignal sqlstate '45000' set message_text='Oops in proc_2';
 
   call proc_3();
 end
@@ -55,7 +55,7 @@
 create procedure proc_3()
 begin
   declare exit handler for sqlexception
-    resignal sqlstate '55555' set message_text='Oops in proc_3';
+    resignal sqlstate '45000' set message_text='Oops in proc_3';
 
   call proc_4();
 end
@@ -64,7 +64,7 @@
 create procedure proc_4()
 begin
   declare exit handler for sqlexception
-    resignal sqlstate '55555' set message_text='Oops in proc_4';
+    resignal sqlstate '45000' set message_text='Oops in proc_4';
 
   call proc_5();
 end
@@ -73,7 +73,7 @@
 create procedure proc_5()
 begin
   declare exit handler for sqlexception
-    resignal sqlstate '55555' set message_text='Oops in proc_5';
+    resignal sqlstate '45000' set message_text='Oops in proc_5';
 
   call proc_6();
 end
@@ -82,7 +82,7 @@
 create procedure proc_6()
 begin
   declare exit handler for sqlexception
-    resignal sqlstate '55555' set message_text='Oops in proc_6';
+    resignal sqlstate '45000' set message_text='Oops in proc_6';
 
   call proc_7();
 end
@@ -91,7 +91,7 @@
 create procedure proc_7()
 begin
   declare exit handler for sqlexception
-    resignal sqlstate '55555' set message_text='Oops in proc_7';
+    resignal sqlstate '45000' set message_text='Oops in proc_7';
 
   call proc_8();
 end
@@ -100,7 +100,7 @@
 create procedure proc_8()
 begin
   declare exit handler for sqlexception
-    resignal sqlstate '55555' set message_text='Oops in proc_8';
+    resignal sqlstate '45000' set message_text='Oops in proc_8';
 
   call proc_9();
 end
@@ -109,7 +109,7 @@
 create procedure proc_9()
 begin
   declare exit handler for sqlexception
-    resignal sqlstate '55555' set message_text='Oops in proc_9';
+    resignal sqlstate '45000' set message_text='Oops in proc_9';
 
   ## Do something that fails, to see how errors are reported
   drop table oops_it_is_not_here;

=== removed file 'mysql-test/t/signal_diag.test'
--- a/mysql-test/t/signal_diag.test	2008-06-20 23:00:44 +0000
+++ b/mysql-test/t/signal_diag.test	1970-01-01 00:00:00 +0000
@@ -1,434 +0,0 @@
-# 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
-
-#
-# GET DIAGNOSTICS can also appear in a query
-#
-
-# Test that GET DIAGNOSTICS does not write to the condition area
-
-select "Clear the previous statement diagnostics area";
-show warnings;
-
-GET DIAGNOSTICS @foo = NUMBER;
-show warnings;
-GET CURRENT DIAGNOSTICS @foo = NUMBER;
-show warnings;
---error ER_STACKED_DIAG_NO_HANDLER
-GET STACKED DIAGNOSTICS @foo = NUMBER;
-show warnings;
-
-select "Populate the previous statement diagnostics area (note)";
-drop table if exists `no_such_table_and_this_error_better_stick`;
-show warnings;
-
-GET DIAGNOSTICS @foo = NUMBER;
-show warnings;
-GET CURRENT DIAGNOSTICS @foo = NUMBER;
-show warnings;
---error ER_STACKED_DIAG_NO_HANDLER
-GET STACKED DIAGNOSTICS @foo = NUMBER;
-show warnings;
-
-select "Clear the previous statement diagnostics area";
-show warnings;
-
-set @foo=12;
-GET DIAGNOSTICS @foo = NUMBER;
-select @foo;
-
-set @foo=12;
-GET CURRENT DIAGNOSTICS @foo = NUMBER;
-select @foo;
-
-set @foo=12;
-# Note + completion : 2 conditions
-drop table if exists `no_such_table_and_this_note_better_stick`;
-show warnings;
-GET CURRENT DIAGNOSTICS @foo = NUMBER;
-show warnings;
-select @foo;
-
-set @foo=12;
-# Error : 1 condition
---error ER_BAD_TABLE_ERROR
-drop table `no_such_table_and_this_error_better_stick`;
-# Bug#37431: no_warnings_for_error is set in mysql_rm_table_part2(),
-# which silence the error
-show warnings;
-GET CURRENT DIAGNOSTICS @foo = NUMBER;
-show warnings;
-# Expecting 0 given no_warnings_for_error
-select @foo;
-
-set @foo=12;
-# Error : 1 condition
---error ER_NO_SUCH_TABLE
-insert into no_such_table value (1);
-show warnings;
-GET CURRENT DIAGNOSTICS @foo = NUMBER;
-show warnings;
-select @foo;
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="more";
-GET CURRENT DIAGNOSTICS @foo = MORE;
-select @foo;
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="command_function";
-GET CURRENT DIAGNOSTICS @foo = COMMAND_FUNCTION;
-select @foo;
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="command_function_code";
-GET CURRENT DIAGNOSTICS @foo = COMMAND_FUNCTION_CODE;
-select @foo;
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="dynamic_function";
-GET CURRENT DIAGNOSTICS @foo = DYNAMIC_FUNCTION;
-select @foo;
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="dynamic_function_code";
-GET CURRENT DIAGNOSTICS @foo = DYNAMIC_FUNCTION_CODE;
-select @foo;
-
-create table t1(a int);
-insert into t1 values (1), (2), (3);
-GET CURRENT DIAGNOSTICS @foo = ROW_COUNT;
-select @foo;
-
-update t1 set a=a*10 where (a <= 2);
-GET CURRENT DIAGNOSTICS @foo = ROW_COUNT;
-select @foo;
-
-delete from t1 where (a = 20);
-GET CURRENT DIAGNOSTICS @foo = ROW_COUNT;
-select @foo;
-
-set @foo="foo";
---error ER_NO_SUCH_TABLE
-insert into no_such_table values (1);
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CLASS_ORIGIN;
-select @foo;
-
-set @foo="foo";
---error ER_NO_SUCH_TABLE
-insert into no_such_table values (1);
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = SUBCLASS_ORIGIN;
-select @foo;
-
-set @foo="foo";
---error ER_NO_SUCH_TABLE
-insert into no_such_table values (1);
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONSTRAINT_CATALOG;
-select @foo;
-
-set @foo="foo";
---error ER_NO_SUCH_TABLE
-insert into no_such_table values (1);
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONSTRAINT_SCHEMA;
-select @foo;
-
-set @foo="foo";
---error ER_NO_SUCH_TABLE
-insert into no_such_table values (1);
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONSTRAINT_NAME;
-select @foo;
-
-set @foo="foo";
---error ER_NO_SUCH_TABLE
-insert into no_such_table values (1);
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CATALOG_NAME;
-select @foo;
-
-set @foo="foo";
---error ER_NO_SUCH_TABLE
-insert into no_such_table values (1);
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = SCHEMA_NAME;
-select @foo;
-
-set @foo="foo";
---error ER_NO_SUCH_TABLE
-insert into no_such_table values (1);
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = TABLE_NAME;
-select @foo;
-
-set @foo="foo";
---error ER_NO_SUCH_TABLE
-insert into no_such_table values (1);
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = COLUMN_NAME;
-select @foo;
-
-set @foo="foo";
---error ER_NO_SUCH_TABLE
-insert into no_such_table values (1);
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CURSOR_NAME;
-select @foo;
-
-set @foo="foo";
---error ER_NO_SUCH_TABLE
-insert into no_such_table values (1);
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = MESSAGE_TEXT;
-select @foo;
-
-set @foo="foo";
---error ER_NO_SUCH_TABLE
-insert into no_such_table values (1);
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = MYSQL_ERRNO;
-select @foo;
-
-set @foo="foo";
---error ER_NO_SUCH_TABLE
-insert into no_such_table values (1);
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONDITION_IDENTIFIER;
-select @foo;
-
-set @foo="foo";
---error ER_NO_SUCH_TABLE
-insert into no_such_table values (1);
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONDITION_NUMBER;
-select @foo;
-
-set @foo="foo";
---error ER_NO_SUCH_TABLE
-insert into no_such_table values (1);
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = CONNECTION_NAME;
-select @foo;
-
-set @foo="foo";
---error ER_NO_SUCH_TABLE
-insert into no_such_table values (1);
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = MESSAGE_LENGTH;
-select @foo;
-
-set @foo="foo";
---error ER_NO_SUCH_TABLE
-insert into no_such_table values (1);
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = MESSAGE_OCTET_LENGTH;
-select @foo;
-
-set @foo="foo";
---error ER_NO_SUCH_TABLE
-insert into no_such_table values (1);
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = PARAMETER_MODE;
-select @foo;
-
-set @foo="foo";
---error ER_NO_SUCH_TABLE
-insert into no_such_table values (1);
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = PARAMETER_NAME;
-select @foo;
-
-set @foo="foo";
---error ER_NO_SUCH_TABLE
-insert into no_such_table values (1);
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = PARAMETER_ORDINAL_POSITION;
-select @foo;
-
-set @foo="foo";
---error ER_NO_SUCH_TABLE
-insert into no_such_table values (1);
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = RETURNED_SQLSTATE;
-select @foo;
-
-set @foo="foo";
---error ER_NO_SUCH_TABLE
-insert into no_such_table values (1);
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = ROUTINE_CATALOG;
-select @foo;
-
-set @foo="foo";
---error ER_NO_SUCH_TABLE
-insert into no_such_table values (1);
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = ROUTINE_SCHEMA;
-select @foo;
-
-set @foo="foo";
---error ER_NO_SUCH_TABLE
-insert into no_such_table values (1);
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = SERVER_NAME;
-select @foo;
-
-set @foo="foo";
---error ER_NO_SUCH_TABLE
-insert into no_such_table values (1);
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = SPECIFIC_NAME;
-select @foo;
-
-set @foo="foo";
---error ER_NO_SUCH_TABLE
-insert into no_such_table values (1);
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = TRIGGER_CATALOG;
-select @foo;
-
-set @foo="foo";
---error ER_NO_SUCH_TABLE
-insert into no_such_table values (1);
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = TRIGGER_NAME;
-select @foo;
-
-set @foo="foo";
---error ER_NO_SUCH_TABLE
-insert into no_such_table values (1);
-GET CURRENT DIAGNOSTICS CONDITION 1 @foo = TRIGGER_SCHEMA;
-select @foo;
-
-## FIXME: the following tests should use CONDITION 1, not 2
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET CLASS_ORIGIN="class origin";
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CLASS_ORIGIN;
-select @foo;
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET SUBCLASS_ORIGIN="subclass origin";
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = SUBCLASS_ORIGIN;
-select @foo;
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET CONSTRAINT_CATALOG="constraint catalog";
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CONSTRAINT_CATALOG;
-select @foo;
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET CONSTRAINT_SCHEMA="constraint schema";
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CONSTRAINT_SCHEMA;
-select @foo;
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET CONSTRAINT_NAME="constraint name";
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CONSTRAINT_NAME;
-select @foo;
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET CATALOG_NAME="catalog name";
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CATALOG_NAME;
-select @foo;
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET SCHEMA_NAME="schema name";
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = SCHEMA_NAME;
-select @foo;
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET TABLE_NAME="table name";
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = TABLE_NAME;
-select @foo;
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET COLUMN_NAME="column name";
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = COLUMN_NAME;
-select @foo;
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET CURSOR_NAME="cursor name";
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CURSOR_NAME;
-select @foo;
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="message text";
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = MESSAGE_TEXT;
-select @foo;
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MYSQL_ERRNO=1234;
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = MYSQL_ERRNO;
-select @foo;
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CONDITION_IDENTIFIER;
-select @foo;
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CONDITION_NUMBER;
-select @foo;
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = CONNECTION_NAME;
-select @foo;
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = MESSAGE_LENGTH;
-select @foo;
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = MESSAGE_OCTET_LENGTH;
-select @foo;
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = PARAMETER_MODE;
-select @foo;
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = PARAMETER_NAME;
-select @foo;
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = PARAMETER_ORDINAL_POSITION;
-select @foo;
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = RETURNED_SQLSTATE;
-select @foo;
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = ROUTINE_CATALOG;
-select @foo;
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = ROUTINE_SCHEMA;
-select @foo;
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = SERVER_NAME;
-select @foo;
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = SPECIFIC_NAME;
-select @foo;
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = TRIGGER_CATALOG;
-select @foo;
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = TRIGGER_NAME;
-select @foo;
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="internal";
-GET CURRENT DIAGNOSTICS CONDITION 2 @foo = TRIGGER_SCHEMA;
-select @foo;
-

=== removed file 'mysql-test/t/signal_diag_tx.test'
--- a/mysql-test/t/signal_diag_tx.test	2008-06-20 23:00:44 +0000
+++ b/mysql-test/t/signal_diag_tx.test	1970-01-01 00:00:00 +0000
@@ -1,86 +0,0 @@
-# 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
-
-#
-# GET DIAGNOSTICS and transactional items
-#
-
---source include/have_falcon.inc
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="transactions_committed";
-GET CURRENT DIAGNOSTICS @foo = TRANSACTIONS_COMMITTED;
-select @foo;
-
-set @foo="foo";
-SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT="transactions_rolled_back";
-GET CURRENT DIAGNOSTICS @foo = TRANSACTIONS_ROLLED_BACK;
-select @foo;
-
---disable_warnings
-drop table if exists t1;
---enable_warnings
-
-create table t1 (a integer) engine=falcon;
-
-set autocommit=0;
-
-GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
-select @foo;
-
-BEGIN;
-
-GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
-select @foo;
-
-insert into t1 value (1);
-
-GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
-select @foo;
-
-COMMIT;
-
-GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
-select @foo;
-
-BEGIN;
-
-GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
-select @foo;
-
-insert into t1 value (2);
-
-GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
-select @foo;
-
-ROLLBACK;
-
-GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
-select @foo;
-
-set autocommit=1;
-
-GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
-select @foo;
-
-insert into t1 value (3);
-
-GET CURRENT DIAGNOSTICS @foo = TRANSACTION_ACTIVE;
-select @foo;
-
-drop table t1;
-

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2008-07-17 17:36:22 +0000
+++ b/sql/sql_class.cc	2008-07-18 01:21:18 +0000
@@ -564,10 +564,10 @@
           when the DDL blocker is engaged.
   */
    DDL_exception(FALSE),
+   m_tmp_syn(NULL),
 #if defined(ENABLED_DEBUG_SYNC)
    debug_sync_control(0),
 #endif /* defined(ENABLED_DEBUG_SYNC) */
-   m_tmp_syn(NULL),
    locked_tables_root(NULL)
 {
   ulong tmp;

=== modified file 'sql/sql_signal.cc'
--- a/sql/sql_signal.cc	2008-07-15 22:13:37 +0000
+++ b/sql/sql_signal.cc	2008-07-18 01:21:18 +0000
@@ -663,6 +663,7 @@
   DBUG_RETURN(result);
 }
 
+#ifdef HAVE_GET_DIAGNOSTICS
 int SQLCOM_get_diag::execute(THD *thd)
 {
   int result;
@@ -1144,5 +1145,5 @@
 
   DBUG_RETURN(0);
 }
-
+#endif
 

=== modified file 'sql/sql_signal.h'
--- a/sql/sql_signal.h	2008-06-30 22:11:40 +0000
+++ b/sql/sql_signal.h	2008-07-18 01:21:18 +0000
@@ -143,6 +143,12 @@
   virtual int execute(THD *thd);
 };
 
+/*
+  Prototyping for WL#2111
+*/
+#define HAVE_GET_DIAGNOSTICS
+
+#ifdef HAVE_GET_DIAGNOSTICS
 /**
   SQLCOM_get_diag represents a GET DIAGNOSTICS statement.
   There are two variants of GET DIAGNOSTICS statements:
@@ -256,6 +262,7 @@
   */
   List<Diag_statement_property> *m_statement_property_list;
 };
+#endif
 
 #endif
 

=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy	2008-07-17 17:36:22 +0000
+++ b/sql/sql_yacc.yy	2008-07-18 01:21:18 +0000
@@ -2942,6 +2942,7 @@
           DIAGNOSTICS_SYM /* $3 */
           statement_information /* $4 */
           {
+#ifdef HAVE_GET_DIAGNOSTICS
             THD *thd= YYTHD;
             LEX *lex= thd->lex;
 
@@ -2949,6 +2950,10 @@
             lex->m_stmt= new (thd->mem_root) SQLCOM_get_diag(lex, 
                                                              $2,
                                                              $4);
+#else
+            my_error(ER_NOT_SUPPORTED_YET, MYF(0), "GET DIAGNOSTICS");
+            MYSQL_YYABORT;
+#endif
           }
         | GET_SYM /* $1 */
           opt_which_area /* $2 */
@@ -2957,6 +2962,7 @@
           expr /* $5 */
           condition_information_list /* $6 */
           {
+#ifdef HAVE_GET_DIAGNOSTICS
             THD *thd= YYTHD;
             LEX *lex= thd->lex;
 
@@ -2965,6 +2971,10 @@
                                                              $2,
                                                              $5,
                                                              $6);
+#else
+            my_error(ER_NOT_SUPPORTED_YET, MYF(0), "GET DIAGNOSTICS");
+            MYSQL_YYABORT;
+#endif
           }
         ;
 



