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

Oracle compatibility: The REVERSE key word for FOR loop behaves incorrectly

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 10.3.9
    • Fix Version/s: 10.3.11
    • Component/s: Parser
    • Labels:
      None
    • Environment:
      Centos 7

      Description

      Release tested: 10.3.9

      The following loop did not produce any output. It worked correctly without the REVERSE key word.

      SET SQL_MODE=ORACLE;
        delimiter //
        #
        DECLARE
           totalprice DECIMAL(12,2):=NULL;
           loop_start INTEGER := 1;
        BEGIN
           FOR idx IN REVERSE loop_start..10 LOOP
              SELECT idx;
           END LOOP;
        END;
        //
      

      With the REVERSE key word, switching the lower and upper bound values also worked:

      FOR idx IN REVERSE 10..loop_start LOOP

      However, this behavior is different from Oracle's documentation below.

      ---------
      If REVERSE is specified:

      If upper_bound is less than lower_bound, the statements do not run, and control transfers to the statement after the FOR LOOP statement.
      ---------

        Attachments

          Activity

            People

            Assignee:
            bar Alexander Barkov
            Reporter:
            dleeyh Daniel Lee
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: