Skip to content

Commit

Permalink
sql/catalog: avoid KV lookup for "" name
Browse files Browse the repository at this point in the history
Sometimes the current DB is "". Normally we wouldn't try to resolve this
name, but if there's a mistake in name resolution logic, this check is a
simple way to avoid a KV lookup when we don't need it.

Release note: None
  • Loading branch information
rafiss committed Jan 11, 2021
1 parent fc2be3a commit b6075a2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/sql/catalog/catalogkv/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ func LookupObjectID(
parentSchemaID descpb.ID,
name string,
) (bool, descpb.ID, error) {
// Avoid a network round-trip if we accidentally ended up here without a
// name to look up.
if name == "" {
return false, descpb.InvalidID, nil
}
var key catalogkeys.DescriptorKey
if parentID == keys.RootNamespaceID {
key = catalogkeys.NewDatabaseKey(name)
Expand Down

0 comments on commit b6075a2

Please sign in to comment.