2

MDEV-15944

 3 years ago
source link: https://jira.mariadb.org/browse/MDEV-15944
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Uploaded image for project: 'MariaDB Server'

Subquery is not allowed as the lower FOR loop bound

Details

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 |
+------+

Issue Links

relates to

Bug - A problem which impairs or prevents the functions of the product.MDEV-16558 Parenthesized expression does not work as a lower FOR loop bound

  • Major - Major loss of function.

Activity

added a comment - 2018-06-25 07:18

Note, Oracle does not support subqueries in FOR loop bounds, neither in the lower, nor in the upper:

BEGIN
  FOR a IN (SELECT 1 FROM DUAL)..2
  LOOP
    NULL;
  END LOOP;
END;
/
BEGIN
  FOR a IN 1 ..(SELECT 2 FROM DUAL)
  LOOP
    NULL;
  END LOOP;
END;
/

People

Assignee:

bar Alexander Barkov Reporter:

bar Alexander Barkov

Votes: 0 Vote for this issue Watchers: 1 Start watching this issue

Dates

Created: 2018-04-20 10:22 Updated: 2019-03-29 12:05

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK