Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: don't panic on auth check with unopen txn #85996

Merged
merged 1 commit into from
Aug 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pkg/sql/authorization.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (p *planner) CheckPrivilegeForUser(
// Verify that the txn is valid in any case, so that
// we don't get the risk to say "OK" to root requests
// with an invalid API usage.
if p.txn == nil || !p.txn.IsOpen() {
if p.txn == nil {
return errors.AssertionFailedf("cannot use CheckPrivilege without a txn")
}

Expand Down Expand Up @@ -326,7 +326,7 @@ func (p *planner) CheckAnyPrivilege(
// Verify that the txn is valid in any case, so that
// we don't get the risk to say "OK" to root requests
// with an invalid API usage.
if p.txn == nil || !p.txn.IsOpen() {
if p.txn == nil {
return errors.AssertionFailedf("cannot use CheckAnyPrivilege without a txn")
}

Expand Down Expand Up @@ -377,7 +377,7 @@ func (p *planner) UserHasAdminRole(ctx context.Context, user username.SQLUsernam
// Verify that the txn is valid in any case, so that
// we don't get the risk to say "OK" to root requests
// with an invalid API usage.
if p.txn == nil || !p.txn.IsOpen() {
if p.txn == nil {
return false, errors.AssertionFailedf("cannot use HasAdminRole without a txn")
}

Expand Down Expand Up @@ -654,7 +654,7 @@ func (p *planner) HasRoleOption(ctx context.Context, roleOption roleoption.Optio
// Verify that the txn is valid in any case, so that
// we don't get the risk to say "OK" to root requests
// with an invalid API usage.
if p.txn == nil || !p.txn.IsOpen() {
if p.txn == nil {
return false, errors.AssertionFailedf("cannot use HasRoleOption without a txn")
}

Expand Down