github.com/cockroachdb/cockroachdb-parser@v0.23.3-0.20240213214944-911057d40c9a/pkg/sql/sem/tree/alter_backup.go (about) 1 // Copyright 2022 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 package tree 12 13 // AlterBackup represents an ALTER BACKUP statement. 14 type AlterBackup struct { 15 // Backup contains the locations for the backup we seek to add new keys to. 16 Backup Expr 17 Subdir Expr 18 Cmds AlterBackupCmds 19 } 20 21 var _ Statement = &AlterBackup{} 22 23 // Format implements the NodeFormatter interface. 24 func (node *AlterBackup) Format(ctx *FmtCtx) { 25 ctx.WriteString("ALTER BACKUP ") 26 27 if node.Subdir != nil { 28 ctx.FormatNode(node.Subdir) 29 ctx.WriteString(" IN ") 30 } 31 32 ctx.FormatNode(node.Backup) 33 ctx.FormatNode(&node.Cmds) 34 } 35 36 // AlterBackupCmds is an array of type AlterBackupCmd 37 type AlterBackupCmds []AlterBackupCmd 38 39 // Format implements the NodeFormatter interface. 40 func (node *AlterBackupCmds) Format(ctx *FmtCtx) { 41 for i, n := range *node { 42 if i > 0 { 43 ctx.WriteString(" ") 44 } 45 ctx.FormatNode(n) 46 } 47 } 48 49 // AlterBackupCmd represents a backup modification operation. 50 type AlterBackupCmd interface { 51 NodeFormatter 52 alterBackupCmd() 53 } 54 55 func (node *AlterBackupKMS) alterBackupCmd() {} 56 57 var _ AlterBackupCmd = &AlterBackupKMS{} 58 59 // AlterBackupKMS represents a possible alter_backup_cmd option. 60 type AlterBackupKMS struct { 61 KMSInfo BackupKMS 62 } 63 64 // Format implements the NodeFormatter interface. 65 func (node *AlterBackupKMS) Format(ctx *FmtCtx) { 66 ctx.WriteString(" ADD NEW_KMS=") 67 ctx.FormatNode(&node.KMSInfo.NewKMSURI) 68 69 ctx.WriteString(" WITH OLD_KMS=") 70 ctx.FormatNode(&node.KMSInfo.OldKMSURI) 71 } 72 73 // BackupKMS represents possible options used when altering a backup KMS 74 type BackupKMS struct { 75 NewKMSURI StringOrPlaceholderOptList 76 OldKMSURI StringOrPlaceholderOptList 77 }