Bug #44421 mysqltest: write_file within if can lead to 'Missing end of block' error
Submitted: 23 Apr 2009 8:35 Modified: 31 Jul 2009 10:48
Reporter: Zhenxing He Email Updates:
Status: Duplicate Impact on me:
None 
Category:Tools: MTR / mysql-test-run Severity:S3 (Non-critical)
Version:5.0, 5.1, 6.0 OS:Any
Assigned to: Bjørn Munch CPU Architecture:Any

[23 Apr 2009 8:35] Zhenxing He
Description:
mysqltest command write_file, append_file or perl, when nesting within an if or while block, will lead to 'Missing end of block' error if the condition is FALSE.

How to repeat:
Try run the following test case:

if (0)
{
write_file var/tmp/test.tmp;
some information
EOF
}

This will result in error:
mysqltest: At line 3: Missing end of block

Suggested fix:
The reason is because when the condition is false, the write_file command will not be executed, and then mysqltest would think the lines after write_file command should be normal commands, so it will try to find for query ending ';' and fail.

There is a work around:

if (0)
{
-- write_file var/tmp/test.tmp EOF;
some information
EOF;
}

by using 'EOF;' as the delimiter for write_file command, it will also ending the query when the condition is FALSE.
[29 Apr 2009 8:57] Sveta Smirnova
Thank you for the report.

Verified as described.
[19 Jun 2009 8:46] Bjørn Munch
May be too difficult to fix, but should at least have a look at it
[31 Jul 2009 10:48] Bjørn Munch
This will also be fixed by the fix to Bug #32296.