Skip to content

feat(query): 查询结果行数上限与 schema include_system 修复 - #85

Merged
zx06 merged 6 commits into
mainfrom
cursor/query-max-rows-limits-2fdd
Oct 10, 2026
Merged

zx06 merged 6 commits into
mainfrom
cursor/query-max-rows-limits-2fdd

Conversation

@zx06

@zx06 zx06 commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Summary

Query result row limits (RFC 0017) with early-stop scanning, truncation metadata, MCP byte guard, and schema include_system fixes.

中文摘要

  • 默认上限:CLI/Web 1000 行,MCP 500 行;MCP max_rows: 0 = 未设置(走默认链),负值拒绝。
  • MCP mcp.max_rows_limit(默认 10000) clamp 超大请求,metadata 含 max_rows_requested / max_rows_limit。
  • 截断字段:truncated_reason(max_rows / max_response_bytes)、max_rows 为配置上限、max_response_bytes、合并 hint。
  • MCP 字节裁剪改为二分查找;CSV 截断时 stderr 提示,stdout 纯 CSV,退出码 0。
  • 已合并 main(含 ci: Codecov hardening and release smoke tests #83);截断 hint 与 internal/errors/hints.go 一致。

Testing

go build / go vet / go test ./... / integration (MySQL 8.0, PG 16) / e2e / golangci-lint

Open in Web Open in Cursor 

Add RFC 0017 with default caps (CLI/Web 1000, MCP 500), early-stop
scanning, truncation metadata, and optional MCP response byte guard.
Fix MySQL/PG include_system listing and empty tables JSON arrays.

Co-authored-by: x_zhuo <zx06@users.noreply.github.com>
@codecov

codecov Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.79365% with 61 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.23%. Comparing base (e38d7ea) to head (fcbb884).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
internal/db/csv_notice.go 0.00% 10 Missing ⚠️
internal/db/truncation.go 16.66% 9 Missing and 1 partial ⚠️
internal/mcp/query_result.go 79.59% 5 Missing and 5 partials ⚠️
internal/mcp/tools.go 68.42% 6 Missing ⚠️
internal/output/writer.go 73.91% 3 Missing and 3 partials ⚠️
internal/app/service.go 42.85% 2 Missing and 2 partials ⚠️
cmd/xsql/query.go 57.14% 2 Missing and 1 partial ⚠️
internal/web/handler.go 78.57% 3 Missing ⚠️
internal/app/max_rows.go 95.55% 1 Missing and 1 partial ⚠️
internal/db/schema.go 66.66% 1 Missing and 1 partial ⚠️
... and 3 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #85      +/-   ##
==========================================
- Coverage   84.47%   84.23%   -0.25%     
==========================================
  Files          69       74       +5     
  Lines        6744     6970     +226     
==========================================
+ Hits         5697     5871     +174     
- Misses        765      802      +37     
- Partials      282      297      +15     
Flag Coverage Δ
e2e 28.94% <29.44%> (+0.27%) ⬆️
integration 28.94% <29.44%> (+0.27%) ⬆️
unittests 77.77% <65.47%> (-0.30%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

cursoragent and others added 5 commits October 10, 2026 06:54
Resolve merge conflicts (RFC 0015–0017, query executeQuery+dbType).
Reuse HintQueryResultTruncated from internal/errors after PR #84.

Co-authored-by: x_zhuo <zx06@users.noreply.github.com>
Co-authored-by: x_zhuo <zx06@users.noreply.github.com>
Co-authored-by: x_zhuo <zx06@users.noreply.github.com>
Co-authored-by: x_zhuo <zx06@users.noreply.github.com>
- MCP max_rows 0 = unset; negative rejected; clamp via mcp.max_rows_limit (10k)
- truncated_reason, max_response_bytes; preserve configured max_rows on byte trim
- Binary-search MCP byte fitting; CSV truncation notice on stderr
- Align docs/RFC; reduce Sonar complexity in include_system test

Co-authored-by: x_zhuo <zx06@users.noreply.github.com>
@sonarqubecloud

Copy link
Copy Markdown

@zx06
zx06 marked this pull request as ready for review October 10, 2026 07:21
@zx06
zx06 merged commit 0811bc1 into main Oct 10, 2026
14 checks passed
@zx06
zx06 deleted the cursor/query-max-rows-limits-2fdd branch October 20, 2026 03:41
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