diff --git a/go/vt/vtgate/executor.go b/go/vt/vtgate/executor.go index 216ecf46394..d0e2acf5986 100644 --- a/go/vt/vtgate/executor.go +++ b/go/vt/vtgate/executor.go @@ -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) diff --git a/go/vt/vtgate/executor_test.go b/go/vt/vtgate/executor_test.go index c2ca76da80b..60d0dc2de3b 100644 --- a/go/vt/vtgate/executor_test.go +++ b/go/vt/vtgate/executor_test.go @@ -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) +}