Repository navigation
fix(sql): preserve typed VALUES branches and DATE/TIME set results - #32350
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: 199140e0271b3b46bdbe0b99df1bddf506fb5e44
Assessment: request_changes
The fixes fit the existing VALUES and set-operation owners without new runtime state. NULL typing and temporal widening are coherent, but the new vector-carrier conversion introduces an unchecked bit-literal path that panics before assignment validation. One P2 correctness finding remains.
Model: gpt-6.1-sol / max
Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0
- P2
pkg/sql/plan/bind_insert.go:6846: For a table t(id int, v vecf32(3), a int), execute INSERT INTO t VALUES (1,b'1',(SELECT 3)); vecf64 has the same problem.
Impact: The new Sval-to-VecVal conversion treats this one-byte bit payload as a pre-parsed floating vector. Constructing the constant executor panics in DecodeSlice instead of returning a vector conversion error; the later assignment checks cannot run. Validate/normalize carriers before re-emitting VecVal, or preserve checked conversion for BIT carriers, and add a rejection/reuse regression.
Evidence: Source-established regression: mysql_sql.y:15637 creates P_bit; MakeInsertValueConstExpr (build_constraint_util.go:2118) obtains a VARCHAR Sval from SetInsertValueString. Its P_bit arm (eval_expr_util.go:962-967) bypasses array parsing and DecodeBinaryString produces 0x01. This new branch re-emits it as VecVal; evalExpression.go:362 and :2336 decode it as float32/64, and types/encoding.go:65-71 panics on the unaligned length. The baseline retains VARCHAR and reaches the checked string-to-array assignment path. See bit-literal-source-proof.md and bit-literal-repro.sql; no local SQL execution is claimed.
Validation:
-
Read the complete seven-file delta, both discussion entries, both linked issue bodies/comments, and the affected binding, set-cast, expression, rowset, pSpool, constraint and fixture consumers. Baseline source comparison isolates the newly introduced unsafe constant decode.
-
Exact-head evidence snapshot reports completed successful Ubuntu UT/UT coverage, arm64 SCA and both active multi-CN BVT jobs. Repository UT discovery includes pkg/sql/plan, pkg/sql/colexec/value_scan and pkg/tests/issues; PR-body focused/combined-fixture runs are attributed author evidence.
-
Local isolation preflight passed (preflight.log; checks/1794073663658444293-3.json, exit 0).
-
Local frozen-range/clean-source/seven-file/gofmt/diff-check audit passed (source-audit.log; checks/1794073925215983384-4.json, exit 0).
-
Focused mo-cgo-test attempt stopped before compilation: missing compatible cgo/libmo.so and rejected primary-worktree reuse (focused-go-tests.log; checks/1794073686968646230-3.json, exit 1). This is an environment diagnostic, not a product-test failure or pass. Receipt/log/source hashes are recorded in validation-evidence.json.
Limitations:
-
The bit-literal SQL witness was established by producer-to-decoder source analysis, not locally executed; compatible native prerequisites are unavailable.
-
local_validation is empty. Raw author-run artifacts and external reusable-workflow flags/per-test logs are absent from the frozen evidence; CI statuses are used only for their reported scope.
… columns A BIT literal is raw decoded bits, never a pre-parsed vector carrier: SetInsertValueString's P_bit arm returns DecodeBinaryString bytes directly and bypasses the array parser, while every other blob-group origin is routed through the parser with its dimension checks. The fast path in MakeInsertValueConstExpr re-emitted those raw bits as an array-domain constant, so the lowered branch of a VALUES row with scalar subqueries reached the constant float decoder with an unaligned payload (panic, skipping assignment validation) or silently decoded destination-aligned but unparsed bits as element floats. Return no fast-path expression for an array destination plus P_bit so the row falls to the generic binder and keeps the checked string-to-array conversion (moerr 20101 malformed vector input). Regression coverage: real BuildPlan -> colexec executor consumers for f32/f64 destinations across INSERT/REPLACE lowered branches and the ordinary all-literal VALUES row (unaligned b'1', destination-aligned unparsed BIT, error class locked to the array parser, and post-error reuse with exact bytes and typed NULL), plan-level branch carrier metadata for the same boundaries, and a public-SQL fixture witness on the existing issue 31882 scene: the BIT insert surfaces Error 20101 and the same connection keeps accepting genuine vector literals. Fixes matrixorigin#31882.
199140e to
c983301
Compare
|
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: c983301ee24fb6732b218d9015d1b8a81652de8d
Assessment: approve
The fixes keep destination typing, checked vector conversion and temporal widening in their existing owners. The prior BIT-literal P2 is resolved; no actionable findings remain.
Model: gpt-6.1-sol / max
Session: 01a1a004-9884-72c0-ad39-f096c4209c4a · slot 1 · generation 0
Validation:
-
Reviewed all eight changed files, four discussion entries and both linked issues; traced affected planner, executor, rowset, pSpool and fixture consumers.
-
Reused current-head successful shared build, Ubuntu UT/coverage, arm64 SCA and both active multi-CN BVT jobs.
-
Reused attributed focused planner/value_scan results and the completed two-CN public SQL fixture covering both issues, BIT rejection and subsequent reuse.
-
Local frozen-range, clean-source, formatting and evidence audits passed. Logs and receipts are reconciled in validation-evidence.json and validation-receipts.json.
Limitations:
- No local Go tests were run. Raw author logs, per-test CI logs and external reusable-workflow flags are unavailable.
✅ Merged into
|
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #31882
Fixes #31913
What this PR does / why we need it:
Scope is unchanged from the original delivery: (1) preserve typed VALUES
branches for bare-NULL rows lowered with scalar subqueries, including
vector columns; (2) keep DATE/TIME set-operation results on their common
type. This update additionally resolves review P2 (XuPeng-SH): a BIT
payload is raw decoded bits, never a pre-parsed vector carrier.
Root cause of the P2 defect:
SetInsertValueString'sP_bitarm returnsDecodeBinaryStringbytes directly and bypasses the array parser, whileevery other blob-group origin is routed through the parser with its
fixed/dynamic dimension checks. The blob-group fast path in
MakeInsertValueConstExprre-emitted those raw bits as an array-domainconstant, so the lowered branch of a VALUES row with scalar subqueries
reached the constant float decoder with an unaligned payload (heap panic
that skips assignment validation) or silently decoded destination-aligned
but unparsed bits as element floats.
Fix: for an array destination plus a
P_bitorigin, the fast path nowreturns no pre-parsed constant, so the row falls to the generic binder and
keeps the checked string-to-array assignment cast (moerr 20101
"malformed vector input") — for
b'1'and for destination-aligned BITpayloads alike, on both INSERT and REPLACE lowered branches and on the
ordinary all-literal VALUES row. DecodeSlice/vector/global cast/NULL/SET
behavior is untouched.
Validation on this head (base main e8765aa, 8 source files):
head's own
build_constraint_util.goproducer through a single-file-overlaymapping (an own-old-PR counterfactual, not a clean-mainbuild): 12 bare-VecVal re-emission failures, 2 unchecked-decoding
failures, 2 unaligned constant-decoder panics (isolated subtests), 1
checked-boundary typing failure.
pkg/sql/colexec/value_scan (21 PASS entries incl. subtests) and 5 roots
in pkg/sql/plan (45 PASS entries incl. subtests), covering f32/f64
destinations through the real BuildPlan -> colexec expression executor
(no hand-made VecVal), error class locked to moerr 20101
"malformed vector input", and post-error reuse with exact physical
bytes, dimension and typed NULL. The f64 destination is a test-local
deepcopy twin resolved through the real mock resolver; it is not a
public-SQL scenario.
pinned 336-package reverse-import closure of the changed owners and
their reverse dependencies (list recorded as
out/return16-current447-CGO-SCA-native-bindings-patrol138/D-static-check-packages.txt;
the 447 in the path is the traceable closure-recording name, the
analyzers ran on current e876-based source). No lint was disabled and
this is not a whole-repo ./... claim.
Actual local SCA command (both analyzers rc 0):
make --no-print-directory static-check-selected STATIC_CHECK_PACKAGES="$(paste -sd' ' '/home/mo/.local/share/matrixone-matrix-meow-intake/batches/meow-31882-31913/out/return16-current447-CGO-SCA-native-bindings-patrol138/D-static-check-packages.txt')"binary (sha256 b8bc412b020ce7e7be1f4164fc1387b70c2902efd96c5ff1b346f6b0db53b6cb,
go1.27.1, CGO) executed
TestIssue31882And31913ValuesSubqueryNullAndUnionDateTime: parent PASS
6.14s with both scenes passing. The new public-SQL BIT witness surfaces
Error 20101 "malformed vector input", and the same connection then
round-trips a genuine '[1,2,3]' vector (l2_distance = 0). The earlier
TestTypeSwitchFamilies atomic coverage note (0) still applies; 2.5% was
a source-scan package-local figure, not PR coverage, and no external CI
job is replayed or claimed here.
pending at the time of writing.