Skip to content

Commit 24caf07

Browse files
author
James Cor
committed
don't use put for now
1 parent 31e6671 commit 24caf07

File tree

3 files changed

+30
-13
lines changed

3 files changed

+30
-13
lines changed

server/handler.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,10 @@ func (h *Handler) resultForDefaultIter(ctx *sql.Context, c *mysql.Conn, schema s
701701
defer wg.Done()
702702
for {
703703
if r == nil {
704-
r = &sqltypes.Result{Fields: resultFields}
704+
r = &sqltypes.Result{
705+
Fields: resultFields,
706+
Rows: make([][]sqltypes.Value, 0, rowsBatch),
707+
}
705708
}
706709
if r.RowsAffected == rowsBatch {
707710
if err := resetCallback(r, more); err != nil {

sql/rowexec/join_iters.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,9 @@ func (i *joinIter) buildRow(primary, secondary sql.Row) sql.Row {
212212
}
213213

214214
func (i *joinIter) Close(ctx *sql.Context) (err error) {
215-
i.rowBuffer.Reset()
216-
sql.RowBufPool.Put(i.rowBuffer)
215+
//i.rowBuffer.Reset()
216+
//sql.RowBufPool.Put(i.rowBuffer)
217+
i.rowBuffer = nil
217218

218219
if i.primary != nil {
219220
if err = i.primary.Close(ctx); err != nil {
@@ -416,8 +417,9 @@ func (i *existsIter) buildRow(primary, secondary sql.Row) sql.Row {
416417
}
417418

418419
func (i *existsIter) Close(ctx *sql.Context) (err error) {
419-
i.rowBuffer.Reset()
420-
sql.RowBufPool.Put(i.rowBuffer)
420+
i.rowBuffer = nil
421+
//i.rowBuffer.Reset()
422+
//sql.RowBufPool.Put(i.rowBuffer)
421423

422424
if i.primary != nil {
423425
if err = i.primary.Close(ctx); err != nil {
@@ -587,8 +589,9 @@ func (i *fullJoinIter) buildRow(primary, secondary sql.Row) sql.Row {
587589
}
588590

589591
func (i *fullJoinIter) Close(ctx *sql.Context) (err error) {
590-
i.rowBuffer.Reset()
591-
sql.RowBufPool.Put(i.rowBuffer)
592+
i.rowBuffer = nil
593+
//i.rowBuffer.Reset()
594+
//sql.RowBufPool.Put(i.rowBuffer)
592595

593596
if i.l != nil {
594597
err = i.l.Close(ctx)
@@ -706,8 +709,9 @@ func (i *crossJoinIterator) removeParentRow(r sql.Row) sql.Row {
706709
}
707710

708711
func (i *crossJoinIterator) Close(ctx *sql.Context) (err error) {
709-
i.rowBuffer.Reset() // TODO: just set i.rowBuffer = nil?
710-
sql.RowBufPool.Put(i.rowBuffer)
712+
i.rowBuffer = nil
713+
//i.rowBuffer.Reset()
714+
//sql.RowBufPool.Put(i.rowBuffer)
711715

712716
if i.l != nil {
713717
err = i.l.Close(ctx)
@@ -909,8 +913,9 @@ func (i *lateralJoinIterator) Next(ctx *sql.Context) (sql.Row, error) {
909913
}
910914

911915
func (i *lateralJoinIterator) Close(ctx *sql.Context) error {
912-
i.rowBuffer.Reset()
913-
sql.RowBufPool.Put(i.rowBuffer)
916+
i.rowBuffer = nil
917+
//i.rowBuffer.Reset()
918+
//sql.RowBufPool.Put(i.rowBuffer)
914919

915920
var lerr, rerr error
916921
if i.lIter != nil {

sql/rowexec/range_heap_iter.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ type rangeHeapJoinIter struct {
3636
childRowIter sql.RowIter
3737
pendingRow sql.Row
3838
activeRanges []sql.Row
39+
40+
rowBuffer *sql.RowBuffer
3941
}
4042

4143
func newRangeHeapJoinIter(ctx *sql.Context, b sql.NodeExecBuilder, j *plan.JoinNode, row sql.Row) (sql.RowIter, error) {
@@ -68,9 +70,11 @@ func newRangeHeapJoinIter(ctx *sql.Context, b sql.NodeExecBuilder, j *plan.JoinN
6870
return nil, errors.New("right side of join must be a range heap")
6971
}
7072

73+
rowBuffer := sql.RowBufPool.Get().(*sql.RowBuffer)
74+
7175
parentLen := len(row)
7276

73-
primaryRow := make(sql.Row, parentLen+len(j.Left().Schema()))
77+
primaryRow := rowBuffer.Get(parentLen + len(j.Left().Schema()))
7478
copy(primaryRow, row)
7579

7680
return sql.NewSpanIter(span, &rangeHeapJoinIter{
@@ -88,6 +92,8 @@ func newRangeHeapJoinIter(ctx *sql.Context, b sql.NodeExecBuilder, j *plan.JoinN
8892
parentLen: parentLen,
8993

9094
rangeHeapPlan: rhp,
95+
96+
rowBuffer: rowBuffer,
9197
}), nil
9298
}
9399

@@ -202,13 +208,16 @@ func (iter *rangeHeapJoinIter) removeParentRow(r sql.Row) sql.Row {
202208

203209
// buildRow builds the result set row using the rows from the primary and secondary tables
204210
func (iter *rangeHeapJoinIter) buildRow(primary, secondary sql.Row) sql.Row {
205-
row := make(sql.Row, iter.rowSize)
211+
row := iter.rowBuffer.Get(iter.rowSize)
206212
copy(row, primary)
207213
copy(row[len(primary):], secondary)
208214
return row
209215
}
210216

211217
func (iter *rangeHeapJoinIter) Close(ctx *sql.Context) (err error) {
218+
iter.rowBuffer.Reset()
219+
sql.RowBufPool.Put(iter.rowBuffer)
220+
212221
if iter.primary != nil {
213222
if err = iter.primary.Close(ctx); err != nil {
214223
if iter.secondary != nil {

0 commit comments

Comments
 (0)