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

parser: fix string repr of ALTER ... START REPLICATION #117834

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
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
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