Skip to content

[planbuilder] nil database doesn't panic building procedure call #2894

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions enginetest/enginetests.go
Original file line number Diff line number Diff line change
Expand Up @@ -4877,6 +4877,7 @@ func TestNoDatabaseSelected(t *testing.T, harness Harness) {
AssertErrWithCtx(t, e, harness, ctx, "create table a (b int primary key)", nil, sql.ErrNoDatabaseSelected)
AssertErrWithCtx(t, e, harness, ctx, "show tables", nil, sql.ErrNoDatabaseSelected)
AssertErrWithCtx(t, e, harness, ctx, "show triggers", nil, sql.ErrNoDatabaseSelected)
AssertErrWithCtx(t, e, harness, ctx, "call non_existent_proc()", nil, sql.ErrNoDatabaseSelected)

_, _, _, err := e.Query(ctx, "ROLLBACK")
require.NoError(t, err)
Expand Down
3 changes: 3 additions & 0 deletions sql/planbuilder/proc.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ func (b *Builder) buildCall(inScope *scope, c *ast.Call) (outScope *scope) {
} else if b.ctx.GetCurrentDatabase() != "" {
db = b.currentDb()
}
if db == nil {
b.handleErr(sql.ErrNoDatabaseSelected.New())
}

var proc *plan.Procedure
var innerQFlags *sql.QueryFlags
Expand Down
Loading