~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/join.test

  • Committer: Brian Aker
  • Date: 2008-10-06 06:47:29 UTC
  • Revision ID: brian@tangent.org-20081006064729-2i9mhjkzyvow9xsm
RemoveĀ uint.

Show diffs side-by-side

added added

removed removed

Lines of Context:
67
67
  count int DEFAULT '0' NOT NULL,
68
68
  qty int,
69
69
  phone char(1) DEFAULT '' NOT NULL,
70
 
  timestamp datetime,
 
70
  timestamp datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
71
71
  PRIMARY KEY (id),
72
72
  KEY token (token(15)),
73
73
  KEY timestamp (timestamp),
126
126
# no matches, still three matches were found.
127
127
#
128
128
 
129
 
CREATE TEMPORARY TABLE t1 (
 
129
CREATE TABLE t1 (
130
130
  a int NOT NULL,
131
131
  b int NOT NULL,
132
132
  PRIMARY KEY  (a,b)
134
134
 
135
135
INSERT INTO t1 VALUES (1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(2,3);
136
136
 
137
 
CREATE TEMPORARY TABLE t2 (
 
137
CREATE TABLE t2 (
138
138
  a int default NULL
139
139
) ENGINE=MyISAM;
140
140
INSERT INTO t2 VALUES (2),(3);
145
145
# TEST LEFT JOIN with DATE columns
146
146
#
147
147
 
148
 
CREATE TABLE t1 (d DATE);
149
 
CREATE TABLE t2 (d DATE);
150
 
INSERT INTO t1 (d) VALUES ('2001-08-01'),(NULL);
 
148
CREATE TABLE t1 (d DATE NOT NULL);
 
149
CREATE TABLE t2 (d DATE NOT NULL);
 
150
INSERT INTO t1 (d) VALUES ('2001-08-01'),('0000-00-00');
151
151
SELECT * FROM t1 LEFT JOIN t2 USING (d) WHERE t2.d IS NULL;
152
152
SELECT * FROM t1 LEFT JOIN t2 USING (d) WHERE d IS NULL;
153
153
SELECT * from t1 WHERE t1.d IS NULL;
231
231
# Bug when doing full join and NULL fields.
232
232
#
233
233
 
234
 
CREATE TEMPORARY TABLE t1 (
 
234
CREATE TABLE t1 (
235
235
  t1_id int default NULL,
236
236
  t2_id int default NULL,
237
237
  type enum('Cost','Percent') default NULL,
242
242
  item_id int default NULL
243
243
) ENGINE=MyISAM;
244
244
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);
245
 
CREATE TEMPORARY TABLE t2 (
 
245
CREATE TABLE t2 (
246
246
  id int NOT NULL auto_increment,
247
247
  name varchar(255) default NULL,
248
248
  PRIMARY KEY  (id)
255
255
# Bug in range optimiser with MAYBE_KEY
256
256
#
257
257
 
258
 
CREATE TEMPORARY TABLE t1 (
 
258
CREATE TABLE t1 (
259
259
  siteid varchar(25) NOT NULL default '',
260
260
  emp_id varchar(30) NOT NULL default '',
261
261
  rate_code varchar(10) default NULL,
263
263
  KEY siteid (siteid)
264
264
) ENGINE=MyISAM;
265
265
INSERT INTO t1 VALUES ('rivercats','psmith','cust'), ('rivercats','KWalker','cust');
266
 
CREATE TEMPORARY TABLE t2 (
 
266
CREATE TABLE t2 (
267
267
  siteid varchar(25) NOT NULL default '',
268
268
  rate_code varchar(10) NOT NULL default '',
269
269
  base_rate float NOT NULL default '0',
576
576
select * from t1, t2, t3 where t3.a=t1.a and t2.a=t1.b;
577
577
explain select * from t1, t2, t3 where t3.a=t1.a and t2.a=t1.b;
578
578
--echo We expect rnd_next=5, and read_key must be 0 because of short-cutting:
579
 
--replace_column 2 #
580
579
show status like 'Handler_read%'; 
581
580
drop table t1, t2, t3;
582
581
 
607
606
insert into t2 select @v:=A.a+10*B.a, @v  from t1 A, t1 B;
608
607
 
609
608
explain select * from t1;
610
 
--replace_column 2 #
611
609
show status like '%cost%';
612
610
select 'The cost of accessing t1 (dont care if it changes' '^';
613
611
 
614
612
select 'vv: Following query must use ALL(t1), eq_ref(A), eq_ref(B): vv' Z;
615
613
 
616
614
explain select * from t1, t2 A, t2 B where A.a = t1.a and B.a=A.b;
617
 
--replace_column 2 #
618
615
show status like '%cost%';
619
616
select '^^: The above should be ~= 20 + cost(select * from t1). Value less than 20 is an error' Z;
620
617