# Test every new reserved and non reserved keywords
#
drop table if exists signal_non_reserved;
create table signal_non_reserved (
class_origin int,
subclass_origin int,
constraint_catalog int,
constraint_schema int,
constraint_name int,
catalog_name int,
schema_name int,
table_name int,
column_name int,
cursor_name int,
message_text int,
sqlcode int
);
drop table signal_non_reserved;
drop table if exists diag_non_reserved;
create table diag_non_reserved (
diagnostics int,
current int,
stacked int,
exception int
);
drop table diag_non_reserved;
drop table if exists diag_cond_non_reserved;
create table diag_cond_non_reserved (
condition_identifier int,
condition_number int,
condition_name int,
connection_name int,
message_length int,
message_octet_length int,
parameter_mode int,
parameter_name int,
parameter_ordinal_position int,
returned_sqlstate int,
routine_catalog int,
routine_name int,
routine_schema int,
server_name int,
specific_name int,
trigger_catalog int,
trigger_name int,
trigger_schema int
);
drop table diag_cond_non_reserved;
drop table if exists diag_stmt_non_reserved;
create table diag_stmt_non_reserved (
number int,
more int,
command_function int,
command_function_code int,
dynamic_function int,
dynamic_function_code int,
row_count int,
transactions_committed int,
transactions_rolled_back int,
transaction_active int
);
drop table diag_stmt_non_reserved;
drop table if exists test_reserved;
create table test_reserved (signal int);
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'signal int)' at line 1
create table test_reserved (resignal int);
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'resignal int)' at line 1
create table test_reserved (condition 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 'condition int)' at line 1
#
# Test the SIGNAL syntax
#
drop procedure if exists test_invalid;
drop procedure if exists test_signal_syntax;
drop function if exists test_signal_func;
create procedure test_invalid()
begin
SIGNAL;
end $$
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ';
end' at line 3
create procedure test_invalid()
begin
SIGNAL foo;
end $$
ERROR 42000: Undefined CONDITION: foo
create procedure test_invalid()
begin
DECLARE foo CONDITION FOR 1234;
SIGNAL foo;
end $$
ERROR HY000: SIGNAL/RESIGNAL can only use a CONDITION defined with SQLSTATE
create procedure test_signal_syntax()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
SIGNAL foo;
end $$
drop procedure test_signal_syntax $$
create procedure test_signal_syntax()
begin
SIGNAL SQLSTATE '23000';
end $$
drop procedure test_signal_syntax $$
create procedure test_signal_syntax()
begin
SIGNAL SQLSTATE VALUE '23000';
end $$
drop procedure test_signal_syntax $$
create procedure test_signal_syntax()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
SIGNAL foo SET CLASS_ORIGIN = 'foo';
end $$
drop procedure test_signal_syntax $$
create procedure test_signal_syntax()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
SIGNAL foo SET SUBCLASS_ORIGIN = 'foo';
end $$
drop procedure test_signal_syntax $$
create procedure test_signal_syntax()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
SIGNAL foo SET CONSTRAINT_CATALOG = 'foo';
end $$
drop procedure test_signal_syntax $$
create procedure test_signal_syntax()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
SIGNAL foo SET CONSTRAINT_SCHEMA = 'foo';
end $$
drop procedure test_signal_syntax $$
create procedure test_signal_syntax()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
SIGNAL foo SET CONSTRAINT_NAME = 'foo';
end $$
drop procedure test_signal_syntax $$
create procedure test_signal_syntax()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
SIGNAL foo SET CATALOG_NAME = 'foo';
end $$
drop procedure test_signal_syntax $$
create procedure test_signal_syntax()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
SIGNAL foo SET SCHEMA_NAME = 'foo';
end $$
drop procedure test_signal_syntax $$
create procedure test_signal_syntax()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
SIGNAL foo SET TABLE_NAME = 'foo';
end $$
drop procedure test_signal_syntax $$
create procedure test_signal_syntax()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
SIGNAL foo SET COLUMN_NAME = 'foo';
end $$
drop procedure test_signal_syntax $$
create procedure test_signal_syntax()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
SIGNAL foo SET CURSOR_NAME = 'foo';
end $$
drop procedure test_signal_syntax $$
create procedure test_signal_syntax()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
SIGNAL foo SET MESSAGE_TEXT = 'foo';
end $$
drop procedure test_signal_syntax $$
create procedure test_signal_syntax()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
SIGNAL foo SET MYSQL_ERRNO = 'foo';
end $$
drop procedure test_signal_syntax $$
create procedure test_invalid()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
SIGNAL foo SET CLASS_ORIGIN = 'foo', CLASS_ORIGIN = 'bar';
end $$
ERROR 42000: Duplicate condition information item 'CLASS_ORIGIN'
create procedure test_invalid()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
SIGNAL foo SET MESSAGE_TEXT = 'foo', MESSAGE_TEXT = 'bar';
end $$
ERROR 42000: Duplicate condition information item 'MESSAGE_TEXT'
create procedure test_invalid()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
SIGNAL foo SET MYSQL_ERRNO = 'foo', MYSQL_ERRNO = 'bar';
end $$
ERROR 42000: Duplicate condition information item 'MYSQL_ERRNO'
create procedure test_signal_syntax()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
SIGNAL foo SET
CLASS_ORIGIN = 'foo',
SUBCLASS_ORIGIN = 'foo',
CONSTRAINT_CATALOG = 'foo',
CONSTRAINT_SCHEMA = 'foo',
CONSTRAINT_NAME = 'foo',
CATALOG_NAME = 'foo',
SCHEMA_NAME = 'foo',
TABLE_NAME = 'foo',
COLUMN_NAME = 'foo',
CURSOR_NAME = 'foo',
MESSAGE_TEXT = 'foo',
MYSQL_ERRNO = 'foo';
end $$
drop procedure test_signal_syntax $$
SIGNAL SQLSTATE '00000' $$
ERROR 42000: Bad SQLSTATE: '00000'
SIGNAL SQLSTATE '00001' $$
ERROR 42000: Bad SQLSTATE: '00001'
create procedure test_invalid()
begin
SIGNAL SQLSTATE '00000';
end $$
ERROR 42000: Bad SQLSTATE: '00000'
create procedure test_invalid()
begin
SIGNAL SQLSTATE '00001';
end $$
ERROR 42000: Bad SQLSTATE: '00001'
#
# Test conditions information that SIGNAL can not set
#
create procedure test_invalid()
begin
SIGNAL SQLSTATE '12345' SET bla_bla = 'foo';
end $$
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'bla_bla = 'foo';
end' at line 3
create procedure test_invalid()
begin
SIGNAL SQLSTATE '12345' SET CONDITION_IDENTIFIER = 'foo';
end $$
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CONDITION_IDENTIFIER = 'foo';
end' at line 3
create procedure test_invalid()
begin
SIGNAL SQLSTATE '12345' SET CONDITION_NUMBER = 'foo';
end $$
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CONDITION_NUMBER = 'foo';
end' at line 3
create procedure test_invalid()
begin
SIGNAL SQLSTATE '12345' SET CONNECTION_NAME = 'foo';
end $$
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CONNECTION_NAME = 'foo';
end' at line 3
create procedure test_invalid()
begin
SIGNAL SQLSTATE '12345' SET MESSAGE_LENGTH = 'foo';
end $$
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MESSAGE_LENGTH = 'foo';
end' at line 3
create procedure test_invalid()
begin
SIGNAL SQLSTATE '12345' SET MESSAGE_OCTET_LENGTH = 'foo';
end $$
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MESSAGE_OCTET_LENGTH = 'foo';
end' at line 3
create procedure test_invalid()
begin
SIGNAL SQLSTATE '12345' SET PARAMETER_MODE = 'foo';
end $$
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PARAMETER_MODE = 'foo';
end' at line 3
create procedure test_invalid()
begin
SIGNAL SQLSTATE '12345' SET PARAMETER_NAME = 'foo';
end $$
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PARAMETER_NAME = 'foo';
end' at line 3
create procedure test_invalid()
begin
SIGNAL SQLSTATE '12345' SET PARAMETER_ORDINAL_POSITION = 'foo';
end $$
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PARAMETER_ORDINAL_POSITION = 'foo';
end' at line 3
create procedure test_invalid()
begin
SIGNAL SQLSTATE '12345' SET RETURNED_SQLSTATE = 'foo';
end $$
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RETURNED_SQLSTATE = 'foo';
end' at line 3
create procedure test_invalid()
begin
SIGNAL SQLSTATE '12345' SET ROUTINE_CATALOG = 'foo';
end $$
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ROUTINE_CATALOG = 'foo';
end' at line 3
create procedure test_invalid()
begin
SIGNAL SQLSTATE '12345' SET ROUTINE_NAME = 'foo';
end $$
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ROUTINE_NAME = 'foo';
end' at line 3
create procedure test_invalid()
begin
SIGNAL SQLSTATE '12345' SET ROUTINE_SCHEMA = 'foo';
end $$
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ROUTINE_SCHEMA = 'foo';
end' at line 3
create procedure test_invalid()
begin
SIGNAL SQLSTATE '12345' SET SERVER_NAME = 'foo';
end $$
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SERVER_NAME = 'foo';
end' at line 3
create procedure test_invalid()
begin
SIGNAL SQLSTATE '12345' SET SPECIFIC_NAME = 'foo';
end $$
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SPECIFIC_NAME = 'foo';
end' at line 3
create procedure test_invalid()
begin
SIGNAL SQLSTATE '12345' SET TRIGGER_CATALOG = 'foo';
end $$
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TRIGGER_CATALOG = 'foo';
end' at line 3
create procedure test_invalid()
begin
SIGNAL SQLSTATE '12345' SET TRIGGER_NAME = 'foo';
end $$
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TRIGGER_NAME = 'foo';
end' at line 3
create procedure test_invalid()
begin
SIGNAL SQLSTATE '12345' SET TRIGGER_SCHEMA = 'foo';
end $$
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TRIGGER_SCHEMA = 'foo';
end' at line 3
#
# Test the RESIGNAL syntax
#
drop procedure if exists test_invalid;
drop procedure if exists test_resignal_syntax;
create procedure test_invalid()
begin
RESIGNAL foo;
end $$
ERROR 42000: Undefined CONDITION: foo
create procedure test_resignal_syntax()
begin
RESIGNAL;
end $$
drop procedure test_resignal_syntax $$
create procedure test_invalid()
begin
DECLARE foo CONDITION FOR 1234;
RESIGNAL foo;
end $$
ERROR HY000: SIGNAL/RESIGNAL can only use a CONDITION defined with SQLSTATE
create procedure test_resignal_syntax()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
RESIGNAL foo;
end $$
drop procedure test_resignal_syntax $$
create procedure test_resignal_syntax()
begin
RESIGNAL SQLSTATE '23000';
end $$
drop procedure test_resignal_syntax $$
create procedure test_resignal_syntax()
begin
RESIGNAL SQLSTATE VALUE '23000';
end $$
drop procedure test_resignal_syntax $$
create procedure test_resignal_syntax()
begin
RESIGNAL SET CLASS_ORIGIN = 'foo';
end $$
drop procedure test_resignal_syntax $$
create procedure test_resignal_syntax()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
RESIGNAL foo SET CLASS_ORIGIN = 'foo';
end $$
drop procedure test_resignal_syntax $$
create procedure test_resignal_syntax()
begin
RESIGNAL SET SUBCLASS_ORIGIN = 'foo';
end $$
drop procedure test_resignal_syntax $$
create procedure test_resignal_syntax()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
RESIGNAL foo SET SUBCLASS_ORIGIN = 'foo';
end $$
drop procedure test_resignal_syntax $$
create procedure test_resignal_syntax()
begin
RESIGNAL SET CONSTRAINT_CATALOG = 'foo';
end $$
drop procedure test_resignal_syntax $$
create procedure test_resignal_syntax()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
RESIGNAL foo SET CONSTRAINT_CATALOG = 'foo';
end $$
drop procedure test_resignal_syntax $$
create procedure test_resignal_syntax()
begin
RESIGNAL SET CONSTRAINT_SCHEMA = 'foo';
end $$
drop procedure test_resignal_syntax $$
create procedure test_resignal_syntax()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
RESIGNAL foo SET CONSTRAINT_SCHEMA = 'foo';
end $$
drop procedure test_resignal_syntax $$
create procedure test_resignal_syntax()
begin
RESIGNAL SET CONSTRAINT_NAME = 'foo';
end $$
drop procedure test_resignal_syntax $$
create procedure test_resignal_syntax()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
RESIGNAL foo SET CONSTRAINT_NAME = 'foo';
end $$
drop procedure test_resignal_syntax $$
create procedure test_resignal_syntax()
begin
RESIGNAL SET CATALOG_NAME = 'foo';
end $$
drop procedure test_resignal_syntax $$
create procedure test_resignal_syntax()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
RESIGNAL foo SET CATALOG_NAME = 'foo';
end $$
drop procedure test_resignal_syntax $$
create procedure test_resignal_syntax()
begin
RESIGNAL SET SCHEMA_NAME = 'foo';
end $$
drop procedure test_resignal_syntax $$
create procedure test_resignal_syntax()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
RESIGNAL foo SET SCHEMA_NAME = 'foo';
end $$
drop procedure test_resignal_syntax $$
create procedure test_resignal_syntax()
begin
RESIGNAL SET TABLE_NAME = 'foo';
end $$
drop procedure test_resignal_syntax $$
create procedure test_resignal_syntax()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
RESIGNAL foo SET TABLE_NAME = 'foo';
end $$
drop procedure test_resignal_syntax $$
create procedure test_resignal_syntax()
begin
RESIGNAL SET COLUMN_NAME = 'foo';
end $$
drop procedure test_resignal_syntax $$
create procedure test_resignal_syntax()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
RESIGNAL foo SET COLUMN_NAME = 'foo';
end $$
drop procedure test_resignal_syntax $$
create procedure test_resignal_syntax()
begin
RESIGNAL SET CURSOR_NAME = 'foo';
end $$
drop procedure test_resignal_syntax $$
create procedure test_resignal_syntax()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
RESIGNAL foo SET CURSOR_NAME = 'foo';
end $$
drop procedure test_resignal_syntax $$
create procedure test_resignal_syntax()
begin
RESIGNAL SET MESSAGE_TEXT = 'foo';
end $$
drop procedure test_resignal_syntax $$
create procedure test_resignal_syntax()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
RESIGNAL foo SET MESSAGE_TEXT = 'foo';
end $$
drop procedure test_resignal_syntax $$
create procedure test_resignal_syntax()
begin
RESIGNAL SET MYSQL_ERRNO = 'foo';
end $$
drop procedure test_resignal_syntax $$
create procedure test_resignal_syntax()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
RESIGNAL foo SET MYSQL_ERRNO = 'foo';
end $$
drop procedure test_resignal_syntax $$
create procedure test_invalid()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
RESIGNAL foo SET CLASS_ORIGIN = 'foo', CLASS_ORIGIN = 'bar';
end $$
ERROR 42000: Duplicate condition information item 'CLASS_ORIGIN'
create procedure test_invalid()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
RESIGNAL foo SET MESSAGE_TEXT = 'foo', MESSAGE_TEXT = 'bar';
end $$
ERROR 42000: Duplicate condition information item 'MESSAGE_TEXT'
create procedure test_invalid()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
RESIGNAL foo SET MYSQL_ERRNO = 'foo', MYSQL_ERRNO = 'bar';
end $$
ERROR 42000: Duplicate condition information item 'MYSQL_ERRNO'
create procedure test_resignal_syntax()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
RESIGNAL foo SET
CLASS_ORIGIN = 'foo',
SUBCLASS_ORIGIN = 'foo',
CONSTRAINT_CATALOG = 'foo',
CONSTRAINT_SCHEMA = 'foo',
CONSTRAINT_NAME = 'foo',
CATALOG_NAME = 'foo',
SCHEMA_NAME = 'foo',
TABLE_NAME = 'foo',
COLUMN_NAME = 'foo',
CURSOR_NAME = 'foo',
MESSAGE_TEXT = 'foo';
end $$
drop procedure test_resignal_syntax $$
create procedure test_invalid()
begin
RESIGNAL SQLSTATE '00000';
end $$
ERROR 42000: Bad SQLSTATE: '00000'
create procedure test_invalid()
begin
RESIGNAL SQLSTATE '00001';
end $$
ERROR 42000: Bad SQLSTATE: '00001'
#
# PART 2: non preparable statements
#
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
ERROR 42000: Variable 'MYSQL_ERRNO' can't be set to the value of '65536'
SIGNAL SQLSTATE 'HY000' SET MYSQL_ERRNO = 99999;
ERROR 42000: Variable 'MYSQL_ERRNO' can't be set to the value of '99999'
SIGNAL SQLSTATE 'HY000' SET MYSQL_ERRNO = 4294967295;
ERROR 42000: Variable 'MYSQL_ERRNO' can't be set to the value of '4294967295'
SIGNAL SQLSTATE 'HY000' SET MYSQL_ERRNO = 0;
ERROR 42000: Variable 'MYSQL_ERRNO' can't be set to the value of '0'
SIGNAL SQLSTATE 'HY000' SET MYSQL_ERRNO = -1;
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 '-1' at line 1
ERROR 42S22: Unknown column 'Hello' in 'field list'
drop procedure test_signal $$
create procedure test_signal()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
SIGNAL foo SET MYSQL_ERRNO = 1000,
MESSAGE_TEXT = 65.4321;
end $$
call test_signal $$
ERROR 12345: 65.4321
drop procedure test_signal $$
create procedure test_signal()
begin
DECLARE céèçà foo CONDITION FOR SQLSTATE '12345';
SIGNAL céèçà SET MYSQL_ERRNO = 1000;
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 '<27>èçà foo CONDITION FOR SQLSTATE '12345';
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"céèçà" CONDITION FOR SQLSTATE '12345';
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''céèçà' CONDITION FOR SQLSTATE '12345';