~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
DROP TABLE IF EXISTS t0,t1,t2,t3,t4,t5,t6,t7,t8,t9;
2
CREATE TABLE t0 (a int, b int, c int);
3
CREATE TABLE t1 (a int, b int, c int);
4
CREATE TABLE t2 (a int, b int, c int);
5
CREATE TABLE t3 (a int, b int, c int);
6
CREATE TABLE t4 (a int, b int, c int);
7
CREATE TABLE t5 (a int, b int, c int);
8
CREATE TABLE t6 (a int, b int, c int);
9
CREATE TABLE t7 (a int, b int, c int);
10
CREATE TABLE t8 (a int, b int, c int);
11
CREATE TABLE t9 (a int, b int, c int);
12
INSERT INTO t0 VALUES (1,1,0), (1,2,0), (2,2,0);
13
INSERT INTO t1 VALUES (1,3,0), (2,2,0), (3,2,0);
14
INSERT INTO t2 VALUES (3,3,0), (4,2,0), (5,3,0);
15
INSERT INTO t3 VALUES (1,2,0), (2,2,0);
16
INSERT INTO t4 VALUES (3,2,0), (4,2,0);
17
INSERT INTO t5 VALUES (3,1,0), (2,2,0), (3,3,0);
18
INSERT INTO t6 VALUES (3,2,0), (6,2,0), (6,1,0);
19
INSERT INTO t7 VALUES (1,1,0), (2,2,0);
20
INSERT INTO t8 VALUES (0,2,0), (1,2,0);
21
INSERT INTO t9 VALUES (1,1,0), (1,2,0), (3,3,0);
22
SELECT t2.a,t2.b
23
FROM t2;
24
a	b
25
3	3
26
4	2
27
5	3
28
SELECT t3.a,t3.b
29
FROM t3;
30
a	b
31
1	2
32
2	2
33
SELECT t4.a,t4.b
34
FROM t4;
35
a	b
36
3	2
37
4	2
38
SELECT t3.a,t3.b,t4.a,t4.b
39
FROM t3,t4;
2141.4.2 by Andrew Hutchings
Implicit joins of the form "SELECT * FROM t1, t2" without WHERE or ON now error.
40
ERROR HY000: Implicit cartesian join attempted.
1 by brian
clean slate
41
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
42
FROM t2
43
LEFT JOIN              
44
(t3, t4)
45
ON t2.b=t4.b;
46
a	b	a	b	a	b
47
3	3	NULL	NULL	NULL	NULL
48
4	2	1	2	3	2
49
4	2	1	2	4	2
50
4	2	2	2	3	2
51
4	2	2	2	4	2
52
5	3	NULL	NULL	NULL	NULL
53
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
54
FROM t2
55
LEFT JOIN              
56
(t3, t4)
57
ON t3.a=1 AND t2.b=t4.b;
58
a	b	a	b	a	b
59
3	3	NULL	NULL	NULL	NULL
60
4	2	1	2	3	2
61
4	2	1	2	4	2
62
5	3	NULL	NULL	NULL	NULL
63
EXPLAIN EXTENDED
64
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
65
FROM t2
66
LEFT JOIN              
67
(t3, t4)
68
ON t2.b=t4.b
69
WHERE t3.a=1 OR t3.c IS NULL;
70
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
71
1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	3	100.00	
72
1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where
73
1	SIMPLE	t4	ALL	NULL	NULL	NULL	NULL	2	100.00	
74
Warnings:
352.2.1 by Harrison Fisk
Fix for bugs 259843 and 256482
75
Note	1003	select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t2` left join (`test`.`t3` join `test`.`t4`) on((`test`.`t4`.`b` = `test`.`t2`.`b`)) where ((`test`.`t3`.`a` = 1) or isnull(`test`.`t3`.`c`))
1 by brian
clean slate
76
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
77
FROM t2
78
LEFT JOIN              
79
(t3, t4)
80
ON t2.b=t4.b
81
WHERE t3.a=1 OR t3.c IS NULL;
82
a	b	a	b	a	b
83
3	3	NULL	NULL	NULL	NULL
84
4	2	1	2	3	2
85
4	2	1	2	4	2
86
5	3	NULL	NULL	NULL	NULL
87
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
88
FROM t2
89
LEFT JOIN              
90
(t3, t4)
91
ON t2.b=t4.b
92
WHERE t3.a>1 OR t3.c IS NULL;
93
a	b	a	b	a	b
94
3	3	NULL	NULL	NULL	NULL
95
4	2	2	2	3	2
96
4	2	2	2	4	2
97
5	3	NULL	NULL	NULL	NULL
98
SELECT t5.a,t5.b
99
FROM t5;
100
a	b
101
3	1
102
2	2
103
3	3
104
SELECT t3.a,t3.b,t4.a,t4.b,t5.a,t5.b
105
FROM t3,t4,t5;
2141.4.2 by Andrew Hutchings
Implicit joins of the form "SELECT * FROM t1, t2" without WHERE or ON now error.
106
ERROR HY000: Implicit cartesian join attempted.
1 by brian
clean slate
107
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b
108
FROM t2
109
LEFT JOIN              
110
(t3, t4, t5)
111
ON t2.b=t4.b;
112
a	b	a	b	a	b	a	b
113
3	3	NULL	NULL	NULL	NULL	NULL	NULL
114
4	2	1	2	3	2	3	1
115
4	2	1	2	3	2	2	2
116
4	2	1	2	3	2	3	3
117
4	2	1	2	4	2	3	1
118
4	2	1	2	4	2	2	2
119
4	2	1	2	4	2	3	3
120
4	2	2	2	3	2	3	1
121
4	2	2	2	3	2	2	2
122
4	2	2	2	3	2	3	3
123
4	2	2	2	4	2	3	1
124
4	2	2	2	4	2	2	2
125
4	2	2	2	4	2	3	3
126
5	3	NULL	NULL	NULL	NULL	NULL	NULL
127
EXPLAIN EXTENDED
128
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b
129
FROM t2
130
LEFT JOIN              
131
(t3, t4, t5)
132
ON t2.b=t4.b
133
WHERE t3.a>1 OR t3.c IS NULL;
134
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
135
1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	3	100.00	
136
1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where
137
1	SIMPLE	t4	ALL	NULL	NULL	NULL	NULL	2	100.00	
138
1	SIMPLE	t5	ALL	NULL	NULL	NULL	NULL	3	100.00	
139
Warnings:
352.2.1 by Harrison Fisk
Fix for bugs 259843 and 256482
140
Note	1003	select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b` from `test`.`t2` left join (`test`.`t3` join `test`.`t4` join `test`.`t5`) on((`test`.`t4`.`b` = `test`.`t2`.`b`)) where ((`test`.`t3`.`a` > 1) or isnull(`test`.`t3`.`c`))
1 by brian
clean slate
141
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b
142
FROM t2
143
LEFT JOIN              
144
(t3, t4, t5)
145
ON t2.b=t4.b
146
WHERE t3.a>1 OR t3.c IS NULL;
147
a	b	a	b	a	b	a	b
148
3	3	NULL	NULL	NULL	NULL	NULL	NULL
149
4	2	2	2	3	2	3	1
150
4	2	2	2	3	2	2	2
151
4	2	2	2	3	2	3	3
152
4	2	2	2	4	2	3	1
153
4	2	2	2	4	2	2	2
154
4	2	2	2	4	2	3	3
155
5	3	NULL	NULL	NULL	NULL	NULL	NULL
156
EXPLAIN EXTENDED
157
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b
158
FROM t2
159
LEFT JOIN              
160
(t3, t4, t5)
161
ON t2.b=t4.b
162
WHERE (t3.a>1 OR t3.c IS NULL) AND 
163
(t5.a<3 OR t5.c IS NULL);
164
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
165
1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	3	100.00	
166
1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where
167
1	SIMPLE	t4	ALL	NULL	NULL	NULL	NULL	2	100.00	
168
1	SIMPLE	t5	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
169
Warnings:
352.2.1 by Harrison Fisk
Fix for bugs 259843 and 256482
170
Note	1003	select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b` from `test`.`t2` left join (`test`.`t3` join `test`.`t4` join `test`.`t5`) on((`test`.`t4`.`b` = `test`.`t2`.`b`)) where (((`test`.`t3`.`a` > 1) or isnull(`test`.`t3`.`c`)) and ((`test`.`t5`.`a` < 3) or isnull(`test`.`t5`.`c`)))
1 by brian
clean slate
171
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b
172
FROM t2
173
LEFT JOIN              
174
(t3, t4, t5)
175
ON t2.b=t4.b
176
WHERE (t3.a>1 OR t3.c IS NULL) AND 
177
(t5.a<3 OR t5.c IS NULL);
178
a	b	a	b	a	b	a	b
179
3	3	NULL	NULL	NULL	NULL	NULL	NULL
180
4	2	2	2	3	2	2	2
181
4	2	2	2	4	2	2	2
182
5	3	NULL	NULL	NULL	NULL	NULL	NULL
183
SELECT t6.a,t6.b
184
FROM t6;
185
a	b
186
3	2
187
6	2
188
6	1
189
SELECT t7.a,t7.b
190
FROM t7;
191
a	b
192
1	1
193
2	2
194
SELECT t6.a,t6.b,t7.a,t7.b
2141.4.2 by Andrew Hutchings
Implicit joins of the form "SELECT * FROM t1, t2" without WHERE or ON now error.
195
FROM t6 CROSS JOIN t7;
1 by brian
clean slate
196
a	b	a	b
197
3	2	1	1
198
3	2	2	2
1718.2.1 by Lee Bieber
For the feature request (https://blueprints.launchpad.net/drizzle/+spec/limit-maximum-sort-size)
199
6	1	1	1
200
6	1	2	2
1 by brian
clean slate
201
6	2	1	1
202
6	2	2	2
203
SELECT t8.a,t8.b
204
FROM t8;
205
a	b
206
0	2
207
1	2
208
EXPLAIN EXTENDED
209
SELECT t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
210
FROM (t6, t7)
211
LEFT JOIN 
212
t8
213
ON t7.b=t8.b AND t6.b < 10;
214
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
215
1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	3	100.00	Using join buffer
1718.2.1 by Lee Bieber
For the feature request (https://blueprints.launchpad.net/drizzle/+spec/limit-maximum-sort-size)
216
1	SIMPLE	t7	ALL	NULL	NULL	NULL	NULL	2	100.00	
1 by brian
clean slate
217
1	SIMPLE	t8	ALL	NULL	NULL	NULL	NULL	2	100.00	
352.2.1 by Harrison Fisk
Fix for bugs 259843 and 256482
218
Note	1003	select `test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t7`.`b` = `test`.`t8`.`b`) and (`test`.`t6`.`b` < 10))) where 1
1718.2.1 by Lee Bieber
For the feature request (https://blueprints.launchpad.net/drizzle/+spec/limit-maximum-sort-size)
219
Warnings:
1 by brian
clean slate
220
SELECT t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
221
FROM (t6, t7)
222
LEFT JOIN 
223
t8
224
ON t7.b=t8.b AND t6.b < 10;
225
a	b	a	b	a	b
226
3	2	1	1	NULL	NULL
227
3	2	2	2	0	2
228
3	2	2	2	1	2
229
6	2	1	1	NULL	NULL
230
6	2	2	2	0	2
231
6	2	2	2	1	2
232
6	1	1	1	NULL	NULL
233
6	1	2	2	0	2
234
6	1	2	2	1	2
235
SELECT t5.a,t5.b
236
FROM t5;
237
a	b
238
3	1
239
2	2
240
3	3
241
SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
242
FROM t5 
243
LEFT JOIN 
244
( 
245
(t6, t7)
246
LEFT JOIN 
247
t8
248
ON t7.b=t8.b AND t6.b < 10
249
)
250
ON t6.b >= 2 AND t5.b=t7.b;
251
a	b	a	b	a	b	a	b
252
3	1	3	2	1	1	NULL	NULL
253
3	1	6	2	1	1	NULL	NULL
254
2	2	3	2	2	2	0	2
255
2	2	3	2	2	2	1	2
256
2	2	6	2	2	2	0	2
257
2	2	6	2	2	2	1	2
258
3	3	NULL	NULL	NULL	NULL	NULL	NULL
259
SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
260
FROM t5 
261
LEFT JOIN 
262
( 
263
(t6, t7)
264
LEFT JOIN 
265
t8
266
ON t7.b=t8.b AND t6.b < 10
267
)
268
ON t6.b >= 2 AND t5.b=t7.b AND
269
(t8.a < 1 OR t8.c IS NULL);
270
a	b	a	b	a	b	a	b
271
3	1	3	2	1	1	NULL	NULL
272
3	1	6	2	1	1	NULL	NULL
273
2	2	3	2	2	2	0	2
274
2	2	6	2	2	2	0	2
275
3	3	NULL	NULL	NULL	NULL	NULL	NULL
276
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
277
FROM t2
278
LEFT JOIN              
279
(t3, t4)
280
ON t3.a=1 AND t2.b=t4.b;
281
a	b	a	b	a	b
282
3	3	NULL	NULL	NULL	NULL
283
4	2	1	2	3	2
284
4	2	1	2	4	2
285
5	3	NULL	NULL	NULL	NULL
286
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
287
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
288
FROM t2
289
LEFT JOIN              
290
(t3, t4)
291
ON t3.a=1 AND t2.b=t4.b,
292
t5 
293
LEFT JOIN 
294
( 
295
(t6, t7)
296
LEFT JOIN 
297
t8
298
ON t7.b=t8.b AND t6.b < 10
299
)
300
ON t6.b >= 2 AND t5.b=t7.b;
301
a	b	a	b	a	b	a	b	a	b	a	b	a	b
302
3	3	NULL	NULL	NULL	NULL	3	1	3	2	1	1	NULL	NULL
303
3	3	NULL	NULL	NULL	NULL	3	1	6	2	1	1	NULL	NULL
304
4	2	1	2	3	2	3	1	3	2	1	1	NULL	NULL
305
4	2	1	2	3	2	3	1	6	2	1	1	NULL	NULL
306
4	2	1	2	4	2	3	1	3	2	1	1	NULL	NULL
307
4	2	1	2	4	2	3	1	6	2	1	1	NULL	NULL
308
5	3	NULL	NULL	NULL	NULL	3	1	3	2	1	1	NULL	NULL
309
5	3	NULL	NULL	NULL	NULL	3	1	6	2	1	1	NULL	NULL
310
3	3	NULL	NULL	NULL	NULL	2	2	3	2	2	2	0	2
311
3	3	NULL	NULL	NULL	NULL	2	2	3	2	2	2	1	2
312
3	3	NULL	NULL	NULL	NULL	2	2	6	2	2	2	0	2
313
3	3	NULL	NULL	NULL	NULL	2	2	6	2	2	2	1	2
314
4	2	1	2	3	2	2	2	3	2	2	2	0	2
315
4	2	1	2	3	2	2	2	3	2	2	2	1	2
316
4	2	1	2	3	2	2	2	6	2	2	2	0	2
317
4	2	1	2	3	2	2	2	6	2	2	2	1	2
318
4	2	1	2	4	2	2	2	3	2	2	2	0	2
319
4	2	1	2	4	2	2	2	3	2	2	2	1	2
320
4	2	1	2	4	2	2	2	6	2	2	2	0	2
321
4	2	1	2	4	2	2	2	6	2	2	2	1	2
322
5	3	NULL	NULL	NULL	NULL	2	2	3	2	2	2	0	2
323
5	3	NULL	NULL	NULL	NULL	2	2	3	2	2	2	1	2
324
5	3	NULL	NULL	NULL	NULL	2	2	6	2	2	2	0	2
325
5	3	NULL	NULL	NULL	NULL	2	2	6	2	2	2	1	2
326
3	3	NULL	NULL	NULL	NULL	3	3	NULL	NULL	NULL	NULL	NULL	NULL
327
4	2	1	2	3	2	3	3	NULL	NULL	NULL	NULL	NULL	NULL
328
4	2	1	2	4	2	3	3	NULL	NULL	NULL	NULL	NULL	NULL
329
5	3	NULL	NULL	NULL	NULL	3	3	NULL	NULL	NULL	NULL	NULL	NULL
330
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
331
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
332
FROM t2
333
LEFT JOIN              
334
(t3, t4)
335
ON t3.a=1 AND t2.b=t4.b,
336
t5 
337
LEFT JOIN 
338
( 
339
(t6, t7)
340
LEFT JOIN 
341
t8
342
ON t7.b=t8.b AND t6.b < 10
343
)
344
ON t6.b >= 2 AND t5.b=t7.b
345
WHERE t2.a > 3 AND
346
(t6.a < 6 OR t6.c IS NULL);
347
a	b	a	b	a	b	a	b	a	b	a	b	a	b
348
4	2	1	2	3	2	2	2	3	2	2	2	0	2
349
4	2	1	2	3	2	2	2	3	2	2	2	1	2
1718.2.1 by Lee Bieber
For the feature request (https://blueprints.launchpad.net/drizzle/+spec/limit-maximum-sort-size)
350
4	2	1	2	3	2	3	1	3	2	1	1	NULL	NULL
351
4	2	1	2	3	2	3	3	NULL	NULL	NULL	NULL	NULL	NULL
1 by brian
clean slate
352
4	2	1	2	4	2	2	2	3	2	2	2	0	2
353
4	2	1	2	4	2	2	2	3	2	2	2	1	2
1718.2.1 by Lee Bieber
For the feature request (https://blueprints.launchpad.net/drizzle/+spec/limit-maximum-sort-size)
354
4	2	1	2	4	2	3	1	3	2	1	1	NULL	NULL
355
4	2	1	2	4	2	3	3	NULL	NULL	NULL	NULL	NULL	NULL
1 by brian
clean slate
356
5	3	NULL	NULL	NULL	NULL	2	2	3	2	2	2	0	2
357
5	3	NULL	NULL	NULL	NULL	2	2	3	2	2	2	1	2
1718.2.1 by Lee Bieber
For the feature request (https://blueprints.launchpad.net/drizzle/+spec/limit-maximum-sort-size)
358
5	3	NULL	NULL	NULL	NULL	3	1	3	2	1	1	NULL	NULL
1 by brian
clean slate
359
5	3	NULL	NULL	NULL	NULL	3	3	NULL	NULL	NULL	NULL	NULL	NULL
360
SELECT t1.a,t1.b
361
FROM t1;
362
a	b
363
1	3
364
2	2
365
3	2
366
SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
367
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
368
FROM t1
369
LEFT JOIN                
370
( 
371
t2
372
LEFT JOIN              
373
(t3, t4)
374
ON t3.a=1 AND t2.b=t4.b,
375
t5 
376
LEFT JOIN 
377
( 
378
(t6, t7)
379
LEFT JOIN 
380
t8
381
ON t7.b=t8.b AND t6.b < 10
382
)
383
ON t6.b >= 2 AND t5.b=t7.b 
384
)
385
ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND
386
(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND
387
(t1.a != 2);
388
a	b	a	b	a	b	a	b	a	b	a	b	a	b	a	b
389
1	3	3	3	NULL	NULL	NULL	NULL	3	1	3	2	1	1	NULL	NULL
390
1	3	3	3	NULL	NULL	NULL	NULL	3	1	6	2	1	1	NULL	NULL
391
1	3	3	3	NULL	NULL	NULL	NULL	2	2	3	2	2	2	0	2
392
1	3	3	3	NULL	NULL	NULL	NULL	2	2	3	2	2	2	1	2
393
1	3	3	3	NULL	NULL	NULL	NULL	2	2	6	2	2	2	0	2
394
1	3	3	3	NULL	NULL	NULL	NULL	2	2	6	2	2	2	1	2
395
1	3	3	3	NULL	NULL	NULL	NULL	3	3	NULL	NULL	NULL	NULL	NULL	NULL
396
1	3	4	2	1	2	3	2	3	1	3	2	1	1	NULL	NULL
397
1	3	4	2	1	2	3	2	3	1	6	2	1	1	NULL	NULL
398
1	3	4	2	1	2	3	2	3	3	NULL	NULL	NULL	NULL	NULL	NULL
399
1	3	4	2	1	2	4	2	3	1	3	2	1	1	NULL	NULL
400
1	3	4	2	1	2	4	2	3	1	6	2	1	1	NULL	NULL
401
1	3	4	2	1	2	4	2	3	3	NULL	NULL	NULL	NULL	NULL	NULL
402
1	3	5	3	NULL	NULL	NULL	NULL	3	1	3	2	1	1	NULL	NULL
403
1	3	5	3	NULL	NULL	NULL	NULL	3	1	6	2	1	1	NULL	NULL
404
1	3	5	3	NULL	NULL	NULL	NULL	2	2	3	2	2	2	0	2
405
1	3	5	3	NULL	NULL	NULL	NULL	2	2	3	2	2	2	1	2
406
1	3	5	3	NULL	NULL	NULL	NULL	2	2	6	2	2	2	0	2
407
1	3	5	3	NULL	NULL	NULL	NULL	2	2	6	2	2	2	1	2
408
1	3	5	3	NULL	NULL	NULL	NULL	3	3	NULL	NULL	NULL	NULL	NULL	NULL
409
2	2	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
410
3	2	3	3	NULL	NULL	NULL	NULL	3	1	3	2	1	1	NULL	NULL
411
3	2	3	3	NULL	NULL	NULL	NULL	3	1	6	2	1	1	NULL	NULL
412
3	2	3	3	NULL	NULL	NULL	NULL	2	2	3	2	2	2	0	2
413
3	2	3	3	NULL	NULL	NULL	NULL	2	2	3	2	2	2	1	2
414
3	2	3	3	NULL	NULL	NULL	NULL	2	2	6	2	2	2	0	2
415
3	2	3	3	NULL	NULL	NULL	NULL	2	2	6	2	2	2	1	2
416
3	2	3	3	NULL	NULL	NULL	NULL	3	3	NULL	NULL	NULL	NULL	NULL	NULL
417
3	2	4	2	1	2	3	2	3	1	3	2	1	1	NULL	NULL
418
3	2	4	2	1	2	3	2	3	1	6	2	1	1	NULL	NULL
419
3	2	4	2	1	2	3	2	2	2	3	2	2	2	0	2
420
3	2	4	2	1	2	3	2	2	2	3	2	2	2	1	2
421
3	2	4	2	1	2	3	2	2	2	6	2	2	2	0	2
422
3	2	4	2	1	2	3	2	2	2	6	2	2	2	1	2
423
3	2	4	2	1	2	3	2	3	3	NULL	NULL	NULL	NULL	NULL	NULL
424
3	2	4	2	1	2	4	2	3	1	3	2	1	1	NULL	NULL
425
3	2	4	2	1	2	4	2	3	1	6	2	1	1	NULL	NULL
426
3	2	4	2	1	2	4	2	2	2	3	2	2	2	0	2
427
3	2	4	2	1	2	4	2	2	2	3	2	2	2	1	2
428
3	2	4	2	1	2	4	2	2	2	6	2	2	2	0	2
429
3	2	4	2	1	2	4	2	2	2	6	2	2	2	1	2
430
3	2	4	2	1	2	4	2	3	3	NULL	NULL	NULL	NULL	NULL	NULL
431
3	2	5	3	NULL	NULL	NULL	NULL	3	1	3	2	1	1	NULL	NULL
432
3	2	5	3	NULL	NULL	NULL	NULL	3	1	6	2	1	1	NULL	NULL
433
3	2	5	3	NULL	NULL	NULL	NULL	2	2	3	2	2	2	0	2
434
3	2	5	3	NULL	NULL	NULL	NULL	2	2	3	2	2	2	1	2
435
3	2	5	3	NULL	NULL	NULL	NULL	2	2	6	2	2	2	0	2
436
3	2	5	3	NULL	NULL	NULL	NULL	2	2	6	2	2	2	1	2
437
3	2	5	3	NULL	NULL	NULL	NULL	3	3	NULL	NULL	NULL	NULL	NULL	NULL
438
SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
439
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
440
FROM t1
441
LEFT JOIN                
442
( 
443
t2
444
LEFT JOIN              
445
(t3, t4)
446
ON t3.a=1 AND t2.b=t4.b,
447
t5 
448
LEFT JOIN 
449
( 
450
(t6, t7)
451
LEFT JOIN 
452
t8
453
ON t7.b=t8.b AND t6.b < 10
454
)
455
ON t6.b >= 2 AND t5.b=t7.b 
456
)
457
ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND
458
(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND
459
(t1.a != 2)
460
WHERE (t2.a >= 4 OR t2.c IS NULL);
461
a	b	a	b	a	b	a	b	a	b	a	b	a	b	a	b
462
1	3	4	2	1	2	3	2	3	1	3	2	1	1	NULL	NULL
463
1	3	4	2	1	2	3	2	3	1	6	2	1	1	NULL	NULL
464
1	3	4	2	1	2	3	2	3	3	NULL	NULL	NULL	NULL	NULL	NULL
465
1	3	4	2	1	2	4	2	3	1	3	2	1	1	NULL	NULL
466
1	3	4	2	1	2	4	2	3	1	6	2	1	1	NULL	NULL
467
1	3	4	2	1	2	4	2	3	3	NULL	NULL	NULL	NULL	NULL	NULL
468
1	3	5	3	NULL	NULL	NULL	NULL	3	1	3	2	1	1	NULL	NULL
469
1	3	5	3	NULL	NULL	NULL	NULL	3	1	6	2	1	1	NULL	NULL
470
1	3	5	3	NULL	NULL	NULL	NULL	2	2	3	2	2	2	0	2
471
1	3	5	3	NULL	NULL	NULL	NULL	2	2	3	2	2	2	1	2
472
1	3	5	3	NULL	NULL	NULL	NULL	2	2	6	2	2	2	0	2
473
1	3	5	3	NULL	NULL	NULL	NULL	2	2	6	2	2	2	1	2
474
1	3	5	3	NULL	NULL	NULL	NULL	3	3	NULL	NULL	NULL	NULL	NULL	NULL
475
2	2	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
476
3	2	4	2	1	2	3	2	3	1	3	2	1	1	NULL	NULL
477
3	2	4	2	1	2	3	2	3	1	6	2	1	1	NULL	NULL
478
3	2	4	2	1	2	3	2	2	2	3	2	2	2	0	2
479
3	2	4	2	1	2	3	2	2	2	3	2	2	2	1	2
480
3	2	4	2	1	2	3	2	2	2	6	2	2	2	0	2
481
3	2	4	2	1	2	3	2	2	2	6	2	2	2	1	2
482
3	2	4	2	1	2	3	2	3	3	NULL	NULL	NULL	NULL	NULL	NULL
483
3	2	4	2	1	2	4	2	3	1	3	2	1	1	NULL	NULL
484
3	2	4	2	1	2	4	2	3	1	6	2	1	1	NULL	NULL
485
3	2	4	2	1	2	4	2	2	2	3	2	2	2	0	2
486
3	2	4	2	1	2	4	2	2	2	3	2	2	2	1	2
487
3	2	4	2	1	2	4	2	2	2	6	2	2	2	0	2
488
3	2	4	2	1	2	4	2	2	2	6	2	2	2	1	2
489
3	2	4	2	1	2	4	2	3	3	NULL	NULL	NULL	NULL	NULL	NULL
490
3	2	5	3	NULL	NULL	NULL	NULL	3	1	3	2	1	1	NULL	NULL
491
3	2	5	3	NULL	NULL	NULL	NULL	3	1	6	2	1	1	NULL	NULL
492
3	2	5	3	NULL	NULL	NULL	NULL	2	2	3	2	2	2	0	2
493
3	2	5	3	NULL	NULL	NULL	NULL	2	2	3	2	2	2	1	2
494
3	2	5	3	NULL	NULL	NULL	NULL	2	2	6	2	2	2	0	2
495
3	2	5	3	NULL	NULL	NULL	NULL	2	2	6	2	2	2	1	2
496
3	2	5	3	NULL	NULL	NULL	NULL	3	3	NULL	NULL	NULL	NULL	NULL	NULL
497
SELECT t0.a,t0.b
498
FROM t0;
499
a	b
500
1	1
501
1	2
502
2	2
503
EXPLAIN EXTENDED
504
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
505
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
506
FROM t0,t1
507
LEFT JOIN                
508
( 
509
t2
510
LEFT JOIN              
511
(t3, t4)
512
ON t3.a=1 AND t2.b=t4.b,
513
t5 
514
LEFT JOIN 
515
( 
516
(t6, t7)
517
LEFT JOIN 
518
t8
519
ON t7.b=t8.b AND t6.b < 10
520
)
521
ON t6.b >= 2 AND t5.b=t7.b 
522
)
523
ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND
524
(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND
525
(t1.a != 2)
526
WHERE t0.a=1 AND
527
t0.b=t1.b AND          
528
(t2.a >= 4 OR t2.c IS NULL);
529
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
530
1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
531
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where; Using join buffer
532
1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
533
1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	100.00	
534
1	SIMPLE	t4	ALL	NULL	NULL	NULL	NULL	2	100.00	
535
1	SIMPLE	t5	ALL	NULL	NULL	NULL	NULL	3	100.00	
536
1	SIMPLE	t7	ALL	NULL	NULL	NULL	NULL	2	100.00	
537
1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	3	100.00	
538
1	SIMPLE	t8	ALL	NULL	NULL	NULL	NULL	2	100.00	
539
Warnings:
352.2.1 by Harrison Fisk
Fix for bugs 259843 and 256482
540
Note	1003	select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) where ((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)))
1 by brian
clean slate
541
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
542
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
543
FROM t0,t1
544
LEFT JOIN                
545
( 
546
t2
547
LEFT JOIN              
548
(t3, t4)
549
ON t3.a=1 AND t2.b=t4.b,
550
t5 
551
LEFT JOIN 
552
( 
553
(t6, t7)
554
LEFT JOIN 
555
t8
556
ON t7.b=t8.b AND t6.b < 10
557
)
558
ON t6.b >= 2 AND t5.b=t7.b 
559
)
560
ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND
561
(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND
562
(t1.a != 2)
563
WHERE t0.a=1 AND
564
t0.b=t1.b AND          
565
(t2.a >= 4 OR t2.c IS NULL);
566
a	b	a	b	a	b	a	b	a	b	a	b	a	b	a	b	a	b
567
1	2	2	2	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
568
1	2	3	2	4	2	1	2	3	2	3	1	3	2	1	1	NULL	NULL
569
1	2	3	2	4	2	1	2	3	2	3	1	6	2	1	1	NULL	NULL
570
1	2	3	2	4	2	1	2	3	2	2	2	3	2	2	2	0	2
571
1	2	3	2	4	2	1	2	3	2	2	2	3	2	2	2	1	2
572
1	2	3	2	4	2	1	2	3	2	2	2	6	2	2	2	0	2
573
1	2	3	2	4	2	1	2	3	2	2	2	6	2	2	2	1	2
574
1	2	3	2	4	2	1	2	3	2	3	3	NULL	NULL	NULL	NULL	NULL	NULL
575
1	2	3	2	4	2	1	2	4	2	3	1	3	2	1	1	NULL	NULL
576
1	2	3	2	4	2	1	2	4	2	3	1	6	2	1	1	NULL	NULL
577
1	2	3	2	4	2	1	2	4	2	2	2	3	2	2	2	0	2
578
1	2	3	2	4	2	1	2	4	2	2	2	3	2	2	2	1	2
579
1	2	3	2	4	2	1	2	4	2	2	2	6	2	2	2	0	2
580
1	2	3	2	4	2	1	2	4	2	2	2	6	2	2	2	1	2
581
1	2	3	2	4	2	1	2	4	2	3	3	NULL	NULL	NULL	NULL	NULL	NULL
582
1	2	3	2	5	3	NULL	NULL	NULL	NULL	3	1	3	2	1	1	NULL	NULL
583
1	2	3	2	5	3	NULL	NULL	NULL	NULL	3	1	6	2	1	1	NULL	NULL
584
1	2	3	2	5	3	NULL	NULL	NULL	NULL	2	2	3	2	2	2	0	2
585
1	2	3	2	5	3	NULL	NULL	NULL	NULL	2	2	3	2	2	2	1	2
586
1	2	3	2	5	3	NULL	NULL	NULL	NULL	2	2	6	2	2	2	0	2
587
1	2	3	2	5	3	NULL	NULL	NULL	NULL	2	2	6	2	2	2	1	2
588
1	2	3	2	5	3	NULL	NULL	NULL	NULL	3	3	NULL	NULL	NULL	NULL	NULL	NULL
589
EXPLAIN EXTENDED
590
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
591
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b
592
FROM t0,t1
593
LEFT JOIN                
594
( 
595
t2
596
LEFT JOIN              
597
(t3, t4)
598
ON t3.a=1 AND t2.b=t4.b,
599
t5 
600
LEFT JOIN 
601
( 
602
(t6, t7)
603
LEFT JOIN 
604
t8
605
ON t7.b=t8.b AND t6.b < 10
606
)
607
ON t6.b >= 2 AND t5.b=t7.b 
608
)
609
ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND
610
(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND
611
(t1.a != 2),
612
t9
613
WHERE t0.a=1 AND
614
t0.b=t1.b AND          
615
(t2.a >= 4 OR t2.c IS NULL) AND
616
(t3.a < 5 OR t3.c IS NULL) AND
617
(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND
618
(t5.a >=2 OR t5.c IS NULL) AND
619
(t6.a >=4 OR t6.c IS NULL) AND
620
(t7.a <= 2 OR t7.c IS NULL) AND
621
(t8.a < 1 OR t8.c IS NULL) AND
622
(t8.b=t9.b OR t8.c IS NULL) AND
623
(t9.a=1);
624
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
625
1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
626
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where; Using join buffer
627
1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
628
1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where
629
1	SIMPLE	t4	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where
630
1	SIMPLE	t5	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
1718.2.1 by Lee Bieber
For the feature request (https://blueprints.launchpad.net/drizzle/+spec/limit-maximum-sort-size)
631
1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
1 by brian
clean slate
632
1	SIMPLE	t7	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where
633
1	SIMPLE	t8	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where
634
1	SIMPLE	t9	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where; Using join buffer
1718.2.1 by Lee Bieber
For the feature request (https://blueprints.launchpad.net/drizzle/+spec/limit-maximum-sort-size)
635
Note	1003	select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
1 by brian
clean slate
636
Warnings:
637
SELECT t9.a,t9.b
638
FROM t9;
639
a	b
640
1	1
641
1	2
642
3	3
643
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
644
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b
645
FROM t0,t1
646
LEFT JOIN                
647
( 
648
t2
649
LEFT JOIN              
650
(t3, t4)
651
ON t3.a=1 AND t2.b=t4.b,
652
t5 
653
LEFT JOIN 
654
( 
655
(t6, t7)
656
LEFT JOIN 
657
t8
658
ON t7.b=t8.b AND t6.b < 10
659
)
660
ON t6.b >= 2 AND t5.b=t7.b 
661
)
662
ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND
663
(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND
664
(t1.a != 2),
665
t9
666
WHERE t0.a=1 AND
667
t0.b=t1.b AND          
668
(t2.a >= 4 OR t2.c IS NULL) AND
669
(t3.a < 5 OR t3.c IS NULL) AND
670
(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND
671
(t5.a >=2 OR t5.c IS NULL) AND
672
(t6.a >=4 OR t6.c IS NULL) AND
673
(t7.a <= 2 OR t7.c IS NULL) AND
674
(t8.a < 1 OR t8.c IS NULL) AND
675
(t8.b=t9.b OR t8.c IS NULL) AND
676
(t9.a=1);
677
a	b	a	b	a	b	a	b	a	b	a	b	a	b	a	b	a	b	a	b
678
1	2	2	2	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1	1
679
1	2	3	2	4	2	1	2	3	2	3	1	6	2	1	1	NULL	NULL	1	1
680
1	2	3	2	4	2	1	2	3	2	3	3	NULL	NULL	NULL	NULL	NULL	NULL	1	1
681
1	2	3	2	4	2	1	2	4	2	3	1	6	2	1	1	NULL	NULL	1	1
682
1	2	3	2	4	2	1	2	4	2	3	3	NULL	NULL	NULL	NULL	NULL	NULL	1	1
683
1	2	3	2	5	3	NULL	NULL	NULL	NULL	3	1	6	2	1	1	NULL	NULL	1	1
684
1	2	3	2	5	3	NULL	NULL	NULL	NULL	3	3	NULL	NULL	NULL	NULL	NULL	NULL	1	1
685
1	2	2	2	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1	2
686
1	2	3	2	4	2	1	2	3	2	3	1	6	2	1	1	NULL	NULL	1	2
687
1	2	3	2	4	2	1	2	3	2	2	2	6	2	2	2	0	2	1	2
688
1	2	3	2	4	2	1	2	3	2	3	3	NULL	NULL	NULL	NULL	NULL	NULL	1	2
689
1	2	3	2	4	2	1	2	4	2	3	1	6	2	1	1	NULL	NULL	1	2
690
1	2	3	2	4	2	1	2	4	2	2	2	6	2	2	2	0	2	1	2
691
1	2	3	2	4	2	1	2	4	2	3	3	NULL	NULL	NULL	NULL	NULL	NULL	1	2
692
1	2	3	2	5	3	NULL	NULL	NULL	NULL	3	1	6	2	1	1	NULL	NULL	1	2
693
1	2	3	2	5	3	NULL	NULL	NULL	NULL	2	2	6	2	2	2	0	2	1	2
694
1	2	3	2	5	3	NULL	NULL	NULL	NULL	3	3	NULL	NULL	NULL	NULL	NULL	NULL	1	2
695
SELECT t1.a,t1.b
696
FROM t1;
697
a	b
698
1	3
699
2	2
700
3	2
701
SELECT t2.a,t2.b
702
FROM t2;
703
a	b
704
3	3
705
4	2
706
5	3
707
SELECT t3.a,t3.b
708
FROM t3;
709
a	b
710
1	2
711
2	2
712
SELECT t2.a,t2.b,t3.a,t3.b
713
FROM t2 
714
LEFT JOIN              
715
t3
716
ON t2.b=t3.b;
717
a	b	a	b
718
3	3	NULL	NULL
719
4	2	1	2
720
4	2	2	2
721
5	3	NULL	NULL
722
SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b
723
FROM t1, t2 
724
LEFT JOIN              
725
t3
726
ON t2.b=t3.b
727
WHERE t1.a <= 2;
728
a	b	a	b	a	b
729
1	3	3	3	NULL	NULL
730
1	3	4	2	1	2
731
1	3	4	2	2	2
1718.2.1 by Lee Bieber
For the feature request (https://blueprints.launchpad.net/drizzle/+spec/limit-maximum-sort-size)
732
1	3	5	3	NULL	NULL
733
2	2	3	3	NULL	NULL
1 by brian
clean slate
734
2	2	4	2	1	2
735
2	2	4	2	2	2
736
2	2	5	3	NULL	NULL
737
SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b
738
FROM t1, t3 
739
RIGHT JOIN              
740
t2
741
ON t2.b=t3.b
742
WHERE t1.a <= 2;
743
a	b	a	b	a	b
744
1	3	3	3	NULL	NULL
745
1	3	4	2	1	2
746
1	3	4	2	2	2
1718.2.1 by Lee Bieber
For the feature request (https://blueprints.launchpad.net/drizzle/+spec/limit-maximum-sort-size)
747
1	3	5	3	NULL	NULL
748
2	2	3	3	NULL	NULL
1 by brian
clean slate
749
2	2	4	2	1	2
750
2	2	4	2	2	2
751
2	2	5	3	NULL	NULL
752
SELECT t3.a,t3.b,t4.a,t4.b
2141.4.2 by Andrew Hutchings
Implicit joins of the form "SELECT * FROM t1, t2" without WHERE or ON now error.
753
FROM t3 CROSS JOIN t4;
1 by brian
clean slate
754
a	b	a	b
755
1	2	3	2
756
2	2	3	2
757
1	2	4	2
758
2	2	4	2
759
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
760
FROM t2 
761
LEFT JOIN              
762
(t3, t4)
763
ON t3.a=1 AND t2.b=t4.b;
764
a	b	a	b	a	b
765
3	3	NULL	NULL	NULL	NULL
766
4	2	1	2	3	2
767
4	2	1	2	4	2
768
5	3	NULL	NULL	NULL	NULL
769
SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
770
FROM t1, t2 
771
LEFT JOIN              
772
(t3, t4)
773
ON t3.a=1 AND t2.b=t4.b
774
WHERE t1.a <= 2;
775
a	b	a	b	a	b	a	b
776
1	3	3	3	NULL	NULL	NULL	NULL
777
1	3	4	2	1	2	3	2
778
1	3	4	2	1	2	4	2
1718.2.1 by Lee Bieber
For the feature request (https://blueprints.launchpad.net/drizzle/+spec/limit-maximum-sort-size)
779
1	3	5	3	NULL	NULL	NULL	NULL
780
2	2	3	3	NULL	NULL	NULL	NULL
1 by brian
clean slate
781
2	2	4	2	1	2	3	2
782
2	2	4	2	1	2	4	2
783
2	2	5	3	NULL	NULL	NULL	NULL
784
SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
785
FROM t1, (t3, t4) 
786
RIGHT JOIN              
787
t2
788
ON t3.a=1 AND t2.b=t4.b
789
WHERE t1.a <= 2;
790
a	b	a	b	a	b	a	b
791
1	3	3	3	NULL	NULL	NULL	NULL
792
1	3	4	2	1	2	3	2
793
1	3	4	2	1	2	4	2
1718.2.1 by Lee Bieber
For the feature request (https://blueprints.launchpad.net/drizzle/+spec/limit-maximum-sort-size)
794
1	3	5	3	NULL	NULL	NULL	NULL
795
2	2	3	3	NULL	NULL	NULL	NULL
1 by brian
clean slate
796
2	2	4	2	1	2	3	2
797
2	2	4	2	1	2	4	2
798
2	2	5	3	NULL	NULL	NULL	NULL
799
SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
800
FROM t1, (t3, t4)
801
RIGHT JOIN              
802
t2
803
ON t3.a=1 AND t2.b=t4.b
804
WHERE t1.a <= 2;
805
a	b	a	b	a	b	a	b
806
1	3	3	3	NULL	NULL	NULL	NULL
807
2	2	3	3	NULL	NULL	NULL	NULL
808
1	3	4	2	1	2	3	2
809
1	3	4	2	1	2	4	2
810
2	2	4	2	1	2	3	2
811
2	2	4	2	1	2	4	2
812
1	3	5	3	NULL	NULL	NULL	NULL
813
2	2	5	3	NULL	NULL	NULL	NULL
814
EXPLAIN EXTENDED
815
SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
816
FROM t1, (t3, t4)
817
RIGHT JOIN
818
t2
819
ON t3.a=1 AND t2.b=t4.b
820
WHERE t1.a <= 2;
821
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
822
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
823
1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	3	100.00	Using join buffer
824
1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	100.00	
825
1	SIMPLE	t4	ALL	NULL	NULL	NULL	NULL	2	100.00	
826
Warnings:
352.2.1 by Harrison Fisk
Fix for bugs 259843 and 256482
827
Note	1003	select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t1` join `test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) where (`test`.`t1`.`a` <= 2)
1 by brian
clean slate
828
CREATE INDEX idx_b ON t2(b);
829
EXPLAIN EXTENDED
830
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
831
FROM (t3,t4)
832
LEFT JOIN              
833
(t1,t2)
834
ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b;
835
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1718.2.1 by Lee Bieber
For the feature request (https://blueprints.launchpad.net/drizzle/+spec/limit-maximum-sort-size)
836
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	100.00	
837
1	SIMPLE	t2	ref	idx_b	idx_b	5	test.t3.b	1	100.00	
1 by brian
clean slate
838
1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	100.00	
839
1	SIMPLE	t4	ALL	NULL	NULL	NULL	NULL	2	100.00	Using join buffer
352.2.1 by Harrison Fisk
Fix for bugs 259843 and 256482
840
Note	1003	select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t4` left join (`test`.`t1` join `test`.`t2`) on(((`test`.`t3`.`a` = 1) and (`test`.`t3`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` = `test`.`t4`.`b`))) where 1
1718.2.1 by Lee Bieber
For the feature request (https://blueprints.launchpad.net/drizzle/+spec/limit-maximum-sort-size)
841
Warnings:
1 by brian
clean slate
842
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
843
FROM (t3,t4)
844
LEFT JOIN              
845
(t1,t2)
846
ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b;
847
a	b	a	b	a	b
848
4	2	1	2	3	2
849
4	2	1	2	3	2
850
4	2	1	2	3	2
851
NULL	NULL	2	2	3	2
852
4	2	1	2	4	2
853
4	2	1	2	4	2
854
4	2	1	2	4	2
855
NULL	NULL	2	2	4	2
856
EXPLAIN EXTENDED
857
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
858
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b
859
FROM t0,t1
860
LEFT JOIN                
861
( 
862
t2
863
LEFT JOIN              
864
(t3, t4)
865
ON t3.a=1 AND t2.b=t4.b,
866
t5 
867
LEFT JOIN 
868
( 
869
(t6, t7)
870
LEFT JOIN 
871
t8
872
ON t7.b=t8.b AND t6.b < 10
873
)
874
ON t6.b >= 2 AND t5.b=t7.b 
875
)
876
ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND
877
(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND
878
(t1.a != 2),
879
t9
880
WHERE t0.a=1 AND
881
t0.b=t1.b AND          
882
(t2.a >= 4 OR t2.c IS NULL) AND
883
(t3.a < 5 OR t3.c IS NULL) AND
884
(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND
885
(t5.a >=2 OR t5.c IS NULL) AND
886
(t6.a >=4 OR t6.c IS NULL) AND
887
(t7.a <= 2 OR t7.c IS NULL) AND
888
(t8.a < 1 OR t8.c IS NULL) AND
889
(t8.b=t9.b OR t8.c IS NULL) AND
890
(t9.a=1);
891
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
892
1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
893
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where; Using join buffer
894
1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
895
1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where
896
1	SIMPLE	t4	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where
897
1	SIMPLE	t5	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
1718.2.1 by Lee Bieber
For the feature request (https://blueprints.launchpad.net/drizzle/+spec/limit-maximum-sort-size)
898
1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
1 by brian
clean slate
899
1	SIMPLE	t7	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where
900
1	SIMPLE	t8	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where
901
1	SIMPLE	t9	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where; Using join buffer
1718.2.1 by Lee Bieber
For the feature request (https://blueprints.launchpad.net/drizzle/+spec/limit-maximum-sort-size)
902
Note	1003	select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
1 by brian
clean slate
903
Warnings:
904
CREATE INDEX idx_b ON t4(b);
905
CREATE INDEX idx_b ON t5(b);
906
EXPLAIN EXTENDED
907
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
908
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b
909
FROM t0,t1
910
LEFT JOIN                
911
( 
912
t2
913
LEFT JOIN              
914
(t3, t4)
915
ON t3.a=1 AND t2.b=t4.b,
916
t5 
917
LEFT JOIN 
918
( 
919
(t6, t7)
920
LEFT JOIN 
921
t8
922
ON t7.b=t8.b AND t6.b < 10
923
)
924
ON t6.b >= 2 AND t5.b=t7.b 
925
)
926
ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND
927
(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND
928
(t1.a != 2),
929
t9
930
WHERE t0.a=1 AND
931
t0.b=t1.b AND          
932
(t2.a >= 4 OR t2.c IS NULL) AND
933
(t3.a < 5 OR t3.c IS NULL) AND
934
(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND
935
(t5.a >=2 OR t5.c IS NULL) AND
936
(t6.a >=4 OR t6.c IS NULL) AND
937
(t7.a <= 2 OR t7.c IS NULL) AND
938
(t8.a < 1 OR t8.c IS NULL) AND
939
(t8.b=t9.b OR t8.c IS NULL) AND
940
(t9.a=1);
941
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
942
1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
943
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where; Using join buffer
944
1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
201 by Brian Aker
Convert default engine to Innodb
945
1	SIMPLE	t4	ref	idx_b	idx_b	5	test.t2.b	1	100.00	
1 by brian
clean slate
946
1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where
947
1	SIMPLE	t5	ALL	idx_b	NULL	NULL	NULL	3	100.00	Using where
948
1	SIMPLE	t7	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where
949
1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
950
1	SIMPLE	t8	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where
951
1	SIMPLE	t9	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where; Using join buffer
952
Warnings:
352.2.1 by Harrison Fisk
Fix for bugs 259843 and 256482
953
Note	1003	select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t3`.`b` = `test`.`t4`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
1 by brian
clean slate
954
CREATE INDEX idx_b ON t8(b);
955
EXPLAIN EXTENDED
956
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
957
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b
958
FROM t0,t1
959
LEFT JOIN                
960
( 
961
t2
962
LEFT JOIN              
963
(t3, t4)
964
ON t3.a=1 AND t2.b=t4.b,
965
t5 
966
LEFT JOIN 
967
( 
968
(t6, t7)
969
LEFT JOIN 
970
t8
971
ON t7.b=t8.b AND t6.b < 10
972
)
973
ON t6.b >= 2 AND t5.b=t7.b 
974
)
975
ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND
976
(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND
977
(t1.a != 2),
978
t9
979
WHERE t0.a=1 AND
980
t0.b=t1.b AND          
981
(t2.a >= 4 OR t2.c IS NULL) AND
982
(t3.a < 5 OR t3.c IS NULL) AND
983
(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND
984
(t5.a >=2 OR t5.c IS NULL) AND
985
(t6.a >=4 OR t6.c IS NULL) AND
986
(t7.a <= 2 OR t7.c IS NULL) AND
987
(t8.a < 1 OR t8.c IS NULL) AND
988
(t8.b=t9.b OR t8.c IS NULL) AND
989
(t9.a=1);
990
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
991
1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
992
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where; Using join buffer
993
1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
201 by Brian Aker
Convert default engine to Innodb
994
1	SIMPLE	t4	ref	idx_b	idx_b	5	test.t2.b	1	100.00	
1 by brian
clean slate
995
1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where
996
1	SIMPLE	t5	ALL	idx_b	NULL	NULL	NULL	3	100.00	Using where
997
1	SIMPLE	t7	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where
998
1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
201 by Brian Aker
Convert default engine to Innodb
999
1	SIMPLE	t8	ref	idx_b	idx_b	5	test.t5.b	1	100.00	Using where
1 by brian
clean slate
1000
1	SIMPLE	t9	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where; Using join buffer
1001
Warnings:
352.2.1 by Harrison Fisk
Fix for bugs 259843 and 256482
1002
Note	1003	select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t3`.`b` = `test`.`t4`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
1 by brian
clean slate
1003
CREATE INDEX idx_b ON t1(b);
1004
CREATE INDEX idx_a ON t0(a);
1005
EXPLAIN EXTENDED
1006
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
1007
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b
1008
FROM t0,t1
1009
LEFT JOIN                
1010
( 
1011
t2
1012
LEFT JOIN              
1013
(t3, t4)
1014
ON t3.a=1 AND t2.b=t4.b,
1015
t5 
1016
LEFT JOIN 
1017
( 
1018
(t6, t7)
1019
LEFT JOIN 
1020
t8
1021
ON t7.b=t8.b AND t6.b < 10
1022
)
1023
ON t6.b >= 2 AND t5.b=t7.b 
1024
)
1025
ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND
1026
(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND
1027
(t1.a != 2),
1028
t9
1029
WHERE t0.a=1 AND
1030
t0.b=t1.b AND          
1031
(t2.a >= 4 OR t2.c IS NULL) AND
1032
(t3.a < 5 OR t3.c IS NULL) AND
1033
(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND
1034
(t5.a >=2 OR t5.c IS NULL) AND
1035
(t6.a >=4 OR t6.c IS NULL) AND
1036
(t7.a <= 2 OR t7.c IS NULL) AND
1037
(t8.a < 1 OR t8.c IS NULL) AND
1038
(t8.b=t9.b OR t8.c IS NULL) AND
1039
(t9.a=1);
1040
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1819.9.70 by Stewart Smith
modified join_nested EXPLAIN output due to innodb stats changes
1041
1	SIMPLE	t0	ref	idx_a	idx_a	5	const	2	100.00	Using where
1042
1	SIMPLE	t1	ALL	idx_b	NULL	NULL	NULL	3	100.00	Using where; Using join buffer
1 by brian
clean slate
1043
1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
201 by Brian Aker
Convert default engine to Innodb
1044
1	SIMPLE	t4	ref	idx_b	idx_b	5	test.t2.b	1	100.00	
1 by brian
clean slate
1045
1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where
1046
1	SIMPLE	t5	ALL	idx_b	NULL	NULL	NULL	3	100.00	Using where
1047
1	SIMPLE	t7	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where
1048
1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
201 by Brian Aker
Convert default engine to Innodb
1049
1	SIMPLE	t8	ref	idx_b	idx_b	5	test.t5.b	1	100.00	Using where
1 by brian
clean slate
1050
1	SIMPLE	t9	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where; Using join buffer
1051
Warnings:
352.2.1 by Harrison Fisk
Fix for bugs 259843 and 256482
1052
Note	1003	select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t3`.`b` = `test`.`t4`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
1 by brian
clean slate
1053
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
1054
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b
1055
FROM t0,t1
1056
LEFT JOIN                
1057
( 
1058
t2
1059
LEFT JOIN              
1060
(t3, t4)
1061
ON t3.a=1 AND t2.b=t4.b,
1062
t5 
1063
LEFT JOIN 
1064
( 
1065
(t6, t7)
1066
LEFT JOIN 
1067
t8
1068
ON t7.b=t8.b AND t6.b < 10
1069
)
1070
ON t6.b >= 2 AND t5.b=t7.b 
1071
)
1072
ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND
1073
(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND
1074
(t1.a != 2),
1075
t9
1076
WHERE t0.a=1 AND
1077
t0.b=t1.b AND          
1078
(t2.a >= 4 OR t2.c IS NULL) AND
1079
(t3.a < 5 OR t3.c IS NULL) AND
1080
(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND
1081
(t5.a >=2 OR t5.c IS NULL) AND
1082
(t6.a >=4 OR t6.c IS NULL) AND
1083
(t7.a <= 2 OR t7.c IS NULL) AND
1084
(t8.a < 1 OR t8.c IS NULL) AND
1085
(t8.b=t9.b OR t8.c IS NULL) AND
1086
(t9.a=1);
1087
a	b	a	b	a	b	a	b	a	b	a	b	a	b	a	b	a	b	a	b
1088
1	2	2	2	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1	1
1089
1	2	3	2	4	2	1	2	3	2	3	1	6	2	1	1	NULL	NULL	1	1
1090
1	2	3	2	4	2	1	2	3	2	3	3	NULL	NULL	NULL	NULL	NULL	NULL	1	1
1091
1	2	3	2	4	2	1	2	4	2	3	1	6	2	1	1	NULL	NULL	1	1
1092
1	2	3	2	4	2	1	2	4	2	3	3	NULL	NULL	NULL	NULL	NULL	NULL	1	1
1093
1	2	3	2	5	3	NULL	NULL	NULL	NULL	3	1	6	2	1	1	NULL	NULL	1	1
1094
1	2	3	2	5	3	NULL	NULL	NULL	NULL	3	3	NULL	NULL	NULL	NULL	NULL	NULL	1	1
1095
1	2	2	2	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1	2
1096
1	2	3	2	4	2	1	2	3	2	3	1	6	2	1	1	NULL	NULL	1	2
1097
1	2	3	2	4	2	1	2	3	2	2	2	6	2	2	2	0	2	1	2
1098
1	2	3	2	4	2	1	2	3	2	3	3	NULL	NULL	NULL	NULL	NULL	NULL	1	2
1099
1	2	3	2	4	2	1	2	4	2	3	1	6	2	1	1	NULL	NULL	1	2
1100
1	2	3	2	4	2	1	2	4	2	2	2	6	2	2	2	0	2	1	2
1101
1	2	3	2	4	2	1	2	4	2	3	3	NULL	NULL	NULL	NULL	NULL	NULL	1	2
1102
1	2	3	2	5	3	NULL	NULL	NULL	NULL	3	1	6	2	1	1	NULL	NULL	1	2
1103
1	2	3	2	5	3	NULL	NULL	NULL	NULL	2	2	6	2	2	2	0	2	1	2
1104
1	2	3	2	5	3	NULL	NULL	NULL	NULL	3	3	NULL	NULL	NULL	NULL	NULL	NULL	1	2
1105
SELECT t2.a,t2.b
1106
FROM t2;
1107
a	b
1108
3	3
1109
4	2
1110
5	3
1111
SELECT t3.a,t3.b
1112
FROM t3;
1113
a	b
1114
1	2
1115
2	2
1116
SELECT t2.a,t2.b,t3.a,t3.b
1117
FROM t2 LEFT JOIN t3 ON t2.b=t3.b
1118
WHERE t2.a = 4 OR (t2.a > 4 AND t3.a IS NULL);
1119
a	b	a	b
1120
4	2	1	2
1121
4	2	2	2
1122
5	3	NULL	NULL
1123
SELECT t2.a,t2.b,t3.a,t3.b
1124
FROM t2 LEFT JOIN (t3) ON t2.b=t3.b
1125
WHERE t2.a = 4 OR (t2.a > 4 AND t3.a IS NULL);
1126
a	b	a	b
1127
4	2	1	2
1128
4	2	2	2
1129
5	3	NULL	NULL
1130
ALTER TABLE t3
1131
CHANGE COLUMN a a1 int,
1132
CHANGE COLUMN c c1 int;
1133
SELECT t2.a,t2.b,t3.a1,t3.b
1134
FROM t2 LEFT JOIN t3 ON t2.b=t3.b
1135
WHERE t2.a = 4 OR (t2.a > 4 AND t3.a1 IS NULL);
1136
a	b	a1	b
1137
4	2	1	2
1138
4	2	2	2
1139
5	3	NULL	NULL
1140
SELECT t2.a,t2.b,t3.a1,t3.b
1141
FROM t2 NATURAL LEFT JOIN t3
1142
WHERE t2.a = 4 OR (t2.a > 4 AND t3.a1 IS NULL);
1143
a	b	a1	b
1144
4	2	1	2
1145
4	2	2	2
1146
5	3	NULL	NULL
1147
DROP TABLE t0,t1,t2,t3,t4,t5,t6,t7,t8,t9;
1148
CREATE TABLE t1 (a int);
1149
CREATE TABLE t2 (a int);
1150
CREATE TABLE t3 (a int);
1151
INSERT INTO t1 VALUES (1);
1152
INSERT INTO t2 VALUES (2);
1153
INSERT INTO t3 VALUES (2);
1154
INSERT INTO t1 VALUES (2);
1155
SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON t2.a=t3.a) ON t1.a=t3.a;
1156
a	a	a
1157
1	NULL	NULL
1158
2	2	2
1159
SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.a=t3.a;
1160
a	a	a
1161
1	NULL	NULL
1162
2	2	2
1163
DELETE FROM t1 WHERE a=2;
1164
SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.a=t3.a;
1165
a	a	a
1166
1	NULL	NULL
1167
DELETE FROM t2;
1168
SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.a=t3.a;
1169
a	a	a
1170
1	NULL	NULL
1171
DROP TABLE t1,t2,t3;
1172
CREATE TABLE t1(a int, key (a));
1173
CREATE TABLE t2(b int, key (b));
1174
CREATE TABLE t3(c int, key (c));
1175
INSERT INTO t1 VALUES (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9),
1176
(10), (11), (12), (13), (14), (15), (16), (17), (18), (19);
1177
INSERT INTO t2 VALUES (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9),
1178
(10), (11), (12), (13), (14), (15), (16), (17), (18), (19);
1179
INSERT INTO t3 VALUES (0), (1), (2), (3), (4), (5);
1180
EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON c < 3 and b = c;
1181
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1182
1	SIMPLE	t1	index	NULL	a	5	NULL	21	Using index
1183
1	SIMPLE	t3	index	c	c	5	NULL	6	Using index
201 by Brian Aker
Convert default engine to Innodb
1184
1	SIMPLE	t2	ref	b	b	5	test.t3.c	1	Using index
1 by brian
clean slate
1185
EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c;
1186
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1187
1	SIMPLE	t1	index	NULL	a	5	NULL	21	Using index
1188
1	SIMPLE	t3	index	c	c	5	NULL	6	Using index
201 by Brian Aker
Convert default engine to Innodb
1189
1	SIMPLE	t2	ref	b	b	5	test.t3.c	1	Using index
1 by brian
clean slate
1190
SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c;
1191
a	b	c
1192
NULL	0	0
1193
NULL	1	1
1194
NULL	2	2
1195
0	0	0
1196
0	1	1
1197
0	2	2
1198
1	0	0
1199
1	1	1
1200
1	2	2
1201
2	0	0
1202
2	1	1
1203
2	2	2
1204
3	0	0
1205
3	1	1
1206
3	2	2
1207
4	0	0
1208
4	1	1
1209
4	2	2
1210
5	0	0
1211
5	1	1
1212
5	2	2
1213
6	0	0
1214
6	1	1
1215
6	2	2
1216
7	0	0
1217
7	1	1
1218
7	2	2
1219
8	0	0
1220
8	1	1
1221
8	2	2
1222
9	0	0
1223
9	1	1
1224
9	2	2
1225
10	0	0
1226
10	1	1
1227
10	2	2
1228
11	0	0
1229
11	1	1
1230
11	2	2
1231
12	0	0
1232
12	1	1
1233
12	2	2
1234
13	0	0
1235
13	1	1
1236
13	2	2
1237
14	0	0
1238
14	1	1
1239
14	2	2
1240
15	0	0
1241
15	1	1
1242
15	2	2
1243
16	0	0
1244
16	1	1
1245
16	2	2
1246
17	0	0
1247
17	1	1
1248
17	2	2
1249
18	0	0
1250
18	1	1
1251
18	2	2
1252
19	0	0
1253
19	1	1
1254
19	2	2
1255
DELETE FROM t3;
1256
EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c;
1257
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1258
1	SIMPLE	t1	index	NULL	a	5	NULL	21	Using index
201 by Brian Aker
Convert default engine to Innodb
1259
1	SIMPLE	t3	index	c	c	5	NULL	1	Using index
1260
1	SIMPLE	t2	ref	b	b	5	test.t3.c	1	Using index
1 by brian
clean slate
1261
SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c;
1262
a	b	c
1263
NULL	NULL	NULL
1264
0	NULL	NULL
1265
1	NULL	NULL
1266
2	NULL	NULL
1267
3	NULL	NULL
1268
4	NULL	NULL
1269
5	NULL	NULL
1270
6	NULL	NULL
1271
7	NULL	NULL
1272
8	NULL	NULL
1273
9	NULL	NULL
1274
10	NULL	NULL
1275
11	NULL	NULL
1276
12	NULL	NULL
1277
13	NULL	NULL
1278
14	NULL	NULL
1279
15	NULL	NULL
1280
16	NULL	NULL
1281
17	NULL	NULL
1282
18	NULL	NULL
1283
19	NULL	NULL
1284
DROP TABLE t1,t2,t3;
1285
CREATE TABLE t1 (c11 int);
1286
CREATE TABLE t2 (c21 int);
1287
CREATE TABLE t3 (c31 int);
1288
INSERT INTO t1 VALUES (4), (5);
1289
SELECT * FROM t1 LEFT JOIN t2 ON c11=c21;
1290
c11	c21
1291
4	NULL
1292
5	NULL
1293
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON c11=c21;
1294
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1295
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	
201 by Brian Aker
Convert default engine to Innodb
1296
1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	
1 by brian
clean slate
1297
SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON c21=c31) ON c11=c21;
1298
c11	c21	c31
1299
4	NULL	NULL
1300
5	NULL	NULL
1301
EXPLAIN SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON c21=c31) ON c11=c21;
1302
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1303
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	
201 by Brian Aker
Convert default engine to Innodb
1304
1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	
1305
1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	
1 by brian
clean slate
1306
DROP TABLE t1,t2,t3;
1307
create table t1 (a int);
1308
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
1309
create table t2 (a int, filler char(100), key(a));
2141.4.2 by Andrew Hutchings
Implicit joins of the form "SELECT * FROM t1, t2" without WHERE or ON now error.
1310
insert into t2 select A.a + 10*B.a, '' from t1 A CROSS JOIN t1 B;
1 by brian
clean slate
1311
create table t3 like t2;
1312
insert into t3 select * from t2;
1313
explain select * from t1 left join 
1314
(t2 left join t3 on (t2.a = t3.a)) 
1315
on (t1.a = t2.a);
1316
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1317
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	10	
1318
1	SIMPLE	t2	ref	a	a	5	test.t1.a	1	
1319
1	SIMPLE	t3	ref	a	a	5	test.t2.a	1	
1320
drop table t1, t2, t3;
1321
CREATE TABLE t1 (
1322
id int NOT NULL PRIMARY KEY,
1323
ct int DEFAULT NULL,
1324
pc int DEFAULT NULL,
1325
INDEX idx_ct (ct),
1326
INDEX idx_pc (pc)
1327
);
1328
INSERT INTO t1 VALUES  
1329
(1,NULL,NULL),(2,NULL,NULL),(3,NULL,NULL),(4,NULL,NULL),(5,NULL,NULL);
1330
CREATE TABLE t2 (
1331
id int NOT NULL PRIMARY KEY,
1332
sr int NOT NULL,
1333
nm varchar(255) NOT NULL,
1334
INDEX idx_sr (sr)
1335
);
1336
INSERT INTO t2 VALUES
1337
(2441905,4308,'LesAbymes'),(2441906,4308,'Anse-Bertrand');
1338
CREATE TABLE t3 (
1339
id int NOT NULL PRIMARY KEY,
1340
ct int NOT NULL,
1341
ln int NOT NULL,
1342
INDEX idx_ct (ct),
1343
INDEX idx_ln (ln)
1344
);
1345
CREATE TABLE t4 (
1346
id int NOT NULL PRIMARY KEY,
1347
nm varchar(255) NOT NULL
1348
);
1349
INSERT INTO t4 VALUES (4308,'Guadeloupe'),(4309,'Martinique');
1350
SELECT t1.*
1351
FROM t1 LEFT JOIN
1352
(t2 LEFT JOIN t3 ON t3.ct=t2.id AND t3.ln='5') ON t1.ct=t2.id
1353
WHERE t1.id='5';
1354
id	ct	pc
1355
5	NULL	NULL
1356
SELECT t1.*, t4.nm
1357
FROM t1 LEFT JOIN
1358
(t2 LEFT JOIN t3 ON t3.ct=t2.id AND t3.ln='5') ON t1.ct=t2.id
1359
LEFT JOIN t4 ON t2.sr=t4.id
1360
WHERE t1.id='5';
1361
id	ct	pc	nm
1362
5	NULL	NULL	NULL
1363
DROP TABLE t1,t2,t3,t4;
1364
CREATE TABLE t1 (a INT, b INT);
1365
CREATE TABLE t2 (a INT);
1366
CREATE TABLE t3 (a INT, c INT);
1367
CREATE TABLE t4 (a INT, c INT);
1368
CREATE TABLE t5 (a INT, c INT);
1369
SELECT b FROM t1 JOIN (t2 LEFT JOIN t3 USING (a) LEFT JOIN t4 USING (a)
1370
LEFT JOIN t5 USING (a)) USING (a);
1371
b
1372
SELECT c FROM t1 JOIN (t2 LEFT JOIN t3 USING (a) LEFT JOIN t4 USING (a)
1373
LEFT JOIN t5 USING (a)) USING (a);
1374
ERROR 23000: Column 'c' in field list is ambiguous
1375
SELECT b FROM t1 JOIN (t2 JOIN t3 USING (a) JOIN t4 USING (a)
1376
JOIN t5 USING (a)) USING (a);
1377
b
1378
SELECT c FROM t1 JOIN (t2 JOIN t3 USING (a) JOIN t4 USING (a)
1379
JOIN t5 USING (a)) USING (a);
1380
ERROR 23000: Column 'c' in field list is ambiguous
1381
DROP TABLE t1,t2,t3,t4,t5;
1382
CREATE TABLE t1 (a INT, b INT);
1383
CREATE TABLE t2 (a INT, b INT);
1384
CREATE TABLE t3 (a INT, b INT);
1385
INSERT INTO t1 VALUES (1,1);
1386
INSERT INTO t2 VALUES (1,1);
1387
INSERT INTO t3 VALUES (1,1);
1388
SELECT * FROM t1 JOIN (t2 JOIN t3 USING (b)) USING (a);
1389
ERROR 23000: Column 'a' in from clause is ambiguous
1390
DROP TABLE t1,t2,t3;
1391
CREATE TABLE t1 (
1392
carrier char(2) default NULL,
1393
id int NOT NULL auto_increment PRIMARY KEY
1394
);
1395
INSERT INTO t1 VALUES
1396
('CO',235371754),('CO',235376554),('CO',235376884),('CO',235377874),
1397
('CO',231060394),('CO',231059224),('CO',231059314),('CO',231060484),
1398
('CO',231060274),('CO',231060124),('CO',231060244),('CO',231058594),
1399
('CO',231058924),('CO',231058504),('CO',231059344),('CO',231060424),
1400
('CO',231059554),('CO',231060304),('CO',231059644),('CO',231059464),
1401
('CO',231059764),('CO',231058294),('CO',231058624),('CO',231058864),
1402
('CO',231059374),('CO',231059584),('CO',231059734),('CO',231059014),
1403
('CO',231059854),('CO',231059494),('CO',231059794),('CO',231058534),
1404
('CO',231058324),('CO',231058684),('CO',231059524),('CO',231059974);
1405
CREATE TABLE t2 (
1406
scan_date date default NULL,
1407
package_id int default NULL,
1408
INDEX scan_date(scan_date),
1409
INDEX package_id(package_id)
1410
);
1411
INSERT INTO t2 VALUES
1412
('2008-12-29',231062944),('2008-12-29',231065764),('2008-12-29',231066124),
1413
('2008-12-29',231060094),('2008-12-29',231061054),('2008-12-29',231065644),
1414
('2008-12-29',231064384),('2008-12-29',231064444),('2008-12-29',231073774),
1415
('2008-12-29',231058594),('2008-12-29',231059374),('2008-12-29',231066004),
1416
('2008-12-29',231068494),('2008-12-29',231070174),('2008-12-29',231071884),
1417
('2008-12-29',231063274),('2008-12-29',231063754),('2008-12-29',231064144),
1418
('2008-12-29',231069424),('2008-12-29',231073714),('2008-12-29',231058414),
1419
('2008-12-29',231060994),('2008-12-29',231069154),('2008-12-29',231068614),
1420
('2008-12-29',231071464),('2008-12-29',231074014),('2008-12-29',231059614),
1421
('2008-12-29',231059074),('2008-12-29',231059464),('2008-12-29',231069094),
1422
('2008-12-29',231067294),('2008-12-29',231070144),('2008-12-29',231073804),
1423
('2008-12-29',231072634),('2008-12-29',231058294),('2008-12-29',231065344),
1424
('2008-12-29',231066094),('2008-12-29',231069034),('2008-12-29',231058594),
1425
('2008-12-29',231059854),('2008-12-29',231059884),('2008-12-29',231059914),
1426
('2008-12-29',231063664),('2008-12-29',231063814),('2008-12-29',231063904);
1427
CREATE TABLE t3 (
1428
package_id int default NULL,
1429
INDEX package_id(package_id)
1430
);
1431
INSERT INTO t3 VALUES
1432
(231058294),(231058324),(231058354),(231058384),(231058414),(231058444),
1433
(231058474),(231058504),(231058534),(231058564),(231058594),(231058624),
1434
(231058684),(231058744),(231058804),(231058864),(231058924),(231058954),
1435
(231059014),(231059074),(231059104),(231059134),(231059164),(231059194),
1436
(231059224),(231059254),(231059284),(231059314),(231059344),(231059374),
1437
(231059404),(231059434),(231059464),(231059494),(231059524),(231059554),
1438
(231059584),(231059614),(231059644),(231059674),(231059704),(231059734),
1439
(231059764),(231059794),(231059824),(231059854),(231059884),(231059914),
1440
(231059944),(231059974),(231060004),(231060034),(231060064),(231060094),
1441
(231060124),(231060154),(231060184),(231060214),(231060244),(231060274),
1442
(231060304),(231060334),(231060364),(231060394),(231060424),(231060454),
1443
(231060484),(231060514),(231060544),(231060574),(231060604),(231060634),
1444
(231060664),(231060694),(231060724),(231060754),(231060784),(231060814),
1445
(231060844),(231060874),(231060904),(231060934),(231060964),(231060994),
1446
(231061024),(231061054),(231061084),(231061144),(231061174),(231061204),
1447
(231061234),(231061294),(231061354),(231061384),(231061414),(231061474),
1448
(231061564),(231061594),(231061624),(231061684),(231061714),(231061774),
1449
(231061804),(231061894),(231061984),(231062074),(231062134),(231062224),
1450
(231062254),(231062314),(231062374),(231062434),(231062494),(231062554),
1451
(231062584),(231062614),(231062644),(231062704),(231062734),(231062794),
1452
(231062854),(231062884),(231062944),(231063004),(231063034),(231063064),
1453
(231063124),(231063154),(231063184),(231063214),(231063274),(231063334),
1454
(231063394),(231063424),(231063454),(231063514),(231063574),(231063664);
1455
CREATE TABLE t4 (
1456
carrier char(2) NOT NULL default '' PRIMARY KEY,
223 by Brian Aker
Cleanup int() work.
1457
id int default NULL,
1 by brian
clean slate
1458
INDEX id(id)
1459
);
1460
INSERT INTO t4 VALUES
1461
('99',6),('SK',456),('UA',486),('AI',1081),('OS',1111),('VS',1510);
1462
CREATE TABLE t5 (
1463
carrier_id int default NULL,
1464
INDEX carrier_id(carrier_id)
1465
);
1466
INSERT INTO t5 VALUES
1467
(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
1468
(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
1469
(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
1470
(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
1471
(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
1472
(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(456),(456),(456),
1473
(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),
1474
(456),(486),(1081),(1111),(1111),(1111),(1111),(1510);
1475
SELECT COUNT(*) 
1476
FROM((t2 JOIN t1 ON t2.package_id = t1.id) 
1477
JOIN t3 ON t3.package_id = t1.id);
1478
COUNT(*)
1479
6
1480
EXPLAIN
1481
SELECT COUNT(*) 
1482
FROM ((t2 JOIN t1 ON t2.package_id = t1.id) 
1483
JOIN t3 ON t3.package_id = t1.id)
1484
LEFT JOIN 
1485
(t5 JOIN t4 ON t5.carrier_id = t4.id)
1486
ON t4.carrier = t1.carrier;
1487
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
201 by Brian Aker
Convert default engine to Innodb
1488
1	SIMPLE	t1	ALL	PRIMARY	NULL	NULL	NULL	36	
383.1.16 by Brian Aker
Force client communication into UTF8
1489
1	SIMPLE	t4	eq_ref	PRIMARY,id	PRIMARY	10	test.t1.carrier	1	
201 by Brian Aker
Convert default engine to Innodb
1490
1	SIMPLE	t5	ref	carrier_id	carrier_id	5	test.t4.id	1	Using index
1685.7.6 by Patrick Crews
Updated test results with changes due to optimizer bug fix. EXPLAIN output now includes 'Using where' for several queries that didn't previously have this output
1491
1	SIMPLE	t2	ref	package_id	package_id	5	test.t1.id	1	Using where; Using index
1492
1	SIMPLE	t3	ref	package_id	package_id	5	test.t1.id	1	Using where; Using index
1 by brian
clean slate
1493
SELECT COUNT(*) 
1494
FROM ((t2 JOIN t1 ON t2.package_id = t1.id) 
1495
JOIN t3 ON t3.package_id = t1.id)
1496
LEFT JOIN 
1497
(t5 JOIN t4 ON t5.carrier_id = t4.id)
1498
ON t4.carrier = t1.carrier;
1499
COUNT(*)
1500
6
1501
DROP TABLE t1,t2,t3,t4,t5;
1502
End of 5.0 tests