Skip to content

fix: support ACCOUNT clause in RESTORE ... FROM PITR - #24591

Merged
XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
Torrent2002:codex/issue-24545
May 28, 2026
Merged

fix: support ACCOUNT clause in RESTORE ... FROM PITR#24591
XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
Torrent2002:codex/issue-24545

Conversation

@Torrent2002

@Torrent2002 Torrent2002 commented May 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #24545.

This PR fixes the grammar inconsistency between RESTORE ... FROM SNAPSHOT and RESTORE ... FROM PITR.

Previously, RESTORE ACCOUNT <tenant> DATABASE ... TABLE ... FROM SNAPSHOT ... was accepted, but the equivalent FROM PITR forms failed in the parser. This change adds support for the ACCOUNT clause in scoped PITR restore statements and keeps the restore privilege checks aligned with the existing snapshot behavior.

What changed

  • add parser support for:
    • RESTORE ACCOUNT <acc> DATABASE <db> FROM PITR ...
    • RESTORE ACCOUNT <acc> DATABASE <db> TABLE <tbl> FROM PITR ...
  • update PITR AST formatting for the new scoped account forms
  • ensure scoped PITR restore only treats ACCOUNT as cross-account restore at the account restore level
  • keep database/table restore validation aligned with snapshot semantics by only allowing explicit ACCOUNT when it matches the current tenant
  • add parser coverage and a distributed regression case for the new syntax

Testing

  • go test ./pkg/sql/parsers/dialect/mysql -run 'TestValid|TestPitrInternal' -count=1
  • added distributed regression:
    • test/distributed/cases/pitr/pitr_restore_account_clause.sql

Notes

  • local pkg/frontend targeted tests were not runnable in this environment because unrelated native dependencies failed to build (for example usearch.h was missing)
  • distributed tests were not executed locally because the current environment does not have a runnable mo-tester setup

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

@CLAassistant

CLAassistant commented May 26, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ XuPeng-SH
❌ Torrent2002
You have signed the CLA already but the status is still pending? Let us recheck it.

@matrix-meow matrix-meow added the size/XXL Denotes a PR that changes 2000+ lines label May 26, 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.

Reviewed multi-angle: parser/AST support for scoped RESTORE ACCOUNT ... DATABASE/TABLE ... FROM PITR is wired correctly, doRestorePitr now treats explicit ACCOUNT as cross-account only at account-restore level, and scoped PITR restore only allows explicit ACCOUNT when it matches the current tenant, which keeps the behavior aligned with snapshot semantics. The added parser/frontend/distributed coverage matches the change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Inconsistent RESTORE grammar — FROM PITR rejects the ACCOUNT clause that FROM SNAPSHOT requires

5 participants