mariadb/mysql-test/main/sp-package.result
Alexander Barkov 36eba98817 MDEV-19123 Change default charset from latin1 to utf8mb4
Changing the default server character set from latin1 to utf8mb4.
2024-07-11 10:21:07 +04:00

123 lines
2.9 KiB
Text

#
# Start of 11.4 tests
#
SET sql_mode='';
CREATE OR REPLACE PACKAGE pkg
PROCEDURE p1();
FUNCTION f1() RETURNS INT;
END;
$$
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;
$$
SHOW CREATE PACKAGE pkg;
Package sql_mode Create Package character_set_client collation_connection Database Collation
pkg CREATE DEFINER=`root`@`localhost` PACKAGE `pkg` PROCEDURE p1();
FUNCTION f1() RETURNS INT;
END latin1 latin1_swedish_ci utf8mb4_uca1400_ai_ci
SHOW CREATE PACKAGE BODY pkg;
Package body sql_mode Create Package Body character_set_client collation_connection Database Collation
pkg CREATE DEFINER=`root`@`localhost` PACKAGE BODY `pkg` 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 latin1 latin1_swedish_ci utf8mb4_uca1400_ai_ci
CALL pkg.p1();
CURRENT_USER
root@localhost
SELECT pkg.f1();
pkg.f1()
1
DROP PACKAGE pkg;
#
# MDEV-33428 Error messages ER_PACKAGE_ROUTINE_* are not good enough
#
#
# Routines declared in CREATE PACKAGE missing in CREATE PACKAGE BODY
#
CREATE PACKAGE test2
PROCEDURE p1();
END;
$$
CREATE PACKAGE BODY test2
PROCEDURE p2() BEGIN SELECT 0; END;
END;
$$
ERROR HY000: PROCEDURE `test.test2.p1` is declared in the package specification but is not defined in the package body
DROP PACKAGE test2;
CREATE PACKAGE test2
FUNCTION f1() RETURNS INT;
END;
$$
CREATE PACKAGE BODY test2
FUNCTION f2() RETURNS INT BEGIN RETURN 10; END;
END;
$$
ERROR HY000: FUNCTION `test.test2.f1` is declared in the package specification but is not defined in the package body
DROP PACKAGE test2;
CREATE PACKAGE test2
PROCEDURE p1();
END;
$$
CREATE PACKAGE BODY test2
FUNCTION p1() RETURNS INT BEGIN RETURN 10; END;
END;
$$
ERROR HY000: PROCEDURE `test.test2.p1` is declared in the package specification but is not defined in the package body
DROP PACKAGE test2;
CREATE PACKAGE test2
PROCEDURE p1();
END;
$$
CREATE PACKAGE BODY test2
PROCEDURE p1(a INT) BEGIN SELECT 0; END; -- Notice different prototype
END;
$$
ERROR HY000: PROCEDURE `test.test2.p1` is declared in the package specification but is not defined in the package body
DROP PACKAGE test2;
#
# Forward declarations in CREATE PACKAGE BODY with missing implementations
#
CREATE PACKAGE test2
PROCEDURE p1();
END;
$$
CREATE PACKAGE BODY test2
PROCEDURE p1() BEGIN SELECT 0; END;
PROCEDURE p2();
END;
$$
ERROR HY000: PROCEDURE `test.test2.p2` has a forward declaration but is not defined
CREATE PACKAGE BODY test2
FUNCTION f1() RETURNS INT;
PROCEDURE p1() BEGIN SELECT 0; END;
END;
$$
ERROR HY000: FUNCTION `test.test2.f1` has a forward declaration but is not defined
DROP PACKAGE test2;
#
# End of 11.4 tests
#