Skip to content
Merged
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
10 changes: 10 additions & 0 deletions go/test/endtoend/vtgate/misc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,16 @@ func TestOffsetAndLimitWithOLAP(t *testing.T) {
assertMatches(t, conn, "select id1 from t1 order by id1 limit 3 offset 2", "[[INT64(3)] [INT64(4)] [INT64(5)]]")
}

func TestSwitchBetweenOlapAndOltp(t *testing.T) {
ctx := context.Background()
conn, err := mysql.Connect(ctx, &vtParams)
require.NoError(t, err)
defer conn.Close()

exec(t, conn, "set workload='olap'")
exec(t, conn, "set workload='oltp'")
}

func assertMatches(t *testing.T, conn *mysql.Conn, query, expected string) {
t.Helper()
qr := exec(t, conn, query)
Expand Down
5 changes: 4 additions & 1 deletion go/vt/vtgate/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,7 @@ func (e *Executor) StreamExecute(ctx context.Context, method string, safeSession
// dictated by stream_buffer_size.
result := &sqltypes.Result{}
byteCount := 0
seenResults := false
err = plan.Instructions.StreamExecute(vcursor, bindVars, true, func(qr *sqltypes.Result) error {
// If the row has field info, send it separately.
// TODO(sougou): this behavior is for handling tests because
Expand All @@ -1005,6 +1006,7 @@ func (e *Executor) StreamExecute(ctx context.Context, method string, safeSession
if err := callback(qrfield); err != nil {
return err
}
seenResults = true
}

for _, row := range qr.Rows {
Expand All @@ -1015,6 +1017,7 @@ func (e *Executor) StreamExecute(ctx context.Context, method string, safeSession

if byteCount >= e.streamSize {
err := callback(result)
seenResults = true
result = &sqltypes.Result{}
byteCount = 0
if err != nil {
Expand All @@ -1026,7 +1029,7 @@ func (e *Executor) StreamExecute(ctx context.Context, method string, safeSession
})

// Send left-over rows.
if len(result.Rows) > 0 {
if len(result.Rows) > 0 || !seenResults {
if err := callback(result); err != nil {
return err
}
Expand Down