Skip to content

avoid quadratic backtracking in the oracle hint comment pattern - #2495

Merged
manticore-projects merged 1 commit into
JSQLParser:masterfrom
dxbjavid:oracle-hint-regex-backtracking
Aug 22, 2026
Merged

avoid quadratic backtracking in the oracle hint comment pattern#2495
manticore-projects merged 1 commit into
JSQLParser:masterfrom
dxbjavid:oracle-hint-regex-backtracking

Conversation

@dxbjavid

Copy link
Copy Markdown
Contributor

OracleHint checks every comment that precedes a select/insert/update/delete/merge against the block-hint pattern with an unanchored find, so a single line comment that happens to contain a /*+ marker followed by a long run of stars and no closing / makes the greedy match backtrack quadratically (a comment with 100k stars takes around twelve seconds), and this is reachable straight through CCJSqlParserUtil.parse. A hint only ever begins the comment though, so anchoring the pattern at the start of the input lets it reject that line-comment case immediately while still matching every real /+ ... */ hint exactly as before. I have added a regression test that pins the crafted comment under a short preemptive timeout.

@manticore-projects

Copy link
Copy Markdown
Contributor

Thank you much!

@manticore-projects
manticore-projects merged commit a5765f3 into JSQLParser:master Aug 22, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants