fix(plan): fallback UPDATE generated-column correctness (follow-up #24536) - #24600
Merged
Merged
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? |
aunjgr
approved these changes
May 26, 2026
aunjgr
left a comment
Contributor
There was a problem hiding this comment.
No blocking issues found.
The fallback UPDATE planner change keeps generated-column projections contiguous after rewrite and now recomputes them from the rewritten source expressions, so DEFAULT / ON UPDATE / chained generated-column cases stay correct. The new planner tests cover the risky cases.
ck89119
added a commit
to ck89119/matrixone
that referenced
this pull request
Jun 1, 2026
The fallback UPDATE rewrite builds the inner SELECT projection by ranging the usedTbl map to order target tables (build_constraint_util.go), so for a multi-table UPDATE the table order followed Go's randomized map iteration. rewriteGeneratedColumnsForUpdate derives projection offsets (tableBase / baseLookup) from that order, so ~50% of runs the generated-column substitution resolved the wrong base column, producing a flaky/incorrect plan (intermittently failing TestUpdateFallbackGeneratedColumns* added in matrixorigin#24600). Port the deterministic ordering already on 4.0-dev: iterate aliases in their original declaration order via orderedDmlAliases() instead of ranging the map. No behavior change beyond determinism. Verified: go test ./pkg/sql/plan -run 'TestUpdateFallback' -count=300 now passes 300/300 (previously failed intermittently); full pkg/sql/plan green; make static-check clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
Which issue(s) this PR fixes:
issue #23137
What this PR does / why we need it:
Follow-up correctness fixes for PostgreSQL-style
UPDATE ... SET ... FROM ... WHEREfallback planning, completing #24536 (already merged tomain).These two fixes were added during review of the 4.0-dev backport (#24562) but were missing on
main:892d892b3): generated-column recompute expressions are inserted into the current target table's contiguous update segment instead of being appended after all targets, so later targets in a multi-target fallbackUPDATEno longer read/write wrong projection positions.988c01bbb): the fallback generated-column recompute now runs afterrewriteUpdateQueryLastNode(), soDEFAULT/ON UPDATErewrites are visible before generated expressions are derived; the generated-column lookup is mutable so generated-on-generated chains use freshly recomputed earlier expressions.Added planner coverage for the multi-target fallback + generated-column case, and for fallback generated columns over
DEFAULT,ON UPDATE, and generated-on-generated chains.