Skip to content

fix: ignore temporary aliases in standalone table rename - #31136

Merged
XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
iamlinjunhong:codex/loom/develop/ac5ef1edf3aa9854d70db7e7e2b350f5785f42ff4b291c668684803a72d71be5
Nov 1, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
iamlinjunhong:codex/loom/develop/ac5ef1edf3aa9854d70db7e7e2b350f5785f42ff4b291c668684803a72d71be5

Conversation

@iamlinjunhong

@iamlinjunhong iamlinjunhong commented Oct 25, 2026 •

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:

What this PR does / why we need it:

RENAME TABLE failed when a session temporary table shadowed its persisted source, and incorrectly rejected destinations occupied only by a temporary alias.

Add an explicit compiler-context operation that skips temporary aliases for both standalone rename lookups while preserving catalog visibility and temporary ownership checks. Temporary-only sources report a missing table; temporary-only destinations remain available. Ordinary SELECT/DML and ALTER TABLE retain temporary-first behavior. View metadata contexts explicitly reject the DDL-only operation.

Original validation (acaa9997ba, reused for unchanged resolver behavior): focused planner/resolver tests, complete plan/frontend/compile packages, protocol regressions for rows and stable table IDs, prepared statements, failed multi-pair renames and physical temporary-table isolation. The SQL BVT passed twice (53/53 each), with database/table cleanup checked between runs. Native service build, affected-package vet, incremental lint and formatting checks passed on Go1.27.1 darwin/arm64.

No wire or catalog format changes. The reporter should verify the issue after merge.

Maintenance validation: rebase onto official main 99bd895c46 preserved the original PR patch. CI run 40219577066, attempt 2 passed the required checks at bd4fa09cfb.

Prepared rename correction (fcce381f85dd2c608be8d59f7c949f3330b4201a): capture persisted source and destination dependencies using the same namespace as the rename plan. Cross-session replacement of a shadowed source now triggers normal view rejection; creation of a persisted destination triggers the normal collision error. This addresses the prepared-schema review feedback.

New validation on Go1.27.1 darwin/arm64: CGo-wrapper go test -count=1 passed the focused TestCollectPrepareDdlSchemas.* / TestBuildRenameTable.* tests, the complete pkg/sql/plan package, and the extended TestRenameTableIgnoresTemporaryAliases real-protocol regression. The SQL test checks source/view replacement, destination collision, preserved rows and table identities. Both new regressions failed on the unfixed source as expected. Formatting, four-package affected-closure vet/incremental lint, and the exact-commit Loom artifact check passed. Unchanged resolver/BVT evidence above is reused; no new multi-CN, race or performance claim. New-head CI has not been awaited.

Official-main CI refresh (d72d6170d8a1e473369230acdd987c4d28c28e67, based on ae40f12a647880a63466de32a9f507c2c72dca0b): both PR patches remain unchanged in git range-diff. The previous coverage rerun failed in embedded-cluster admission during upgrade recovery; this update picks up the current main/CI corrections and triggers fresh CI. No additional product change or old-run rerun.

New validation at this revision (Go1.27.1 darwin/arm64, go test -count=1): focused planner/PREPARE tests and the complete pkg/sql/plan package passed; frontend/compile resolver ownership and delegation controls passed; TestRenameTableIgnoresTemporaryAliases and TestRenameTableImplicitCommit passed through real SQL. Matching pinned usearch/libmo were built in the task temporary directory because the retained local native installation has the old API; the documented expanded CGo test flags used these staged libraries. Formatting, whitespace and exact-commit artifact checks passed. Historical BVT/red-baseline evidence above is reused; full current CI remains 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 Oct 25, 2026
@matrix-meow matrix-meow added the size/L Denotes a PR that changes [500,999] lines label Oct 25, 2026
@iamlinjunhong
iamlinjunhong force-pushed the codex/loom/develop/ac5ef1edf3aa9854d70db7e7e2b350f5785f42ff4b291c668684803a72d71be5 branch from acaa999 to bd4fa09 Compare October 25, 2026 18:05
@XuPeng-SH

XuPeng-SH commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: bd4fa09cfbcb0704bd90359a8b951ed681a56dfd

Review completed. Read the assessment.

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

mo-bot review · mo-bot-local · review

Commit: bd4fa09cfbcb0704bd90359a8b951ed681a56dfd

Assessment: request_changes

Reviewed the complete 17-file delta. The explicit resolver policy appropriately reuses existing ownership and visibility checks, but prepared-statement dependency collection remains inconsistent and causes a reproduced executor panic.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1

  • P2 pkg/sql/plan/build_ddl.go:6874: Session A creates a temporary table shadowing persisted src and prepares 'RENAME TABLE src TO dst'. Session B drops persisted src and creates a view named src. Session A executes the prepared statement.
    Impact: The rename plan targets the persisted table, but collectPrepareDdlSchemas still uses temporary-first Resolve at build_dcl.go:508. Consequently, persisted-source replacement does not invalidate the plan. EXECUTE reaches doLockTable with stale table metadata and returns a recovered 'panic invalid primary keys' instead of rejecting the view normally. Apply the same alias-free resolution policy to standalone RENAME's prepared source/destination dependencies and add a cross-session replacement regression.
    Evidence: The diagnostic planner probe records temporary ID 99 while the rename plan targets persisted ID 11. The two-session SQL probe reproduces the recovered panic; fresh RENAME and the unshadowed prepared control return the normal view-rejection error. See planner-probe.log and protocol-probe.log:1195 in the assigned attempt directory.

Validation:

  • Artifacts retained under /home/xupeng/.local/state/mo-bot/jobs/c315505c4a13c3a5e2e843dd/attempt-1. review-evidence.json reconciles commands, source fingerprints, exit receipts, log hashes and test-only overlays; source remained unchanged.

  • Isolation preflight passed. Missing native prerequisites were rebuilt through make cgo using hash-verified frozen inputs; native-build.log and native-inputs.json/native-outputs.json preserve provenance.

  • planner-probe.log, receipt checks/1792961019340603463-6.json: all nine existing rename-planner cases and the unshadowed dependency control passed; the shadowed dependency assertion failed.

  • protocol-probe.log, receipt checks/1792961073120841232-3.json: the real SQL replacement probe reproduced the recovered panic; cluster cleanup completed.

  • git diff --check passed. Evidence audit passed with receipt checks/1792961161279688738-4.json.

Limitations:

  • Frozen CI reports successful UT, SCA and BVT checks; raw CI/author logs were not supplied. Full suites were not rerun locally.

  • The linked issue's full body was unavailable; its behavioral contract was assessed from the frozen PR description.

  • No performance benchmark was run. Source tracing shows constant-cost resolver dispatch, no added catalog I/O or shared state, and removal of the alias lookup from standalone rename resolution.

@XuPeng-SH

XuPeng-SH commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: d72d6170d8a1e473369230acdd987c4d28c28e67

Review completed. Read the assessment.

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

mo-bot review · mo-bot-local · review

Commit: d72d6170d8a1e473369230acdd987c4d28c28e67

Assessment: approve

Reviewed the complete 19-file change and affected consumers. Standalone rename and prepared dependencies consistently use persisted names while preserving temporary-table ownership and ordinary ALTER behavior. Prior review 5645200817 is resolved; no actionable findings remain.

Model: gpt-6-astra / xhigh

Session: 01a1869d-820c-7212-9788-aecfb86a4141 · slot 0 · generation 2

Validation:

  • Focused tests passed across four packages: 19 top-level tests, 51 total test/subtest passes, zero failures or skips. Includes public SQL tests for cross-session invalidation and transaction behavior. Evidence: focused-tests.jsonl and checks/1793462260583602280-3.json.

  • Isolation preflight passed; reused native artifacts matched 193 current inputs and seven output hashes.

  • Final audit confirmed the frozen head, unchanged source, complete patch match and assessment of all four discussion entries. Evidence: validation-summary.json and checks/1793462394793566071-4.json.

  • Frozen evidence reports successful UT, static analysis and enabled BVT checks; skipped checks were not counted as passes.

Limitations:

  • Full package and BVT suites were not rerun locally; raw CI logs and author-reported older-head runs were not independently verified.

@mergify

mergify Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

This branch was previously deployed

1 inactive deployment
ci — d72d6170 Deployed Oct 31, 2026 by iamlinjunhong
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/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants