Skip to content

fix: support LAST_INSERT_ID(expr) in ODKU assignments - #28531

Closed
VioletQwQ-0 wants to merge 12 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/issue-28163-last-insert-id-expr
Closed

VioletQwQ-0 wants to merge 12 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/issue-28163-last-insert-id-expr

Conversation

@VioletQwQ-0

@VioletQwQ-0 VioletQwQ-0 commented Sep 9, 2026 •

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • BUG

Which issue(s) this PR fixes:

issue #28163

What this PR does / why we need it:

Paused — Draft; not proposed for merge. Following the maintainer's objection to supporting LAST_INSERT_ID(expr), the author accepts retaining rejection as the current proposed direction. No concrete customer/framework dependency has been provided in the issue to justify adding the side-effecting expression. Further merge preparation is paused pending an accepted requirement and product decision.

The retained implementation adds the one-argument form while preserving the zero-argument session read. It carries expression state through statement publication, ODKU provenance, retry handling, and pipeline/MORPC transport, including a v58 capability gate. These changes are retained for reference and are not an accepted product contract or a completed fix.

Reconsideration requires a concrete application/framework dependency, its SQL and version, and the cost or correctness limitations of alternatives. Correctness of the supported zero-argument LAST_INSERT_ID() remains a separate concern.

Validation

Current retained head: 0d465e267999ad4dc36412bd7b1d1c0bacef12fe. This body-only disposition update does not change source or run tests.

Earlier package/race checks reported at 8786a69bad8f77512b5428323a23565205dde5ff are historical evidence, not a complete validation of the current head.

The recorded current-head CI run 34753387943 did not fully pass. Prior investigation recorded UT Coverage success, MinIO image-pull setup failures before Compose/Standalone BVT, an unrelated SCA finding, and a logservice bootstrap test failure with a passing local focused rerun. This disposition does not independently revalidate those diagnoses or rerun CI.

Real SQL/BVT, COM_QUERY/COM_STMT_EXECUTE, raw OK/driver LastInsertId, conversion-oracle and multi-CN validation remain incomplete. No Ready, semantic-completion, BVT PASS or QA PASS claim is made.

QA required: yes if support is reconsidered, because the change affects user-visible SQL, session state, client protocol and distributed execution. Issue #28163 remains open for the compatibility decision.

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

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator Author

CI repair: added the missing pkg/pb/plan import required by hasUserVisibleAutoIncrementColumn. The previous exact-head build failed at pkg/sql/colexec/preinsert/preinsert.go:357 with undefined: plan; the one-line fix is pushed in head f8d655dda46b0d1fb6eee8cf5e8956abf2128e7e. Local go list and pkg/pb/plan tests pass; the owning package build/vet/test remain blocked by the local missing CGo/docfilter prerequisites. Awaiting exact-head CI.

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator Author

CI repair pushed at 0d465e2. The production planner now passes the generated-provenance flag only for real ODKU, so INSERT IGNORE keeps the dependent-unique-index reorder guard. The failing regression fixtures now initialize DedupJoin provenance sentinels, Process sequence state, generated-ID provenance, and neutral remote DedupJoin metadata. Run 34748398521 also recorded an unrelated SCA failure in pkg/tests/issues/issue_27666_test.go plus Compose/Standalone MinIO image pull-denied setup failures; coverage was consequently dependent. Local frontend/plan/compile tests remain blocked by the missing cgo/libmo.dylib prerequisite. New exact-head run 34753387943 is in progress; no CI rerun or reviewer re-request was performed.

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator Author

Current exact-head run 34753387943 has partial results on 0d465e267999ad4dc36412bd7b1d1c0bacef12fe: UT Coverage passed; Compose and Standalone stopped before BVT because Docker could not pull minio/mc and minio/minio, and the dependent Coverage job therefore has no verdict. Ubuntu UT and arm64 SCA are still in progress. The earlier source/fixture repair remains pushed; no rerun was started.

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator Author

Run 34753387943 is now terminal on exact head 0d465e2. UT Coverage passed; Compose and Standalone failed before BVT because Docker could not pull minio/mc and minio/minio, so Coverage had no complete producer. SCA reported the unrelated existing pkg/tests/issues/issue_27666_test.go:436 unused-function error. Ubuntu UT reported only pkg/logservice/TestFailedBootstrap; the PR diff does not touch pkg/logservice, and an exact-head local GOWORK=off go test -mod=readonly -race -count=3 -run '^TestFailedBootstrap$' ./pkg/logservice passed. This is retained as unrelated/transient CI evidence; no rerun was started.

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

See my comment in the issue. I believe this is an anti feature that we simply should NOT support at all.

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator Author

The current-head review is a product/scope decision rather than a concrete code or test defect: it says LAST_INSERT_ID(expr) is an anti-feature and should be rejected. Issue #28163 currently documents the opposite contract, including the standalone SELECT LAST_INSERT_ID(4242) form as the root missing overload and ODKU/prepared use as downstream cases.

I am leaving the implementation unchanged and recording this as a maintainer decision blocker. Once the supported SQL contract is decided, the PR can either continue with the existing compatibility scope or be revised to remove it deliberately.

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator Author

@fengttt I accept retaining rejection as the current direction. There is no concrete customer/framework dependency in issue #28163 that justifies proceeding solely for MySQL compatibility. I have marked the implementation paused in the PR description and retained Draft status; the earlier Ready wording and stale current-head validation claim have been removed.

The code is retained for reference. Reconsideration requires an actual dependency and an accepted product requirement. This does not affect the supported zero-argument LAST_INSERT_ID() correctness work. Your CHANGES_REQUESTED remains applicable; I am not requesting re-review or marking the objection resolved.

This branch had an error being deployed

1 failed 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 size/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants