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

sqlsmith: make sure we don't call ALTER DATABASE SURVIVE with invalid goal #74335

Merged
merged 1 commit into from
Dec 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions pkg/internal/sqlsmith/alter.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,13 @@ func makeAlterDatabaseDropRegion(s *Smither) (tree.Statement, bool) {
}

func makeAlterSurvivalGoal(s *Smither) (tree.Statement, bool) {
const numSurvivalGoals = 3
randInt := rand.Intn(numSurvivalGoals)
const numSurvivalGoals = 2
// Only {1, 2} are valid values for SurvivalGoal.
// 1. SurvivalGoalRegionFailure
// 2. SurvivalGoalZoneFailure
//
// 0. SurvivalGoalDefault is not valid as a value to alter to.
randInt := rand.Intn(numSurvivalGoals) + 1
survivalGoal := tree.SurvivalGoal(randInt)

ast := &tree.AlterDatabaseSurvivalGoal{
Expand Down