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

--echo #
--echo # DEFAULT clause in SYS_REFCURSOR declarations
--echo #

DELIMITER $$;
BEGIN NOT ATOMIC
  DECLARE c SYS_REFCURSOR DEFAULT NULL;
END;
$$
DELIMITER ;$$

DELIMITER $$;
BEGIN NOT ATOMIC
  DECLARE c0 SYS_REFCURSOR DEFAULT NULL;
  DECLARE c1 SYS_REFCURSOR DEFAULT c0;
END;
$$
DELIMITER ;$$

DELIMITER $$;
BEGIN NOT ATOMIC
  DECLARE c0 SYS_REFCURSOR DEFAULT NULL;
  OPEN c0 FOR SELECT 'c0-value';
  BEGIN
    DECLARE c1 SYS_REFCURSOR DEFAULT c0;
    DECLARE v VARCHAR(30);
    FETCH c1 INTO v;
    SELECT v;
  END;
END;
$$
DELIMITER ;$$

DELIMITER $$;
--error ER_WRONG_COLUMN_NAME
BEGIN NOT ATOMIC
  DECLARE c0 SYS_REFCURSOR DEFAULT NULL;
  DECLARE c1 SYS_REFCURSOR DEFAULT DEFAULT(c0);
END;
$$
DELIMITER ;$$


DELIMITER $$;
--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
BEGIN NOT ATOMIC
  DECLARE c SYS_REFCURSOR DEFAULT 0;
END;
$$
DELIMITER ;$$

DELIMITER $$;
--error ER_PARSE_ERROR
BEGIN NOT ATOMIC
  DECLARE c SYS_REFCURSOR DEFAULT IGNORE;
END;
$$
DELIMITER ;$$

DELIMITER $$;
--error ER_PARSE_ERROR
BEGIN NOT ATOMIC
  DECLARE c SYS_REFCURSOR DEFAULT DEFAULT;
END;
$$
DELIMITER ;$$
