@@ -229,6 +229,56 @@ var DefaultJoinOpTests = []joinOpTest{
229229 },
230230 },
231231 },
232+ {
233+ name : "left join null-filter" ,
234+ setup : [][]string {
235+ setup .MydbData [0 ],
236+ {
237+ "CREATE table xy (x int primary key, y int, z int, index y_idx(y));" ,
238+ "CREATE table ab (a int primary key, b int, c int);" ,
239+ "insert into xy values (1,0,0), (2,null,1), (3,2,2),(4,2,3);" ,
240+ "insert into ab values (0,1,0), (1,2,1), (2,3,2), (3,4,3);" ,
241+ },
242+ },
243+ tests : []JoinOpTests {
244+ {
245+ Query : "select /*+ JOIN_ORDER(ab,xy) */ x from xy left join ab on x = a and z = 5 where a is null order by x " ,
246+ Expected : []sql.Row {{1 }, {2 }, {3 }, {4 }},
247+ },
248+ {
249+ Query : "select /*+ JOIN_ORDER(xy,ab) */ x from xy left join ab on x = a and z = 5 where a is null order by x " ,
250+ Expected : []sql.Row {{1 }, {2 }, {3 }, {4 }},
251+ },
252+ // partial return
253+ {
254+ Query : "select /*+ JOIN_ORDER(ab,xy) */ x from xy left join ab on x = a and z = 1 where a is null order by x " ,
255+ Expected : []sql.Row {{1 }, {3 }, {4 }},
256+ },
257+ {
258+ Query : "select /*+ JOIN_ORDER(xy,ab) */ x from xy left join ab on x = a and z in (1,2) where a is null order by x " ,
259+ Expected : []sql.Row {{1 }, {4 }},
260+ },
261+ },
262+ },
263+ {
264+ name : "type conversion panic bug" ,
265+ setup : [][]string {
266+ setup .MydbData [0 ],
267+ {
268+ "create table xy (x int primary key, y int, z varchar(10), key (y,z));" ,
269+ "insert into xy values (0,0,'0'), (1,1,'1');" ,
270+ "create table ab (a int primary key, b int);" ,
271+ "insert into ab values (0,0), (1,1);" ,
272+ },
273+ },
274+ tests : []JoinOpTests {
275+ {
276+ // the literal z should be internally cast to the appropriate string type
277+ Query : "select /*+ JOIN_ORDER(ab,xy) */ count(*) from xy join ab on y = a and z = 0" ,
278+ Expected : []sql.Row {{1 }},
279+ },
280+ },
281+ },
232282 {
233283 name : "partial key null lookup join indexes" ,
234284 setup : [][]string {
0 commit comments