mariadb/mysql-test/t/create_drop_procedure.test
Alexander Barkov 2dbd26932d MDEV-7283 UDF: CREATE OR REPLACE, CREATE IF NOT EXISTS, DROP IF EXISTS
MDEV-7282 SP: CREATE OR REPLACE, CREATE IF NOT EXISTS
2014-12-15 17:41:15 +04:00

41 lines
1.3 KiB
Text

CREATE TABLE t1 (id INT);
DELIMITER $$;
CREATE PROCEDURE proc1 (OUT cnt INT) COMMENT 'comment1' BEGIN SELECT COUNT(*) INTO cnt FROM t1; END$$
DELIMITER ;$$
CALL proc1(@cnt);
SELECT @cnt;
INSERT INTO t1 VALUES (1), (2), (3);
CALL proc1(@cnt);
SELECT @cnt;
DELIMITER $$;
--error ER_SP_ALREADY_EXISTS
CREATE PROCEDURE proc1 (OUT cnt INT) COMMENT 'comment2'
BEGIN SELECT COUNT(*) INTO cnt FROM t1; END$$
SELECT comment FROM mysql.proc WHERE name='proc1'$$
CREATE PROCEDURE IF NOT EXISTS proc1 (OUT cnt INT) COMMENT 'comment3'
BEGIN SELECT COUNT(*) INTO cnt FROM t1; END$$
SELECT comment FROM mysql.proc WHERE name='proc1'$$
--error ER_WRONG_USAGE
CREATE OR REPLACE PROCEDURE IF NOT EXISTS proc1 (OUT cnt INT) COMMENT 'comment4'
BEGIN SELECT COUNT(*) INTO cnt FROM t1; END$$
SELECT comment FROM mysql.proc WHERE name='proc1'$$
CREATE OR REPLACE PROCEDURE proc1 (OUT cnt INT) COMMENT 'comment5'
BEGIN SELECT COUNT(*) INTO cnt FROM t1; END$$
SELECT comment FROM mysql.proc WHERE name='proc1'$$
DELIMITER ;$$
DROP PROCEDURE proc1;
DELIMITER $$;
CREATE PROCEDURE IF NOT EXISTS proc1 (OUT cnt INT) BEGIN SELECT COUNT(*) INTO cnt FROM t1; END$$
DELIMITER ;$$
INSERT INTO t1 VALUES (1), (2), (3);
CALL proc1(@cnt);
SELECT @cnt;
DROP TABLE IF EXISTS t1;
DROP PROCEDURE IF EXISTS proc1;
DROP PROCEDURE IF EXISTS proc1;