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

Subquery is not allowed as the lower FOR loop bound

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.3
    • 10.4
    • Stored routines
    • None

    Description

      DELIMITER $$
      SET @v=0;
      FOR a IN (SELECT 1) .. 3 DO SET @v = @v + a; END FOR;
      $$
      

      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '.. 3 DO SET @v = @v + a; END FOR' at line 1
      

      If I use a subquery in the upper bound, it works fine:

      DELIMITER $$
      SET @v=0;
      FOR a IN 1 ..(SELECT 3) DO SET @v = @v + a; END FOR;
      SELECT @v;
      $$
      

      +------+
      | @v   |
      +------+
      |    6 |
      +------+
      

      Attachments

        Issue Links

          Activity

            People

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