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

PROCEDURE and anonymous blocks silently ignore FETCH GROUP NEXT ROW

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.3(EOL), 10.4(EOL)
    • 10.4.4
    • Stored routines
    • None

    Description

      The FETCH GROUP NEXT ROW statement is accepted in various unexpected contexts.

      Procedures

      DELIMITER $$
      CREATE OR REPLACE PROCEDURE p1()
      BEGIN
        FETCH GROUP NEXT ROW;
      END;
      $$
      DELIMITER ;
      CALL p1;
      

      It silently compiles and executes the procedure. The FETCH GROUP NEXT ROW is silently ignored.
      It should probably return an error at compile time, like inside a non-aggregate FUNCTION.

      Anonymous blocks

      The same problem is repeatable with anonymous blocks:

      DELIMITER $$
      BEGIN NOT ATOMIC
        FETCH GROUP NEXT ROW;
      END;
      $$
      DELIMITER ;
      

      Non-aggregate functions with DEFINER

      If I add the DEFINER clause into a non-aggregate function, FETCH GROUP NEXT ROW is silently accepted:

      DELIMITER $$
      CREATE OR REPLACE DEFINER=root@localhost  FUNCTION f1() RETURNS INT
      BEGIN
        FETCH GROUP NEXT ROW;
        RETURN 0;
      END;
      $$
      

      Triggers

      CREATE OR REPLACE TABLE t1 (a INT);
      CREATE OR REPLACE TRIGGER tr1
        AFTER INSERT ON t1 FOR EACH ROW 
         FETCH GROUP NEXT ROW;
      

      Events

      CREATE OR REPLACE EVENT ev1
        ON SCHEDULE EVERY 1 HOUR
        STARTS CURRENT_TIMESTAMP + INTERVAL 1 MONTH
        ENDS CURRENT_TIMESTAMP + INTERVAL 1 MONTH + INTERVAL 1 WEEK
      DO FETCH GROUP NEXT ROW;
      

      Package body (10.4.4 only)

      SET sql_mode=ORACLE;
      DELIMITER $$
      CREATE OR REPLACE PACKAGE pkg1 AS
        PROCEDURE p1;
      END;
      CREATE OR REPLACE PACKAGE BODY pkg1 AS
        PROCEDURE p1 AS
        BEGIN
          NULL;
        END;
      BEGIN
        FETCH GROUP NEXT ROW;
      END;
      $$
      DELIMITER ;
      

      Attachments

        Issue Links

          Activity

            People

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