Skip to content

fix(sql): preserve typed VALUES branches and DATE/TIME set results - #32350

Merged
mergify[bot] merged 3 commits into
matrixorigin:mainfrom
aptend:fix/astra-meow-31882-31913
Nov 8, 2026
Merged

mergify[bot] merged 3 commits into
matrixorigin:mainfrom
aptend:fix/astra-meow-31882-31913

Conversation

@aptend

@aptend aptend commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

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'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
fixed/dynamic dimension checks. The blob-group 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 (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_bit origin, the fast path now
returns 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 BIT
payloads 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):

  • Counterfactual RED: 17 isolated subtests against the exact previous PR
    head's own build_constraint_util.go producer through a single-file
    -overlay mapping (an own-old-PR counterfactual, not a clean-main
    build): 12 bare-VecVal re-emission failures, 2 unchecked-decoding
    failures, 2 unaligned constant-decoder panics (isolated subtests), 1
    checked-boundary typing failure.
  • GREEN: the same tests plus nearest neighbors pass — 3 roots in
    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.
  • Static checks: molint + golangci-lint both report 0 over the same
    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')"
  • Real fixture: a single foreground run of the compiled pkg/tests/issues
    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.
  • CI on the new head has just been triggered by this push and is still
    pending at the time of writing.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH

XuPeng-SH commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 199140e0271b3b46bdbe0b99df1bddf506fb5e44

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@XuPeng-SH

XuPeng-SH commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: c983301ee24fb6732b218d9015d1b8a81652de8d

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mergify mergify Bot added the queued label Nov 8, 2026
@mergify
mergify Bot merged commit 7a73a73 into matrixorigin:main Nov 8, 2026
@mergify

mergify Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

✅ Merged into main as 7a73a73 at 00:02 UTC

Less than a minute in the queue, with no time running CI.

So far

  • ✅ Entered the queue Sun 8 Nov, 00:02 · rule main · triggered by rule Automatic queue on approval for main
  • ✅ Checks skipped · PR is already up-to-date
  • ✅ Merged 00:02 · 7a73a73 · squash
3 merge conditions met
  • #review-threads-unresolved = 0 · required by GitHub branch protection
  • github-review-approved · required by GitHub branch protection
  • any of · required by GitHub branch protection:
    • check-success = CI Required
    • check-neutral = CI Required
    • check-skipped = CI Required

Times in UTC · dashboard · how the merge queue works

This branch was previously deployed

1 inactive deployment
ci — c983301e Deployed Nov 7, 2026 by aptend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

3 participants