Comments
The three comment forms, executable comments, and how they are treated.
A comment is text the server skips. Raft DB reads the three forms of MySQL.
Syntax#
# text to the end of the line
-- text to the end of the line
/* text, possibly over several lines */
/*! code that is run */
/*!40101 code that is run */Remarks#
--starts a comment only when it is followed by a space, a tab or the end of the line (SELECT 1--1is1 - -1, not a comment), as in MySQL./* ... */comments do not nest. An unterminated one is a syntax error (unterminated comment)./*! ... */is an executable comment: its content is read as code. An optional version number after the!is read and ignored, whatever the server version is, so/*!40101 SET NAMES utf8 */runs. Only/*!is read as code; MariaDB's/*M! ... */is an ordinary comment here.- A comment can sit anywhere white space can, including in front of the first word:
/* ping */ SELECT 1runs (this is what some drivers send as a health check). - Optimizer hints (
/*+ ... */) are ordinary comments and are ignored.
Examples#
SELECT 1; # one
SELECT 2; -- two
SELECT /* three */ 3;
/*!40101 SET NAMES utf8 */;