Skip to content

Commit

Permalink
Fix panic with select database() in OLAP mode (#6200)
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Saponara <[email protected]>
  • Loading branch information
adsr committed May 20, 2020
1 parent 2d7b53f commit c6e5eac
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 c6e5eac

Please sign in to comment.