Repository navigation
fix(sql): report malformed integer argument warnings - #30312
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 9214a01640455123c296ce7daead8e65b92086e7
Assessment: request_changes
Reviewed the complete seven-file delta. Shared conversion and warning ownership is appropriate, but BIT_COUNT’s new diagnostics are not integrated with runtime folding, causing incorrect warning counts.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1
- P2
pkg/sql/plan/function/func_unary.go:1054: With three rows, SELECT BIT_COUNT('3x') FROM t ORDER BY id returns three values but only one warning. SELECT IF(id=1,0,BIT_COUNT('3x')) FROM t ORDER BY id likewise reports one warning for two evaluated rows.
Impact: The per-row diagnostic contract is lost for literal inputs. Integrate the warning-producing text overload with diagnostic-aware runtime folding and add frontend tests for constant projections and partially selected branches.
Evidence: A real-frontend reproduction confirmed one warning instead of three/two; equivalent column inputs produced three warnings, while inactive branches and empty results produced none. evalExpression.go:472-474 protects string-to-numeric CASTs only; evalExpressionReset.go:334-352 folds BIT_COUNT at length one. The added constant_rows unit test bypasses this executor. Reproduction: bitcount-frontend.log and checks/1792084978458242630-4.json in the assigned diagnostic directory.
Validation:
-
Preflight passed. Verified 192 native build inputs and 62 artifact hashes; source remained unchanged.
-
Passed 26 focused function tests and all 23 TestBuiltinConversionWarnings frontend scenarios.
-
Base-production overlay failed the new warning assertions while preserving expected values and controls.
-
Reviewer frontend probe reproduced the finding in two scenarios; column, inactive-branch and empty-result controls passed.
-
Measured valid-text overhead: BIT_COUNT kernel 9.58→18.14 ns/row; integer conversion 18.56→27.01 ns/row. Warm 8192-row SQL medians increased 0.426→0.571 ms for text BIT_COUNT and 0.580→0.705 ms for text ROUND. Numeric and folded-constant controls were roughly unchanged.
-
Commands, source fingerprints, exits and retained logs were reconciled in /home/xupeng/.local/state/mo-bot/jobs/a395900db1c269054403d05e/attempt-1/evidence-manifest.json. Complete review coverage is recorded in review-report.json.
Limitations:
-
Supplied exact-head CI reports successful UT and BVT jobs; raw CI logs and individual mo-tester reports were unavailable. Local execution was targeted.
-
The linked issue body was not supplied, and no live MySQL comparison was performed.
-
Benchmarks cover small warm workloads, not production-scale concurrency or throughput.
|
mo-bot review · Commit: Review completed. Read the assessment. |
72c4338 to
445fe00
Compare
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep re-review of exact head 445fe006be874697bc2d1dcf4944b1c428b477d8 against merge base 65bcea5d24610dde1a21bb9f4dea1efd82a8ce50. Read every hunk in all 23 files, the issue/discussion and all previous reviews; traced the increment since the previously approved head together with the full current range. Implementation +149/-41 in 12 files; tests/golden +798/-1 in 11 files; separate docs zero.
No blocking finding remains. Existing conversion and warning owners remain authoritative. Separating value volatility from row diagnostics is justified by actual consumers: generated columns/RETURNING still accept deterministic expressions, speculative folders use isolated warning sinks, and runtime scalar publication happens after selected-row diagnostics execute. No new persistent state, retry machine or diagnostic cache is introduced.
The four prior blocker classes are closed: literal warning cardinality; deterministic-expression admission; valid constant consumers; and malformed constant consumers with selected/empty branches and prepared reuse. The latest main's DECIMAL diagnostic interaction needed fresh verification and passes independently.
Exact-head validation with a matching native build and the repository CGO wrapper, Go 1.27.1/darwin-arm64:
- Complete
TestBuiltinConversionWarningspasses (4.68s). - Independent actual-SQL neighbor test passes:
cast(bit_count('1023x') as decimal(1,0))over three rows returns 9/9/9 with six warnings; selecting two rows gives four; inactive/empty branches give zero. Valid text is the nearest zero-warning control. - The same binary-prepared statement reused across valid, doubly malformed, NULL, singly malformed and valid bindings returns the expected values and 0/6/0/3/0 warnings, without stale results or diagnostics. Both test roots and package exit 0 (8.338s). Temporary probe removed from the worktree.
- Reused exact-head CI run 38992970982, latest attempt 2: UT/SCA/build/coverage/enabled BVT pass. Retained UT artifact confirms DML embedded race batches and all planner shards terminate successfully; actual BVT log records
integer_parameter_coercion.sql118/118 and its binary-domain control 47/47. The earlier failed UT attempt is not root-caused or relabeled by this review.
Performance boundary: diagnostics add real text-processing cost. Historical unchanged conversion-kernel measurements remain about 9.6 -> 18.1 ns/row for valid-text BIT_COUNT and 18.6 -> 27.0 ns/row for integer conversion; these are not current-head TP measurements. Warning-free constants still fold, numeric/binary conversion fast paths remain, and there is no new I/O/lock/retained queue. The duplicate prefix scan is an optional optimization opportunity; this approval does not claim zero CPU overhead or measured TP throughput equivalence.
APPROVE. No production changes made during review.
Merge Queue Status
This pull request spent 4 hours 25 minutes 50 seconds in the queue, including 58 minutes 20 seconds running CI. Required conditions to merge
|
…4a3128831d9ba553ac0c30fd2f05ce1ff68fa0a
|
合并后独立实测(2026-10-17,冻结 main 独立通过真实 MySQL 协议重跑原 issue 的 9 组 SELECT / SHOW WARNINGS,覆盖 17 个 reported built-ins:返回值保持不变,合计 17 条预期 1292 告警;合法文本/数值/二进制、未选分支及空结果对照无多余告警。#30265/#30271 的显式 CAST 旧复现也通过。 完整 function、colexec、plan/rule、plan 普通回归通过;plan 中两个现有 HNSW/Interval setup 跳过项不计通过。SQL/binary prepared 复用、列输入/NULL、分支选择、XML/CEIL 常量消费者、生成列及告警容量回归实际执行。 本 PR 的原始 DML BVT 不全绿:普通/race 均有 4 个新 RETURNING 子场景在宿主机自动 spill cap=1 下失败。保留原断言,仅对测试夹具明确 64 MiB spill 预算的 overlay 对照,普通/race 各 67 个测试/子测试全部通过。该独立的新夹具问题已建 #30480,指派 iamlinjunhong;生产磁盘保护和生产源码未修改。不能把 overlay 对照说成原夹具已修复。 原 issue 报告的 main 修复范围已验证,按约定转给 @Ariznawlll;新增独立问题继续由其单独 issue 跟踪。 |
What type of PR is this?
Which issue(s) this PR fixes:
What this PR does / why we need it:
Integer arguments such as
REPEAT('x','3x')returned the integer-prefix result while omitting conversion warnings. Emit warning 1292 (Truncated incorrect INTEGER value) from the shared integer-argument conversion boundary and BIT_COUNT's separate text path. Preserve converted values, range errors, binary-string behavior, and existing empty-string handling.Reuse the existing warning sink and warning-aware constant folding. BIT_COUNT retains its binary fast path and evaluates textual diagnostics only for selected, non-NULL rows. Separate diagnostic effects from value volatility. Warning-isolated planner and runtime probes fold deterministic constants only after warning-free success, preserving CEIL, XML XPath, and percentile constant arguments. Malformed text remains executable for selected-row diagnostics. After real evaluation, structurally scalar diagnostic trees retain constant vector shape through CAST, CONCAT and scalar flow control, including an explicit DECIMAL cast after rebasing onto current main, preserving malformed CEIL/XML constant arguments without caching away warnings. Prepared reuse rechecks each binding. Retain main's row-evaluation ownership for explicit DECIMAL casts and SQL-mode-dependent division. Ordinary expressions retain their existing partial-selection NULL shape. Conservative optimization and diagnostic-ownership predicates remain unchanged. Generated columns, RETURNING, GROUP BY, and numeric/binary folding retain their supported behavior. Text conversion adds a bounded prefix scan without retaining additional state. Non-folded execution checks diagnostic-tree ancestry; cached warning-free values keep their existing path.
Regression coverage checks all reported built-ins, secondary integer positions, column inputs, projection warning counts, inactive branches, and SQL/binary prepared-statement reuse across malformed text, valid text/numeric values, and NULL. FIELD's already-correct DOUBLE diagnostics remain covered. Extend the existing integer-parameter BVT with exact value and warning checks.
Validation after rebasing onto official main
c21a102e74590253dad70d86e0f18646b61457ae, on Go 1.27.1 / macOS arm64 with the repository CGo wrapper:pkg/sql/plan/function,pkg/sql/plan,pkg/sql/plan/rule, andpkg/sql/colexecsuites with-vet=all -count=1: passed.TestBuiltinConversionWarningsandTestStatementInfoDiagnosticCapacitySQLinpkg/tests/dml, through the real frontend with-short -race -tags matrixone_test -vet=all -count=1: passed. Conversion regressions cover selected-row diagnostics, branch selection, generated-column insert/update, RETURNING, constant-only consumers including the explicit DECIMAL cast, and prepared text/XML reuse.The previous-head UT run 38836114410 failed in
TestStatementInfoDiagnosticCapacitySQLduring connection setup (context deadline exceeded / internal error: AddressFunc). The case passes locally with race enabled; the original timeout remains unattributed and is not claimed fixed. The rebased head needs fresh CI; the old run was not rerun. The local mo-tester harness was not rerun. MySQL 8.0.46 source supports the diagnostic contract; no live MySQL execution or current SQL throughput benchmark is claimed. Issue verification is left to the reporter after merge.