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

Overloading in stored routines: different number of arguments

    XMLWordPrintable

Details

    Description

      Implement overloading in package functions and procedures, to make it possible to declare routines with the same name but with different number of arguments. This is an SQL Standard feature.

      Note: Having routines with the same name and same number of arguments, but with different argument types is also called overloading, but is not subject of this MDEV. This is not an SQL Standard feature.

      to make possible declarations like this:

      SET sql_mode=ORACLE;
      DELIMITER $$
      CREATE OR REPLACE PACKAGE pkg1
      AS
        FUNCTION f1() RETURN INT; -- zero arguments
        FUNCTION f1(a INT) RETURN INT; -- one argument 
        FUNCTION f1(a INT, b TEXT) RETURN INT; -- two arguments
        FUNCTION f1(a INT, b TEXT, c DATE, d CHAR DEFAULT 'x' ) RETURN INT; -- three or four arguments
      END;
      $$
      

      Overloading will work in all sql_mode's using their respective syntax.

      To support such overloading in schema routines we'll need to introduce a concept of routine's specific name, which is mangled name and is unique within a schema. CREATE and routine invocation will use routine name, but DROP and other commands (like SHOW) must use specific name. For backward compatibility and user-friendliness we'll allow DROP and other commands to use routine name, when unambiguous (not overloaded).

      Attachments

        Issue Links

          Activity

            People

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