-
Notifications
You must be signed in to change notification settings - Fork 38.9k
Description
Affects: 5.1.4
Bug Description
I am using ResourceDatabasePopulator to populate a MySQL database using SQL scripts. These scripts contain multi-line comments of the form:
/*--------------------------------------------
-- This is a multi-line comment block
--------------------------------------------*/
ScriptUtils.executeSqlScript then fails with the error:
Failed to parse SQL script from resource [Byte array resource [resource loaded from byte array]]: Missing block comment end delimiter: */
More Details
What appears to be happening is that ScriptUtils.readScript(LineNumberReader, String, String) trims all single-line comments from the input script before passing it to ScriptUtils.splitSqlScript(). The last line of the comment, containing the block-comment end-delimiter, also gets removed because it assumes that this is a single-line comment. The line does start with the single-line comment prefix '--' after all.
Subsequently the trimmed version of the script is passed to and processed by ScriptUtils.splitSqlScript(EncodedResource resource, String, String, String, String, String, List<String>) which finds a block-comment-open delimiter but doesn't find a corresponding block-comment-end delimiter. Which then causes the error listed above.
Effectively, it appears that code allows the block-comment end-delimiter to itself be commented-away by a single-line comment prefix. This is not the behavior we see in standard SQL which allows
I forked and fixed this in the following commits:
- 5488b2004 - Failing test that demonstrates this issue.
- a320f622bc - The fix I ended up using.