=== 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;

=== 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;
+



