Add backslash escape support to containsSqlScriptDelimiters
Prior to this commit, ScriptUtils supported MySQL-style escapes ('\\')
when splitting a script into statements; however, MySQL-style escapes
were not supported when determining if a given script contained a
specified statement delimiter. This caused executeSqlScript() to
erroneously fallback to a newline as the statement separator in such
cases.
This commit fixes this issue by implementing the same check for
MySQL-style escapes in containsSqlScriptDelimiters() that was already
present in splitSqlScript().
Issue: SPR-17120
This commit is contained in:
committed by
Sam Brannen
parent
ac544924c8
commit
24ed6de6aa
@@ -343,8 +343,20 @@ public abstract class ScriptUtils {
|
||||
*/
|
||||
public static boolean containsSqlScriptDelimiters(String script, String delim) {
|
||||
boolean inLiteral = false;
|
||||
boolean inEscape = false;
|
||||
for (int i = 0; i < script.length(); i++) {
|
||||
if (script.charAt(i) == '\'') {
|
||||
|
||||
char c = script.charAt(i);
|
||||
if (c == '\\') {
|
||||
inEscape = !inEscape;
|
||||
continue;
|
||||
}
|
||||
else if (inEscape) {
|
||||
inEscape = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c == '\'') {
|
||||
inLiteral = !inLiteral;
|
||||
}
|
||||
if (!inLiteral && script.startsWith(delim, i)) {
|
||||
|
||||
Reference in New Issue
Block a user