Skip to content

Commit e3b419f

Browse files
committed
[misc] client side parsing removing "//" single line comment
1 parent 3b9bebd commit e3b419f

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/main/java/org/mariadb/jdbc/util/ClientParser.java

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,22 @@ private ClientParser(
3434
}
3535

3636
/**
37-
* Separate query in a String list and set flag isQueryMultipleRewritable. The resulting string
38-
* list is separed by ? that are not in comments. isQueryMultipleRewritable flag is set if query
39-
* can be rewrite in one query (all case but if using "-- comment"). example for query : "INSERT
40-
* INTO tableName(id, name) VALUES (?, ?)" result list will be : {"INSERT INTO tableName(id, name)
41-
* VALUES (", ", ", ")"}
37+
* Separate a query in a String list and set flag isQueryMultipleRewritable. The resulting string
38+
* list is separated by ? that are not in comments. isQueryMultipleRewritable flag is set if the query
39+
* can be rewrite in one query (all cases but if using "-- comment").
40+
* <p>
41+
* Example for the query:
42+
* <code>
43+
* INSERT * INTO tableName(id, name) VALUES (?, ?)
44+
* </code>
45+
* result list will be:
46+
* <code>
47+
* {
48+
* "INSERT INTO tableName(id, name) VALUES (",
49+
* ", ",
50+
* ")"
51+
* }
52+
* </code>
4253
*
4354
* @param queryString query
4455
* @param noBackslashEscapes escape mode
@@ -75,8 +86,6 @@ public static ClientParser parameterParts(String queryString, boolean noBackslas
7586
case (byte) '/':
7687
if (state == LexState.SlashStarComment && lastChar == (byte) '*') {
7788
state = LexState.Normal;
78-
} else if (state == LexState.Normal && lastChar == (byte) '/') {
79-
state = LexState.EOLComment;
8089
}
8190
break;
8291

@@ -171,10 +180,7 @@ public static ClientParser parameterParts(String queryString, boolean noBackslas
171180
break;
172181

173182
case (byte) '\\':
174-
if (noBackslashEscapes) {
175-
break;
176-
}
177-
if (state == LexState.String) {
183+
if (state == LexState.String && !noBackslashEscapes) {
178184
state = LexState.Escape;
179185
}
180186
break;

0 commit comments

Comments
 (0)