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

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • 10.3.9
    • 10.3.11
    • Parser
    • None
    • 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

            bar Alexander Barkov
            dleeyh Daniel Lee (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 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.