Bug #11785 mysqltest, wrong detection of comments starting with '--'
Submitted: 6 Jul 2005 21:40 Modified: 1 Sep 2005 19:19
Reporter: Matthias Leich Email Updates:
Status: Closed Impact on me:
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:4.1 OS:
Assigned to: Magnus Blåudd CPU Architecture:Any

[6 Jul 2005 21:40] Matthias Leich
The standard SQL comments start with "--" and end at the next line.
(Peter Gulutzan/Trudy Pelzer: SQL-99 Complete + our manual 
9.5. Comment Syntax ...) . MySQL prefers "#", but "--" is allowed.
"--" works fine as long as the command line client 
- "mysql" is used or
- "mysqltest" is used and the dashes are not followed by
   mysqltest specific keywords like
   "If", "while", "end", "let", "dec", "inc", "{", "}", "begin", "end".

If such a keyword is used, the execution of a script for mysqltest
aborts with an totally misleading error message.
-- The test ........... will
... lt-mysqltest: Stray '}' - end of block before beginning

I assume that customers use "mysql" or other tools, but not
"mysqltest". Therefore I guess it is not so important for them. 

This bug harms the development of tests for MySQL, because
we get often testscripts written for "mysql" or other SQL
systems and they contain masses of comments starting with "--".
Any conversion to scripts for "mysqltest" costs much time,
because any simple "-- end <some other texts" causes an
error and "-- begin <some text" causes errors which appear
a bit later. 
Example: The NIST tests  contain about 12000 comments.
               All comments start with "--".

Workaround: Start comments with "#"  .

How to repeat:
Please "play" with the attached test script for mysqltest.

Suggested fix:
Accurate detection of comments starting with "--".
[6 Jul 2005 21:42] Matthias Leich

Attachment: ml032.test (application/test, text), 338 bytes.

[16 Aug 2005 15:23] Magnus Blåudd
Normally a command in a mysqltest test file is ended by a ; (or the characters set using the "delimiter" command).
delimiter stop;
echo teststop

In addition to this a comment started with "--" may contain a valid query as the first word after the comment start. Thus it's always checked to see if that is the case.
The advantage with this approach is to be able to execute commands terminated by new line '\n' regardless how many "delimiter" it contain. Where "delimiter" can be set by using the delimiter keyword.
--delimiter stop
echo test3stop
--delimiter ;
echo test4;

is equal to the command 
--  enable_query_log

Remember that this is the syntax we use to for the _mysqltest_ program.
[23 Aug 2005 13:42] Magnus Blåudd
I expect this problem to be fixed "well enough" by my patch for bug#11316. I have tested with the ml032.test file and it will point out line 13 as the offending line.  I have also changed the error message to say " Stray 'end' command - end of block before beginning". Hope this will be enough, at least it point's out the correct line. If there are any opther cases with strange error messages(or you think it's still strange) please let me know.
[24 Aug 2005 8:23] Sergei Golubchik
same reviewer as in bug#11316
[31 Aug 2005 15:18] Magnus Blåudd
Will be fixed by the patch for bug#11316
[1 Sep 2005 19:19] Paul DuBois
No changelog entry needed.