You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add truncated flag to execute_sql results when max_rows cuts off rows
When a configured max_rows cap fired, the tool response was
indistinguishable from a table that genuinely has exactly max_rows rows
(count simply equaled the cap), so LLM consumers could silently reason
from incomplete data.
Detection is exact rather than heuristic: when the cap is the binding
constraint, SQLRowLimiter rewrites the query to fetch max_rows + 1 rows
(LIMIT/TOP probe). If the probe row comes back, the connector drops it,
clamps the count to max_rows, and marks the result set truncated; the
statements payload then carries "truncated": true alongside count. The
flag is omitted entirely for complete results, and never fires when the
query's own smaller LIMIT/TOP is what bounded the result.
Applies to all five connectors (PostgreSQL, MySQL, MariaDB, SQLite,
SQL Server), including per-statement flags in multi-statement batches.
SQL Server now also echoes the original statement text instead of the
TOP-rewritten one, matching the other connectors.
Closes#404
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SxUnGXE7MRMyezpunumuFH
Copy file name to clipboardExpand all lines: docs/tools/execute-sql.mdx
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -158,6 +158,7 @@ max_rows = 1000
158
158
- Only applied to SELECT statements, not INSERT/UPDATE/DELETE
159
159
- If your query already has a `LIMIT` or `TOP` clause, DBHub uses the smaller value
160
160
- Can be configured per-tool in [TOML configuration](/config/toml)
161
+
- When the cap actually cuts off rows, the statement's result carries `"truncated": true` alongside `count`, so a capped result is distinguishable from a table that genuinely has exactly `max_rows` rows (detection is exact — DBHub fetches one probe row past the cap; the flag is omitted for complete results). Run `COUNT(*)` to get the true total when you see it.
0 commit comments