Skip to content

Commit

Permalink
Merge pull request #6205 from adsr/fix-olap-select-db
Browse files Browse the repository at this point in the history
Fix panic with `select database()` in OLAP mode (#6200)
  • Loading branch information
harshit-gangal authored May 20, 2020
2 parents 2d7b53f + c6e5eac commit 3de43f6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions go/vt/vtgate/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,11 @@ func (e *Executor) StreamExecute(ctx context.Context, method string, safeSession
return err
}

err = e.addNeededBindVars(plan.BindVarNeeds, bindVars, safeSession)
if err != nil {
return err
}

execStart := time.Now()
logStats.PlanTime = execStart.Sub(logStats.StartTime)

Expand Down
18 changes: 18 additions & 0 deletions go/vt/vtgate/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2344,3 +2344,21 @@ func TestGenerateCharsetRows(t *testing.T) {
})
}
}

func TestOlapSelectDatabase(t *testing.T) {
executor, _, _, _ := createExecutorEnv()
executor.normalize = true

session := &vtgatepb.Session{Autocommit: true}

sql := `select database()`
target := querypb.Target{}
cbInvoked := false
cb := func(r *sqltypes.Result) error {
cbInvoked = true
return nil
}
err := executor.StreamExecute(context.Background(), "TestExecute", NewSafeSession(session), sql, nil, target, cb)
assert.NoError(t, err)
assert.True(t, cbInvoked)
}

0 comments on commit 3de43f6

Please sign in to comment.