Skip to content

Commit 9cafba3

Browse files
committed
introduce --singleton-table DDL strategy flag
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
1 parent e87457e commit 9cafba3

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

go/vt/schema/ddl_strategy.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const (
3838
skipTopoFlag = "skip-topo" // legacy. Kept for backwards compatibility, but unused
3939
singletonFlag = "singleton"
4040
singletonContextFlag = "singleton-context"
41+
singletonTableFlag = "singleton-table"
4142
allowZeroInDateFlag = "allow-zero-in-date"
4243
postponeLaunchFlag = "postpone-launch"
4344
postponeCompletionFlag = "postpone-completion"
@@ -177,6 +178,11 @@ func (setting *DDLStrategySetting) IsSingletonContext() bool {
177178
return setting.hasFlag(singletonContextFlag)
178179
}
179180

181+
// IsSingletonTable checks if strategy options include --singleton-table
182+
func (setting *DDLStrategySetting) IsSingletonTable() bool {
183+
return setting.hasFlag(singletonTableFlag)
184+
}
185+
180186
// IsAllowZeroInDateFlag checks if strategy options include --allow-zero-in-date
181187
func (setting *DDLStrategySetting) IsAllowZeroInDateFlag() bool {
182188
return setting.hasFlag(allowZeroInDateFlag)
@@ -322,6 +328,7 @@ func (setting *DDLStrategySetting) RuntimeOptions() []string {
322328
case isFlag(opt, skipTopoFlag): // deprecated flag, parsed for backwards compatibility
323329
case isFlag(opt, singletonFlag):
324330
case isFlag(opt, singletonContextFlag):
331+
case isFlag(opt, singletonTableFlag):
325332
case isFlag(opt, allowZeroInDateFlag):
326333
case isFlag(opt, postponeLaunchFlag):
327334
case isFlag(opt, postponeCompletionFlag):

go/vt/schema/ddl_strategy_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ func TestParseDDLStrategy(t *testing.T) {
189189
options string
190190
isDeclarative bool
191191
isSingleton bool
192+
isSingletonContext bool
193+
isSingletonTable bool
192194
isPostponeLaunch bool
193195
isPostponeCompletion bool
194196
isInOrderCompletion bool
@@ -258,6 +260,20 @@ func TestParseDDLStrategy(t *testing.T) {
258260
runtimeOptions: "",
259261
isSingleton: true,
260262
},
263+
{
264+
strategyVariable: "vitess --singleton-context",
265+
strategy: DDLStrategyVitess,
266+
options: "--singleton-context",
267+
runtimeOptions: "",
268+
isSingletonContext: true,
269+
},
270+
{
271+
strategyVariable: "vitess --singleton-table",
272+
strategy: DDLStrategyVitess,
273+
options: "--singleton-table",
274+
runtimeOptions: "",
275+
isSingletonTable: true,
276+
},
261277
{
262278
strategyVariable: "online -postpone-launch",
263279
strategy: DDLStrategyOnline,
@@ -387,6 +403,8 @@ func TestParseDDLStrategy(t *testing.T) {
387403
assert.Equal(t, ts.options, setting.Options)
388404
assert.Equal(t, ts.isDeclarative, setting.IsDeclarative())
389405
assert.Equal(t, ts.isSingleton, setting.IsSingleton())
406+
assert.Equal(t, ts.isSingletonContext, setting.IsSingletonContext())
407+
assert.Equal(t, ts.isSingletonTable, setting.IsSingletonTable())
390408
assert.Equal(t, ts.isPostponeCompletion, setting.IsPostponeCompletion())
391409
assert.Equal(t, ts.isPostponeLaunch, setting.IsPostponeLaunch())
392410
assert.Equal(t, ts.isAllowConcurrent, setting.IsAllowConcurrent())

0 commit comments

Comments
 (0)