@@ -261,7 +261,7 @@ var JoinPlanningTests = []struct {
261261 {
262262 // anti join will be cross-join-right, be passed non-nil parent row
263263 q : "select x,a from ab, (select * from xy where x != (select r from rs where r = 1) order by 1) sq where x = 2 and b = 2 order by 1,2;" ,
264- types : []plan.JoinType {plan .JoinTypeCross , plan .JoinTypeLeftOuterHashExcludeNulls },
264+ types : []plan.JoinType {plan .JoinTypeCrossHash , plan .JoinTypeLeftOuterHashExcludeNulls },
265265 exp : []sql.Row {{2 , 0 }, {2 , 1 }, {2 , 2 }},
266266 },
267267 {
@@ -276,7 +276,7 @@ select * from uv where u > (
276276 order by 1 limit 1
277277)
278278order by 1;` ,
279- types : []plan.JoinType {plan .JoinTypeSemi , plan .JoinTypeCross , plan .JoinTypeLeftOuterHashExcludeNulls },
279+ types : []plan.JoinType {plan .JoinTypeSemi , plan .JoinTypeCrossHash , plan .JoinTypeLeftOuterHashExcludeNulls },
280280 exp : []sql.Row {{1 , 1 }, {2 , 2 }, {3 , 2 }},
281281 },
282282 {
@@ -305,7 +305,7 @@ order by 1;`,
305305 {
306306 // semi join will be right-side, be passed non-nil parent row
307307 q : "select x,a from ab, (select * from xy where x = (select r from rs where r = 1) order by 1) sq order by 1,2" ,
308- types : []plan.JoinType {plan .JoinTypeCross , plan .JoinTypeLookup },
308+ types : []plan.JoinType {plan .JoinTypeCrossHash , plan .JoinTypeLookup },
309309 exp : []sql.Row {{1 , 0 }, {1 , 1 }, {1 , 2 }, {1 , 3 }},
310310 },
311311 //{
@@ -321,7 +321,7 @@ order by 1;`,
321321 // order by 1 limit 1
322322 //)
323323 //order by 1;`,
324- //types: []plan.JoinType{plan.JoinTypeCross , plan.JoinTypeLookup},
324+ //types: []plan.JoinType{plan.JoinTypeCrossHash , plan.JoinTypeLookup},
325325 //exp: []sql.Row{{2, 2}, {3, 2}},
326326 //},
327327 {
@@ -459,7 +459,7 @@ WHERE EXISTS (
459459 },
460460 {
461461 q : `select * from xy where exists (select * from uv) and x = 0` ,
462- types : []plan.JoinType {plan .JoinTypeLookup },
462+ types : []plan.JoinType {plan .JoinTypeCrossHash },
463463 exp : []sql.Row {{0 , 2 }},
464464 },
465465 {
@@ -481,6 +481,31 @@ select * from xy where x in (
481481 types : []plan.JoinType {plan .JoinTypeHash , plan .JoinTypeHash },
482482 exp : []sql.Row {{1 , 0 }},
483483 },
484+ {
485+ q : `
486+ SELECT *
487+ FROM xy
488+ WHERE
489+ EXISTS (
490+ SELECT 1
491+ FROM ab
492+ WHERE
493+ xy.x = ab.a AND
494+ EXISTS (
495+ SELECT 1
496+ FROM uv
497+ WHERE
498+ ab.a = uv.v
499+ )
500+ )` ,
501+ types : []plan.JoinType {plan .JoinTypeLookup , plan .JoinTypeLookup },
502+ exp : []sql.Row {{1 , 0 }, {2 , 1 }},
503+ },
504+ {
505+ q : `select * from xy where exists (select * from uv join ab on u = a)` ,
506+ types : []plan.JoinType {plan .JoinTypeCrossHash , plan .JoinTypeMerge },
507+ exp : []sql.Row {{0 , 2 }, {1 , 0 }, {2 , 1 }, {3 , 3 }},
508+ },
484509 },
485510 },
486511 {
0 commit comments