Repository navigation
fix(sql): MySQL warnings for FORMAT locale, LN/LOG args, STR_TO_DATE - #30373
mergify[bot] merged 5 commits into
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: d5d321d58ea69136e67b57f10e658d2359598ad9
Assessment: request_changes
Reviewed the complete six-file delta. Reusing the warning sink and parser is reasonable, but public SQL reproduces missing FORMAT warnings and incorrect constant-expression warning counts. STR_TO_DATE also introduces substantial avoidable allocation for large invalid inputs.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1
-
P2
pkg/sql/plan/function/func_binary.go:6738: Execute SELECT FORMAT(1234.5,2,'bad_locale'), including string-valued numbers and empty or NULL locales.
Impact: The promised warning 1649 remains absent from normal SQL. Wire the diagnostics into the canonical FORMAT implementation and cover it through SQL binding.
Evidence: SQL returned '1,234.50' with empty SHOW WARNINGS and warning_count=0. list_builtIn.go binds overloads 2/3 to formatIntegerPrecision, which never emits locale warnings; this patch and its tests update only legacy FormatWith3Args paths. Reproductions are retained in sql-warning-contract.log. -
P2
pkg/sql/plan/function/func_builtin.go:4859: Over a three-row table, execute SELECT LN(0) FROM t or SELECT LOG(1,2) FROM t.
Impact: SHOW WARNINGS and @@warning_count report one warning instead of the required three. Preserve row-level diagnostics through runtime folding and constant-vector fast paths.
Evidence: Both queries returned three NULLs but warning_count=1; column-based invalid logarithms correctly reported three warnings. Constant invalid STR_TO_DATE also reported only one. Runtime doFold caches these expressions after evaluating length=1, and the logarithm templates independently invoke callbacks once for constant vectors. See sql-warning-contract.log. -
P2
pkg/sql/plan/function/func_str_to_date.go:80: STR_TO_DATE receives a large invalid string or a valid prefix followed by a large suffix.
Impact: Formatting the entire input creates input-sized temporary allocations even when diagnostics are discarded. Bound message construction before formatting and avoid constructing unused messages.
Evidence: The same kernel benchmark with a 2 MiB invalid input measured 216 B/op and approximately 121 ns/op at the merge-base versus 4,211,006 B/op and approximately 296,000 ns/op at this head without a sink. A discard-only WarningProbe showed the same regression. The sink's later message bound cannot prevent these allocations. Logs: base-bench.log and head-focused-and-bench.log.
Validation:
-
Artifacts are retained under /home/xupeng/.local/state/mo-bot/jobs/112b0faad65aee362e0b0f65/attempt-1. validation-ledger.json reconciles commands, source fingerprints, exit receipts, overlays and log hashes; evidence-audit.log passed. Source remained unchanged.
-
Private /tmp and loopback preflight passed. Current native provenance matched retained artifacts and was verified through the repository build owner. A bookkeeping failure after recovery was followed by successful provenance verification.
-
Public SQL check completed: 19 subtests passed and 8 failed on the reported FORMAT/count defects. Receipt: checks/1792138060906731095-146.json; log: sql-warning-contract.log.
-
All 11 focused unit-test roots and the complete vectorize/format package passed. Head/base kernel benchmarks completed successfully with verified base overlays. Short valid STR_TO_DATE inputs retained identical allocation counts.
Limitations:
-
Supplied CI records report success, but contain no raw execution logs; local_validation is empty and linked issue bodies were not supplied.
-
Public validation used one CN. No independent MySQL or multi-CN run was performed. Performance measurements cover kernel cost, not end-to-end throughput.
…atrixorigin#30373) Review findings fixed: 1. FORMAT locale warning (P2): the binder routes FORMAT to formatIntegerPrecision (integer overloads), not the legacy FormatWith3Args path the original patch warned through. Emit the ER_UNKNOWN_LOCALE warning (1649) from formatIntegerPrecision for NULL and unknown constant/vector locales while keeping the en_US fallback. 2. Folded scalar warning counts (P2): a cached constant result cannot represent one warning per evaluated row, so LN/LOG folded to one warning across a batch. Generalize the runtime fold guard into function.ScalarDiagnosticNeedsRowEvaluation (DIV/MOD preserve matrixorigin#30211 behavior verbatim) and extend it to LN/LOG/LOG2/LOG10, STR_TO_DATE and FORMAT: constants whose single evaluation would warn stay non-folded; proven-safe constants keep the fold fast path. LN/LOG diagnostics also move out of the value kernels into a shared post-pass (npZeroWarn pattern) so NULL operands stay silent and the count survives constant-vector fast paths. 3. STR_TO_DATE allocation (P2): appendStrToDateWarning now builds the diagnostic lazily only when a warning sink exists, and caps the echoed input at 128 bytes, so a multi-megabyte invalid input no longer forces input-sized allocations on discard-only evaluation. Regression: pkg/sql/colexec/compat_warning_folding_test.go verifies folded scalar LN/LOG/FORMAT constants keep per-row warning counts while safe constants still fold.
|
@XuPeng-SH @mo-bot Pushed 1) FORMAT locale warning on the canonical binder path (P2) 2) Folded scalar warning counts (P2) 3) STR_TO_DATE allocation amplification (P2) Regression coverage: |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of 247298e against d304047. No blocking finding remains.
All three findings from my previous review are addressed:
- Diagnostic-producing overloads now declare rowScopedDiagnostics at the existing semantic owner. The shared runtime/direct-evaluation probes preserve per-row diagnostics while warning-free constants still fold; file pruning rejects effectful predicates. The duplicate function-ID prediction switch and duplicate STR_TO_DATE calendar validator are removed.
- FORMAT bounds the locale before constructing a diagnostic, rejects unsupported lengths before case conversion, and does not copy unknown locale payloads into the formatter. No-sink/count-only paths avoid message formatting. The benchmark allocates its input outside the timed loop and measures the real canonical kernel as well as the helper.
- NULL locale reports "Unknown locale: 'NULL'"; empty locale remains distinct.
Reviewed all 15 changed files, including production code, unit tests, benchmarks and SQL/result fixtures. Traced the canonical and legacy FORMAT entries, selected-row/NULL logarithm behavior, all three STR_TO_DATE result types, shared folding and external-file admission. The issue's >6-digit %f case follows the same remaining-input diagnostic path. Existing value parsing and warning-budget ownership are reused; no new state machine or execution pipeline is introduced.
The logarithm post-pass returns immediately for a batch without NULL results; invalid rows pay the necessary diagnostic work. No demonstrated material performance regression was found. This is not a claim of zero execution cost for newly required warnings.
Validation: current-head build, UT, coverage, SCA and both enabled BVT jobs pass in run 39050212481. Reviewed the new bound-expression, zero/multi-row, NULL/empty/long-locale, mask, prepared-reuse and retention-limit checks, and the author's reported targeted SQL and allocation results. No additional local test run was performed in this review; the CI log inspected does not independently establish execution of the newly added scalar_compat_warnings.sql fixture.
Approving this revision.
Merge Queue Status
This pull request spent 1 hour 8 minutes 35 seconds in the queue, including 53 minutes 4 seconds running CI. Required conditions to merge
|
|
独立合并后实测完成,存在确认的新回归,不能称全部通过。 新增问题 #30505:main main原始ASCII/NULL/行/CASE/prepared/zero-retention组合SQL16事件通过;7完整归属包34098事件通过,11跳过单列;64条警告BVT在真实MySQL逐条与仓库golden行值对照通过(不比较JDBC展示头,不声称mo-tester/全CI资格)。这些通过不覆盖上述Unicode反例。 4.2-dev |
|
本轮 continue18 当前 main |
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #30217
Fixes #30214
Fixes #30213
What this PR does / why we need it:
Return MySQL diagnostics alongside existing scalar results: FORMAT warning 1649 with the en_US fallback for unknown/empty/NULL locales, logarithm warning 3020 with NULL results for invalid arguments, and STR_TO_DATE warnings 1411 for invalid input and 1292 for accepted trailing text.
Register diagnostic-producing overloads in the existing
rowScopedDiagnosticsmetadata. Optimizer/file-pruning admission and the shared folding/direct-evaluation probes now preserve per-row effects; safe constants still fold. Remove the duplicate scalar-warning prediction switch and STR_TO_DATE calendar validator, preserving the existing DIV/INTEGER_DIV/MOD policy. Logarithm diagnostics and all three STR_TO_DATE return types respect selected-row masks and NULLs.Bound FORMAT locale echoes before formatting, reject unsupported locale lengths before case conversion, and avoid cloning unknown locale strings into the formatter. No-sink and zero-retention probes skip message construction. NULL now reports exactly
Unknown locale: 'NULL', while an empty locale retainsUnknown locale: ''. STR_TO_DATE diagnostic text remains bounded before construction.Rebased onto main
d304047724. Validation:function/scalar_compat_warnings.sql: 64 statements passed twice through normal mo-tester comparison. Independent SQL assertions check values, diagnostic codes/counts, exact NULL/empty locale messages, short-circuit branches, prepared reuse andmax_error_count=0(three counted warnings, no retained rows). Schema cleanup and owned-service shutdown passed.Full CI on the pushed revision is required before merging.