Skip to content

fix(frontend): quote LCA primary key references - #26200

Merged
XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
gouhongshen:agent/issue-26071
Jul 27, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
gouhongshen:agent/issue-26071

Conversation

@gouhongshen

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 #26071

What this PR does / why we need it:

handleDelsOnLCA quoted the LCA database, table, and projected columns, but inserted raw primary-key names into the generated VALUES alias and join predicates. Reserved words or punctuation in a primary-key column therefore produced invalid SQL during DATA BRANCH DIFF, MERGE, and PICK.

This change quotes the LCA primary-key identifiers once and reuses the same ordered list for the VALUES alias, LCA references, and probe references. It preserves the existing key order and cast behavior.

Coverage includes:

  • a unit test that captures the generated join SQL for a reserved-word primary key;
  • BVT cases for single and composite quoted primary keys across DIFF, MERGE, and PICK.

Validation:

  • make build
  • go vet ./pkg/frontend
  • go test ./pkg/frontend -run "^TestHandleDelsOnLCA_SQLPaths$" -count=1
  • mo-tester ... -i branch_lca_quoted_pk -r 100 (32/32 passed)

@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 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 the LCA delete-probe SQL path.

The fix now quotes primary-key identifiers consistently in the VALUES alias and join predicates, while preserving key order and the existing cast behavior. The added unit/BVT coverage matches the reachable failure modes for reserved-word and punctuation PK names, and I did not find a high-confidence blocking correctness issue in this diff.

@XuPeng-SH
XuPeng-SH merged commit 9c1121e into matrixorigin:main Jul 27, 2026
2 of 5 checks passed
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes matrixorigin#26071

## What this PR does / why we need it:

`handleDelsOnLCA` quoted the LCA database, table, and projected columns,
but inserted raw primary-key names into the generated VALUES alias and
join predicates. Reserved words or punctuation in a primary-key column
therefore produced invalid SQL during DATA BRANCH DIFF, MERGE, and PICK.

This change quotes the LCA primary-key identifiers once and reuses the
same ordered list for the VALUES alias, LCA references, and probe
references. It preserves the existing key order and cast behavior.

Coverage includes:
- a unit test that captures the generated join SQL for a reserved-word
primary key;
- BVT cases for single and composite quoted primary keys across DIFF,
MERGE, and PICK.

Validation:
- `make build`
- `go vet ./pkg/frontend`
- `go test ./pkg/frontend -run "^TestHandleDelsOnLCA_SQLPaths$"
-count=1`
- `mo-tester ... -i branch_lca_quoted_pk -r 100` (32/32 passed)

Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes matrixorigin#26071

## What this PR does / why we need it:

`handleDelsOnLCA` quoted the LCA database, table, and projected columns,
but inserted raw primary-key names into the generated VALUES alias and
join predicates. Reserved words or punctuation in a primary-key column
therefore produced invalid SQL during DATA BRANCH DIFF, MERGE, and PICK.

This change quotes the LCA primary-key identifiers once and reuses the
same ordered list for the VALUES alias, LCA references, and probe
references. It preserves the existing key order and cast behavior.

Coverage includes:
- a unit test that captures the generated join SQL for a reserved-word
primary key;
- BVT cases for single and composite quoted primary keys across DIFF,
MERGE, and PICK.

Validation:
- `make build`
- `go vet ./pkg/frontend`
- `go test ./pkg/frontend -run "^TestHandleDelsOnLCA_SQLPaths$"
-count=1`
- `mo-tester ... -i branch_lca_quoted_pk -r 100` (32/32 passed)

Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes matrixorigin#26071

## What this PR does / why we need it:

`handleDelsOnLCA` quoted the LCA database, table, and projected columns,
but inserted raw primary-key names into the generated VALUES alias and
join predicates. Reserved words or punctuation in a primary-key column
therefore produced invalid SQL during DATA BRANCH DIFF, MERGE, and PICK.

This change quotes the LCA primary-key identifiers once and reuses the
same ordered list for the VALUES alias, LCA references, and probe
references. It preserves the existing key order and cast behavior.

Coverage includes:
- a unit test that captures the generated join SQL for a reserved-word
primary key;
- BVT cases for single and composite quoted primary keys across DIFF,
MERGE, and PICK.

Validation:
- `make build`
- `go vet ./pkg/frontend`
- `go test ./pkg/frontend -run "^TestHandleDelsOnLCA_SQLPaths$"
-count=1`
- `mo-tester ... -i branch_lca_quoted_pk -r 100` (32/32 passed)

Co-authored-by: XuPeng-SH <[email protected]>

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/test-ci size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: DATA BRANCH DIFF fails when LCA primary-key columns require quoting

3 participants