diff --git a/pkg/sql/sem/tree/backup.go b/pkg/sql/sem/tree/backup.go index 521be0067201..2406d6a3c7f2 100644 --- a/pkg/sql/sem/tree/backup.go +++ b/pkg/sql/sem/tree/backup.go @@ -294,7 +294,7 @@ func (o *RestoreOptions) Format(ctx *FmtCtx) { if o.IntoDB != nil { maybeAddSep() ctx.WriteString("into_db=") - o.IntoDB.Format(ctx) + ctx.formatNodeOrHideConstants(o.IntoDB) } if o.SkipMissingFKs { diff --git a/pkg/sql/sem/tree/format_test.go b/pkg/sql/sem/tree/format_test.go index 106ebced0a0b..9779ede0ac6e 100644 --- a/pkg/sql/sem/tree/format_test.go +++ b/pkg/sql/sem/tree/format_test.go @@ -127,6 +127,13 @@ func TestFormatStatement(t *testing.T) { `ALTER TYPE _ DROP VALUE _`}, {`ALTER TYPE a RENAME VALUE 'value1' TO 'value2'`, tree.FmtAnonymize, `ALTER TYPE _ RENAME VALUE _ TO _`}, + + {`RESTORE abc.xzy FROM 'a' WITH into_db='foo', skip_missing_foreign_keys`, + tree.FmtHideConstants | tree.FmtAnonymize, + `RESTORE TABLE _._ FROM _ WITH into_db=_, skip_missing_foreign_keys`}, + {`RESTORE FROM 'a' WITH into_db='foo', skip_missing_foreign_keys`, + tree.FmtHideConstants | tree.FmtAnonymize, + `RESTORE FROM _ WITH into_db=_, skip_missing_foreign_keys`}, } for i, test := range testData {