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.
8
9
SELECT * FROM t1 INNER JOIN t2;
9
ERROR HY000: Implicit cartesian join attempted.
10
12
SELECT * from t1 JOIN t2 USING (S1);
12
14
SELECT * FROM t1 INNER JOIN t2 USING (S1);
72
74
count int DEFAULT '0' NOT NULL,
74
76
phone char(1) DEFAULT '' NOT NULL,
75
timestamp_arg datetime,
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)
81
83
INSERT INTO t1 VALUES (21,'e45703b64de71482360de8fec94c3ade',3,7800,'n','1999-12-23 17:22:21');
592
600
select * from (t1 cross join t2) join (t3 cross join t4) on (a < y and t2.b < t3.c);
594
603
10 1 2 1 1 10 11 3
596
605
3 1 2 1 1 10 11 3
598
607
3 2 2 1 1 10 11 3
600
608
select * from (t1, t2) join (t3, t4) on (a < y and t2.b < t3.c);
602
611
10 1 2 1 1 10 11 3
604
613
3 1 2 1 1 10 11 3
606
615
3 2 2 1 1 10 11 3
608
616
select * from (t1 natural join t2) join (t3 natural join t4) on a = y;
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;
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
768
Handler_read_rnd_next #
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));
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
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
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;
804
812
^^: The above should be ~= 20 + cost(select * from t1). Value less than 20 is an error