Don't construct queries with too many OR statements for SQLite#803
Merged
mcserep merged 1 commit intoEricsson:masterfrom Jul 25, 2025
Merged
Don't construct queries with too many OR statements for SQLite#803mcserep merged 1 commit intoEricsson:masterfrom
mcserep merged 1 commit intoEricsson:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR addresses SQLite's recursive descent parser limitation by implementing conditional compilation to handle large OR queries that can cause stack overflow. The change splits the Lack of Cohesion metric calculation into two approaches: a safer iterative approach for SQLite and an optimized query-based approach for more robust database engines.
- Added conditional compilation (
#ifdef DATABASE_SQLITE) to use different query strategies based on database type - Moved field counting outside the conditional blocks for code reuse
- Implemented a simpler query approach for SQLite that avoids constructing queries with many OR statements
Comments suppressed due to low confidence (1)
plugins/cpp_metrics/parser/src/cppmetricsparser.cpp:410
- The fieldCount variable declaration was moved outside the conditional blocks but is still being removed from the non-SQLite branch. This creates duplicate variable declarations since fieldCount is now declared at line 318. Remove this duplicate declaration.
// Counter variables.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#801 improved the performance for Lack of Cohesion metric, by refactoring 3 level nested query loop to 2 level.
However, SQLite has a fixed-size recursive descent parser, and each logical operator (like OR) adds a level to the parser's stack. Constructing queries with many ORs can lead to a stack overflow.