Skip to content

fix(plan): narrow constant character slices across metadata consumers - #29112

Merged
XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/expression-followups-28896-28901
Sep 20, 2026
Merged

XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/expression-followups-28896-28901

Conversation

@XuPeng-SH

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 #28901
Related to #28896 (NULLIF regression coverage; no temporal production change required).

What this PR does / why we need it:

Character SUBSTRING/SUBSTR/MID, LEFT, and RIGHT retained a source width such as VARCHAR(5000), even with a constant requested length of 3. Refine the selected character result's width to the proven source/constant-length bound without changing its selected type family, charset, overload, or value semantics.

  • Limit refinement to proven CHAR/VARCHAR character semantics. Preserve dynamic/NULL length, unbounded input, and binary-domain behavior.
  • Cover zero/negative/oversized/unsigned lengths, dynamic start, and multibyte characters.
  • Extend existing public regressions across direct queries, views, CTAS, catalog metadata, SQL PREPARE reuse, and cleanup.
  • Verify NULLIF follows its first argument: TIME(6)/DATETIME(6) preserve fractions; reversing TIME(0) and TIME(6) correctly produces TIME(0). Include equality, NULL, and repeated-execution controls.
  • Retain the existing v86 persisted-expression gate. No new overload, vector family, wire field, or execution-value semantics are introduced.
  • Preserve Substrait/Sirius eligibility by sharing exact literal-width derivation with its validator. Admit the legacy width or the proven new width, while retaining overload/type/scale/charset/nullability checks and rejecting mixed or unresolved source domains.

Validation

Local macOS arm64 / Go 1.26.4, own-worktree native build and service:

  • Focused planner, persisted-admission and view-regeneration tests: PASS.
  • Full final packages: planner PASS (11.839s), function PASS (20.210s), Substrait PASS (1.581s), including canonical TPC-H and real bound/export regressions. The new substring export regression failed before the consumer repair and passes after it.
  • Scoped vet and configured full-package golangci-lint: PASS, 0 lint issues. Molint exits 0 with seven diagnostics matched to an executed frozen-main baseline; no new findings.
  • GPT-6 medium design and independent overall review, followed by consumer-fix/test-delta/evidence reconciliation: final PASS, no unresolved material blocker.
  • Public mo-tester expression contract fixture: 68/68 PASS; one bounded cleanup/reuse rerun also 68/68 PASS.
  • Binary prepared reuse over an actual service, using isolated Connector/J 8.4.0: PASS for width 3, TIME metadata/fractions, multibyte values, NULL and parameter reuse.
  • Actual historical main-v86 binary (52913d41f0ec765d054d5f2a45a195eb5701a103) versus new binary, sequentially on a task-owned store: new reads old-produced views retaining conservative metadata; old reads new-produced VARCHAR(3)/TIME(6) views with correct values and catalog metadata.

The bundled test client's Connector/J 8.0.15 truncates binary TIME fractions for both a raw TIME column and NULLIF; an isolated 8.4.0 driver against the same old/new servers preserves them. The shared tester installation was not changed. Text SQL and server expression results already preserve NULLIF's first-argument precision; this PR does not claim a temporal engine correction.

No row-processing algorithm change or measured runtime speedup is claimed. Fresh Linux CI is pending.

@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 →

@mergify mergify Bot added the kind/bug Something isn't working label Sep 19, 2026
@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Sep 19, 2026
@XuPeng-SH
XuPeng-SH force-pushed the codex/expression-followups-28896-28901 branch from 71497be to c08e1bb Compare September 19, 2026 15:55

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

COMMENT — PASS at 8a8f161ba6e9034234553df0c04d5ee260593d10; self-authored PR, so comment only. Reviewed all 12 changed files and affected metadata/execution consumers; no actionable P0–P2 regression found.

Character narrowing requires a proven text domain, preserves type family/charset and rune bounds, and remains conservative for binary, unresolved and NULL cases. Traced folding, comparison/cast, JSON/fulltext, hash/deepcopy, views, prepared reuse, Substrait and distributed transport; no dropped-byte, equality or routing failure identified. Exact-head CI is green.

Evidence gaps: detailed CI logs were unavailable, binary-prepared and historical-v86 compatibility evidence remains author-reported, and upgrade CI was skipped.

This branch was previously deployed

1 inactive deployment
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 kind/enhancement kind/test-ci size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Compatibility]: SUBSTRING, LEFT, and RIGHT do not narrow bounded VARCHAR result metadata

2 participants