@@ -189,6 +189,8 @@ func (i *joinIter) Next(ctx *sql.Context) (sql.Row, error) {
189189 }
190190
191191 if ! sql .IsTrue (res ) {
192+ // TODO: we are trashing row here, so we can release the memory...right?
193+ i .rowBuffer .Erase (i .rowSize )
192194 continue
193195 }
194196
@@ -212,9 +214,8 @@ func (i *joinIter) buildRow(primary, secondary sql.Row) sql.Row {
212214}
213215
214216func (i * joinIter ) Close (ctx * sql.Context ) (err error ) {
215- //i.rowBuffer.Reset()
216- //sql.RowBufPool.Put(i.rowBuffer)
217- i .rowBuffer = nil
217+ i .rowBuffer .Reset ()
218+ sql .RowBufPool .Put (i .rowBuffer )
218219
219220 if i .primary != nil {
220221 if err = i .primary .Close (ctx ); err != nil {
@@ -417,9 +418,8 @@ func (i *existsIter) buildRow(primary, secondary sql.Row) sql.Row {
417418}
418419
419420func (i * existsIter ) Close (ctx * sql.Context ) (err error ) {
420- i .rowBuffer = nil
421- //i.rowBuffer.Reset()
422- //sql.RowBufPool.Put(i.rowBuffer)
421+ i .rowBuffer .Reset ()
422+ sql .RowBufPool .Put (i .rowBuffer )
423423
424424 if i .primary != nil {
425425 if err = i .primary .Close (ctx ); err != nil {
@@ -589,9 +589,8 @@ func (i *fullJoinIter) buildRow(primary, secondary sql.Row) sql.Row {
589589}
590590
591591func (i * fullJoinIter ) Close (ctx * sql.Context ) (err error ) {
592- i .rowBuffer = nil
593- //i.rowBuffer.Reset()
594- //sql.RowBufPool.Put(i.rowBuffer)
592+ i .rowBuffer .Reset ()
593+ sql .RowBufPool .Put (i .rowBuffer )
595594
596595 if i .l != nil {
597596 err = i .l .Close (ctx )
@@ -709,9 +708,8 @@ func (i *crossJoinIterator) removeParentRow(r sql.Row) sql.Row {
709708}
710709
711710func (i * crossJoinIterator ) Close (ctx * sql.Context ) (err error ) {
712- i .rowBuffer = nil
713- //i.rowBuffer.Reset()
714- //sql.RowBufPool.Put(i.rowBuffer)
711+ i .rowBuffer .Reset ()
712+ sql .RowBufPool .Put (i .rowBuffer )
715713
716714 if i .l != nil {
717715 err = i .l .Close (ctx )
@@ -913,9 +911,8 @@ func (i *lateralJoinIterator) Next(ctx *sql.Context) (sql.Row, error) {
913911}
914912
915913func (i * lateralJoinIterator ) Close (ctx * sql.Context ) error {
916- i .rowBuffer = nil
917- //i.rowBuffer.Reset()
918- //sql.RowBufPool.Put(i.rowBuffer)
914+ i .rowBuffer .Reset ()
915+ sql .RowBufPool .Put (i .rowBuffer )
919916
920917 var lerr , rerr error
921918 if i .lIter != nil {
0 commit comments