Skip to content

Commit

Permalink
parser: fix string repr of ALTER ... START REPLICATION
Browse files Browse the repository at this point in the history
Release note: none.
Epic: none.
  • Loading branch information
dt committed Jan 16, 2024
1 parent 515663b commit 067a73a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions pkg/sql/parser/testdata/alter_virtual_cluster
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,10 @@ ALTER VIRTUAL CLUSTER 'foo' SET REPLICATION RETENTION = '-2h' -- identifiers rem
parse
ALTER TENANT 'foo' START REPLICATION OF 'bar' ON 'baz' WITH RETENTION = '-1h'
----
ALTER VIRTUAL CLUSTER 'foo' SET REPLICATION RETENTION = '-1h' -- normalized!
ALTER VIRTUAL CLUSTER ('foo') SET REPLICATION RETENTION = ('-1h') -- fully parenthesized
ALTER VIRTUAL CLUSTER '_' SET REPLICATION RETENTION = '_' -- literals removed
ALTER VIRTUAL CLUSTER 'foo' SET REPLICATION RETENTION = '-1h' -- identifiers removed
ALTER VIRTUAL CLUSTER 'foo' START REPLICATION OF 'bar' ON 'baz' WITH RETENTION = '-1h' -- normalized!
ALTER VIRTUAL CLUSTER ('foo') START REPLICATION OF ('bar') ON ('baz') WITH RETENTION = ('-1h') -- fully parenthesized
ALTER VIRTUAL CLUSTER '_' START REPLICATION OF '_' ON '_' WITH RETENTION = '_' -- literals removed
ALTER VIRTUAL CLUSTER 'foo' START REPLICATION OF 'bar' ON 'baz' WITH RETENTION = '-1h' -- identifiers removed

parse
ALTER VIRTUAL CLUSTER 'foo' SET REPLICATION EXPIRATION WINDOW = '2h'
Expand Down
12 changes: 6 additions & 6 deletions pkg/sql/sem/tree/alter_tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@ func (n *AlterTenantReplication) Format(ctx *FmtCtx) {
ctx.WriteString("SYSTEM TIME ")
ctx.FormatNode(n.Cutover.Timestamp)
}
} else if !n.Options.IsDefault() {
ctx.WriteString("SET REPLICATION ")
ctx.FormatNode(&n.Options)
} else if n.Command == PauseJob || n.Command == ResumeJob {
ctx.WriteString(JobCommandToStatement[n.Command])
ctx.WriteString(" REPLICATION")
} else if n.ReplicationSourceTenantName != nil {
ctx.WriteString("START REPLICATION OF ")
ctx.FormatNode(n.ReplicationSourceTenantName)
Expand All @@ -67,6 +61,12 @@ func (n *AlterTenantReplication) Format(ctx *FmtCtx) {
ctx.WriteString(" WITH ")
ctx.FormatNode(&n.Options)
}
} else if !n.Options.IsDefault() {
ctx.WriteString("SET REPLICATION ")
ctx.FormatNode(&n.Options)
} else if n.Command == PauseJob || n.Command == ResumeJob {
ctx.WriteString(JobCommandToStatement[n.Command])
ctx.WriteString(" REPLICATION")
}
}

Expand Down

0 comments on commit 067a73a

Please sign in to comment.