Details
-
New Feature
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Fixed
Description
Let's allow the CREATE PACKAGE [BODY] statement in sql_mode=DEFAULT.
It will work almost like the same statement for sql_mode=ORACLE, but will use SQL/PSM dialect instead of PL/SQL dialect in all parts of the statement, including:
- routine declarations
- variable declatations
- initialization section
- etc
For example:
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; |
|
-- package initialization section |
SET a=a-b; |
END; |
$$
|
DELIMITER ;
|
Invocation examples:
MariaDB [test]> SELECT pkg.f1(); |
+----------+ |
| pkg.f1() |
|
+----------+ |
| 1 |
|
+----------+ |
MariaDB [test]> CALL pkg.p1();
|
+---------------+ |
| CURRENT_USER | |
+---------------+ |
| bar@localhost |
|
+---------------+ |
In the future we can add CREATE MODULE on top of this work, for sql_mode=DB2, for IBM DB2 compatibility.
Attachments
Issue Links
- is blocked by
-
MDEV-32219 Shift/reduce grammar conflict: GRANT .. ON FUNCTION
- Closed
-
MDEV-32220 sql_yacc.yy: unify the drop_routine rule
- Closed
- relates to
-
MDEV-10591 Oracle-style packages
- Closed
-
MDEV-33384 ALTER PACKAGE [ BODY ] statement
- Open
-
MDEV-33385 Support package routines in metadata views
- Open
-
MDEV-33386 Wrong error message on `GRANT .. ON PACKAGE no_such_package ..`
- Closed
-
MDEV-33395 I_S views to list stored packages
- Open
-
MDEV-33382 Documentation fixes for CREATE PACKAGE and CREATE PACKAGE BODY
- Open
-
MDEV-33399 Package variables return a wrong result when changed inside a function
- Open
-
MDEV-33402 Calling a private package routine by its 3-step name does not fail
- Confirmed
-
MDEV-33403 Document stored packages overview
- Open
-
MDEV-33428 Error messages ER_PACKAGE_ROUTINE_* are not good enough
- Closed
-
MDEV-34655 Package methods can't be used before their declaration
- Confirmed
- links to