Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-10764 PL/SQL parser - Phase 2
  3. MDEV-12087

sql_mode=ORACLE: a new option to make dash-dash to start a comment

    XMLWordPrintable

Details

    Description

      Oracle uses the SQL standard syntax for simple comments: dash-dash starts a comment, the rest of the line is a comment.

      DROP PROCEDURE p1;
      CREATE PROCEDURE p1 AS
      BEGIN
        --This is a comment
        NULL;
      END;
      /
      

      MariaDB uses non-standard syntaxt: dash-dash-space starts a comment. This is an example of a valid script:

      SET sql_mode=DEFAULT;
      DROP PROCEDURE p1;
      DELIMITER /
      CREATE PROCEDURE p1()
      BEGIN
        -- This is a comment
      END;
      /
      DELIMITER ;
      

      If I remove the space character after "--", it returns a syntax error:

      SET sql_mode=DEFAULT;
      DROP PROCEDURE p1;
      DELIMITER /
      CREATE PROCEDURE p1()
      BEGIN
        --This is a comment
      END;
      /
      DELIMITER ;
      

      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 '--This is a comment
      END' at line 3
      

      That was an intentional design in early MySQL versions:
      https://dev.mysql.com/doc/refman/5.7/en/ansi-diff-comments.html

      We should add an option to make dash-dash without an extra space start a comment, as it makes migration from Oracle difficult.

      Perhaps, a new flag in sql_mode or old_mode can solve the issue.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              bar Alexander Barkov
              Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.