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

Package variables return a wrong result when changed inside a function

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.5, 10.6, 10.7(EOL), 10.8(EOL), 10.9(EOL), 10.10(EOL), 10.11, 11.0(EOL), 11.1(EOL), 11.2, 11.3(EOL), 11.4, 11.5(EOL)
    • 10.5
    • Stored routines
    • None

    Description

      I create the following package in Oracle-19.0 and call its procedure:

      CREATE OR REPLACE PACKAGE pkg AS
        PROCEDURE p1;
      END;
      /
       
      CREATE OR REPLACE PACKAGE BODY pkg AS
        a INT:=11;
        b INT:=10;
        FUNCTION f1 RETURN INT AS
        BEGIN
          a:=a-1;
          RETURN a;
        END;
        PROCEDURE p1 AS
          res VARCHAR(1024):= a || ' ' || f1() || ' ' || a;
        BEGIN
          DBMS_OUTPUT.PUT_LINE(res);
        END;
      BEGIN
        a:=a-b;
      END;
      /
       
      CALL pkg.p1();
      

      Statement processed.
      0 0 0
      

      Now I create the same package in MariaDB (in Oracle compatibility mode) and call its procedure:

      SET sql_mode=ORACLE;
      DELIMITER /
       
      CREATE OR REPLACE PACKAGE pkg AS
        PROCEDURE p1;
      END;
      /
       
      CREATE OR REPLACE PACKAGE BODY pkg AS
        a INT:=11;
        b INT:=10;
        FUNCTION f1 RETURN INT AS
        BEGIN
          a:=a-1;
          RETURN a;
        END;
        PROCEDURE p1 AS
          res VARCHAR(1024):= a || ' ' || f1() || ' ' || a;
        BEGIN
          SELECT res;
        END;
      BEGIN
        a:=a-b;
      END;
      /
       
      DELIMITER ;
      CALL pkg.p1();
      

      +-------+
      | res   |
      +-------+
      | 1 0 1 |
      +-------+
      

      Notice, it returns a different result.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:

                Git Integration

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