Skip to content

Commit

Permalink
backupccl: use FmtParsable when storing statement in scheduled backup
Browse files Browse the repository at this point in the history
Previously, the executed backup statement for schedules was serialized and
stored using FmtSimple. This format can be lossy and the preferred format to
retain all information is FmtParsable. This patch switches the serialization to
use FmtParsable.

Resolves #63216

Release justification: change should have no impact on current backup schedules.

Release note: None
  • Loading branch information
Rui Hu committed Sep 9, 2021
1 parent b444f85 commit c30d567
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions pkg/ccl/backupccl/create_scheduled_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ func doCreateBackupSchedules(
if err != nil {
return errors.Wrapf(err, "failed to evaluate backup encryption_passphrase")
}
backupNode.Options.EncryptionPassphrase = tree.NewDString(pw)
backupNode.Options.EncryptionPassphrase = tree.NewStrVal(pw)
}

// Evaluate encryption KMS URIs if set.
Expand All @@ -360,7 +360,7 @@ func doCreateBackupSchedules(
}
for _, kmsURI := range kmsURIs {
backupNode.Options.EncryptionKMSURI = append(backupNode.Options.EncryptionKMSURI,
tree.NewDString(kmsURI))
tree.NewStrVal(kmsURI))
}
}

Expand All @@ -371,7 +371,7 @@ func doCreateBackupSchedules(
}

for _, dest := range destinations {
backupNode.To = append(backupNode.To, tree.NewDString(dest))
backupNode.To = append(backupNode.To, tree.NewStrVal(dest))
}

backupNode.Targets = eval.Targets
Expand Down Expand Up @@ -600,10 +600,7 @@ func makeBackupSchedule(

// We do not set backupNode.AsOf: this is done when the scheduler kicks off the backup.
// Serialize backup statement and set schedule executor and its args.
//
// TODO(bulkio): this serialization is erroneous, see issue
// https://github.com/cockroachdb/cockroach/issues/63216
args.BackupStatement = tree.AsStringWithFlags(backupNode, tree.FmtSimple|tree.FmtShowPasswords)
args.BackupStatement = tree.AsStringWithFlags(backupNode, tree.FmtParsable|tree.FmtShowPasswords)
any, err := pbtypes.MarshalAny(args)
if err != nil {
return nil, nil, err
Expand Down

0 comments on commit c30d567

Please sign in to comment.