Skip to content

backup: add BEFORE/AFTER syntax to SHOW BACKUPS - #160085

Merged
craig[bot] merged 1 commit into
cockroachdb:masterfrom
kev-cao:backup/add-before-after-show
Dec 24, 2025
Merged

backup: add BEFORE/AFTER syntax to SHOW BACKUPS#160085
craig[bot] merged 1 commit into
cockroachdb:masterfrom
kev-cao:backup/add-before-after-show

Conversation

@kev-cao

@kev-cao kev-cao commented Dec 23, 2025

Copy link
Copy Markdown
Contributor

This commit adds the BEFORE <ts> AFTER <ts> to the SHOW BACKUPS syntax.

Epic: CRDB-57536

Informs: #159647

Release note: None

@kev-cao
kev-cao requested a review from a team as a code owner December 23, 2025 20:16
@kev-cao
kev-cao requested review from DrewKimball and removed request for a team December 23, 2025 20:16
@cockroach-teamcity

Copy link
Copy Markdown
Member

This change is Reviewable

@kev-cao
kev-cao requested review from Copilot and msbutler and removed request for DrewKimball December 23, 2025 20:16

Copilot AI 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.

Pull request overview

This PR adds time range filtering syntax to the SHOW BACKUPS command, allowing users to filter backups using BEFORE <timestamp> and/or AFTER <timestamp> clauses.

Key changes:

  • Introduces ShowBeforeAfter struct to represent time range filtering with BEFORE/AFTER expressions
  • Updates parser grammar to accept BEFORE/AFTER clauses in any order (normalized to BEFORE-AFTER)
  • Adds comprehensive test coverage for all syntax variations

Reviewed changes

Copilot reviewed 3 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/sql/sem/tree/show.go Adds ShowBeforeAfter struct with formatting and default-checking methods; integrates time range into ShowBackup AST node
pkg/sql/parser/sql.y Extends grammar to support opt_show_before_after_clause with BEFORE/AFTER in any order; adds helper function for type conversion
pkg/sql/parser/testdata/backup_restore Adds test cases covering BEFORE-only, AFTER-only, both clauses, and order normalization scenarios
docs/generated/sql/bnf/stmt_block.bnf Updates BNF grammar to include opt_show_before_after_clause in the SHOW BACKUPS syntax
docs/generated/sql/bnf/show_backup.bnf Updates BNF grammar for SHOW BACKUP statement to include the new time range clause

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/sql/sem/tree/show.go Outdated
Comment thread pkg/sql/sem/tree/show.go Outdated

func (s *ShowBeforeAfter) Format(ctx *FmtCtx) {
if s.Before != nil {
ctx.WriteString("BEFORE ")

@msbutler msbutler Dec 23, 2025

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i find it more intuitive for "after" to be returned before "before". as after indicates the lower bound. But maybe i'm weird. i don't have strong opinions.

e.g.: AFTER 10/1 BEFORE 10/3 reads easier to me than BEFORE 10/3 AFTER 10/1.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, i imagine BEFORE will be used less frequently

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yea I guess semantically it makes more sense for AFTER to show up first. I was thinking linguistically. I think your interpretation makes more sense.

@github-actions

Copy link
Copy Markdown
Contributor

Potential Bug(s) Detected

The three-stage Claude Code analysis has identified potential bug(s) in this PR that may warrant investigation.

Next Steps:
Please review the detailed findings in the workflow run.

Note: When viewing the workflow output, scroll to the bottom to find the Final Analysis Summary.

After you review the findings, please tag the issue as follows:

  • If the detected issue is real or was helpful in any way, please tag the issue with O-AI-Review-Real-Issue-Found
  • If the detected issue was not helpful in any way, please tag the issue with O-AI-Review-Not-Helpful

@github-actions github-actions Bot added the o-AI-Review-Potential-Issue-Detected AI reviewer found potential issue. Never assign manually—auto-applied by GH action only. label Dec 24, 2025
@github-actions

Copy link
Copy Markdown
Contributor

Potential Bug(s) Detected

The three-stage Claude Code analysis has identified potential bug(s) in this PR that may warrant investigation.

Next Steps:
Please review the detailed findings in the workflow run.

Note: When viewing the workflow output, scroll to the bottom to find the Final Analysis Summary.

After you review the findings, please tag the issue as follows:

  • If the detected issue is real or was helpful in any way, please tag the issue with O-AI-Review-Real-Issue-Found
  • If the detected issue was not helpful in any way, please tag the issue with O-AI-Review-Not-Helpful

This commit adds the `AFTER <ts> BEFORE <ts>` to the `SHOW BACKUPS`
syntax.

Epic: CRDB-57536

Informs: #159647

Release note: None
@kev-cao kev-cao removed the o-AI-Review-Potential-Issue-Detected AI reviewer found potential issue. Never assign manually—auto-applied by GH action only. label Dec 24, 2025
@kev-cao

kev-cao commented Dec 24, 2025

Copy link
Copy Markdown
Contributor Author

TFTR!

bors r=msbutler

@craig

craig Bot commented Dec 24, 2025

Copy link
Copy Markdown
Contributor

@craig
craig Bot merged commit 9c3c636 into cockroachdb:master Dec 24, 2025
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants