Skip to content

Commit

Permalink
introduce --singleton-table DDL strategy flag
Browse files Browse the repository at this point in the history
Signed-off-by: Shlomi Noach <[email protected]>
  • Loading branch information
shlomi-noach committed Nov 7, 2024
1 parent e87457e commit 9cafba3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
7 changes: 7 additions & 0 deletions go/vt/schema/ddl_strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const (
skipTopoFlag = "skip-topo" // legacy. Kept for backwards compatibility, but unused
singletonFlag = "singleton"
singletonContextFlag = "singleton-context"
singletonTableFlag = "singleton-table"
allowZeroInDateFlag = "allow-zero-in-date"
postponeLaunchFlag = "postpone-launch"
postponeCompletionFlag = "postpone-completion"
Expand Down Expand Up @@ -177,6 +178,11 @@ func (setting *DDLStrategySetting) IsSingletonContext() bool {
return setting.hasFlag(singletonContextFlag)
}

// IsSingletonTable checks if strategy options include --singleton-table
func (setting *DDLStrategySetting) IsSingletonTable() bool {
return setting.hasFlag(singletonTableFlag)
}

// IsAllowZeroInDateFlag checks if strategy options include --allow-zero-in-date
func (setting *DDLStrategySetting) IsAllowZeroInDateFlag() bool {
return setting.hasFlag(allowZeroInDateFlag)
Expand Down Expand Up @@ -322,6 +328,7 @@ func (setting *DDLStrategySetting) RuntimeOptions() []string {
case isFlag(opt, skipTopoFlag): // deprecated flag, parsed for backwards compatibility
case isFlag(opt, singletonFlag):
case isFlag(opt, singletonContextFlag):
case isFlag(opt, singletonTableFlag):
case isFlag(opt, allowZeroInDateFlag):
case isFlag(opt, postponeLaunchFlag):
case isFlag(opt, postponeCompletionFlag):
Expand Down
18 changes: 18 additions & 0 deletions go/vt/schema/ddl_strategy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ func TestParseDDLStrategy(t *testing.T) {
options string
isDeclarative bool
isSingleton bool
isSingletonContext bool
isSingletonTable bool
isPostponeLaunch bool
isPostponeCompletion bool
isInOrderCompletion bool
Expand Down Expand Up @@ -258,6 +260,20 @@ func TestParseDDLStrategy(t *testing.T) {
runtimeOptions: "",
isSingleton: true,
},
{
strategyVariable: "vitess --singleton-context",
strategy: DDLStrategyVitess,
options: "--singleton-context",
runtimeOptions: "",
isSingletonContext: true,
},
{
strategyVariable: "vitess --singleton-table",
strategy: DDLStrategyVitess,
options: "--singleton-table",
runtimeOptions: "",
isSingletonTable: true,
},
{
strategyVariable: "online -postpone-launch",
strategy: DDLStrategyOnline,
Expand Down Expand Up @@ -387,6 +403,8 @@ func TestParseDDLStrategy(t *testing.T) {
assert.Equal(t, ts.options, setting.Options)
assert.Equal(t, ts.isDeclarative, setting.IsDeclarative())
assert.Equal(t, ts.isSingleton, setting.IsSingleton())
assert.Equal(t, ts.isSingletonContext, setting.IsSingletonContext())
assert.Equal(t, ts.isSingletonTable, setting.IsSingletonTable())
assert.Equal(t, ts.isPostponeCompletion, setting.IsPostponeCompletion())
assert.Equal(t, ts.isPostponeLaunch, setting.IsPostponeLaunch())
assert.Equal(t, ts.isAllowConcurrent, setting.IsAllowConcurrent())
Expand Down

0 comments on commit 9cafba3

Please sign in to comment.