mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
9500575f0a
Changing the format in error messages: - ER_PACKAGE_ROUTINE_IN_SPEC_NOT_DEFINED_IN_BODY - ER_PACKAGE_ROUTINE_FORWARD_DECLARATION_NOT_DEFINED from "Subroutine 'db.pkg.f1' ..." to a more clear: "FUNCTION `db.pkg.f1` ..." "PROCEDURE `db.pkg.p1` ..."
140 lines
2.4 KiB
Text
140 lines
2.4 KiB
Text
--echo #
|
|
--echo # Start of 11.4 tests
|
|
--echo #
|
|
|
|
#
|
|
# CREATE PACKAGE for sql_mode='';
|
|
# Resebmles SQL Standard 'CREATE MODULE'.
|
|
#
|
|
|
|
SET sql_mode='';
|
|
|
|
DELIMITER $$;
|
|
CREATE OR REPLACE PACKAGE pkg
|
|
PROCEDURE p1();
|
|
FUNCTION f1() RETURNS INT;
|
|
END;
|
|
$$
|
|
DELIMITER ;$$
|
|
|
|
|
|
DELIMITER $$;
|
|
CREATE OR REPLACE PACKAGE BODY pkg
|
|
-- variable declarations
|
|
DECLARE a INT DEFAULT 11;
|
|
DECLARE b INT DEFAULT 10;
|
|
|
|
-- routine declarations
|
|
PROCEDURE p1()
|
|
BEGIN
|
|
SELECT CURRENT_USER;
|
|
END;
|
|
FUNCTION f1() RETURNS INT
|
|
BEGIN
|
|
RETURN a;
|
|
END;
|
|
|
|
-- initialization section
|
|
SET a=a-b;
|
|
END;
|
|
$$
|
|
DELIMITER ;$$
|
|
|
|
|
|
SHOW CREATE PACKAGE pkg;
|
|
SHOW CREATE PACKAGE BODY pkg;
|
|
|
|
CALL pkg.p1();
|
|
SELECT pkg.f1();
|
|
|
|
DROP PACKAGE pkg;
|
|
|
|
|
|
--echo #
|
|
--echo # MDEV-33428 Error messages ER_PACKAGE_ROUTINE_* are not good enough
|
|
--echo #
|
|
|
|
--echo #
|
|
--echo # Routines declared in CREATE PACKAGE missing in CREATE PACKAGE BODY
|
|
--echo #
|
|
|
|
DELIMITER $$;
|
|
CREATE PACKAGE test2
|
|
PROCEDURE p1();
|
|
END;
|
|
$$
|
|
--error ER_PACKAGE_ROUTINE_IN_SPEC_NOT_DEFINED_IN_BODY
|
|
CREATE PACKAGE BODY test2
|
|
PROCEDURE p2() BEGIN SELECT 0; END;
|
|
END;
|
|
$$
|
|
DELIMITER ;$$
|
|
DROP PACKAGE test2;
|
|
|
|
DELIMITER $$;
|
|
CREATE PACKAGE test2
|
|
FUNCTION f1() RETURNS INT;
|
|
END;
|
|
$$
|
|
--error ER_PACKAGE_ROUTINE_IN_SPEC_NOT_DEFINED_IN_BODY
|
|
CREATE PACKAGE BODY test2
|
|
FUNCTION f2() RETURNS INT BEGIN RETURN 10; END;
|
|
END;
|
|
$$
|
|
DELIMITER ;$$
|
|
DROP PACKAGE test2;
|
|
|
|
DELIMITER $$;
|
|
CREATE PACKAGE test2
|
|
PROCEDURE p1();
|
|
END;
|
|
$$
|
|
--error ER_PACKAGE_ROUTINE_IN_SPEC_NOT_DEFINED_IN_BODY
|
|
CREATE PACKAGE BODY test2
|
|
FUNCTION p1() RETURNS INT BEGIN RETURN 10; END;
|
|
END;
|
|
$$
|
|
DELIMITER ;$$
|
|
DROP PACKAGE test2;
|
|
|
|
DELIMITER $$;
|
|
CREATE PACKAGE test2
|
|
PROCEDURE p1();
|
|
END;
|
|
$$
|
|
--error ER_PACKAGE_ROUTINE_IN_SPEC_NOT_DEFINED_IN_BODY
|
|
CREATE PACKAGE BODY test2
|
|
PROCEDURE p1(a INT) BEGIN SELECT 0; END; -- Notice different prototype
|
|
END;
|
|
$$
|
|
DELIMITER ;$$
|
|
DROP PACKAGE test2;
|
|
|
|
--echo #
|
|
--echo # Forward declarations in CREATE PACKAGE BODY with missing implementations
|
|
--echo #
|
|
|
|
DELIMITER $$;
|
|
CREATE PACKAGE test2
|
|
PROCEDURE p1();
|
|
END;
|
|
$$
|
|
--error ER_PACKAGE_ROUTINE_FORWARD_DECLARATION_NOT_DEFINED
|
|
CREATE PACKAGE BODY test2
|
|
PROCEDURE p1() BEGIN SELECT 0; END;
|
|
PROCEDURE p2();
|
|
END;
|
|
$$
|
|
--error ER_PACKAGE_ROUTINE_FORWARD_DECLARATION_NOT_DEFINED
|
|
CREATE PACKAGE BODY test2
|
|
FUNCTION f1() RETURNS INT;
|
|
PROCEDURE p1() BEGIN SELECT 0; END;
|
|
END;
|
|
$$
|
|
DELIMITER ;$$
|
|
DROP PACKAGE test2;
|
|
|
|
|
|
--echo #
|
|
--echo # End of 11.4 tests
|
|
--echo #
|