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

support FOR loop in stored aggregate functions

    XMLWordPrintable

    Details

      Description

      Support the syntax (subject to discussion):

      [begin_label:]
      FOR GROUP ROWS DO
        statement_list
      END FOR [ end_label ]
      

      See also MDEV-14415.

      Example:

      CREATE AGGREGATE FUNCTION avg(x DOUBLE) RETURNS DOUBLE
      BEGIN
        DECLARE count INT DEFAULT 0;
        DECLARE sum DOUBLE DEFAULT 0;
        FOR GROUP ROWS DO
          SET count:=count+1;
          SET sum:=sum+x;
        END FOR;
        RETURN sum/count;
      END
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              varun Varun Gupta
              Reporter:
              serg Sergei Golubchik
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated: