Skip to content

Fix/40139 calculate total row count#40691

Open
odegroot1234 wants to merge 4 commits intodbeaver:develfrom
odegroot1234:fix/40139-calculate_total_row_count
Open

Fix/40139 calculate total row count#40691
odegroot1234 wants to merge 4 commits intodbeaver:develfrom
odegroot1234:fix/40139-calculate_total_row_count

Conversation

@odegroot1234
Copy link
Copy Markdown

Description

The "Calculate total row count" feature in DBeaver versions 25.3.3 and 26.0.1 throws an exception when executing MSSQL queries. According to issue #40139, this is a regression introduced in version 25.3.3 which previously functioned correctly in 25.3.2.

Cause

This failure can be attributed to the wrapSourceQuery() method in SQLQueryTransformerCount.java. In the method, SQLSemanticProcessor.parseQuery() was called and stored as a Statement object without a SQL dialect parameter as context. As a result, the parser could not handle the MSSQL syntax used in the query, preventing the statement from being recognized as a valid PlainSelect instance and throwing an exception.

Bug Fix

Extracted dataSource.getSQLDialect() as the named variable sqlDialect and passed it as a context parameter to SQLSemanticProcessor.parseQuery(). Verified the fix against the original bug report query from #40139 as well as other queries on MSSQL 2022 via a Docker container.

Additional Observation

After selecting the "Calculate total row count" button, an X button appears. However, clicking the X button does not revert it back to the original. This issue did not exist in version 25.3.2 but exists in subsequent versions 25.3.3 and 26.0.1. This is unrelated to the fix in this PR. Attached below is a screenshot showcasing the instance.

Screenshot 2026-04-03 155729

@E1izabeth E1izabeth linked an issue Apr 7, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Calculate Total Row Count generates an invalid SQL query

2 participants