Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-10764 PL/SQL parser - Phase 2
  3. MDEV-10576

sql_mode=ORACLE: Functions with no parameters can be called without parentheses

    Details

      Description

      When running with sql_mode=ORACLE, MariaDB should allow calling stored functions that have no parameters without having to type parentheses after the function name.

      DROP FUNCTION f1;
      CREATE FUNCTION f1 RETURN INT
      AS
      BEGIN
        RETURN 10;
      END;
      /
      SELECT f1 FROM DUAL;
      SELECT f1() FROM DUAL;
      

      Notice, the above two SELECT queries return the same result:

      SQL> 
      	F1
      ----------
      	10
       
      SQL> 
            F1()
      ----------
      	10
      

      Name resolution will follow Oracle rules. For example, table columns shadow stored functions:

      DROP FUNCTION f1;
      CREATE FUNCTION f1 RETURN VARCHAR
      AS
      BEGIN
        RETURN 10;
      END;
      /
      DROP TABLE t1;
      CREATE TABLE t1 (f1 INT);
      INSERT INTO t1 VALUES (20);
      SELECT f1 FROM t1;
      

      SQL> 
      	F1
      ----------
      	20
      

      Notice, it returned the value of the column t1.f1 rather than the function f1.

      Under terms of this task we'll also allow calling SP control functions SQLCODE and SQLERRM with empty parentheses:

      DROP FUNCTION f1;
      CREATE FUNCTION f1 RETURN INT
      AS
      BEGIN
        EXECUTE IMMEDIATE 'xxx';
        RETURN 0;
      EXCEPTION
        WHEN OTHERS THEN RETURN SQLCODE();
      END;
      /
      SELECT f1 FROM DUAL;
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                bar Alexander Barkov
                Reporter:
                bar Alexander Barkov
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: