2009-10-26 10:55:57 +01:00
|
|
|
# Test file for stored procedure bugfixes
|
|
|
|
|
|
|
|
--echo #
|
|
|
|
--echo # Bug #47412: Valgrind warnings / user can read uninitalized memory
|
|
|
|
--echo # using SP variables
|
|
|
|
--echo #
|
|
|
|
|
|
|
|
CREATE SCHEMA testdb;
|
|
|
|
USE testdb;
|
|
|
|
DELIMITER |;
|
|
|
|
CREATE FUNCTION f2 () RETURNS INTEGER
|
|
|
|
BEGIN
|
|
|
|
DECLARE CONTINUE HANDLER FOR SQLSTATE '42000' SET @aux = 1;
|
|
|
|
RETURN f_not_exists () ;
|
|
|
|
END|
|
|
|
|
CREATE PROCEDURE p3 ( arg1 VARCHAR(32) )
|
|
|
|
BEGIN
|
|
|
|
CALL p_not_exists ( );
|
|
|
|
END|
|
|
|
|
DELIMITER ;|
|
|
|
|
--echo # should not return valgrind warnings
|
|
|
|
--error ER_SP_DOES_NOT_EXIST
|
|
|
|
CALL p3 ( f2 () );
|
|
|
|
|
|
|
|
DROP SCHEMA testdb;
|
|
|
|
|
|
|
|
CREATE SCHEMA testdb;
|
|
|
|
USE testdb;
|
|
|
|
DELIMITER |;
|
|
|
|
CREATE FUNCTION f2 () RETURNS INTEGER
|
|
|
|
BEGIN
|
|
|
|
DECLARE CONTINUE HANDLER FOR SQLSTATE '42000' SET @aux = 1;
|
|
|
|
RETURN f_not_exists () ;
|
|
|
|
END|
|
|
|
|
CREATE PROCEDURE p3 ( arg2 INTEGER )
|
|
|
|
BEGIN
|
|
|
|
CALL p_not_exists ( );
|
|
|
|
END|
|
|
|
|
DELIMITER ;|
|
|
|
|
--echo # should not return valgrind warnings
|
|
|
|
--error ER_SP_DOES_NOT_EXIST
|
|
|
|
CALL p3 ( f2 () );
|
|
|
|
|
|
|
|
DROP SCHEMA testdb;
|
|
|
|
|
|
|
|
CREATE SCHEMA testdb;
|
|
|
|
USE testdb;
|
|
|
|
DELIMITER |;
|
|
|
|
CREATE FUNCTION f2 () RETURNS INTEGER
|
|
|
|
BEGIN
|
|
|
|
DECLARE CONTINUE HANDLER FOR SQLSTATE '42000' SET @aux = 1;
|
|
|
|
RETURN f_not_exists () ;
|
|
|
|
END|
|
|
|
|
DELIMITER ;|
|
|
|
|
--echo # should not return valgrind warnings
|
|
|
|
SELECT f2 ();
|
|
|
|
|
|
|
|
DROP SCHEMA testdb;
|
|
|
|
|
2010-01-28 15:41:14 +01:00
|
|
|
USE test;
|
|
|
|
|
|
|
|
--echo #
|
|
|
|
--echo # Bug#50423: Crash on second call of a procedure dropping a trigger
|
|
|
|
--echo #
|
|
|
|
|
|
|
|
--disable_warnings
|
|
|
|
DROP TABLE IF EXISTS t1;
|
|
|
|
DROP TRIGGER IF EXISTS tr1;
|
|
|
|
DROP PROCEDURE IF EXISTS p1;
|
|
|
|
--enable_warnings
|
|
|
|
|
|
|
|
CREATE TABLE t1 (f1 INTEGER);
|
|
|
|
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET @aux = 1;
|
|
|
|
CREATE PROCEDURE p1 () DROP TRIGGER tr1;
|
|
|
|
|
|
|
|
CALL p1 ();
|
|
|
|
--error ER_TRG_DOES_NOT_EXIST
|
|
|
|
CALL p1 ();
|
|
|
|
|
|
|
|
DROP TABLE t1;
|
|
|
|
DROP PROCEDURE p1;
|
2009-10-26 10:55:57 +01:00
|
|
|
|
2010-02-13 11:35:14 +01:00
|
|
|
--echo #
|
|
|
|
--echo # Bug#50423: Crash on second call of a procedure dropping a trigger
|
|
|
|
--echo #
|
|
|
|
|
|
|
|
--disable_warnings
|
|
|
|
DROP TABLE IF EXISTS t1;
|
|
|
|
DROP TRIGGER IF EXISTS tr1;
|
|
|
|
DROP PROCEDURE IF EXISTS p1;
|
|
|
|
--enable_warnings
|
|
|
|
|
|
|
|
CREATE TABLE t1 (f1 INTEGER);
|
|
|
|
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET @aux = 1;
|
|
|
|
CREATE PROCEDURE p1 () DROP TRIGGER tr1;
|
|
|
|
|
|
|
|
CALL p1 ();
|
|
|
|
--error ER_TRG_DOES_NOT_EXIST
|
|
|
|
CALL p1 ();
|
|
|
|
|
|
|
|
DROP TABLE t1;
|
|
|
|
DROP PROCEDURE p1;
|
|
|
|
|
Fixed bug#54375 - Error in stored procedure leaves connection
in different default schema.
In strict mode, when data truncation or conversion happens,
THD::killed is set to THD::KILL_BAD_DATA.
This is abuse of KILL mechanism to guarantee that execution
of statement is aborted.
The stored procedures execution, on the other hand,
upon detection that a connection was killed, would
terminate immediately, without trying to restore the caller's
context, in particular, restore the caller's current schema.
The fix is, when terminating a stored procedure execution,
to only bypass cleanup if the entire connection was killed,
not in case of other forms of KILL.
mysql-test/r/sp-bugs.result:
Added result for a test case for bug#54375.
mysql-test/t/sp-bugs.test:
Added test case for bug#54375.
sql/sp_head.cc:
sp_head::execute modified: restore saved current db if
connection is not killed.
2010-11-11 05:52:51 +01:00
|
|
|
--echo #
|
|
|
|
--echo # Bug#54375: Error in stored procedure leaves connection
|
|
|
|
--echo # in different default schema
|
|
|
|
--echo #
|
|
|
|
|
|
|
|
--disable_warnings
|
|
|
|
SET @@SQL_MODE = 'STRICT_ALL_TABLES';
|
|
|
|
DROP DATABASE IF EXISTS db1;
|
|
|
|
CREATE DATABASE db1;
|
|
|
|
USE db1;
|
|
|
|
DROP TABLE IF EXISTS t1;
|
|
|
|
CREATE TABLE t1 (c1 int NOT NULL PRIMARY KEY);
|
|
|
|
INSERT INTO t1 VALUES (1);
|
|
|
|
DELIMITER $$;
|
|
|
|
CREATE FUNCTION f1 (
|
|
|
|
some_value int
|
|
|
|
)
|
|
|
|
RETURNS smallint
|
|
|
|
DETERMINISTIC
|
|
|
|
BEGIN
|
|
|
|
INSERT INTO t1 SET c1 = some_value;
|
|
|
|
RETURN(LAST_INSERT_ID());
|
|
|
|
END$$
|
|
|
|
DELIMITER ;$$
|
|
|
|
DROP DATABASE IF EXISTS db2;
|
|
|
|
CREATE DATABASE db2;
|
|
|
|
--enable_warnings
|
|
|
|
USE db2;
|
|
|
|
SELECT DATABASE();
|
|
|
|
--error ER_DUP_ENTRY
|
|
|
|
SELECT db1.f1(1);
|
|
|
|
SELECT DATABASE();
|
|
|
|
USE test;
|
|
|
|
DROP FUNCTION db1.f1;
|
|
|
|
DROP TABLE db1.t1;
|
|
|
|
DROP DATABASE db1;
|
|
|
|
DROP DATABASE db2;
|
2012-03-27 09:12:11 +02:00
|
|
|
USE test;
|
2012-01-30 07:27:33 +01:00
|
|
|
|
|
|
|
--echo #
|
|
|
|
--echo # Bug#13105873:valgrind warning:possible crash in foreign
|
|
|
|
--echo # key handling on subsequent create table if not exists
|
|
|
|
--echo #
|
|
|
|
|
|
|
|
--disable_warnings
|
|
|
|
DROP DATABASE IF EXISTS testdb;
|
|
|
|
--enable_warnings
|
|
|
|
CREATE DATABASE testdb;
|
|
|
|
USE testdb;
|
|
|
|
CREATE TABLE t1 (id1 INT PRIMARY KEY);
|
|
|
|
DELIMITER $;
|
|
|
|
CREATE PROCEDURE `p1`()
|
|
|
|
BEGIN
|
|
|
|
CREATE TABLE IF NOT EXISTS t2(id INT PRIMARY KEY,
|
|
|
|
CONSTRAINT FK FOREIGN KEY (id) REFERENCES t1( id1 ));
|
|
|
|
END$
|
|
|
|
DELIMITER ;$
|
|
|
|
CALL p1();
|
|
|
|
--echo # below stmt should not return valgrind warnings
|
|
|
|
CALL p1();
|
|
|
|
DROP DATABASE testdb;
|
2012-03-27 09:12:11 +02:00
|
|
|
USE test;
|
2012-01-30 07:27:33 +01:00
|
|
|
|
2009-10-26 10:55:57 +01:00
|
|
|
--echo End of 5.1 tests
|
2012-03-27 09:12:11 +02:00
|
|
|
|
|
|
|
--echo #
|
|
|
|
--echo # Bug#11763507 - 56224: FUNCTION NAME IS CASE-SENSITIVE
|
|
|
|
--echo #
|
|
|
|
SET @@SQL_MODE = '';
|
|
|
|
DELIMITER $;
|
|
|
|
CREATE FUNCTION testf_bug11763507() RETURNS INT
|
|
|
|
BEGIN
|
|
|
|
RETURN 0;
|
|
|
|
END
|
|
|
|
$
|
|
|
|
|
|
|
|
CREATE PROCEDURE testp_bug11763507()
|
|
|
|
BEGIN
|
|
|
|
SELECT "PROCEDURE testp_bug11763507";
|
|
|
|
END
|
|
|
|
$
|
|
|
|
|
|
|
|
DELIMITER ;$
|
|
|
|
|
|
|
|
# STORED FUNCTIONS
|
|
|
|
SELECT testf_bug11763507();
|
|
|
|
SELECT TESTF_bug11763507();
|
|
|
|
|
|
|
|
--replace_column 5 # 6 #
|
|
|
|
SHOW FUNCTION STATUS LIKE 'testf_bug11763507';
|
|
|
|
--replace_column 5 # 6 #
|
|
|
|
SHOW FUNCTION STATUS WHERE NAME='testf_bug11763507';
|
|
|
|
--replace_column 5 # 6 #
|
|
|
|
SHOW FUNCTION STATUS LIKE 'TESTF_bug11763507';
|
|
|
|
--replace_column 5 # 6 #
|
|
|
|
SHOW FUNCTION STATUS WHERE NAME='TESTF_bug11763507';
|
|
|
|
|
|
|
|
SHOW CREATE FUNCTION testf_bug11763507;
|
|
|
|
SHOW CREATE FUNCTION TESTF_bug11763507;
|
|
|
|
|
|
|
|
# STORED PROCEDURE
|
|
|
|
CALL testp_bug11763507();
|
|
|
|
CALL TESTP_bug11763507();
|
|
|
|
|
|
|
|
--replace_column 5 # 6 #
|
|
|
|
SHOW PROCEDURE STATUS LIKE 'testp_bug11763507';
|
|
|
|
--replace_column 5 # 6 #
|
|
|
|
SHOW PROCEDURE STATUS WHERE NAME='testp_bug11763507';
|
|
|
|
--replace_column 5 # 6 #
|
|
|
|
SHOW PROCEDURE STATUS LIKE 'TESTP_bug11763507';
|
|
|
|
--replace_column 5 # 6 #
|
|
|
|
SHOW PROCEDURE STATUS WHERE NAME='TESTP_bug11763507';
|
|
|
|
|
|
|
|
SHOW CREATE PROCEDURE testp_bug11763507;
|
|
|
|
SHOW CREATE PROCEDURE TESTP_bug11763507;
|
|
|
|
|
|
|
|
# INFORMATION SCHEMA
|
|
|
|
SELECT specific_name FROM INFORMATION_SCHEMA.ROUTINES WHERE specific_name LIKE 'testf_bug11763507';
|
|
|
|
SELECT specific_name FROM INFORMATION_SCHEMA.ROUTINES WHERE specific_name LIKE 'TESTF_bug11763507';
|
|
|
|
|
|
|
|
SELECT specific_name FROM INFORMATION_SCHEMA.ROUTINES WHERE specific_name='testf_bug11763507';
|
|
|
|
SELECT specific_name FROM INFORMATION_SCHEMA.ROUTINES WHERE specific_name='TESTF_bug11763507';
|
|
|
|
|
|
|
|
DROP PROCEDURE testp_bug11763507;
|
|
|
|
DROP FUNCTION testf_bug11763507;
|
|
|
|
|
|
|
|
--echo #END OF BUG#11763507 test.
|