release-20.2: sql: avoid looking up empty-string object names #58900
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport 2/2 commits from #58674.
/cc @cockroachdb/release
sql: fix name resolution to avoid empty-name db lookups
The internal executor has a current DB of "", and it also executes
against queries against system tables using names like
system.users
.The name resolution logic turned this into a lookup of "".system.users,
which was not desired.
Now we explicitly only allow the "" DB name if the schema name
corresponds to a virtual schema.
Release note: None
sql/catalog: avoid KV lookup for "" name
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