Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-32101

CREATE PACKAGE [BODY] for sql_mode=DEFAULT

    XMLWordPrintable

Details

    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

          Activity

            People

              bar Alexander Barkov
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.