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

Package methods can't be used before their declaration

    XMLWordPrintable

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Major
    • Resolution: Unresolved
    • 11.4, 11.5(EOL)
    • 11.4
    • Stored routines
    • None

    Description

      Non-Oracle mode.

      The following package can be created without errors:

      CREATE SCHEMA IF NOT EXISTS test;
      USE test;
       
      DELIMITER ||
       
      CREATE OR REPLACE PACKAGE ctr
        FUNCTION a() RETURNS INT;
      END;
      ||
       
      CREATE OR REPLACE PACKAGE BODY ctr
       
        FUNCTION a() RETURNS INT
        BEGIN
          RETURN b();
        END;
       
        FUNCTION b() RETURNS INT
        BEGIN
          RETURN 1;
        END;
      END;
      ||
       
      DELIMITER ;
      

      But calling a() returns an error:

      MariaDB [test]> SELECT ctr.a();
      ERROR 1305 (42000): FUNCTION test.b does not exist
      

      This happens because b() was not defined before the line that calls it.

      You can verify that the code works if you invert a() and b() code, or if you declare b() in CREATE PACKAGE.

      This error makes it impossible to have two mutually recursive private methods.

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              f_razzoli Federico Razzoli
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.