diff --git a/go/vt/vtgate/engine/memory_sort.go b/go/vt/vtgate/engine/memory_sort.go index 6d2c36682ad..b896b303923 100644 --- a/go/vt/vtgate/engine/memory_sort.go +++ b/go/vt/vtgate/engine/memory_sort.go @@ -63,17 +63,6 @@ func (ms *MemorySort) SetTruncateColumnCount(count int) { ms.TruncateColumnCount = count } -func PanicHandler(err *error) { - if r := recover(); r != nil { - badness, ok := r.(error) - if !ok { - panic(r) - } - - *err = badness - } -} - // TryExecute satisfies the Primitive interface. func (ms *MemorySort) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error) { count, err := ms.fetchCount(ctx, vcursor, bindVars) @@ -97,7 +86,7 @@ func (ms *MemorySort) TryExecute(ctx context.Context, vcursor VCursor, bindVars // TryStreamExecute satisfies the Primitive interface. func (ms *MemorySort) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) (err error) { - defer PanicHandler(&err) + defer evalengine.PanicHandler(&err) count, err := ms.fetchCount(ctx, vcursor, bindVars) if err != nil { @@ -117,7 +106,6 @@ func (ms *MemorySort) TryStreamExecute(ctx context.Context, vcursor VCursor, bin if err := cb(&sqltypes.Result{Fields: qr.Fields}); err != nil { return err } - sorter.SetFields(qr.Fields) } for _, row := range qr.Rows { sorter.Push(row) diff --git a/go/vt/vtgate/engine/merge_sort.go b/go/vt/vtgate/engine/merge_sort.go index 2135d00b633..3c26a383594 100644 --- a/go/vt/vtgate/engine/merge_sort.go +++ b/go/vt/vtgate/engine/merge_sort.go @@ -76,7 +76,7 @@ func (ms *MergeSort) GetFields(ctx context.Context, vcursor VCursor, bindVars ma // TryStreamExecute performs a streaming exec. func (ms *MergeSort) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) (err error) { - defer PanicHandler(&err) + defer evalengine.PanicHandler(&err) var cancel context.CancelFunc ctx, cancel = context.WithCancel(ctx) @@ -104,7 +104,6 @@ func (ms *MergeSort) TryStreamExecute(ctx context.Context, vcursor VCursor, bind if err := callback(&sqltypes.Result{Fields: fields}); err != nil { return err } - merge.SetFields(fields) } var errs []error diff --git a/go/vt/vtgate/evalengine/api_compare.go b/go/vt/vtgate/evalengine/api_compare.go index 195a38d5422..6d6629ea287 100644 --- a/go/vt/vtgate/evalengine/api_compare.go +++ b/go/vt/vtgate/evalengine/api_compare.go @@ -311,23 +311,15 @@ type Sorter struct { Compare Comparison Limit int - weights []tinyWeighter - rows []sqltypes.Row - heap bool + rows []sqltypes.Row + heap bool } func (s *Sorter) Len() int { return len(s.rows) } -func (s *Sorter) SetFields(f []*querypb.Field) { - s.weights = s.Compare.tinyWeighters(f) -} - func (s *Sorter) Push(row sqltypes.Row) { - for _, w := range s.weights { - w.apply(&row[w.col]) - } if len(s.rows) < s.Limit { s.rows = append(s.rows, row) return @@ -367,9 +359,8 @@ type mergeRow struct { type Merger struct { Compare Comparison - weights []tinyWeighter - rows []mergeRow - less func(a, b mergeRow) bool + rows []mergeRow + less func(a, b mergeRow) bool } func (m *Merger) Len() int { @@ -383,10 +374,6 @@ func (m *Merger) Init() { heapify(m.rows, m.less) } -func (m *Merger) SetFields(f []*querypb.Field) { - m.weights = m.Compare.tinyWeighters(f) -} - func (m *Merger) Push(row sqltypes.Row, source int) { m.rows = append(m.rows, mergeRow{row, source}) if m.less != nil {