mirror of
https://github.com/MariaDB/server.git
synced 2025-07-21 21:22:27 +03:00
- CREATE PACKAGE [BODY] statements are now entirely written to mysql.proc with type='PACKAGE' and type='PACKAGE BODY'. - CREATE PACKAGE BODY now supports IF NOT EXISTS - DROP PACKAGE BODY now supports IF EXISTS - CREATE OR REPLACE PACKAGE [BODY] is now supported - CREATE PACKAGE [BODY] now support the DEFINER clause: CREATE DEFINER user@host PACKAGE pkg ... END; CREATE DEFINER user@host PACKAGE BODY pkg ... END; - CREATE PACKAGE [BODY] now supports SQL SECURITY and COMMENT clauses, e.g.: CREATE PACKAGE p1 SQL SECURITY INVOKER COMMENT "comment" AS ... END; - Package routines are now created from the package CREATE PACKAGE BODY statement and don't produce individual records in mysql.proc. - CREATE PACKAGE BODY now supports package-wide variables. Package variables can be read and set inside package routines. Package variables are stored in a separate sp_rcontext, which is cached in THD on the first packate routine call. - CREATE PACKAGE BODY now supports the initialization section. - All public routines (i.e. declared in CREATE PACKAGE) must have implementations in CREATE PACKAGE BODY - Only public package routines are available outside of the package - {CREATE|DROP} PACKAGE [BODY] now respects CREATE ROUTINE and ALTER ROUTINE privileges - "GRANT EXECUTE ON PACKAGE BODY pkg" is now supported - SHOW CREATE PACKAGE [BODY] is now supported - SHOW PACKAGE [BODY] STATUS is now supported - CREATE and DROP for PACKAGE [BODY] now works for non-current databases - mysqldump now supports packages - "SHOW {PROCEDURE|FUNCTION) CODE pkg.routine" now works for package routines - "SHOW PACKAGE BODY CODE pkg" now works (the package initialization section) - A new package body level MDL was added - Recursive calls for package procedures are now possible - Routine forward declarations in CREATE PACKATE BODY are now supported. - Package body variables now work as SP OUT parameters - Package body variables now work as SELECT INTO targets - Package body variables now support ROW, %ROWTYPE, %TYPE
94 lines
1.6 KiB
Plaintext
94 lines
1.6 KiB
Plaintext
--source include/not_embedded.inc
|
|
|
|
SET sql_mode=ORACLE;
|
|
|
|
#
|
|
# Create a standalone procedure test.p1 and a package pkg1.
|
|
# The standalone routine test.p1 and the package routines call each other.
|
|
#
|
|
|
|
DELIMITER $$;
|
|
CREATE PROCEDURE p1 AS
|
|
BEGIN
|
|
SELECT pkg1.f1(); -- a standalone routine calls a package routine
|
|
END;
|
|
$$
|
|
DELIMITER ;$$
|
|
|
|
|
|
DELIMITER $$;
|
|
CREATE PACKAGE pkg1 AS
|
|
PROCEDURE p1;
|
|
FUNCTION f1 RETURN INT;
|
|
END;
|
|
$$
|
|
DELIMITER ;$$
|
|
|
|
|
|
DELIMITER $$;
|
|
CREATE PACKAGE BODY pkg1 AS
|
|
PROCEDURE p1 AS
|
|
BEGIN
|
|
CALL test.p1; -- a package routine calls a standalone routine
|
|
END;
|
|
FUNCTION f1 RETURN INT AS
|
|
BEGIN
|
|
RETURN 10;
|
|
END;
|
|
END;
|
|
$$
|
|
DELIMITER ;$$
|
|
|
|
CALL p1;
|
|
CALL pkg1.p1;
|
|
SELECT pkg1.f1();
|
|
|
|
|
|
#
|
|
# Create specifications for one more package, without a BODY
|
|
#
|
|
DELIMITER $$;
|
|
CREATE PACKAGE pkg2 AS
|
|
PROCEDURE p1;
|
|
FUNCTION f1 RETURN INT;
|
|
END;
|
|
$$
|
|
DELIMITER ;$$
|
|
|
|
|
|
--exec $MYSQL_DUMP --skip-comments --routines test
|
|
--exec $MYSQL_DUMP --skip-comments --routines --xml test
|
|
|
|
let $dump = $MYSQLTEST_VARDIR/tmp/sp-package-mysqldump.sql;
|
|
|
|
--exec $MYSQL_DUMP --compact --routines test > $dump
|
|
|
|
DROP PACKAGE pkg1;
|
|
DROP PACKAGE pkg2;
|
|
DROP PROCEDURE p1;
|
|
|
|
--exec $MYSQL test < $dump
|
|
|
|
--vertical_results
|
|
--replace_column 4 'root@localhost' 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
|
|
SHOW PACKAGE STATUS;
|
|
--replace_column 4 'root@localhost' 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
|
|
SHOW PACKAGE BODY STATUS;
|
|
--horizontal_results
|
|
|
|
SHOW CREATE PACKAGE pkg1;
|
|
SHOW CREATE PACKAGE pkg2;
|
|
SHOW CREATE PACKAGE BODY pkg1;
|
|
|
|
CALL p1;
|
|
CALL pkg1.p1;
|
|
SELECT pkg1.f1();
|
|
|
|
DROP PACKAGE pkg1;
|
|
DROP PACKAGE pkg2;
|
|
DROP PROCEDURE p1;
|
|
|
|
--echo # removing the dump file
|
|
--error 0,1
|
|
--remove_file $dump
|