Skip to content

Commit b5c215d

Browse files
committed
Add some comments
1 parent 34e7a79 commit b5c215d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

instrumentation-api-incubator/src/main/jflex/SqlSanitizer.jflex

+4
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ WHITESPACE = [ \t\r\n]+
5454
// max length of the sanitized statement - SQLs longer than this will be trimmed
5555
static final int LIMIT = 32 * 1024;
5656

57+
// Match on "IN(?, ?, ...)". This can also match invalid sql syntax like IN(?,,), which is a tradeoff to avoid stack overflows
5758
private static final Pattern IN_STATEMENT_PATTERN = Pattern.compile("\\sin\\s*\\(\\s*\\?[\\s?,]*?\\)", Pattern.CASE_INSENSITIVE);
5859
private static final String IN_STATEMENT_NORMALIZED = " in(?)";
5960

@@ -283,7 +284,10 @@ WHITESPACE = [ \t\r\n]+
283284
builder.delete(LIMIT, builder.length());
284285
}
285286
String fullStatement = builder.toString();
287+
288+
// Normalize all 'in (?, ?, ...)' statements to in (?) to reduce cardinality
286289
String normalizedStatement = IN_STATEMENT_PATTERN.matcher(fullStatement).replaceAll(IN_STATEMENT_NORMALIZED);
290+
287291
return operation.getResult(normalizedStatement);
288292
}
289293

0 commit comments

Comments
 (0)