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

RETURN can't be used right after BEGIN

    XMLWordPrintable

    Details

      Description

      In a stored function, RETURN can't be used right after BEGIN.

      For example, this fails:

      DELIMITER //
       
      CREATE FUNCTION trust_me(x INT)
      RETURNS INT
      DETERMINISTIC
      READS SQL DATA
      BEGIN
         RETURN (x) //
      END //
       
      DELIMITER ;
      

      With the non-sensical "empty string" error message:

      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 '' at line 6
      

      https://mariadb.com/kb/en/library/basic-sql-debugging/#interpreting-the-empty-error

      But it works just fine if you remove the BEGIN/END. For example:

      CREATE FUNCTION trust_me(x INT)
      RETURNS INT
      DETERMINISTIC
      READS SQL DATA
         RETURN (x);
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            GeoffMontee Geoff Montee
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: