Commit 992a20fc authored by unknown's avatar unknown

Merge rurik.mysql.com:/home/igor/tmp_merge

into  rurik.mysql.com:/home/igor/dev/mysql-5.0-0


BitKeeper/deleted/.del-errmsg.txt~31abf77f9e7b9211:
  Auto merged
BitKeeper/deleted/.del-sql_state.h~4307ea5f1fe99019:
  Auto merged
mysql-test/r/explain.result:
  Auto merged
mysql-test/r/key_cache.result:
  Auto merged
mysql-test/r/preload.result:
  Auto merged
mysql-test/t/explain.test:
  Auto merged
mysql-test/t/select.test:
  Auto merged
scripts/make_win_src_distribution.sh:
  Auto merged
sql/sql_base.cc:
  Auto merged
BitKeeper/deleted/.del-errmsg.txt~11edc4db89248c16:
  Manual merge
BitKeeper/deleted/.del-errmsg.txt~184eb1f09242dc72:
  Manual merge
BitKeeper/deleted/.del-errmsg.txt~2cdeb8d6f80eba72:
  Manual merge
BitKeeper/deleted/.del-errmsg.txt~4617575065d612b9:
  Manual merge
BitKeeper/deleted/.del-errmsg.txt~587903f9311db2d1:
  Manual merge
BitKeeper/deleted/.del-errmsg.txt~606dfaeb9e81aa4e:
  Manual merge
BitKeeper/deleted/.del-errmsg.txt~6bbd9eac7f0e6b89:
  Manual merge
BitKeeper/deleted/.del-errmsg.txt~7397c423c52c6d2c:
  Manual merge
BitKeeper/deleted/.del-errmsg.txt~898865062c970766:
  Manual merge
BitKeeper/deleted/.del-errmsg.txt~8ed1999cbd481dc4:
  Manual merge
BitKeeper/deleted/.del-errmsg.txt~94a93cc742fca24d:
  Manual merge
BitKeeper/deleted/.del-errmsg.txt~9dab24f7fb11b1e1:
  Manual merge
BitKeeper/deleted/.del-errmsg.txt~b44a85a177954da0:
  Manual merge
BitKeeper/deleted/.del-errmsg.txt~b6181e29d8282b06:
  Manual merge
BitKeeper/deleted/.del-errmsg.txt~ba132dc9bc936c8a:
  Manual merge
BitKeeper/deleted/.del-errmsg.txt~e2609fdf7870795:
  Manual merge
BitKeeper/deleted/.del-errmsg.txt~e3183b99fbba0a9c:
  Manual merge
BitKeeper/deleted/.del-errmsg.txt~eeb2c47537ed9c23:
  Manual merge
BitKeeper/deleted/.del-errmsg.txt~ef28b592c7591b7:
  Manual merge
BitKeeper/deleted/.del-errmsg.txt~ef53c33ac0ff8a84:
  Manual merge
BitKeeper/deleted/.del-errmsg.txt~f19bfd5d4c918964:
  Manual merge
BitKeeper/deleted/.del-errmsg.txt~f96b7055cac394e:
  Manual merge
BitKeeper/deleted/.del-errmsg.txt~ffe4a0c9e3206150:
  Manual merge
BitKeeper/deleted/.del-mysqld_error.h~9dac75782467aab7:
  Manual merge
parents 4cae5175 291b58b3
......@@ -24,9 +24,9 @@ explain select * from t1 use key (str,str) where str="foo";
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 const str str 11 const 1
explain select * from t1 use key (str,str,foo) where str="foo";
ERROR 42000: Key column 'foo' doesn't exist in table
ERROR HY000: Key 'foo' doesn't exist in table 't1'
explain select * from t1 ignore key (str,str,foo) where str="foo";
ERROR 42000: Key column 'foo' doesn't exist in table
ERROR HY000: Key 'foo' doesn't exist in table 't1'
drop table t1;
explain select 1;
id select_type table type possible_keys key key_len ref rows Extra
......
......@@ -191,7 +191,7 @@ cache index t1 in unknown_key_cache;
ERROR HY000: Unknown key cache 'unknown_key_cache'
cache index t1 key (unknown_key) in keycache1;
Table Op Msg_type Msg_text
test.t1 assign_to_keycache error Key column 'unknown_key' doesn't exist in table
test.t1 assign_to_keycache error Key 'unknown_key' doesn't exist in table 't1'
test.t1 assign_to_keycache status Operation failed
Warnings:
Error 1072 Key column 'unknown_key' doesn't exist in table
......
......@@ -160,7 +160,7 @@ Key_reads 0
load index into cache t3 key (b), t2 key (c) ;
Table Op Msg_type Msg_text
test.t3 preload_keys error Table 'test.t3' doesn't exist
test.t2 preload_keys error Key column 'c' doesn't exist in table
test.t2 preload_keys error Key 'c' doesn't exist in table 't2'
test.t2 preload_keys status Operation failed
Warnings:
Error 1146 Table 'test.t3' doesn't exist
......
drop table if exists t1,t2,t3,t4,t11;
drop table if exists t1_1,t1_2,t9_1,t9_2,t1aa,t2aa;
drop view if exists v1;
drop table if exists t1,t2,t3,t4;
drop table if exists t1_1,t1_2,t9_1,t9_2;
CREATE TABLE t1 (
Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
......@@ -144,9 +143,9 @@ explain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ref fld3 fld3 30 const 1 Using where; Using index
explain select fld3 from t2 ignore index (fld3,not_used);
ERROR 42000: Key column 'not_used' doesn't exist in table
ERROR HY000: Key 'not_used' doesn't exist in table 't2'
explain select fld3 from t2 use index (not_used);
ERROR 42000: Key column 'not_used' doesn't exist in table
ERROR HY000: Key 'not_used' doesn't exist in table 't2'
select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3;
fld3
honeysuckle
......@@ -1364,17 +1363,6 @@ explain select t2.companynr,companyname from t4 left join t2 using (companynr) w
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 ALL NULL NULL NULL NULL 12
1 SIMPLE t2 ALL NULL NULL NULL NULL 1200 Using where; Not exists
select companynr,companyname from t2 left join t4 using (companynr) where companynr is null;
companynr companyname
select count(*) from t2 left join t4 using (companynr) where companynr is not null;
count(*)
1200
explain select companynr,companyname from t2 left join t4 using (companynr) where companynr is null;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr is null;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
delete from t2 where fld1=999999;
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra
......@@ -1387,19 +1375,7 @@ id select_type table type possible_keys key key_len ref rows Extra
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 Using where
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 ALL NULL NULL NULL NULL 12
......@@ -1412,26 +1388,14 @@ explain select t2.companynr,companyname from t4 left join t2 using (companynr) w
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 ALL NULL NULL NULL NULL 12
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
companynr companynr
37 36
41 40
explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 index NULL PRIMARY 1 NULL 12 Using index; Using temporary
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using temporary
1 SIMPLE t4 index NULL PRIMARY 1 NULL 12 Using where; Using index
select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008;
fld1 companynr fld3 period
038008 37 reporters 1008
......@@ -1507,7 +1471,7 @@ explain extended select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
Warnings:
Note 1003 select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> _latin1''))
Note 1003 select count(0) AS `count(*)`,min(test.t2.fld4) AS `min(fld4)`,max(test.t2.fld4) AS `max(fld4)`,sum(test.t2.fld1) AS `sum(fld1)`,avg(test.t2.fld1) AS `avg(fld1)`,std(test.t2.fld1) AS `std(fld1)`,variance(test.t2.fld1) AS `variance(fld1)` from test.t2 where ((test.t2.companynr = 34) and (test.t2.fld4 <> _latin1''))
select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3;
companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1)
00 82 Anthony windmills 10355753 126289.6707 115550.9757 13352027981.7087
......@@ -1707,7 +1671,7 @@ fld1 count(*)
158402 4181
select sum(Period)/count(*) from t1;
sum(Period)/count(*)
9410.0000
9410.00
select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr;
companynr count sum diff func
37 12543 309394878010 0.0000 464091
......@@ -1719,7 +1683,7 @@ companynr count sum diff func
512 4181 3288532102 0.0000 2140672
select companynr,sum(price)/count(price) as avg from t3 group by companynr having avg > 70000000 order by avg;
companynr avg
154 983543950.0000
154 983543950.00
select companynr,count(*) from t2 group by companynr order by 2 desc;
companynr count(*)
37 588
......@@ -2069,20 +2033,20 @@ show tables from test like "t?";
Tables_in_test (t?)
show full columns from t2;
Field Type Collation Null Key Default Extra Privileges Comment
auto int(11) NULL NO PRI NULL auto_increment #
fld1 int(6) unsigned zerofill NULL NO UNI 000000 #
companynr tinyint(2) unsigned zerofill NULL NO 00 #
fld3 char(30) latin1_swedish_ci NO MUL #
fld4 char(35) latin1_swedish_ci NO #
fld5 char(35) latin1_swedish_ci NO #
fld6 char(4) latin1_swedish_ci NO #
auto int(11) NULL PRI NULL auto_increment #
fld1 int(6) unsigned zerofill NULL UNI 000000 #
companynr tinyint(2) unsigned zerofill NULL 00 #
fld3 char(30) latin1_swedish_ci MUL #
fld4 char(35) latin1_swedish_ci #
fld5 char(35) latin1_swedish_ci #
fld6 char(4) latin1_swedish_ci #
show full columns from t2 from test like 'f%';
Field Type Collation Null Key Default Extra Privileges Comment
fld1 int(6) unsigned zerofill NULL NO UNI 000000 #
fld3 char(30) latin1_swedish_ci NO MUL #
fld4 char(35) latin1_swedish_ci NO #
fld5 char(35) latin1_swedish_ci NO #
fld6 char(4) latin1_swedish_ci NO #
fld1 int(6) unsigned zerofill NULL UNI 000000 #
fld3 char(30) latin1_swedish_ci MUL #
fld4 char(35) latin1_swedish_ci #
fld5 char(35) latin1_swedish_ci #
fld6 char(4) latin1_swedish_ci #
show full columns from t2 from test like 's%';
Field Type Collation Null Key Default Extra Privileges Comment
show keys from t2;
......@@ -2108,15 +2072,17 @@ INSERT INTO t1 (pseudo) VALUES ('test1');
SELECT 1 as rnd1 from t1 where rand() > 2;
rnd1
DROP TABLE t1;
CREATE TABLE t1 (gvid int(10) unsigned default NULL, hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, mmid int(10) unsigned default NULL, hdid int(10) unsigned default NULL, fsid int(10) unsigned default NULL, ctid int(10) unsigned default NULL, dtid int(10) unsigned default NULL, cost int(10) unsigned default NULL, performance int(10) unsigned default NULL, serialnumber bigint(20) unsigned default NULL, monitored tinyint(3) unsigned default '1', removed tinyint(3) unsigned default '0', target tinyint(3) unsigned default '0', dt_modified timestamp NOT NULL, name varchar(255) binary default NULL, description varchar(255) default NULL, UNIQUE KEY hmid (hmid,volid)) ENGINE=MyISAM;
CREATE TABLE t1 (gvid int(10) unsigned default NULL, hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, mmid int(10) unsigned default NULL, hdid int(10) unsigned default NULL, fsid int(10) unsigned default NULL, ctid int(10) unsigned default NULL, dtid int(10) unsigned default NULL, cost int(10) unsigned default NULL, performance int(10) unsigned default NULL, serialnumber bigint(20) unsigned default NULL, monitored tinyint(3) unsigned default '1', removed tinyint(3) unsigned default '0', target tinyint(3) unsigned default '0', dt_modified timestamp(14) NOT NULL, name varchar(255) binary default NULL, description varchar(255) default NULL, UNIQUE KEY hmid (hmid,volid)) ENGINE=MyISAM;
INSERT INTO t1 VALUES (200001,2,1,1,100,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\E$',''),(200002,2,2,1,101,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\C$',''),(200003,1,3,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,1,0,1,20020425060427,'c:',NULL);
CREATE TABLE t2 ( hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, sampletid smallint(5) unsigned default NULL, sampletime datetime default NULL, samplevalue bigint(20) unsigned default NULL, KEY idx1 (hmid,volid,sampletid,sampletime)) ENGINE=MyISAM;
INSERT INTO t2 VALUES (1,3,10,'2002-06-01 08:00:00',35),(1,3,1010,'2002-06-01 12:00:01',35);
SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= 'wrong-date-value' AND b.sampletime < 'wrong-date-value' AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid;
gvid the_success the_fail the_size the_time
Warnings:
Warning 1292 Incorrect datetime value: 'wrong-date-value' for column 'sampletime' at row 1
Warning 1292 Incorrect datetime value: 'wrong-date-value' for column 'sampletime' at row 1
Warning 1292 Truncated incorrect datetime value: 'wrong-date-value'
Warning 1292 Truncated incorrect datetime value: 'wrong-date-value'
Warning 1292 Truncated incorrect datetime value: 'wrong-date-value'
Warning 1292 Truncated incorrect datetime value: 'wrong-date-value'
SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= NULL AND b.sampletime < NULL AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid;
gvid the_success the_fail the_size the_time
DROP TABLE t1,t2;
......@@ -2144,165 +2110,196 @@ select @b;
aaaa
select @c;
@c
6.260
6.26
create table t1 (a int not null auto_increment primary key);
insert into t1 values ();
insert into t1 values ();
insert into t1 values ();
select * from (t1 as t2 left join t1 as t3 using (a)), t1;
a a
1 1
2 1
3 1
1 2
2 2
3 2
1 3
2 3
3 3
a a a
1 1 1
2 2 1
3 3 1
1 1 2
2 2 2
3 3 2
1 1 3
2 2 3
3 3 3
select * from t1, (t1 as t2 left join t1 as t3 using (a));
a a
1 1
2 1
3 1
1 2
2 2
3 2
1 3
2 3
3 3
a a a
1 1 1
2 1 1
3 1 1
1 2 2
2 2 2
3 2 2
1 3 3
2 3 3
3 3 3
select * from (t1 as t2 left join t1 as t3 using (a)) straight_join t1;
a a
1 1
2 1
3 1
1 2
2 2
3 2
1 3
2 3
3 3
a a a
1 1 1
2 2 1
3 3 1
1 1 2
2 2 2
3 3 2
1 1 3
2 2 3
3 3 3
select * from t1 straight_join (t1 as t2 left join t1 as t3 using (a));
a a
1 1
2 1
3 1
1 2
2 2
3 2
1 3
2 3
3 3
a a a
1 1 1
2 1 1
3 1 1
1 2 2
2 2 2
3 2 2
1 3 3
2 3 3
3 3 3
select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 on t1.a>1;
a a
1 2
2 2
3 2
1 3
2 3
3 3
a a a
1 1 2
1 1 3
2 2 2
2 2 3
3 3 2
3 3 3
select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1;
a a
2 1
3 1
2 2
3 2
2 3
3 3
a a a
1 1 NULL
2 1 1
3 1 1
1 2 NULL
2 2 2
3 2 2
1 3 NULL
2 3 3
3 3 3
select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 using ( a );
a
1
2
3
a a a
1 1 1
2 2 2
3 3 3
select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) using ( a );
a
1
2
3
a a a
1 1 1
2 1 NULL
3 1 NULL
1 2 NULL
2 2 2
3 2 NULL
1 3 NULL
2 3 NULL
3 3 3
select * from (t1 as t2 left join t1 as t3 using (a)) left outer join t1 on t1.a>1;
a a
1 2
1 3
2 2
2 3
3 2
3 3
a a a
1 1 2
1 1 3
2 2 2
2 2 3
3 3 2
3 3 3
select * from t1 left outer join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1;
a a
1 NULL
2 1
2 2
2 3
3 1
3 2
3 3
a a a
1 1 NULL
2 1 1
3 1 1
1 2 NULL
2 2 2
3 2 2
1 3 NULL
2 3 3
3 3 3
select * from (t1 as t2 left join t1 as t3 using (a)) left join t1 using ( a );
a
1
2
3
a a a
1 1 1
2 2 2
3 3 3
select * from t1 left join (t1 as t2 left join t1 as t3 using (a)) using ( a );
a
1
2
3
a a a
1 1 1
2 1 NULL
3 1 NULL
1 2 NULL
2 2 2
3 2 NULL
1 3 NULL
2 3 NULL
3 3 3
select * from (t1 as t2 left join t1 as t3 using (a)) natural left join t1;
a
1
2
3
a a a
1 1 1
2 2 2
3 3 3
select * from t1 natural left join (t1 as t2 left join t1 as t3 using (a));
a
1
2
3
a a a
1 1 1
2 2 2
3 3 3
select * from (t1 as t2 left join t1 as t3 using (a)) right join t1 on t1.a>1;
a a
NULL 1
1 2
2 2
3 2
1 3
2 3
3 3
a a a
1 NULL 1
2 NULL 1
3 NULL 1
1 1 2
2 2 2
3 3 2
1 1 3
2 2 3
3 3 3
select * from t1 right join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1;
a a
2 1
3 1
2 2
3 2
2 3
3 3
a a a
2 1 1
3 1 1
2 2 2
3 2 2
2 3 3
3 3 3
select * from (t1 as t2 left join t1 as t3 using (a)) right outer join t1 using ( a );
a
1
2
3
a a a
1 1 1
2 NULL 1
3 NULL 1
1 NULL 2
2 2 2
3 NULL 2
1 NULL 3
2 NULL 3
3 3 3
select * from t1 right outer join (t1 as t2 left join t1 as t3 using (a)) using ( a );
a
1
2
3
a a a
1 1 1
2 2 2
3 3 3
select * from (t1 as t2 left join t1 as t3 using (a)) natural right join t1;
a
1
2
3
a a a
1 1 1
2 NULL 1
3 NULL 1
1 NULL 2
2 2 2
3 NULL 2
1 NULL 3
2 NULL 3
3 3 3
select * from t1 natural right join (t1 as t2 left join t1 as t3 using (a));
a
1
2
3
a a a
1 1 1
2 2 2
3 3 3
select * from t1 natural join (t1 as t2 left join t1 as t3 using (a));
a
1
2
3
a a
1 1
2 2
3 3
select * from (t1 as t2 left join t1 as t3 using (a)) natural join t1;
a
1
2
3
a a a
1 1 1
2 2 2
3 3 3
drop table t1;
CREATE TABLE t1 ( aa char(2), id int(11) NOT NULL auto_increment, t2_id int(11) NOT NULL default '0', PRIMARY KEY (id), KEY replace_id (t2_id)) ENGINE=MyISAM;
INSERT INTO t1 VALUES ("1",8264,2506),("2",8299,2517),("3",8301,2518),("4",8302,2519),("5",8303,2520),("6",8304,2521),("7",8305,2522);
......@@ -2651,8 +2648,8 @@ create table t11 like t1;
insert into t1 values(1,""),(2,"");
show table status like 't1%';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 MyISAM 10 Dynamic 2 20 X X X X X X X X latin1_swedish_ci NULL
t11 MyISAM 10 Dynamic 0 0 X X X X X X X X latin1_swedish_ci NULL
t1 MyISAM 9 Dynamic 2 20 X X X X X X X X latin1_swedish_ci NULL
t11 MyISAM 9 Dynamic 0 0 X X X X X X X X latin1_swedish_ci NULL
select 123 as a from t1 where f1 is null;
a
drop table t1,t11;
......@@ -2668,9 +2665,10 @@ a c
drop table t1;
CREATE TABLE t1 ( a INT NOT NULL, b INT NOT NULL, UNIQUE idx (a,b) );
INSERT INTO t1 VALUES (1,1),(1,2),(1,3),(1,4);
CREATE TABLE t2 ( a INT NOT NULL, b INT NOT NULL, e INT );
INSERT INTO t2 VALUES ( 1,10,1), (1,10,2), (1,11,1), (1,11,2), (1,2,1), (1,2,2),(1,2,3);
SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN
CREATE TABLE t2 ( a INT NOT NULL, b INT NOT NULL, c INT );
INSERT INTO t2 VALUES ( 1,10,1), (1,10,2), (1,11,1), (1,11,2), (1,2,1), (1,2,2),
(1,2,3);
SELECT t2.a, t2.b, IF(t1.b IS NULL,'',c) AS c, COUNT(*) AS d FROM t2 LEFT JOIN
t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY a, b, c;
a b c d
1 2 1 1
......@@ -2678,14 +2676,14 @@ a b c d
1 2 3 1
1 10 2
1 11 2
SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN
SELECT t2.a, t2.b, IF(t1.b IS NULL,'',c) AS c, COUNT(*) AS d FROM t2 LEFT JOIN
t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY t1.a, t1.b, c;
a b c d
1 10 4
1 2 1 1
1 2 2 1
1 2 3 1
SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN
SELECT t2.a, t2.b, IF(t1.b IS NULL,'',c) AS c, COUNT(*) AS d FROM t2 LEFT JOIN
t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY t2.a, t2.b, c;
a b c d
1 2 1 1
......@@ -2693,7 +2691,7 @@ a b c d
1 2 3 1
1 10 2
1 11 2
SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2,t1
SELECT t2.a, t2.b, IF(t1.b IS NULL,'',c) AS c, COUNT(*) AS d FROM t2,t1
WHERE t2.a = t1.a AND t2.b = t1.b GROUP BY a, b, c;
a b c d
1 2 1 1
......@@ -2716,733 +2714,13 @@ select * from t1 where f1 in (select f3 from t2 where (f3,f4)= (select f3,f4 fro
f1 f2
1 1
drop table t1,t2;
CREATE TABLE t1 ( city char(30) );
INSERT INTO t1 VALUES ('London');
INSERT INTO t1 VALUES ('Paris');
SELECT * FROM t1 WHERE city='London';
city
London
SELECT * FROM t1 WHERE city='london';
city
London
EXPLAIN SELECT * FROM t1 WHERE city='London' AND city='london';
CREATE TABLE t1 (a int, INDEX idx(a));
INSERT INTO t1 VALUES (2), (3), (1);
EXPLAIN SELECT * FROM t1 IGNORE INDEX (idx);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
SELECT * FROM t1 WHERE city='London' AND city='london';
city
London
EXPLAIN SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London';
city
London
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
EXPLAIN SELECT * FROM t1 IGNORE INDEX (a);
ERROR HY000: Key 'a' doesn't exist in table 't1'
EXPLAIN SELECT * FROM t1 FORCE INDEX (a);
ERROR HY000: Key 'a' doesn't exist in table 't1'
DROP TABLE t1;
create table t1 (a int(11) unsigned, b int(11) unsigned);
insert into t1 values (1,0), (1,1), (1,2);
select a-b from t1 order by 1;
a-b
0
1
18446744073709551615
select a-b , (a-b < 0) from t1 order by 1;
a-b (a-b < 0)
0 0
1 0
18446744073709551615 0
select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0;
d (a-b >= 0) b
1 1 0
0 1 1
18446744073709551615 1 2
select cast((a - b) as unsigned) from t1 order by 1;
cast((a - b) as unsigned)
0
1
18446744073709551615
drop table t1;
create table t1 (a int(11));
select all all * from t1;
a
select distinct distinct * from t1;
a
select all distinct * from t1;
ERROR HY000: Incorrect usage of ALL and DISTINCT
select distinct all * from t1;
ERROR HY000: Incorrect usage of ALL and DISTINCT
drop table t1;
CREATE TABLE t1 (
K2C4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '',
K4N4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '0000',
F2I4 int(11) NOT NULL default '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO t1 VALUES
('W%RT', '0100', 1),
('W-RT', '0100', 1),
('WART', '0100', 1),
('WART', '0200', 1),
('WERT', '0100', 2),
('WORT','0200', 2),
('WT', '0100', 2),
('W_RT', '0100', 2),
('WaRT', '0100', 3),
('WART', '0300', 3),
('WRT' , '0400', 3),
('WURM', '0500', 3),
('W%T', '0600', 4),
('WA%T', '0700', 4),
('WA_T', '0800', 4);
SELECT K2C4, K4N4, F2I4 FROM t1
WHERE K2C4 = 'WART' AND
(F2I4 = 2 AND K2C4 = 'WART' OR (F2I4 = 2 OR K4N4 = '0200'));
K2C4 K4N4 F2I4
WART 0200 1
SELECT K2C4, K4N4, F2I4 FROM t1
WHERE K2C4 = 'WART' AND (K2C4 = 'WART' OR K4N4 = '0200');
K2C4 K4N4 F2I4
WART 0100 1
WART 0200 1
WART 0300 3
DROP TABLE t1;
CREATE TABLE t1 ( a BLOB, INDEX (a(20)) );
CREATE TABLE t2 ( a BLOB, INDEX (a(20)) );
INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five');
INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five');
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5
1 SIMPLE t2 ref a a 23 test.t1.a 2
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5
1 SIMPLE t2 ref a a 23 test.t1.a 2
DROP TABLE t1, t2;
create table t1 (a int, b int);
create table t2 like t1;
select t1.a from (t1 inner join t2 on t1.a=t2.a) where t2.a=1;
a
select t1.a from ((t1 inner join t2 on t1.a=t2.a)) where t2.a=1;
a
select x.a, y.a, z.a from ( (t1 x inner join t2 y on x.a=y.a) inner join t2 z on y.a=z.a) WHERE x.a=1;
a a a
drop table t1,t2;
create table t1 (s1 varchar(5));
insert into t1 values ('Wall');
select min(s1) from t1 group by s1 with rollup;
min(s1)
Wall
Wall
drop table t1;
create table t1 (s1 int) engine=myisam;
insert into t1 values (0);
select avg(distinct s1) from t1 group by s1 with rollup;
avg(distinct s1)
0.0000
0.0000
drop table t1;
create table t1 (s1 int);
insert into t1 values (null),(1);
select distinct avg(s1) as x from t1 group by s1 with rollup;
x
NULL
1.0000
drop table t1;
create table t1 (a int(11));
select all all * from t1;
a
select distinct distinct * from t1;
a
select all distinct * from t1;
ERROR HY000: Incorrect usage of ALL and DISTINCT
select distinct all * from t1;
ERROR HY000: Incorrect usage of ALL and DISTINCT
drop table t1;
CREATE TABLE t1 ( a BLOB, INDEX (a(20)) );
CREATE TABLE t2 ( a BLOB, INDEX (a(20)) );
INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five');
INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five');
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5
1 SIMPLE t2 ref a a 23 test.t1.a 2
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5
1 SIMPLE t2 ref a a 23 test.t1.a 2
DROP TABLE t1, t2;
CREATE TABLE t1 (a int);
CREATE TABLE t2 (a int);
INSERT INTO t1 VALUES (1), (2), (3), (4), (5);
INSERT INTO t2 VALUES (2), (4), (6);
SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a;
a
2
4
EXPLAIN SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
EXPLAIN SELECT t1.a FROM t1 INNER JOIN t2 ON t1.a=t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 3
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where
DROP TABLE t1,t2;
select x'10' + 0, X'10' + 0, b'10' + 0, B'10' + 0;
x'10' + 0 X'10' + 0 b'10' + 0 B'10' + 0
16 16 2 2
create table t1 (f1 varchar(6) default NULL, f2 int(6) primary key not null);
create table t2 (f3 varchar(5) not null, f4 varchar(5) not null, UNIQUE KEY UKEY (f3,f4));
insert into t1 values (" 2", 2);
insert into t2 values (" 2", " one "),(" 2", " two ");
select * from t1 left join t2 on f1 = f3;
f1 f2 f3 f4
2 2 2 one
2 2 2 two
drop table t1,t2;
create table t1 (empnum smallint, grp int);
create table t2 (empnum int, name char(5));
insert into t1 values(1,1);
insert into t2 values(1,'bob');
create view v1 as select * from t2 inner join t1 using (empnum);
select * from v1;
empnum name grp
1 bob 1
drop table t1,t2;
drop view v1;
create table t1 (pk int primary key, b int);
create table t2 (pk int primary key, c int);
select pk from t1 inner join t2 using (pk);
pk
drop table t1,t2;
create table t1 (s1 int, s2 char(5), s3 decimal(10));
create view v1 as select s1, s2, 'x' as s3 from t1;
select * from t1 natural join v1;
s1 s2 s3
insert into t1 values (1,'x',5);
select * from t1 natural join v1;
s1 s2 s3
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'x'
drop table t1;
drop view v1;
create table t1(a1 int);
create table t2(a2 int);
insert into t1 values(1),(2);
insert into t2 values(1),(2);
create view v2 (c) as select a1 from t1;
select * from t1 natural left join t2;
a1 a2
1 1
1 2
2 1
2 2
select * from t1 natural right join t2;
a2 a1
1 1
1 2
2 1
2 2
select * from v2 natural left join t2;
c a2
1 1
1 2
2 1
2 2
select * from v2 natural right join t2;
a2 c
1 1
1 2
2 1
2 2
drop table t1, t2;
drop view v2;
create table t1 (a int(10), t1_val int(10));
create table t2 (b int(10), t2_val int(10));
create table t3 (a int(10), b int(10));
insert into t1 values (1,1),(2,2);
insert into t2 values (1,1),(2,2),(3,3);
insert into t3 values (1,1),(2,1),(3,1),(4,1);
select * from t1 natural join t2 natural join t3;
a b t1_val t2_val
1 1 1 1
2 1 2 1
select * from t1 natural join t3 natural join t2;
b a t1_val t2_val
1 1 1 1
1 2 2 1
drop table t1, t2, t3;
DO IFNULL(NULL, NULL);
SELECT CAST(IFNULL(NULL, NULL) AS DECIMAL);
CAST(IFNULL(NULL, NULL) AS DECIMAL)
NULL
SELECT ABS(IFNULL(NULL, NULL));
ABS(IFNULL(NULL, NULL))
NULL
SELECT IFNULL(NULL, NULL);
IFNULL(NULL, NULL)
NULL
SET @OLD_SQL_MODE12595=@@SQL_MODE, @@SQL_MODE='';
SHOW LOCAL VARIABLES LIKE 'SQL_MODE';
Variable_name Value
sql_mode
CREATE TABLE BUG_12595(a varchar(100));
INSERT INTO BUG_12595 VALUES ('hakan%'), ('hakank'), ("ha%an");
SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%';
a
hakan%
SELECT * FROM BUG_12595 WHERE a LIKE 'hakan*%' ESCAPE '*';
a
hakan%
SELECT * FROM BUG_12595 WHERE a LIKE 'hakan**%' ESCAPE '**';
ERROR HY000: Incorrect arguments to ESCAPE
SELECT * FROM BUG_12595 WHERE a LIKE 'hakan%' ESCAPE '';
a
hakan%
hakank
SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%' ESCAPE '';
a
SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE 0x5c;
a
ha%an
SELECT * FROM BUG_12595 WHERE a LIKE 'ha%%an' ESCAPE '%';
a
ha%an
SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE '\\';
a
ha%an
SELECT * FROM BUG_12595 WHERE a LIKE 'ha|%an' ESCAPE '|';
a
ha%an
SET @@SQL_MODE='NO_BACKSLASH_ESCAPES';
SHOW LOCAL VARIABLES LIKE 'SQL_MODE';
Variable_name Value
sql_mode NO_BACKSLASH_ESCAPES
SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%';
a
SELECT * FROM BUG_12595 WHERE a LIKE 'hakan*%' ESCAPE '*';
a
hakan%
SELECT * FROM BUG_12595 WHERE a LIKE 'hakan**%' ESCAPE '**';
ERROR HY000: Incorrect arguments to ESCAPE
SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%' ESCAPE '\\';
ERROR HY000: Incorrect arguments to ESCAPE
SELECT * FROM BUG_12595 WHERE a LIKE 'hakan%' ESCAPE '';
ERROR HY000: Incorrect arguments to ESCAPE
SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE 0x5c;
a
ha%an
SELECT * FROM BUG_12595 WHERE a LIKE 'ha|%an' ESCAPE '|';
a
ha%an
SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\n%' ESCAPE '\n';
ERROR HY000: Incorrect arguments to ESCAPE
SET @@SQL_MODE=@OLD_SQL_MODE12595;
DROP TABLE BUG_12595;
create table t1 (a char(1));
create table t2 (a char(1));
insert into t1 values ('a'),('b'),('c');
insert into t2 values ('b'),('c'),('d');
select a from t1 natural join t2;
a
b
c
select * from t1 natural join t2 where a = 'b';
a
b
drop table t1, t2;
CREATE TABLE t1 (`id` TINYINT);
CREATE TABLE t2 (`id` TINYINT);
CREATE TABLE t3 (`id` TINYINT);
INSERT INTO t1 VALUES (1),(2),(3);
INSERT INTO t2 VALUES (2);
INSERT INTO t3 VALUES (3);
SELECT t1.id,t3.id FROM t1 JOIN t2 ON (t2.id=t1.id) LEFT JOIN t3 USING (id);
ERROR 23000: Column 'id' in from clause is ambiguous
SELECT t1.id,t3.id FROM t1 JOIN t2 ON (t2.notacolumn=t1.id) LEFT JOIN t3 USING (id);
ERROR 23000: Column 'id' in from clause is ambiguous
SELECT id,t3.id FROM t1 JOIN t2 ON (t2.id=t1.id) LEFT JOIN t3 USING (id);
ERROR 23000: Column 'id' in from clause is ambiguous
SELECT id,t3.id FROM (t1 JOIN t2 ON (t2.id=t1.id)) LEFT JOIN t3 USING (id);
ERROR 23000: Column 'id' in from clause is ambiguous
drop table t1, t2, t3;
create table t1 (a int(10),b int(10));
create table t2 (a int(10),b int(10));
insert into t1 values (1,10),(2,20),(3,30);
insert into t2 values (1,10);
select * from t1 inner join t2 using (A);
a b b
1 10 10
select * from t1 inner join t2 using (a);
a b b
1 10 10
drop table t1, t2;
create table t1 (a int, c int);
create table t2 (b int);
create table t3 (b int, a int);
create table t4 (c int);
insert into t1 values (1,1);
insert into t2 values (1);
insert into t3 values (1,1);
insert into t4 values (1);
select * from t1 join t2 join t3 on (t2.b = t3.b and t1.a = t3.a);
a c b b a
1 1 1 1 1
select * from t1, t2 join t3 on (t2.b = t3.b and t1.a = t3.a);
ERROR 42S22: Unknown column 't1.a' in 'on clause'
select * from t1 join t2 join t3 join t4 on (t1.a = t4.c and t2.b = t4.c);
a c b b a c
1 1 1 1 1 1
select * from t1 join t2 join t4 using (c);
c a b
1 1 1
drop table t1, t2, t3, t4;
create table t1(x int, y int);
create table t2(x int, y int);
create table t3(x int, primary key(x));
insert into t1 values (1, 1), (2, 1), (3, 1), (4, 3), (5, 6), (6, 6);
insert into t2 values (1, 1), (2, 1), (3, 3), (4, 6), (5, 6);
insert into t3 values (1), (2), (3), (4), (5);
select t1.x, t3.x from t1, t2, t3 where t1.x = t2.x and t3.x >= t1.y and t3.x <= t2.y;
x x
1 1
2 1
3 1
3 2
3 3
4 3
4 4
4 5
drop table t1,t2,t3;
create table t1 (id char(16) not null default '', primary key (id));
insert into t1 values ('100'),('101'),('102');
create table t2 (id char(16) default null);
insert into t2 values (1);
create view v1 as select t1.id from t1;
create view v2 as select t2.id from t2;
create view v3 as select (t1.id+2) as id from t1 natural left join t2;
select t1.id from t1 left join v2 using (id);
id
100
101
102
select t1.id from v2 right join t1 using (id);
id
100
101
102
select t1.id from t1 left join v3 using (id);
id
100
101
102
select * from t1 left join v2 using (id);
id
100
101
102
select * from v2 right join t1 using (id);
id
100
101
102
select * from t1 left join v3 using (id);
id
100
101
102
select v1.id from v1 left join v2 using (id);
id
100
101
102
select v1.id from v2 right join v1 using (id);
id
100
101
102
select v1.id from v1 left join v3 using (id);
id
100
101
102
select * from v1 left join v2 using (id);
id
100
101
102
select * from v2 right join v1 using (id);
id
100
101
102
select * from v1 left join v3 using (id);
id
100
101
102
drop table t1, t2;
drop view v1, v2, v3;
create table t1 (id int(11) not null default '0');
insert into t1 values (123),(191),(192);
create table t2 (id char(16) character set utf8 not null);
insert into t2 values ('58013'),('58014'),('58015'),('58016');
create table t3 (a_id int(11) not null, b_id char(16) character set utf8);
insert into t3 values (123,null),(123,null),(123,null),(123,null),(123,null),(123,'58013');
select count(*)
from t1 inner join (t3 left join t2 on t2.id = t3.b_id) on t1.id = t3.a_id;
count(*)
6
select count(*)
from t1 inner join (t2 right join t3 on t2.id = t3.b_id) on t1.id = t3.a_id;
count(*)
6
drop table t1,t2,t3;
create table t1 (a int);
create table t2 (b int);
create table t3 (c int);
select * from t1 join t2 join t3 on (t1.a=t3.c);
a b c
select * from t1 join t2 left join t3 on (t1.a=t3.c);
a b c
select * from t1 join t2 right join t3 on (t1.a=t3.c);
a b c
select * from t1 join t2 straight_join t3 on (t1.a=t3.c);
a b c
drop table t1, t2 ,t3;
create table t1(f1 int, f2 date);
insert into t1 values(1,'2005-01-01'),(2,'2005-09-01'),(3,'2005-09-30'),
(4,'2005-10-01'),(5,'2005-12-30');
select * from t1 where f2 >= 0;
f1 f2
1 2005-01-01
2 2005-09-01
3 2005-09-30
4 2005-10-01
5 2005-12-30
select * from t1 where f2 >= '0000-00-00';
f1 f2
1 2005-01-01
2 2005-09-01
3 2005-09-30
4 2005-10-01
5 2005-12-30
select * from t1 where f2 >= '2005-09-31';
f1 f2
4 2005-10-01
5 2005-12-30
select * from t1 where f2 >= '2005-09-3a';
f1 f2
4 2005-10-01
5 2005-12-30
Warnings:
Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 1
select * from t1 where f2 <= '2005-09-31';
f1 f2
1 2005-01-01
2 2005-09-01
3 2005-09-30
select * from t1 where f2 <= '2005-09-3a';
f1 f2
1 2005-01-01
2 2005-09-01
3 2005-09-30
Warnings:
Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 1
drop table t1;
create table t1 (f1 int, f2 int);
insert into t1 values (1, 30), (2, 20), (3, 10);
create algorithm=merge view v1 as select f1, f2 from t1;
create algorithm=merge view v2 (f2, f1) as select f1, f2 from t1;
create algorithm=merge view v3 as select t1.f1 as f2, t1.f2 as f1 from t1;
select t1.f1 as x1, f1 from t1 order by t1.f1;
x1 f1
1 1
2 2
3 3
select v1.f1 as x1, f1 from v1 order by v1.f1;
x1 f1
1 1
2 2
3 3
select v2.f1 as x1, f1 from v2 order by v2.f1;
x1 f1
10 10
20 20
30 30
select v3.f1 as x1, f1 from v3 order by v3.f1;
x1 f1
10 10
20 20
30 30
select f1, f2, v1.f1 as x1 from v1 order by v1.f1;
f1 f2 x1
1 30 1
2 20 2
3 10 3
select f1, f2, v2.f1 as x1 from v2 order by v2.f1;
f1 f2 x1
10 3 10
20 2 20
30 1 30
select f1, f2, v3.f1 as x1 from v3 order by v3.f1;
f1 f2 x1
10 3 10
20 2 20
30 1 30
drop table t1;
drop view v1, v2, v3;
CREATE TABLE t1(key_a int4 NOT NULL, optimus varchar(32), PRIMARY KEY(key_a));
CREATE TABLE t2(key_a int4 NOT NULL, prime varchar(32), PRIMARY KEY(key_a));
CREATE table t3(key_a int4 NOT NULL, key_b int4 NOT NULL, foo varchar(32),
PRIMARY KEY(key_a,key_b));
INSERT INTO t1 VALUES (0,'');
INSERT INTO t1 VALUES (1,'i');
INSERT INTO t1 VALUES (2,'j');
INSERT INTO t1 VALUES (3,'k');
INSERT INTO t2 VALUES (1,'r');
INSERT INTO t2 VALUES (2,'s');
INSERT INTO t2 VALUES (3,'t');
INSERT INTO t3 VALUES (1,5,'x');
INSERT INTO t3 VALUES (1,6,'y');
INSERT INTO t3 VALUES (2,5,'xx');
INSERT INTO t3 VALUES (2,6,'yy');
INSERT INTO t3 VALUES (2,7,'zz');
INSERT INTO t3 VALUES (3,5,'xxx');
SELECT t2.key_a,foo
FROM t1 INNER JOIN t2 ON t1.key_a = t2.key_a
INNER JOIN t3 ON t1.key_a = t3.key_a
WHERE t2.key_a=2 and key_b=5;
key_a foo
2 xx
EXPLAIN SELECT t2.key_a,foo
FROM t1 INNER JOIN t2 ON t1.key_a = t2.key_a
INNER JOIN t3 ON t1.key_a = t3.key_a
WHERE t2.key_a=2 and key_b=5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index
1 SIMPLE t2 const PRIMARY PRIMARY 4 const 1 Using index
1 SIMPLE t3 const PRIMARY PRIMARY 8 const,const 1
SELECT t2.key_a,foo
FROM t1 INNER JOIN t2 ON t2.key_a = t1.key_a
INNER JOIN t3 ON t1.key_a = t3.key_a
WHERE t2.key_a=2 and key_b=5;
key_a foo
2 xx
EXPLAIN SELECT t2.key_a,foo
FROM t1 INNER JOIN t2 ON t2.key_a = t1.key_a
INNER JOIN t3 ON t1.key_a = t3.key_a
WHERE t2.key_a=2 and key_b=5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index
1 SIMPLE t2 const PRIMARY PRIMARY 4 const 1 Using index
1 SIMPLE t3 const PRIMARY PRIMARY 8 const,const 1
DROP TABLE t1,t2,t3;
create table t1 (f1 int);
insert into t1 values(1),(2);
create table t2 (f2 int, f3 int, key(f2));
insert into t2 values(1,1),(2,2);
create table t3 (f4 int not null);
insert into t3 values (2),(2),(2);
select f1,(select count(*) from t2,t3 where f2=f1 and f3=f4) as count from t1;
f1 count
1 0
2 3
drop table t1,t2,t3;
create table t1 (f1 int unique);
create table t2 (f2 int unique);
create table t3 (f3 int unique);
insert into t1 values(1),(2);
insert into t2 values(1),(2);
insert into t3 values(1),(NULL);
select * from t3 where f3 is null;
f3
NULL
select t2.f2 from t1 left join t2 on f1=f2 join t3 on f1=f3 where f1=1;
f2
1
drop table t1,t2,t3;
create table t1(f1 char, f2 char not null);
insert into t1 values(null,'a');
create table t2 (f2 char not null);
insert into t2 values('b');
select * from t1 left join t2 on f1=t2.f2 where t1.f2='a';
f1 f2 f2
NULL a NULL
drop table t1,t2;
select * from (select * left join t on f1=f2) tt;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'on f1=f2) tt' at line 1
CREATE TABLE t1 (sku int PRIMARY KEY, pr int);
CREATE TABLE t2 (sku int PRIMARY KEY, sppr int, name varchar(255));
INSERT INTO t1 VALUES
(10, 10), (20, 10), (30, 20), (40, 30), (50, 10), (60, 10);
INSERT INTO t2 VALUES
(10, 10, 'aaa'), (20, 10, 'bbb'), (30, 10, 'ccc'), (40, 20, 'ddd'),
(50, 10, 'eee'), (60, 20, 'fff'), (70, 20, 'ggg'), (80, 30, 'hhh');
SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.pr
FROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku);
sku sppr name sku pr
20 10 bbb 10 10
20 10 bbb 20 10
EXPLAIN
SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.pr
FROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 const PRIMARY PRIMARY 4 const 1
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where
DROP TABLE t1,t2;
CREATE TABLE t1 (i TINYINT UNSIGNED NOT NULL);
INSERT t1 SET i = 0;
UPDATE t1 SET i = -1;
Warnings:
Warning 1264 Out of range value adjusted for column 'i' at row 1
SELECT * FROM t1;
i
0
UPDATE t1 SET i = CAST(i - 1 AS SIGNED);
Warnings:
Warning 1264 Out of range value adjusted for column 'i' at row 1
SELECT * FROM t1;
i
0
UPDATE t1 SET i = i - 1;
Warnings:
Warning 1264 Out of range value adjusted for column 'i' at row 1
SELECT * FROM t1;
i
255
DROP TABLE t1;
create table t1 (a int);
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t2 (a int, b int, c int, e int, primary key(a,b,c));
insert into t2 select A.a, B.a, C.a, C.a from t1 A, t1 B, t1 C;
analyze table t2;
Table Op Msg_type Msg_text
test.t2 analyze status OK
select 'In next EXPLAIN, B.rows must be exactly 10:' Z;
Z
In next EXPLAIN, B.rows must be exactly 10:
explain select * from t2 A, t2 B where A.a=5 and A.b=5 and A.C<5
and B.a=5 and B.b=A.e and (B.b =1 or B.b = 3 or B.b=5);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE A range PRIMARY PRIMARY 12 NULL 3 Using where
1 SIMPLE B ref PRIMARY PRIMARY 8 const,test.A.e 10
drop table t1, t2;
CREATE TABLE t1 (a int PRIMARY KEY, b int, INDEX(b));
INSERT INTO t1 VALUES (1, 3), (9,4), (7,5), (4,5), (6,2),
(3,1), (5,1), (8,9), (2,2), (0,9);
CREATE TABLE t2 (c int, d int, f int, INDEX(c,f));
INSERT INTO t2 VALUES
(1,0,0), (1,0,1), (2,0,0), (2,0,1), (3,0,0), (4,0,1),
(5,0,0), (5,0,1), (6,0,0), (0,0,1), (7,0,0), (7,0,1),
(0,0,0), (0,0,1), (8,0,0), (8,0,1), (9,0,0), (9,0,1);
EXPLAIN
SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY,b b 5 NULL 3 Using where
1 SIMPLE t2 ref c c 5 test.t1.a 2 Using where
EXPLAIN
SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6 AND a > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY,b b 5 NULL 3 Using where
1 SIMPLE t2 ref c c 5 test.t1.a 2 Using where
DROP TABLE t1, t2;
......@@ -15,9 +15,9 @@ explain select * from t1 ignore key (str) where str="foo";
explain select * from t1 use key (str,str) where str="foo";
#The following should give errors
--error 1072
--error 1176
explain select * from t1 use key (str,str,foo) where str="foo";
--error 1072
--error 1176
explain select * from t1 ignore key (str,str,foo) where str="foo";
drop table t1;
......
......@@ -1296,9 +1296,9 @@ explain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle';
# The next should give an error
#
-- error 1072
-- error 1176
explain select fld3 from t2 ignore index (fld3,not_used);
-- error 1072
-- error 1176
explain select fld3 from t2 use index (not_used);
#
......@@ -2264,6 +2264,21 @@ insert into t2 values(1,1);
select * from t1 where f1 in (select f3 from t2 where (f3,f4)= (select f3,f4 from t2));
drop table t1,t2;
#
# Bug #17873: confusing error message when IGNORE INDEX refers a column name
#
CREATE TABLE t1 (a int, INDEX idx(a));
INSERT INTO t1 VALUES (2), (3), (1);
EXPLAIN SELECT * FROM t1 IGNORE INDEX (idx);
--error 1176
EXPLAIN SELECT * FROM t1 IGNORE INDEX (a);
--error 1176
EXPLAIN SELECT * FROM t1 FORCE INDEX (a);
DROP TABLE t1;
# End of 4.1 tests
#
......
......@@ -45,9 +45,11 @@ fi
mkdir -p $BASE/lib
for i in \
libmysql/.libs/libmysqlclient.s{l,o}* \
libmysql/.libs/libmysqlclient.so* \
libmysql/.libs/libmysqlclient.sl* \
libmysql/.libs/libmysqlclient*.dylib \
libmysql_r/.libs/libmysqlclient_r.s{l,o}* \
libmysql_r/.libs/libmysqlclient_r.so* \
libmysql_r/.libs/libmysqlclient_r.sl* \
libmysql_r/.libs/libmysqlclient_r*.dylib
do
if [ -f $i ]
......
......@@ -345,6 +345,7 @@ mv $BASE/sql/sql_yacc.cpp-new $BASE/sql/sql_yacc.cpp
find $BASE \( -name "*.cnf" -o -name "*.ini" \
-o -name COPYING -o -name ChangeLog -o -name EXCEPTIONS-CLIENT \
-o -name "INSTALL*" -o -name LICENSE -o -name "README*" \
-o -name "*.dsp" -o -name "*.dsw" \
-o -name "*.vcproj" -o -name "*.sln" \) -type f -print \
| while read v
do
......
......@@ -4584,7 +4584,7 @@ bool get_key_map_from_key_list(key_map *map, TABLE *table,
name->length(), 1)) <=
0)
{
my_error(ER_KEY_COLUMN_DOES_NOT_EXITS, MYF(0), name->c_ptr(),
my_error(ER_KEY_DOES_NOT_EXITS, MYF(0), name->c_ptr(),
table->s->table_name);
map->set_all();
return 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment