~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/join.result

  • Committer: Monty Taylor
  • Date: 2008-11-16 05:36:13 UTC
  • mto: (584.1.9 devel)
  • mto: This revision was merged to the branch mainline in revision 589.
  • Revision ID: monty@inaugust.com-20081116053613-bld4rqxhlkb49c02
Split out cache_row and type_holder.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
INSERT INTO t1 VALUES (1);
5
5
INSERT INTO t2 VALUES (2);
6
6
SELECT * FROM t1 JOIN t2;
7
 
ERROR HY000: Implicit cartesian join attempted.
 
7
S1      S1
 
8
1       2
8
9
SELECT * FROM t1 INNER JOIN t2;
9
 
ERROR HY000: Implicit cartesian join attempted.
 
10
S1      S1
 
11
1       2
10
12
SELECT * from t1 JOIN t2 USING (S1);
11
13
S1
12
14
SELECT * FROM t1 INNER JOIN t2 USING (S1);
72
74
count int DEFAULT '0' NOT NULL,
73
75
qty int,
74
76
phone char(1) DEFAULT '' NOT NULL,
75
 
timestamp_arg datetime,
 
77
timestamp datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
76
78
PRIMARY KEY (id),
77
79
KEY token (token(15)),
78
 
KEY timestamp_arg (timestamp_arg),
 
80
KEY timestamp (timestamp),
79
81
UNIQUE token_2 (token(75),count,phone)
80
82
);
81
83
INSERT INTO t1 VALUES (21,'e45703b64de71482360de8fec94c3ade',3,7800,'n','1999-12-23 17:22:21');
124
126
1
125
127
2
126
128
select t1.a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a) left join t1 as t32 using (a) left join t1 as t33 using (a) left join t1 as t34 using (a) left join t1 as t35 using (a) left join t1 as t36 using (a) left join t1 as t37 using (a) left join t1 as t38 using (a) left join t1 as t39 using (a) left join t1 as t40 using (a) left join t1 as t41 using (a) left join t1 as t42 using (a) left join t1 as t43 using (a) left join t1 as t44 using (a) left join t1 as t45 using (a) left join t1 as t46 using (a) left join t1 as t47 using (a) left join t1 as t48 using (a) left join t1 as t49 using (a) left join t1 as t50 using (a) left join t1 as t51 using (a) left join t1 as t52 using (a) left join t1 as t53 using (a) left join t1 as t54 using (a) left join t1 as t55 using (a) left join t1 as t56 using (a) left join t1 as t57 using (a) left join t1 as t58 using (a) left join t1 as t59 using (a) left join t1 as t60 using (a) left join t1 as t61 using (a) left join t1 as t62 using (a) left join t1 as t63 using (a) left join t1 as t64 using (a) left join t1 as t65 using (a);
127
 
ERROR HY000: Too many tables; Drizzle can only use XX tables in a join
 
129
ERROR HY000: Too many tables; MySQL can only use XX tables in a join
128
130
select a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a);
129
131
a
130
132
1
131
133
2
132
134
select a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a) left join t1 as t32 using (a) left join t1 as t33 using (a) left join t1 as t34 using (a) left join t1 as t35 using (a) left join t1 as t36 using (a) left join t1 as t37 using (a) left join t1 as t38 using (a) left join t1 as t39 using (a) left join t1 as t40 using (a) left join t1 as t41 using (a) left join t1 as t42 using (a) left join t1 as t43 using (a) left join t1 as t44 using (a) left join t1 as t45 using (a) left join t1 as t46 using (a) left join t1 as t47 using (a) left join t1 as t48 using (a) left join t1 as t49 using (a) left join t1 as t50 using (a) left join t1 as t51 using (a) left join t1 as t52 using (a) left join t1 as t53 using (a) left join t1 as t54 using (a) left join t1 as t55 using (a) left join t1 as t56 using (a) left join t1 as t57 using (a) left join t1 as t58 using (a) left join t1 as t59 using (a) left join t1 as t60 using (a) left join t1 as t61 using (a) left join t1 as t62 using (a) left join t1 as t63 using (a) left join t1 as t64 using (a) left join t1 as t65 using (a);
133
 
ERROR HY000: Too many tables; Drizzle can only use XX tables in a join
 
135
ERROR HY000: Too many tables; MySQL can only use XX tables in a join
134
136
drop table t1;
135
 
CREATE TEMPORARY TABLE t1 (
 
137
CREATE TABLE t1 (
136
138
a int NOT NULL,
137
139
b int NOT NULL,
138
140
PRIMARY KEY  (a,b)
139
141
) ENGINE=MyISAM;
140
142
INSERT INTO t1 VALUES (1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(2,3);
141
 
CREATE TEMPORARY TABLE t2 (
 
143
CREATE TABLE t2 (
142
144
a int default NULL
143
145
) ENGINE=MyISAM;
144
146
INSERT INTO t2 VALUES (2),(3);
146
148
a       a       b
147
149
2       2       3
148
150
DROP TABLE t1, t2;
149
 
CREATE TABLE t1 (d DATE);
150
 
CREATE TABLE t2 (d DATE);
151
 
INSERT INTO t1 (d) VALUES ('2001-08-01'),(NULL);
 
151
CREATE TABLE t1 (d DATE NOT NULL);
 
152
CREATE TABLE t2 (d DATE NOT NULL);
 
153
INSERT INTO t1 (d) VALUES ('2001-08-01'),('0000-00-00');
152
154
SELECT * FROM t1 LEFT JOIN t2 USING (d) WHERE t2.d IS NULL;
153
155
d
154
156
2001-08-01
155
 
NULL
 
157
0000-00-00
156
158
SELECT * FROM t1 LEFT JOIN t2 USING (d) WHERE d IS NULL;
157
159
d
158
 
NULL
 
160
0000-00-00
159
161
SELECT * from t1 WHERE t1.d IS NULL;
160
162
d
161
 
NULL
 
163
0000-00-00
162
164
SELECT * FROM t1 WHERE 1/0 IS NULL;
163
 
ERROR 22012: Division by 0
 
165
d
 
166
2001-08-01
 
167
0000-00-00
 
168
Warnings:
 
169
Error   1365    Division by 0
 
170
Error   1365    Division by 0
 
171
Error   1365    Division by 0
164
172
DROP TABLE t1,t2;
165
173
CREATE TABLE t1 (
166
174
Document_ID varchar(50) NOT NULL default '',
232
240
COUNT(t1.Title)
233
241
1
234
242
drop table t1,t2,t3;
235
 
CREATE TEMPORARY TABLE t1 (
 
243
CREATE TABLE t1 (
236
244
t1_id int default NULL,
237
245
t2_id int default NULL,
238
246
type enum('Cost','Percent') default NULL,
243
251
item_id int default NULL
244
252
) ENGINE=MyISAM;
245
253
INSERT INTO t1 VALUES (12,5,'Percent','Cost',-1,0,-1,-1),(14,4,'Percent','Cost',-1,0,-1,-1),(18,5,'Percent','Cost',-1,0,-1,-1),(19,4,'Percent','Cost',-1,0,-1,-1),(20,5,'Percent','Cost',100,-1,22,291),(21,5,'Percent','Cost',100,-1,18,291),(22,1,'Percent','Cost',100,-1,6,291),(23,1,'Percent','Cost',100,-1,21,291),(24,1,'Percent','Cost',100,-1,9,291),(25,1,'Percent','Cost',100,-1,4,291),(26,1,'Percent','Cost',100,-1,20,291),(27,4,'Percent','Cost',100,-1,7,202),(28,1,'Percent','Cost',50,-1,-1,137),(29,2,'Percent','Cost',100,-1,4,354),(30,2,'Percent','Cost',100,-1,9,137),(93,2,'Cost','Cost',-1,10000000,-1,-1);
246
 
CREATE TEMPORARY TABLE t2 (
 
254
CREATE TABLE t2 (
247
255
id int NOT NULL auto_increment,
248
256
name varchar(255) default NULL,
249
257
PRIMARY KEY  (id)
254
262
22      1       Percent Cost    100     -1      6       291     1       s1
255
263
23      1       Percent Cost    100     -1      21      291     1       s1
256
264
drop table t1,t2;
257
 
CREATE TEMPORARY TABLE t1 (
 
265
CREATE TABLE t1 (
258
266
siteid varchar(25) NOT NULL default '',
259
267
emp_id varchar(30) NOT NULL default '',
260
268
rate_code varchar(10) default NULL,
262
270
KEY siteid (siteid)
263
271
) ENGINE=MyISAM;
264
272
INSERT INTO t1 VALUES ('rivercats','psmith','cust'), ('rivercats','KWalker','cust');
265
 
CREATE TEMPORARY TABLE t2 (
 
273
CREATE TABLE t2 (
266
274
siteid varchar(25) NOT NULL default '',
267
275
rate_code varchar(10) NOT NULL default '',
268
276
base_rate float NOT NULL default '0',
297
305
CREATE TABLE t2 (b int);
298
306
CREATE TABLE t3 (c int);
299
307
SELECT * FROM t1 NATURAL JOIN t2 NATURAL JOIN t3;
300
 
ERROR HY000: Implicit cartesian join attempted.
 
308
a       b       c
301
309
DROP TABLE t1, t2, t3;
302
310
create table t1 (i int);
303
311
create table t2 (i int);
591
599
3       1       2       2
592
600
select * from (t1 cross join t2) join (t3 cross join t4) on (a < y and t2.b < t3.c);
593
601
c       b       a       b       b       c       y       c
 
602
10      1       2       1       1       3       11      3
594
603
10      1       2       1       1       10      11      3
595
 
10      1       2       1       1       3       11      3
 
604
3       1       2       1       1       3       11      3
596
605
3       1       2       1       1       10      11      3
597
 
3       1       2       1       1       3       11      3
 
606
3       2       2       1       1       3       11      3
598
607
3       2       2       1       1       10      11      3
599
 
3       2       2       1       1       3       11      3
600
608
select * from (t1, t2) join (t3, t4) on (a < y and t2.b < t3.c);
601
609
c       b       a       b       b       c       y       c
 
610
10      1       2       1       1       3       11      3
602
611
10      1       2       1       1       10      11      3
603
 
10      1       2       1       1       3       11      3
 
612
3       1       2       1       1       3       11      3
604
613
3       1       2       1       1       10      11      3
605
 
3       1       2       1       1       3       11      3
 
614
3       2       2       1       1       3       11      3
606
615
3       2       2       1       1       10      11      3
607
 
3       2       2       1       1       3       11      3
608
616
select * from (t1 natural join t2) join (t3 natural join t4) on a = y;
609
617
b       c       a       c       b       y
610
618
1       10      2       3       1       2
611
619
1       3       2       3       1       2
612
620
select * from ((t3 join (t1 join t2 on c > a) on t3.b < t2.a) join t4 on y > t1.c) join t5 on z = t1.b + 3;
613
621
b       c       c       b       a       b       y       c       y       z
 
622
1       3       10      1       2       1       11      3       11      4
614
623
1       10      10      1       2       1       11      3       11      4
 
624
1       3       3       1       2       1       11      3       11      4
615
625
1       10      3       1       2       1       11      3       11      4
616
 
1       3       10      1       2       1       11      3       11      4
617
 
1       3       3       1       2       1       11      3       11      4
618
626
select * from t1 natural join t2 where t1.b > 0;
619
627
b       c       a
620
628
1       10      2
760
768
We expect rnd_next=5, and read_key must be 0 because of short-cutting:
761
769
show status like 'Handler_read%';
762
770
Variable_name   Value
763
 
Handler_read_first      #
764
 
Handler_read_key        #
765
 
Handler_read_next       #
766
 
Handler_read_prev       #
767
 
Handler_read_rnd        #
768
 
Handler_read_rnd_next   #
 
771
Handler_read_first      1
 
772
Handler_read_key        2
 
773
Handler_read_next       0
 
774
Handler_read_prev       0
 
775
Handler_read_rnd        0
 
776
Handler_read_rnd_next   5
769
777
drop table t1, t2, t3;
770
778
create table t1 (a int);
771
779
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
772
780
create table t2 (a int, b int, filler char(100), key(a), key(b));
773
781
create table t3 (a int, b int, filler char(100), key(a), key(b));
774
782
insert into t2 
775
 
select @a:= A.a + 10*(B.a + 10*C.a), @a, 'filler' from t1 A, t1 B, t1 C where B.a >= 0;
 
783
select @a:= A.a + 10*(B.a + 10*C.a), @a, 'filler' from t1 A, t1 B, t1 C;
776
784
insert into t3 select * from t2 where a < 800;
777
785
drop table t1, t2, t3;
778
786
create table t1 (a int);
779
787
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
780
788
create table t2 (a int, b int, primary key(a));
781
 
insert into t2 select @v:=A.a+10*B.a, @v  from t1 A, t1 B where B.a >= 0;
 
789
insert into t2 select @v:=A.a+10*B.a, @v  from t1 A, t1 B;
782
790
explain select * from t1;
783
791
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
784
792
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    10      
785
793
show status like '%cost%';
786
794
Variable_name   Value
787
 
Last_query_cost #
 
795
Last_query_cost 2.999000
788
796
select 'The cost of accessing t1 (dont care if it changes' '^';
789
797
The cost of accessing t1 (dont care if it changes
790
798
The cost of accessing t1 (dont care if it changes^
798
806
1       SIMPLE  B       eq_ref  PRIMARY PRIMARY 4       test.A.b        1       
799
807
show status like '%cost%';
800
808
Variable_name   Value
801
 
Last_query_cost #
 
809
Last_query_cost 22.999000
802
810
select '^^: The above should be ~= 20 + cost(select * from t1). Value less than 20 is an error' Z;
803
811
Z
804
812
^^: The above should be ~= 20 + cost(select * from t1). Value less than 20 is an error