Skip to content

Commit

Permalink
sql: fix nil pointer error in RunPostDeserializationChanges
Browse files Browse the repository at this point in the history
In some restore paths, the privilegeDescriptor would be nil in
RunPostDeserializationChanges, avoid doing work on a nil pointer.

Release note: None
  • Loading branch information
RichardJCai committed Feb 7, 2022
1 parent 9ef0fed commit ff8e7cf
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/sql/catalog/dbdesc/database_desc_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ func (ddb *databaseDescriptorBuilder) RunRestoreChanges(
func maybeConvertIncompatibleDBPrivilegesToDefaultPrivileges(
privileges *descpb.PrivilegeDescriptor, defaultPrivileges *descpb.DefaultPrivilegeDescriptor,
) (hasChanged bool) {
// If privileges are nil, there is nothing to convert.
// This case can happen during restore where privileges are not yet created.
if privileges == nil {
return false
}

var pgIncompatibleDBPrivileges = privilege.List{
privilege.SELECT, privilege.INSERT, privilege.UPDATE, privilege.DELETE,
}
Expand Down

0 comments on commit ff8e7cf

Please sign in to comment.