Skip to content

fix(plan): return 42S22 for missing columns - #27053

Merged
XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
iamlinjunhong:m-27024
Aug 17, 2026
Merged

XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
iamlinjunhong:m-27024

Conversation

@iamlinjunhong

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:

issue #27024

What this PR does / why we need it:

fix(plan): return 42S22 for missing columns

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

@matrix-meow matrix-meow added the size/S Denotes a PR that changes [10,99] lines label Aug 12, 2026

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

Deep-reviewed exact head d8c1b09.

Blocking: the fix only reclassifies missing columns that reach baseBinder. Other public SQL paths still return ErrorCode 20301 / MySQL 1105 / SQLSTATE HY000 instead of ErrBadFieldError / 1054 / 42S22. Reproduced on this head with:

  • SELECT * FROM nation JOIN region USING (missing_col)
  • INSERT ... ON DUPLICATE KEY UPDATE n_name = missing_col
  • REPLACE ... SET n_name = missing_col

The remaining constructors are in bind_context.go, ondup_update_binder.go, and replace_value_binder.go. Please close the missing-column classification across the public binder paths and add black-box coverage for these cases.

The focused and full pkg/common/moerr, pkg/sql/plan, and pkg/frontend tests, plus build, vet, and diff checks otherwise pass.

@aptend aptend 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.

Deep re-review of exact head 93c33b9 completed. The prior blockers are closed: UPDATE assignment targets (unqualified, qualified, and CTE), both LOAD column-list planner paths, and ODKU assignment-target map lookup now consistently produce ErrBadFieldError / MySQL 1054 / SQLSTATE 42S22. I also rechecked the earlier JOIN USING, ODKU expression/VALUES, REPLACE SET, SELECT, and prepared-statement paths and their black-box coverage. The remaining ODKU InvalidInput constructors are for malformed VALUES() syntax/types, not unresolved columns. The Ubuntu UT failure is an unrelated pre-existing publication TestExecuteIteration1 cardinality assertion (expected 2, actual 3) under pkg/vm/engine/test; it does not touch this planner/error-classification diff.

@aunjgr aunjgr 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.

Reviewed exact head 1c8ec9b. Missing-column failures now consistently preserve MatrixOne’s BadField error identity while exposing SQLSTATE 42S22 across SELECT/JOIN, UPDATE, ODKU, REPLACE, LOAD, prepared, and protocol paths. The tests assert the public error contract rather than incidental planner structure.

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

Deep-reviewed exact head 1c8ec9b0498edf56551d72254599c729ba2b12f1.

Blocking: the missing-column classification still has a public DML bypass in the specialized Iceberg UPDATE planner. buildIcebergUpdateReplacementProjects binds assignment values through NewUpdateBinder, but UpdateBinder.bindColRef still constructs NewInvalidInputf (pkg/sql/plan/update_binder.go:59). On this exact head, a real parser + BuildPlan counterexample using the repository's Iceberg compiler context:

UPDATE gold_orders SET id = missing_col;

returns error code 20301 / MySQL 1105 / SQLSTATE HY000 (invalid input: column 'missing_col' does not exist) instead of ErrBadFieldError / 1054 / 42S22. The existing TestMissingColumnUsesMySQLBadFieldDiagnostic only exercises normal catalog-table routes, so all of its cases pass while this specialized route remains inconsistent.

Please classify the unresolved reference in UpdateBinder.bindColRef as a bad-field error and add a black-box Iceberg BuildPlan regression. The same binder is also used by the legacy ODKU builder, so the regression should cover every production caller rather than patching only the Iceberg call site.

The broader audit also found that generated-column/CHECK expressions and FK local/referenced missing columns still produce 1105/HY000. Those DDL forms may require MySQL-specific error codes rather than always 1054, but they should at least use SQLSTATE class 42 per #27024 instead of an internal/generic HY000. Please either close those public missing-reference routes in this PR or explicitly narrow and test the intended contract.

Fresh exact-head checks: the PR's focused missing-column matrix passes; the Iceberg counterexample above reproduces deterministically; git diff --check and the review worktree are clean.

@iamlinjunhong

Copy link
Copy Markdown
Contributor Author

已在 dc4c1a856346e0185dc63d8fe1a57c1ebd281659 修复并覆盖该 review:

  • UpdateBinder.bindColRef 对未解析列统一返回 ErrBadFieldError / MySQL 1054 / SQLSTATE 42S22;新增真实 parser + Iceberg compiler context 的 BuildPlan 回归:UPDATE gold_orders SET id = missing_col。
  • 同一 binder 的 legacy ODKU 调用方也有独立回归;现代 ODKU 路径仍由既有缺列矩阵覆盖。
  • 按 review 的 DDL 审计,generated-column/CHECK 缺列与 FK 本地/被引用列缺失也改为相同的 1054/42S22 分类,并加入黑盒 BuildPlan 覆盖。

Fresh verification:

.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=120s -run '^(TestIcebergUpdateMissingValueColumnUsesBadFieldDiagnostic|TestMissingColumnUsesMySQLBadFieldDiagnostic|TestLegacyOnDuplicateUpdateMissingValueColumnUsesBadFieldDiagnostic)$' ./pkg/sql/plan
PASS
.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=120s ./pkg/sql/plan
PASS

同时 GOWORK=off go build 与 go vet(仓库 CGo include/lib 环境)及 git diff --check 通过。请基于 dc4c1a8563 re-review。

@iamlinjunhong

Copy link
Copy Markdown
Contributor Author

针对 review #4950208338,已重新核验当前 exact head dc4c1a856346e0185dc63d8fe1a57c1ebd281659:该 review 针对的 1c8ec9b 反例已闭环,且没有未解决 inline thread。

  • UpdateBinder.bindColRef 的未解析列现在构造 ErrBadFieldError,保留原有 public diagnostic 文本,并映射为 MySQL 1054 / SQLSTATE 42S22;
  • TestIcebergUpdateMissingValueColumnUsesBadFieldDiagnostic 通过 parser + Iceberg compiler context + BuildPlan 覆盖 UPDATE gold_orders SET id = missing_col;
  • TestLegacyOnDuplicateUpdateMissingValueColumnUsesBadFieldDiagnostic 覆盖同一 binder 的 legacy ODKU 调用方;
  • generated-column/CHECK 和 FK local/referenced 缺引用均已归类为同一 bad-field diagnostic,并由 TestMissingColumnUsesMySQLBadFieldDiagnostic 覆盖。

Fresh local evidence on this exact head:

mo-cgo-test -run ^(TestIcebergUpdateMissingValueColumnUsesBadFieldDiagnostic|TestMissingColumnUsesMySQLBadFieldDiagnostic|TestLegacyOnDuplicateUpdateMissingValueColumnUsesBadFieldDiagnostic)$ ./pkg/sql/plan  PASS
mo-cgo-test ./pkg/sql/plan  PASS
mo-cgo-test -run ^Test_SendResponse$ ./pkg/frontend  PASS
GOWORK=off go test ./pkg/common/moerr  PASS
CGo-configured go build/vet for pkg/sql/plan and pkg/frontend  PASS
git diff --check  PASS

CI run 32017093704 is attempt 1 and still in progress; no failed check is present.

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

Deep-reviewed exact head dc4c1a856346e0185dc63d8fe1a57c1ebd281659.

The prior blocker is closed: the specialized Iceberg UPDATE binder now classifies unresolved value columns as ErrBadFieldError / MySQL 1054 / SQLSTATE 42S22, with a parser + BuildPlan regression. The same change closes the shared UpdateBinder caller, and the generated-column/CHECK and local/referenced-FK missing-column paths are now covered by the black-box diagnostic matrix.

I also re-audited the remaining "missing column" constructors. The legacy UPDATE fallback first resolves assignment targets through DMLContext before routing, while the IVFFLAT/FULLTEXT INCLUDE sites consume already-validated catalog metadata; neither provides a user-facing counterexample to this contract.

Fresh exact-head verification passed:

  • focused missing-column, Iceberg, legacy ODKU, moerr, and MySQL protocol tests under -race
  • full pkg/sql/plan suite
  • git diff --check

No blocking findings.

@mergify mergify Bot added the queued label Aug 17, 2026
@mergify

mergify Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-08-17 11:05 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-08-17 12:10 UTC · at 6e3c6d4129a67a92e4e742eb8edbee22dbdd21a2

This pull request spent 1 hour 4 minutes 58 seconds in the queue, with no time running CI.

Waiting for
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
All conditions
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Linux/arm64
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86

Reason

Pull request #27053 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

The author needs to enable "Allow edits from maintainers" on this pull request.

Failing checks:

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

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

size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants