Skip to content

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

Open
Torrent2002 wants to merge 4 commits into
matrixorigin:mainfrom
Torrent2002:codex/issue-24545
Open

fix: support ACCOUNT clause in RESTORE ... FROM PITR#24591
Torrent2002 wants to merge 4 commits into
matrixorigin:mainfrom
Torrent2002:codex/issue-24545

Conversation

@Torrent2002
Copy link
Copy Markdown
Collaborator

@Torrent2002 Torrent2002 commented May 26, 2026

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
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 sign our Contributor License Agreement before we can accept your contribution.
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
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

4 participants