Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backupccl] Use Expr for backup's Detached and Revision History options #85146

Merged
merged 1 commit into from
Jul 29, 2022

Conversation

benbardin
Copy link
Collaborator

This will allow us to set them to null, which will be helpful for ALTER commands.

Release note: None

@benbardin benbardin requested review from dt and a team July 27, 2022 16:13
@benbardin benbardin requested a review from a team as a code owner July 27, 2022 16:13
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@miretskiy
Copy link
Contributor

is the goal to do something like alter .... set revision_history=null to clear out revision history option?
Could we do "clear revision_history" instead? Just curious what the overall plan is.

@benbardin
Copy link
Collaborator Author

is the goal to do something like alter .... set revision_history=null to clear out revision history option? Could we do "clear revision_history" instead? Just curious what the overall plan is.

Not quite - We want to be able to take a BackupOptions struct, and distinguish between revision_history==false and revision_history==nil. In the former case we'll set revision_history to false, and in the latter case we'll make no changes (and assume that another field in BackupOptions is in fact set, representing the clause of the ALTER command). That make sense?

@benbardin benbardin force-pushed the backupexpr branch 2 times, most recently from 38b870f to 7d90c69 Compare July 27, 2022 22:11
@benbardin benbardin requested a review from a team as a code owner July 27, 2022 22:11
$$.val = &tree.BackupOptions{CaptureRevisionHistory: true}
$$.val = &tree.BackupOptions{CaptureRevisionHistory: tree.MakeDBool(true)}
}
| REVISION_HISTORY '=' TRUE
Copy link
Member

Choose a reason for hiding this comment

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

Should we just make this a general expr instead of the literals only? seems like placeholder support would be nice.

Copy link
Contributor

Choose a reason for hiding this comment

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

yep that would be best

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done, this look good?

Copy link
Member

Choose a reason for hiding this comment

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

yep, however now that it is an expr, you'll need to evaluate it rather than just compare it to DBoolTrue below, and I'm now looking at PlanHook and I'm not actually sure if we have that eval + check plumbed to here; might need to ask some sql folks how we should be eval'ing and typing as bool

Copy link
Contributor

Choose a reason for hiding this comment

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

I think since you know that this expression must be of type bool, you can
type check it yourself.

typedExpr, err := expr.TypeCheck(ctx, semaCtx, types.Bool)

@dt
Copy link
Member

dt commented Jul 28, 2022

side nit: following the go project style, we use pkgname: rather than [packagename] for commit prefixes

@benbardin benbardin force-pushed the backupexpr branch 5 times, most recently from 6676b1a to 71edb61 Compare July 28, 2022 18:31
@benbardin
Copy link
Collaborator Author

I made some changes to the planner to properly type-check bools, take another look?

Copy link
Member

@dt dt left a comment

Choose a reason for hiding this comment

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

Nice! one wrinkle with DETACHED which makes it special, but also maybe irrelevant to the ALTER work motivating this change

pkg/ccl/backupccl/backup_planning.go Outdated Show resolved Hide resolved
pkg/sql/parser/testdata/backup_restore Show resolved Hide resolved
Release note (sql change): Can now specify explicit "true" and "false" values
for "detached" and "revision_history" arguments in CREATE BACKUP and CREATE
SCHEDULE FOR BACKUP.
@benbardin
Copy link
Collaborator Author

Test failure appears on master, likely fixed by #85281

@benbardin
Copy link
Collaborator Author

bors r+

@craig
Copy link
Contributor

craig bot commented Jul 29, 2022

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Jul 29, 2022

Build failed (retrying...):

@craig craig bot merged commit 7e2df69 into cockroachdb:master Jul 29, 2022
@craig
Copy link
Contributor

craig bot commented Jul 29, 2022

Build succeeded:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants