Bug #4313 C-style comments causing SQL script failures
Submitted: 28 Jun 2004 18:53 Modified: 28 Jun 2004 22:04
Reporter: William Barrett Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:mysql-standard-4.0.18-pc-linux-i686 OS:Linux (Linux 8.0)
Assigned to: Dean Ellis CPU Architecture:Any

[28 Jun 2004 18:53] William Barrett
Description:
Certain characters (semicolon or single quote mark) in a C-style comment used in an SQL script cause syntax errors.

1. run mysql
2. source an SQL textfile similar to the following
3. C-style comments generally work, except when semicolon or single-quote are in the comment.  A syntax error is reported, very general in tone, on the first line of the offending SQL statement.

For example --

insert into sites set
  sitekey= 1,    /* site of yard; (semicolon causes failure) */
  sitename='Pacific1',   /* sitename 'Pacific1' (quotes cause failure) */
  ;

How to repeat:
1.  Write any SQL textfile that works properly.
2.  Include a comment of the style shown in the description that includes a semicolon or single quote.  (Other characters may cause a similar problem; I haven't investigated thoroughly)
3.  Source the file.
4.  You will get a syntax error with a vague diagnostic.

Suggested fix:
Fix your lexical analyzer so that comments like these work properly.
I am a compiler expert and can show you what needs to be done, except that I have not examined your source code.  It appears that you are using some special kind of compiler tool, not lex/yacc or equivalent, to parse the SQL files.
[28 Jun 2004 22:04] Dean Ellis
I cannot repeat this with current builds of 4.0.21 or 4.1.3.

FYI, this is discussed in the manual:

http://dev.mysql.com/doc/mysql/en/Comments.html