@@ -47,8 +47,6 @@ func newMergeJoinIter(ctx *sql.Context, b sql.NodeExecBuilder, j *plan.JoinNode,
47
47
}
48
48
49
49
fullRow := sql .GetRow (len (row ) + len (j .Left ().Schema ()) + len (j .Right ().Schema ()))
50
- // TODO: what is this for?
51
- fullRow [0 ] = row
52
50
if len (row ) > 0 {
53
51
copy (fullRow [0 :], row [:])
54
52
}
@@ -202,7 +200,6 @@ func (i *mergeJoinIter) Next(ctx *sql.Context) (sql.Row, error) {
202
200
nextState = msExhaustCheck
203
201
case msExhaustCheck :
204
202
if i .lojFinalize () {
205
- ret = i .copyReturnRow ()
206
203
nextState = msRetLeft
207
204
} else if i .exhausted () {
208
205
return nil , io .EOF
@@ -228,7 +225,6 @@ func (i *mergeJoinIter) Next(ctx *sql.Context) (sql.Row, error) {
228
225
if i .leftMatched {
229
226
nextState = msIncLeft
230
227
} else {
231
- ret = i .copyReturnRow ()
232
228
nextState = msRetLeft
233
229
}
234
230
} else {
@@ -243,7 +239,6 @@ func (i *mergeJoinIter) Next(ctx *sql.Context) (sql.Row, error) {
243
239
left , _ := i .cmp .Left ().Eval (ctx , i .fullRow )
244
240
if left == nil {
245
241
if i .typ .IsLeftOuter () && ! i .leftMatched {
246
- ret = i .copyReturnRow ()
247
242
nextState = msRetLeft
248
243
} else {
249
244
nextState = msIncLeft
@@ -264,10 +259,9 @@ func (i *mergeJoinIter) Next(ctx *sql.Context) (sql.Row, error) {
264
259
}
265
260
nextState = msExhaustCheck
266
261
case msSelect :
267
- ret = i .copyReturnRow () // TODO: only copy once we know we're going to return this
268
262
currLeftMatched := i .leftMatched
269
263
270
- ok , err := i .sel (ctx , ret )
264
+ ok , err := i .sel (ctx , i . fullRow )
271
265
if err != nil {
272
266
return nil , err
273
267
}
@@ -296,14 +290,17 @@ func (i *mergeJoinIter) Next(ctx *sql.Context) (sql.Row, error) {
296
290
// |i.incMatch| call incremented the left row.
297
291
// |currLeftMatched| indicates whether |ret| has already
298
292
// successfully met a join condition.
293
+ ret = i .copyReturnRow ()
299
294
return i .removeParentRow (i .nullifyRightRow (ret )), nil
300
295
} else {
301
296
nextState = msExhaustCheck
302
297
}
303
298
304
299
case msRet :
300
+ ret = i .copyReturnRow ()
305
301
return i .removeParentRow (ret ), nil
306
302
case msRetLeft :
303
+ ret = i .copyReturnRow ()
307
304
ret = i .removeParentRow (i .nullifyRightRow (ret ))
308
305
err = i .incLeft (ctx )
309
306
if err != nil {
0 commit comments