Details
-
Technical task
-
Status: Open (View Workflow)
-
Minor
-
Resolution: Unresolved
-
None
-
None
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
- is duplicated by
-
MDEV-19728 Comments in SQL
- Closed