Commit 16a1f41f authored by unknown's avatar unknown

Fixup of lingo (PR clean) in "-- as the start of a comment" text.

parent 710bea33
...@@ -4025,37 +4025,38 @@ system. @xref{Privilege system}. ...@@ -4025,37 +4025,38 @@ system. @xref{Privilege system}.
@cindex comments, starting @cindex comments, starting
@cindex starting, comments @cindex starting, comments
Some other SQL databases use @samp{--} to start comments. MySQL Some other SQL databases use @samp{--} to start comments.
has @samp{#} as the start comment character, even if the @code{mysql} MySQL has @samp{#} as the start comment character. You can also use
command-line tool removes all lines that start with @samp{--}. the C comment style @code{/* this is a comment */} with MySQL.
You can also use the C comment style @code{/* this is a comment */} with
MySQL.
@xref{Comments}. @xref{Comments}.
MySQL Version 3.23.3 and above supports the @samp{--} comment style MySQL Version 3.23.3 and above supports the @samp{--} comment style,
only if the comment is followed by a space. This is because this provided the comment is followed by a space. This is because this
degenerate comment style has caused many problems with automatically comment style has caused many problems with automatically generated
generated SQL queries that have used something like the following code, SQL queries that have used something like the following code, where
where we automatically insert the value of the payment for we automatically insert the value of the payment for
@code{!payment!}: @code{!payment!}:
@example @example
UPDATE tbl_name SET credit=credit-!payment! UPDATE tbl_name SET credit=credit-!payment!
@end example @end example
What do you think will happen when the value of @code{payment} is negative? Think about what happens if the value of @code{payment} is negative?
Because @code{1--1} is legal in SQL, the consequences of allowing
comments to start with @samp{--} are terrible.
Using our implementation of this method of commenting in MySQL
Version 3.23.3 and up, @code{1-- This is a comment} is actually safe.
Because @code{1--1} is legal in SQL, we think it is terrible that Another safe feature is that the @code{mysql} command-line client
@samp{--} means start comment. removes all lines that start with @samp{--}.
In MySQL Version 3.23 you can, however, use:
@code{1-- This is a comment}
The following discussion only concerns you if you are running a MySQL The following information is only relevant if you are running a
version earlier than Version 3.23: MySQL version earlier than Version 3.23.3:
If you have a SQL program in a text file that contains @samp{--} comments If you have a SQL program in a text file that contains @samp{--}
you should use: comments you should use:
@example @example
shell> replace " --" " #" < text-file-with-funny-comments.sql \ shell> replace " --" " #" < text-file-with-funny-comments.sql \
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment