--echo #
--echo # MDEV-20034 Add support for the pre-defined weak SYS_REFCURSOR
--echo #

DELIMITER /;
--error ER_NOT_ALLOWED_IN_THIS_CONTEXT
CREATE AGGREGATE FUNCTION f1(x int) RETURNS INT
BEGIN
  DECLARE c SYS_REFCURSOR;
  DECLARE mini INT DEFAULT 0;
  DECLARE CONTINUE HANDLER FOR NOT FOUND RETURN mini;
  LOOP
    FETCH GROUP NEXT ROW;
    SET mini= mini+x;
    FETCH GROUP NEXT ROW;
  END LOOP;
END;
/
DELIMITER ;/
