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

Subquery is not allowed as the lower FOR loop bound

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 10.3
    • Fix Version/s: 10.3
    • Component/s: Stored routines
    • Labels:
      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

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

                Dates

                • Created:
                  Updated: