Repository navigation
Description
Description
With save_query_result=ON, both supported SHOW COUNT(*) WARNINGS and SHOW COUNT(*) ERRORS fail with an internal Go type-assertion panic instead of returning their diagnostic counts. The same statements return 0 with result saving off; ordinary SHOW WARNINGS still works with it on.
Environment
- Branch:
main - Commit:
f847803802289b2b2d0df4f0a2f842c2804b823a(git_version() = f847803802) - Deployment: isolated local standalone, one CN, MySQL port 49301, macOS arm64, 2026-10-28; synthetic data only.
Steps to reproduce
SET save_query_result=OFF;
SHOW COUNT(*) WARNINGS; -- 0
SHOW COUNT(*) ERRORS; -- 0
SET save_query_result=ON;
/* save_result */ SELECT 1;
SHOW WARNINGS; -- succeeds, empty
SHOW COUNT(*) WARNINGS; -- 20101 internal error
SHOW COUNT(*) ERRORS; -- same 20101 internal error
SELECT 2; -- succeeds: session remains usable
SET save_query_result=OFF;
SHOW COUNT(*) WARNINGS; -- 0 againActual behavior
Both count statements return ERROR 20101 internal error: panic interface conversion: interface {} is uint64, not int64. The stack begins in pkg/frontend.convertRowsIntoBatch (util.go:1686), called by trySaveQueryResult from doShowDiagnosticCount. This occurs even when the count is 0 and no warning/error has been generated.
Expected behavior
Result saving should not change the validity or values of the diagnostic-count statements. Both should return an unsigned count (here 0) without an internal panic; saving the result, if supported, should preserve the same value and metadata.
Stability and controls
- Reproducer: 3/3 fresh databases and sessions (
qshowcount_02/03/04) on the pinned SHA; both count statements failed in every round. - Normal controls: with saving off, both returned
((0,),)in all three rounds. With saving on,SHOW WARNINGSreturned an empty result normally;SELECT 2succeeded after each failure; switching saving off restored the count query. - Failure atomicity/data check: no user data was changed; the SQL session remained usable. The problem is a frontend statement failure and exposed internal panic stack, not an observed service crash.
Evidence
Exact isolated reproducer and per-round output: /private/tmp/mo-explore-run-20261028/show_count_saved_panic.py. Source anchors at this SHA: doShowDiagnosticCount publishes an unsigned MYSQL_TYPE_LONGLONG result and calls trySaveQueryResult; convertRowsIntoBatch asserts row[colIndex].(int64) for the destination vector. The observed uint64 value reaches that assertion.
Code analysis
Confirmed from the returned stack and source: doShowDiagnosticCount's unsigned result enters result-saving conversion as uint64, while the converter assumes int64. The mismatch triggers the panic, which is recovered as SQL error 20101. The repair should align the result metadata/vector type and value conversion without truncating counts above MaxInt64.
Regression coverage
Add frontend integration tests for SHOW COUNT(*) WARNINGS and SHOW COUNT(*) ERRORS with save_query_result on/off, with zero and nonzero counts, followed by result scan and a subsequent query; assert exact values, unsigned metadata, absence of panic and session health.
Related
- [Compatibility]: SHOW COUNT(*) diagnostics and @@warning_count/@@error_count are unsupported #28682 was the earlier parser/variable-support gap for diagnostic counts and is closed; this is a new runtime failure introduced by the interaction with result saving.
Activity
Ariznawlll commentedon Oct 28, 2026
补充:DATA BRANCH DIFF 可导致服务进程退出
在同一
maincommitf847803802289b2b2d0df4f0a2f842c2804b823a上,结果保存的同一处uint64→int64断言错误还可以通过DATA BRANCH DIFF触发;与SHOW COUNT返回 SQL 错误不同,这条路径中的 panic 没有被恢复,导致服务进程退出、客户端连接中断。最小复现
实际结果与范围
panic: interface conversion: interface {} is uint64, not int64;调用链为convertRowsIntoBatch→trySaveQueryResult→satisfyDiffOutputOpt→diffMergeAgency.func6。建议回归时除了检查返回值,还检查后台路径 panic 恢复、服务进程和其他连接的可用性,以及 SET/无符号值的边界。
fix(frontend): honor column signedness when saving query results (#31498
XuPeng-SH commentedon Oct 28, 2026
QA handoff for merged main
6c7813b588f5122aaacdeca7ce17cd898949acdd(#31559): this environment did not run the affected frontend package or current-head service. The existing resource guard leaves insufficient headroom for a safe large link or service build.git diff --checkpassed and native/module/proto inputs are unchanged; these do not validate saved-result behavior.The PR author reports separate single-CN SHOW COUNT and DATA BRANCH DIFF/SET result-save tests, including saved-result readback and other-connection liveness. Those are not local results here. Please verify both original paths, unsigned boundary values, NULL/type errors, saved metadata and service/connection recovery. Separate JSON/BIT/BLOB and DATETIME reports #31534 and #31547 are not claimed fixed by this PR.
Ariznawlll commentedon Oct 28, 2026
结论
测试通过。结果保存开启时的诊断计数和 SET 列 DATA BRANCH DIFF 均正常,原先会终止服务的分支未再触发进程退出。
关键证据
main@9eb05ce0f5ac5ddce36024aaa21c4c79d3e4334c,包含 修复 PR #31559;隔离 1 Log + 1 TN + 2 CN,测试连接一个 CN 并以第二连接确认存活。SHOW COUNT(*) WARNINGS/ERRORS返回 0,制造告警后分别返回 1/0;线协议列类型为无符号 LONGLONG。SET 分支 DIFF 在保存开关两种状态下均为UPDATE, id=1, v=3,result_scan回读(1,3);另一个连接继续执行SELECT 42,基表数据仍为(1,'a')。pkg/frontend定向 Go 测试-count=3通过:覆盖0、1、MaxInt64、MaxInt64+1、MaxUint64、NULL的内部 unsigned 向量及负数、溢出、错误类型拒绝;没有把内部夹具冒充 SQL 线协议结果。待解决点