summaryrefslogtreecommitdiff
path: root/mysql-test/r
diff options
context:
space:
mode:
authorunknown <gkodinov@dl145s.mysql.com>2006-09-18 12:57:20 +0200
committerunknown <gkodinov@dl145s.mysql.com>2006-09-18 12:57:20 +0200
commit5222b59093bfd3d6055ff4d375f450c4468a7366 (patch)
tree5370a5cf6745df5fd6690197a45f08ce5e60daf1 /mysql-test/r
parentdaaf51fbe97d13acc13cb457ab6adc435fd93114 (diff)
parentdb1a94a7ffd31d2e028c4c45c876c549a43d3630 (diff)
downloadmariadb-git-5222b59093bfd3d6055ff4d375f450c4468a7366.tar.gz
Merge dl145s.mysql.com:/data/bk/team_tree_merge/MERGE/mysql-5.0-opt
into dl145s.mysql.com:/data/bk/team_tree_merge/MERGE/mysql-5.1 mysql-test/r/func_gconcat.result: Auto merged mysql-test/r/func_group.result: Auto merged mysql-test/r/func_str.result: Auto merged mysql-test/r/func_time.result: Auto merged mysql-test/r/group_by.result: Auto merged mysql-test/r/heap_hash.result: Auto merged mysql-test/r/information_schema.result: Auto merged mysql-test/r/innodb_mysql.result: Auto merged mysql-test/r/join_outer.result: Auto merged mysql-test/r/olap.result: Auto merged mysql-test/r/query_cache.result: Auto merged mysql-test/r/range.result: Auto merged mysql-test/r/row.result: Auto merged mysql-test/r/subselect.result: Auto merged mysql-test/r/type_date.result: Auto merged mysql-test/r/union.result: Auto merged mysql-test/r/view_grant.result: Auto merged mysql-test/t/func_group.test: Auto merged mysql-test/t/func_str.test: Auto merged mysql-test/t/func_time.test: Auto merged mysql-test/t/view.test: Auto merged sql/item.cc: Auto merged sql/item_func.cc: Auto merged sql/item_func.h: Auto merged sql/log.cc: Auto merged sql/mysql_priv.h: Auto merged sql/opt_range.cc: Auto merged sql/opt_range.h: Auto merged sql/opt_sum.cc: Auto merged sql/sql_delete.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_lex.cc: Auto merged sql/sql_lex.h: Auto merged sql/sql_list.h: Auto merged sql/sql_parse.cc: Auto merged sql/sql_update.cc: Auto merged sql/sql_yacc.yy: Auto merged mysql-test/t/sp.test: SCCS merged sql/item_cmpfunc.cc: SCCS merged sql/sql_select.cc: SCCS merged
Diffstat (limited to 'mysql-test/r')
-rw-r--r--mysql-test/r/delete.result4
-rw-r--r--mysql-test/r/func_gconcat.result4
-rw-r--r--mysql-test/r/func_group.result16
-rw-r--r--mysql-test/r/func_str.result35
-rw-r--r--mysql-test/r/func_time.result25
-rw-r--r--mysql-test/r/group_by.result4
-rw-r--r--mysql-test/r/heap_hash.result2
-rw-r--r--mysql-test/r/information_schema.result2
-rw-r--r--mysql-test/r/innodb_mysql.result8
-rw-r--r--mysql-test/r/insert_update.result28
-rw-r--r--mysql-test/r/join_outer.result2
-rw-r--r--mysql-test/r/olap.result2
-rw-r--r--mysql-test/r/query_cache.result12
-rw-r--r--mysql-test/r/range.result8
-rw-r--r--mysql-test/r/row.result125
-rw-r--r--mysql-test/r/sp.result98
-rw-r--r--mysql-test/r/subselect.result58
-rw-r--r--mysql-test/r/type_date.result10
-rw-r--r--mysql-test/r/union.result2
-rw-r--r--mysql-test/r/view.result55
-rw-r--r--mysql-test/r/view_grant.result6
21 files changed, 442 insertions, 64 deletions
diff --git a/mysql-test/r/delete.result b/mysql-test/r/delete.result
index 0946dc8f809..9d337a1ed34 100644
--- a/mysql-test/r/delete.result
+++ b/mysql-test/r/delete.result
@@ -172,6 +172,10 @@ a
0
2
DROP TABLE t1;
+create table t1 (a int);
+delete `4.t1` from t1 as `4.t1` where `4.t1`.a = 5;
+delete FROM `4.t1` USING t1 as `4.t1` where `4.t1`.a = 5;
+drop table t1;
CREATE TABLE t1 (a int not null,b int not null);
CREATE TABLE t2 (a int not null, b int not null, primary key (a,b));
CREATE TABLE t3 (a int not null, b int not null, primary key (a,b));
diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result
index 675e0faa1a0..aef29ef9525 100644
--- a/mysql-test/r/func_gconcat.result
+++ b/mysql-test/r/func_gconcat.result
@@ -572,14 +572,14 @@ COUNT(*) GROUP_CONCAT(DISTINCT t2.somename SEPARATOR ' |')
DROP TABLE t1,t2;
select * from (select group_concat('c') from DUAL) t;
group_concat('c')
-NULL
+c
create table t1 ( a int not null default 0);
select * from (select group_concat(a) from t1) t2;
group_concat(a)
NULL
select group_concat('x') UNION ALL select 1;
group_concat('x')
-NULL
+x
1
drop table t1;
CREATE TABLE t1 (id int, a varchar(9));
diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result
index c7d95a4a446..3838f04e20d 100644
--- a/mysql-test/r/func_group.result
+++ b/mysql-test/r/func_group.result
@@ -847,6 +847,22 @@ EXPLAIN SELECT MAX(b) FROM t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4
DROP TABLE t1;
+CREATE TABLE t1 (a INT, b INT);
+INSERT INTO t1 VALUES (1,1),(1,2),(2,3);
+SELECT (SELECT COUNT(DISTINCT t1.b)) FROM t1 GROUP BY t1.a;
+(SELECT COUNT(DISTINCT t1.b))
+0
+2
+SELECT (SELECT COUNT(DISTINCT 12)) FROM t1 GROUP BY t1.a;
+(SELECT COUNT(DISTINCT 12))
+1
+1
+SELECT AVG(2), BIT_AND(2), BIT_OR(2), BIT_XOR(2), COUNT(*), COUNT(12),
+COUNT(DISTINCT 12), MIN(2),MAX(2),STD(2), VARIANCE(2),SUM(2),
+GROUP_CONCAT(2),GROUP_CONCAT(DISTINCT 2);
+AVG(2) BIT_AND(2) BIT_OR(2) BIT_XOR(2) COUNT(*) COUNT(12) COUNT(DISTINCT 12) MIN(2) MAX(2) STD(2) VARIANCE(2) SUM(2) GROUP_CONCAT(2) GROUP_CONCAT(DISTINCT 2)
+2.00000 2 2 2 1 1 1 2 2 0.00000 0.00000 2 2 2
+DROP TABLE t1;
create table t2 (ff double);
insert into t2 values (2.2);
select cast(sum(distinct ff) as decimal(5,2)) from t2;
diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result
index 940ca71ebbc..f99847a679a 100644
--- a/mysql-test/r/func_str.result
+++ b/mysql-test/r/func_str.result
@@ -1113,4 +1113,39 @@ conv("18383815659218730760",10,10) + 0
select "18383815659218730760" + 0;
"18383815659218730760" + 0
1.8383815659219e+19
+CREATE TABLE t1 (code varchar(10));
+INSERT INTO t1 VALUES ('a12'), ('A12'), ('a13');
+SELECT ASCII(code), code FROM t1 WHERE code='A12';
+ASCII(code) code
+97 a12
+65 A12
+SELECT ASCII(code), code FROM t1 WHERE code='A12' AND ASCII(code)=65;
+ASCII(code) code
+65 A12
+INSERT INTO t1 VALUES ('a12 '), ('A12 ');
+SELECT LENGTH(code), code FROM t1 WHERE code='A12';
+LENGTH(code) code
+3 a12
+3 A12
+4 a12
+5 A12
+SELECT LENGTH(code), code FROM t1 WHERE code='A12' AND LENGTH(code)=5;
+LENGTH(code) code
+5 A12
+ALTER TABLE t1 ADD INDEX (code);
+CREATE TABLE t2 (id varchar(10) PRIMARY KEY);
+INSERT INTO t2 VALUES ('a11'), ('a12'), ('a13'), ('a14');
+SELECT * FROM t1 INNER JOIN t2 ON t1.code=t2.id
+WHERE t2.id='a12' AND (LENGTH(code)=5 OR code < 'a00');
+code id
+A12 a12
+EXPLAIN EXTENDED
+SELECT * FROM t1 INNER JOIN t2 ON code=id
+WHERE id='a12' AND (LENGTH(code)=5 OR code < 'a00');
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref code code 13 const 3 Using where; Using index
+1 SIMPLE t2 ref PRIMARY PRIMARY 12 const 1 Using where; Using index
+Warnings:
+Note 1003 select `test`.`t1`.`code` AS `code`,`test`.`t2`.`id` AS `id` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`code` = _latin1'a12') and (`test`.`t2`.`id` = _latin1'a12') and (length(`test`.`t1`.`code`) = 5))
+DROP TABLE t1,t2;
End of 5.0 tests
diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result
index cfb675652f2..2e4f03a17d9 100644
--- a/mysql-test/r/func_time.result
+++ b/mysql-test/r/func_time.result
@@ -840,39 +840,38 @@ drop table t1;
create table t1(f1 date, f2 time, f3 datetime);
insert into t1 values ("2006-01-01", "12:01:01", "2006-01-01 12:01:01");
insert into t1 values ("2006-01-02", "12:01:02", "2006-01-02 12:01:02");
-select f1 from t1 where f1 between "2006-1-1" and 20060101;
+select f1 from t1 where f1 between CAST("2006-1-1" as date) and CAST(20060101 as date);
f1
2006-01-01
-select f1 from t1 where f1 between "2006-1-1" and "2006.1.1";
+select f1 from t1 where f1 between cast("2006-1-1" as date) and cast("2006.1.1" as date);
f1
2006-01-01
-select f1 from t1 where date(f1) between "2006-1-1" and "2006.1.1";
+select f1 from t1 where date(f1) between cast("2006-1-1" as date) and cast("2006.1.1" as date);
f1
2006-01-01
-select f2 from t1 where f2 between "12:1:2" and "12:2:2";
+select f2 from t1 where f2 between cast("12:1:2" as time) and cast("12:2:2" as time);
f2
12:01:02
-select f2 from t1 where time(f2) between "12:1:2" and "12:2:2";
+select f2 from t1 where time(f2) between cast("12:1:2" as time) and cast("12:2:2" as time);
f2
12:01:02
-select f3 from t1 where f3 between "2006-1-1 12:1:1" and "2006-1-1 12:1:2";
+select f3 from t1 where f3 between cast("2006-1-1 12:1:1" as datetime) and cast("2006-1-1 12:1:2" as datetime);
f3
2006-01-01 12:01:01
-select f3 from t1 where timestamp(f3) between "2006-1-1 12:1:1" and "2006-1-1 12:1:2";
+select f3 from t1 where timestamp(f3) between cast("2006-1-1 12:1:1" as datetime) and cast("2006-1-1 12:1:2" as datetime);
f3
2006-01-01 12:01:01
-select f1 from t1 where "2006-1-1" between f1 and f3;
+select f1 from t1 where cast("2006-1-1" as date) between f1 and f3;
f1
2006-01-01
-select f1 from t1 where "2006-1-1" between date(f1) and date(f3);
+select f1 from t1 where cast("2006-1-1" as date) between date(f1) and date(f3);
f1
2006-01-01
-select f1 from t1 where "2006-1-1" between f1 and 'zzz';
+select f1 from t1 where cast("2006-1-1" as date) between f1 and cast('zzz' as date);
f1
Warnings:
-Warning 1292 Incorrect date value: 'zzz' for column 'f1' at row 1
-Warning 1292 Truncated incorrect DOUBLE value: 'zzz'
-Warning 1292 Truncated incorrect DOUBLE value: 'zzz'
+Warning 1292 Truncated incorrect datetime value: 'zzz'
+Warning 1292 Truncated incorrect datetime value: 'zzz'
select f1 from t1 where makedate(2006,1) between date(f1) and date(f3);
f1
2006-01-01
diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result
index 709d60b963f..80988bd8047 100644
--- a/mysql-test/r/group_by.result
+++ b/mysql-test/r/group_by.result
@@ -807,8 +807,8 @@ explain
SELECT straight_join sql_no_cache v1.a, v1.b, v1.real_b from t2, v1
where t2.b=v1.a GROUP BY t2.b;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t2 index b b 2 NULL 10 Using index
-1 PRIMARY t1 eq_ref PRIMARY PRIMARY 1 test.t2.b 1
+1 SIMPLE t2 index b b 2 NULL 10 Using index
+1 SIMPLE t1 eq_ref PRIMARY PRIMARY 1 test.t2.b 1
SELECT straight_join sql_no_cache v1.a, v1.b, v1.real_b from t2, v1
where t2.b=v1.a GROUP BY t2.b;
a b real_b
diff --git a/mysql-test/r/heap_hash.result b/mysql-test/r/heap_hash.result
index bf7c250cbcf..41f00fd2ad8 100644
--- a/mysql-test/r/heap_hash.result
+++ b/mysql-test/r/heap_hash.result
@@ -354,7 +354,7 @@ t3 1 a 2 b NULL 13 NULL NULL HASH
explain select * from t1 ignore key(btree_idx), t3 where t1.name='matt' and t3.a = concat('',t1.name) and t3.b=t1.name;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref heap_idx heap_idx 22 const 7 Using where
-1 SIMPLE t3 ref a a 44 const,const 7 Using where
+1 SIMPLE t3 ref a a 44 func,const 7 Using where
drop table t1, t2, t3;
create temporary table t1 ( a int, index (a) ) engine=memory;
insert into t1 values (1),(2),(3),(4),(5);
diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result
index 077fa0f2376..5d355f1b8db 100644
--- a/mysql-test/r/information_schema.result
+++ b/mysql-test/r/information_schema.result
@@ -353,7 +353,7 @@ mysql
test
explain select * from v0;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY # ALL NULL NULL NULL NULL 2
+1 SIMPLE # ALL NULL NULL NULL NULL 2
create view v1 (c) as select table_name from information_schema.tables
where table_name="v1";
select * from v1;
diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result
index 98e03239567..fc38a38eb36 100644
--- a/mysql-test/r/innodb_mysql.result
+++ b/mysql-test/r/innodb_mysql.result
@@ -124,7 +124,7 @@ min(7)
NULL
select min(7) from DUAL;
min(7)
-NULL
+7
explain select min(7) from t2m join t1m;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
@@ -139,7 +139,7 @@ max(7)
NULL
select max(7) from DUAL;
max(7)
-NULL
+7
explain select max(7) from t2m join t1m;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
@@ -178,7 +178,7 @@ min(7)
NULL
select min(7) from DUAL;
min(7)
-NULL
+7
explain select min(7) from t2i join t1i;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2i ALL NULL NULL NULL NULL 1
@@ -194,7 +194,7 @@ max(7)
NULL
select max(7) from DUAL;
max(7)
-NULL
+7
explain select max(7) from t2i join t1i;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2i ALL NULL NULL NULL NULL 1
diff --git a/mysql-test/r/insert_update.result b/mysql-test/r/insert_update.result
index 030c1976e20..169b5286fbe 100644
--- a/mysql-test/r/insert_update.result
+++ b/mysql-test/r/insert_update.result
@@ -62,10 +62,10 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,values(`test`.`t1`.`a`) AS `VALUES(a)` from `test`.`t1`
explain extended select * from t1 where values(a);
-id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1`
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where values(`test`.`t1`.`a`)
DROP TABLE t1;
create table t1(a int primary key, b int);
insert into t1 values(1,1),(2,2),(3,3),(4,4),(5,5);
@@ -197,3 +197,25 @@ PRIMARY KEY (a)
) ENGINE=MyISAM;
INSERT INTO t1 ( a ) SELECT 0 ON DUPLICATE KEY UPDATE a = a + VALUES (a) ;
DROP TABLE t1;
+CREATE TABLE t1
+(
+a BIGINT UNSIGNED,
+b BIGINT UNSIGNED,
+PRIMARY KEY (a)
+);
+INSERT INTO t1 VALUES (45, 1) ON DUPLICATE KEY UPDATE b =
+IF(VALUES(b) > t1.b, VALUES(b), t1.b);
+SELECT * FROM t1;
+a b
+45 1
+INSERT INTO t1 VALUES (45, 2) ON DUPLICATE KEY UPDATE b =
+IF(VALUES(b) > t1.b, VALUES(b), t1.b);
+SELECT * FROM t1;
+a b
+45 2
+INSERT INTO t1 VALUES (45, 1) ON DUPLICATE KEY UPDATE b =
+IF(VALUES(b) > t1.b, VALUES(b), t1.b);
+SELECT * FROM t1;
+a b
+45 2
+DROP TABLE t1;
diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result
index 0a309371725..4d58d035f21 100644
--- a/mysql-test/r/join_outer.result
+++ b/mysql-test/r/join_outer.result
@@ -1126,7 +1126,7 @@ a b a b
7 8 7 5
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a = t2.a OR t1.a = t2.b;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 4 Using where
+1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 4
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.a 1
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a IN(t2.a, t2.b);
id select_type table type possible_keys key key_len ref rows Extra
diff --git a/mysql-test/r/olap.result b/mysql-test/r/olap.result
index 993426a02fc..f9e211c8186 100644
--- a/mysql-test/r/olap.result
+++ b/mysql-test/r/olap.result
@@ -611,7 +611,7 @@ C
NULL
EXPLAIN SELECT type FROM v1 GROUP BY type WITH ROLLUP;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 10 Using filesort
+1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using filesort
DROP VIEW v1;
DROP TABLE t1;
CREATE TABLE t1 (a int(11) NOT NULL);
diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result
index 684d216f856..96289305da1 100644
--- a/mysql-test/r/query_cache.result
+++ b/mysql-test/r/query_cache.result
@@ -949,24 +949,24 @@ COUNT(*)
Warnings:
Warning 1292 Incorrect datetime value: '20050327 invalid' for column 'date' at row 1
Warning 1292 Incorrect datetime value: '20050327 invalid' for column 'date' at row 1
-Warning 1292 Truncated incorrect DOUBLE value: '20050327 invalid'
-Warning 1292 Truncated incorrect DOUBLE value: '20050327 invalid'
+Warning 1292 Truncated incorrect INTEGER value: '20050327 invalid'
+Warning 1292 Truncated incorrect INTEGER value: '20050327 invalid'
SELECT COUNT(*) FROM t1 WHERE date BETWEEN '20050326' AND '20050328 invalid';
COUNT(*)
0
Warnings:
Warning 1292 Incorrect datetime value: '20050328 invalid' for column 'date' at row 1
Warning 1292 Incorrect datetime value: '20050328 invalid' for column 'date' at row 1
-Warning 1292 Truncated incorrect DOUBLE value: '20050328 invalid'
-Warning 1292 Truncated incorrect DOUBLE value: '20050328 invalid'
+Warning 1292 Truncated incorrect INTEGER value: '20050328 invalid'
+Warning 1292 Truncated incorrect INTEGER value: '20050328 invalid'
SELECT COUNT(*) FROM t1 WHERE date BETWEEN '20050326' AND '20050327 invalid';
COUNT(*)
0
Warnings:
Warning 1292 Incorrect datetime value: '20050327 invalid' for column 'date' at row 1
Warning 1292 Incorrect datetime value: '20050327 invalid' for column 'date' at row 1
-Warning 1292 Truncated incorrect DOUBLE value: '20050327 invalid'
-Warning 1292 Truncated incorrect DOUBLE value: '20050327 invalid'
+Warning 1292 Truncated incorrect INTEGER value: '20050327 invalid'
+Warning 1292 Truncated incorrect INTEGER value: '20050327 invalid'
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result
index 4141e6061d2..a7074b9a9ed 100644
--- a/mysql-test/r/range.result
+++ b/mysql-test/r/range.result
@@ -750,13 +750,13 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using where; Using index
EXPLAIN SELECT a,b FROM v1 WHERE a < 2 and b=3;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 range PRIMARY PRIMARY 4 NULL 4 Using where; Using index
+1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using where; Using index
EXPLAIN SELECT a,b FROM t1 WHERE a < 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using where; Using index
EXPLAIN SELECT a,b FROM v1 WHERE a < 2;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 range PRIMARY PRIMARY 4 NULL 4 Using where; Using index
+1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using where; Using index
SELECT a,b FROM t1 WHERE a < 2 and b=3;
a b
1 3
@@ -799,13 +799,13 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index
explain select * from v1 where a in (3,4) and b in (1,2,3);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index
+1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index
explain select * from t1 where a between 3 and 4 and b between 1 and 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index
explain select * from v1 where a between 3 and 4 and b between 1 and 2;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index
+1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index
drop view v1;
drop table t1;
create table t3 (a int);
diff --git a/mysql-test/r/row.result b/mysql-test/r/row.result
index 3028f42de1a..75258af552b 100644
--- a/mysql-test/r/row.result
+++ b/mysql-test/r/row.result
@@ -181,3 +181,128 @@ SELECT ROW(1,1,1) = ROW(1,1,1) as `1`, ROW(1,1,1) = ROW(1,2,1) as `0`, ROW(1,NUL
select row(NULL,1)=(2,0);
row(NULL,1)=(2,0)
0
+CREATE TABLE t1 (a int, b int, PRIMARY KEY (a,b));
+INSERT INTO t1 VALUES (1,1), (2,1), (3,1), (1,2), (3,2), (3,3);
+EXPLAIN SELECT * FROM t1 WHERE a=3 AND b=2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 const PRIMARY PRIMARY 8 const,const 1 Using index
+EXPLAIN SELECT * FROM t1 WHERE (a,b)=(3,2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 const PRIMARY PRIMARY 8 const,const 1 Using index
+SELECT * FROM t1 WHERE a=3 and b=2;
+a b
+3 2
+SELECT * FROM t1 WHERE (a,b)=(3,2);
+a b
+3 2
+CREATE TABLE t2 (a int, b int, c int, PRIMARY KEY (a,b,c));
+INSERT INTO t2 VALUES
+(1,1,2), (3,1,3), (1,2,2), (4,4,2),
+(1,1,1), (3,1,1), (1,2,1);
+EXPLAIN SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b=t2.b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL 6 Using index
+1 SIMPLE t2 ref PRIMARY PRIMARY 8 test.t1.a,test.t1.b 1 Using index
+EXPLAIN SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,t2.b);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL 6 Using index
+1 SIMPLE t2 ref PRIMARY PRIMARY 8 test.t1.a,test.t1.b 1 Using index
+SELECT * FROM t1,t2 WHERE t1.a=t2.a and t1.b=t2.b;
+a b a b c
+1 1 1 1 1
+1 1 1 1 2
+1 2 1 2 1
+1 2 1 2 2
+3 1 3 1 1
+3 1 3 1 3
+SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,t2.b);
+a b a b c
+1 1 1 1 1
+1 1 1 1 2
+1 2 1 2 1
+1 2 1 2 2
+3 1 3 1 1
+3 1 3 1 3
+EXPLAIN SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b=2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL 5 Using where; Using index
+1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a 1 Using index
+EXPLAIN SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL 5 Using where; Using index
+1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a 1 Using index
+SELECT * FROM t1,t2 WHERE t1.a=1 and t1.b=t2.b;
+a b a b c
+1 1 1 1 2
+1 1 3 1 3
+1 2 1 2 2
+1 1 1 1 1
+1 1 3 1 1
+1 2 1 2 1
+SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,2);
+a b a b c
+1 2 1 1 1
+1 2 1 1 2
+1 2 1 2 1
+1 2 1 2 2
+3 2 3 1 1
+3 2 3 1 3
+EXPLAIN EXTENDED SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,t2.b+1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL 6 Using index
+1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a 1 Using where; Using index
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` = (`test`.`t2`.`b` + 1)))
+SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,t2.b+1);
+a b a b c
+1 2 1 1 1
+1 2 1 1 2
+3 2 3 1 1
+3 2 3 1 3
+EXPLAIN EXTENDED SELECT * FROM t1,t2 WHERE (t1.a-1,t1.b)=(t2.a-1,t2.b+1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 8 NULL 6 Using index
+1 SIMPLE t2 index NULL PRIMARY 12 NULL 7 Using where; Using index
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where (((`test`.`t1`.`a` - 1) = (`test`.`t2`.`a` - 1)) and (`test`.`t1`.`b` = (`test`.`t2`.`b` + 1)))
+SELECT * FROM t1,t2 WHERE (t1.a-1,t1.b)=(t2.a-1,t2.b+1);
+a b a b c
+1 2 1 1 2
+3 2 3 1 3
+1 2 1 1 1
+3 2 3 1 1
+EXPLAIN SELECT * FROM t2 WHERE a=3 AND b=2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ref PRIMARY PRIMARY 8 const,const 1 Using index
+EXPLAIN SELECT * FROM t2 WHERE (a,b)=(3,2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ref PRIMARY PRIMARY 8 const,const 1 Using index
+SELECT * FROM t2 WHERE a=3 and b=2;
+a b c
+SELECT * FROM t2 WHERE (a,b)=(3,2);
+a b c
+EXPLAIN SELECT * FROM t1,t2 WHERE t2.a=t1.a AND t2.b=2 AND t2.c=1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL 6 Using index
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 12 test.t1.a,const,const 1 Using index
+EXPLAIN EXTENDED SELECT * FROM t1,t2 WHERE (t2.a,(t2.b,t2.c))=(t1.a,(2,1));
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL 6 Using index
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 12 test.t1.a,const,const 1 Using index
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = 1) and (`test`.`t2`.`b` = 2) and (`test`.`t2`.`a` = `test`.`t1`.`a`))
+SELECT * FROM t1,t2 WHERE (t2.a,(t2.b,t2.c))=(t1.a,(2,1));
+a b a b c
+1 1 1 2 1
+1 2 1 2 1
+EXPLAIN EXTENDED SELECT * FROM t1,t2 WHERE t2.a=t1.a AND (t2.b,t2.c)=(2,1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL 6 Using index
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 12 test.t1.a,const,const 1 Using index
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = 1) and (`test`.`t2`.`b` = 2) and (`test`.`t2`.`a` = `test`.`t1`.`a`))
+SELECT * FROM t1,t2 WHERE t2.a=t1.a AND (t2.b,t2.c)=(2,1);
+a b a b c
+1 1 1 2 1
+1 2 1 2 1
+DROP TABLE t1,t2;
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index fb40b52475b..5fdc7275fd7 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -5379,5 +5379,103 @@ Procedure sql_mode Create Procedure
bug21416 CREATE DEFINER=`root`@`localhost` PROCEDURE `bug21416`()
show create procedure bug21416
drop procedure bug21416|
+drop table if exists t3|
+drop database if exists mysqltest1|
+create table t3 (a int)|
+insert into t3 (a) values (1), (2)|
+create database mysqltest1|
+use mysqltest1|
+drop database mysqltest1|
+select database()|
+database()
+NULL
+select * from (select 1 as a) as t1 natural join (select * from test.t3) as t2|
+a
+1
+use test|
+drop table t3|
+DROP PROCEDURE IF EXISTS bug16899_p1|
+DROP FUNCTION IF EXISTS bug16899_f1|
+CREATE DEFINER=1234567890abcdefGHIKL@localhost PROCEDURE bug16899_p1()
+BEGIN
+SET @a = 1;
+END|
+ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no longer than 16)
+CREATE DEFINER=some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY
+FUNCTION bug16899_f1() RETURNS INT
+BEGIN
+RETURN 1;
+END|
+ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY' is too long for host name (should be no longer than 60)
+drop procedure if exists bug21416|
+create procedure bug21416() show create procedure bug21416|
+call bug21416()|
+Procedure sql_mode Create Procedure
+bug21416 CREATE DEFINER=`root`@`localhost` PROCEDURE `bug21416`()
+show create procedure bug21416
+drop procedure bug21416|
+CREATE TABLE t3 (
+Member_ID varchar(15) NOT NULL,
+PRIMARY KEY (Member_ID)
+)|
+CREATE TABLE t4 (
+ID int(10) unsigned NOT NULL auto_increment,
+Member_ID varchar(15) NOT NULL default '',
+Action varchar(12) NOT NULL,
+Action_Date datetime NOT NULL,
+Track varchar(15) default NULL,
+User varchar(12) default NULL,
+Date_Updated timestamp NOT NULL default CURRENT_TIMESTAMP on update
+CURRENT_TIMESTAMP,
+PRIMARY KEY (ID),
+KEY Action (Action),
+KEY Action_Date (Action_Date)
+)|
+INSERT INTO t3(Member_ID) VALUES
+('111111'), ('222222'), ('333333'), ('444444'), ('555555'), ('666666')|
+INSERT INTO t4(Member_ID, Action, Action_Date, Track) VALUES
+('111111', 'Disenrolled', '2006-03-01', 'CAD' ),
+('111111', 'Enrolled', '2006-03-01', 'CAD' ),
+('111111', 'Disenrolled', '2006-07-03', 'CAD' ),
+('222222', 'Enrolled', '2006-03-07', 'CAD' ),
+('222222', 'Enrolled', '2006-03-07', 'CHF' ),
+('222222', 'Disenrolled', '2006-08-02', 'CHF' ),
+('333333', 'Enrolled', '2006-03-01', 'CAD' ),
+('333333', 'Disenrolled', '2006-03-01', 'CAD' ),
+('444444', 'Enrolled', '2006-03-01', 'CAD' ),
+('555555', 'Disenrolled', '2006-03-01', 'CAD' ),
+('555555', 'Enrolled', '2006-07-21', 'CAD' ),
+('555555', 'Disenrolled', '2006-03-01', 'CHF' ),
+('666666', 'Enrolled', '2006-02-09', 'CAD' ),
+('666666', 'Enrolled', '2006-05-12', 'CHF' ),
+('666666', 'Disenrolled', '2006-06-01', 'CAD' )|
+DROP FUNCTION IF EXISTS bug21493|
+Warnings:
+Note 1305 FUNCTION bug21493 does not exist
+CREATE FUNCTION bug21493(paramMember VARCHAR(15)) RETURNS varchar(45)
+BEGIN
+DECLARE tracks VARCHAR(45);
+SELECT GROUP_CONCAT(Track SEPARATOR ', ') INTO tracks FROM t4
+WHERE Member_ID=paramMember AND Action='Enrolled' AND
+(Track,Action_Date) IN (SELECT Track, MAX(Action_Date) FROM t4
+WHERE Member_ID=paramMember GROUP BY Track);
+RETURN tracks;
+END|
+SELECT bug21493('111111')|
+bug21493('111111')
+NULL
+SELECT bug21493('222222')|
+bug21493('222222')
+CAD
+SELECT bug21493(Member_ID) FROM t3|
+bug21493(Member_ID)
+NULL
+CAD
+CAD
+CAD
+CAD
+CHF
+DROP FUNCTION bug21493|
+DROP TABLE t3,t4|
End of 5.0 tests
drop table t1,t2;
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index 141f9ed0f4a..ba16bb9410b 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -1011,7 +1011,7 @@ INSERT INTO t1 VALUES (1);
UPDATE t1 SET i=i+1 WHERE i=(SELECT MAX(i));
select * from t1;
i
-1
+2
drop table t1;
CREATE TABLE t1 (a int(1));
EXPLAIN EXTENDED SELECT (SELECT RAND() FROM t1) FROM t1;
@@ -1203,7 +1203,7 @@ UPDATE t1 SET t.i=i+(SELECT MAX(i) FROM (SELECT 1) t);
ERROR 42S22: Unknown column 't.i' in 'field list'
select * from t1;
i
-1
+3
drop table t1;
CREATE TABLE t1 (
id int(11) default NULL
@@ -2937,6 +2937,35 @@ retailerID statusID changed
0048 1 2006-01-06 12:37:50
0059 1 2006-01-06 12:37:50
drop table t1;
+create table t1(a int, primary key (a));
+insert into t1 values (10);
+create table t2 (a int primary key, b varchar(32), c int, unique key b(c, b));
+insert into t2(a, c, b) values (1,10,'359'), (2,10,'35988'), (3,10,'35989');
+explain SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
+ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
+ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
+1 PRIMARY r const PRIMARY PRIMARY 4 const 1
+2 DEPENDENT SUBQUERY t2 range b b 40 NULL 2 Using where
+SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
+ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
+ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10;
+a a b
+10 3 35989
+explain SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
+ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
+ORDER BY t2.c, t2.b LIMIT 1) WHERE t1.a = 10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
+1 PRIMARY r const PRIMARY PRIMARY 4 const 1
+2 DEPENDENT SUBQUERY t2 range b b 40 NULL 2 Using where
+SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
+ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
+ORDER BY t2.c, t2.b LIMIT 1) WHERE t1.a = 10;
+a a b
+10 1 359
+drop table t1,t2;
create table t1 (df decimal(5,1));
insert into t1 values(1.1);
insert into t1 values(2.2);
@@ -3368,3 +3397,28 @@ ORDER BY t1.t DESC LIMIT 1);
i1 i2 t i1 i2 t
24 1 2005-05-27 12:40:30 24 1 2006-06-20 12:29:40
DROP TABLE t1, t2;
+CREATE TABLE t1 (i INT);
+(SELECT i FROM t1) UNION (SELECT i FROM t1);
+i
+SELECT sql_no_cache * FROM t1 WHERE NOT EXISTS
+(
+(SELECT i FROM t1) UNION
+(SELECT i FROM t1)
+);
+i
+SELECT * FROM t1
+WHERE NOT EXISTS (((SELECT i FROM t1) UNION (SELECT i FROM t1)));
+i
+explain select ((select t11.i from t1 t11) union (select t12.i from t1 t12))
+from t1;
+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 'union (select t12.i from t1 t12))
+from t1' at line 1
+explain select * from t1 where not exists
+((select t11.i from t1 t11) union (select t12.i from t1 t12));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 system NULL NULL NULL NULL 0 const row not found
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
+3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
+4 UNION t12 system NULL NULL NULL NULL 0 const row not found
+NULL UNION RESULT <union2,4> ALL NULL NULL NULL NULL NULL
+DROP TABLE t1;
diff --git a/mysql-test/r/type_date.result b/mysql-test/r/type_date.result
index 3f0b9f4c13c..12ce742eab4 100644
--- a/mysql-test/r/type_date.result
+++ b/mysql-test/r/type_date.result
@@ -27,12 +27,12 @@ INSERT INTO t1 VALUES ( "2000-1-2" );
INSERT INTO t1 VALUES ( "2000-1-3" );
INSERT INTO t1 VALUES ( "2000-1-4" );
INSERT INTO t1 VALUES ( "2000-1-5" );
-SELECT * FROM t1 WHERE datum BETWEEN "2000-1-2" AND "2000-1-4";
+SELECT * FROM t1 WHERE datum BETWEEN cast("2000-1-2" as date) AND cast("2000-1-4" as date);
datum
2000-01-02
2000-01-03
2000-01-04
-SELECT * FROM t1 WHERE datum BETWEEN "2000-1-2" AND datum - INTERVAL 100 DAY;
+SELECT * FROM t1 WHERE datum BETWEEN cast("2000-1-2" as date) AND datum - INTERVAL 100 DAY;
datum
DROP TABLE t1;
CREATE TABLE t1 (
@@ -104,3 +104,9 @@ SELECT * FROM t1;
y
0000
DROP TABLE t1;
+create table t1(start_date date, end_date date);
+insert into t1 values ('2000-01-01','2000-01-02');
+select 1 from t1 where cast('2000-01-01 12:01:01' as datetime) between start_date and end_date;
+1
+1
+drop table t1;
diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result
index 58a217f4b14..05870d23ed6 100644
--- a/mysql-test/r/union.result
+++ b/mysql-test/r/union.result
@@ -1365,7 +1365,7 @@ drop table t1, t2;
(select avg(1)) union (select avg(1)) union (select avg(1)) union
(select avg(1)) union (select avg(1)) union (select avg(1));
avg(1)
-NULL
+1.0000
select _utf8'12' union select _latin1'12345';
12
12
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index 7e14874a3e6..5d009ed7840 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -49,7 +49,7 @@ select v1.b from v1;
ERROR 42S22: Unknown column 'v1.b' in 'field list'
explain extended select c from v1;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 5 100.00
+1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00
Warnings:
Note 1003 select (`test`.`t1`.`b` + 1) AS `c` from `test`.`t1`
create algorithm=temptable view v2 (c) as select b+1 from t1;
@@ -83,7 +83,7 @@ c
12
explain extended select c from v3;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 5 100.00
+1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00
Warnings:
Note 1003 select ((`test`.`t1`.`b` + 1) + 1) AS `c` from `test`.`t1`
create algorithm=temptable view v4 (c) as select c+1 from v2;
@@ -376,7 +376,7 @@ c
30
explain extended select * from v1;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 5 100.00 Using where
+1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where
Warnings:
Note 1003 select `test`.`t1`.`b` AS `c` from `test`.`t1` where (`test`.`t1`.`a` < 3)
update v1 set c=c+1;
@@ -1391,9 +1391,9 @@ a a b
4 NULL NULL
explain extended select * from t3 left join v3 on (t3.a = v3.a);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
-1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00
-1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `b` from `test`.`t3` left join (`test`.`t1` left join `test`.`t2` on((`test`.`t1`.`a` = `test`.`t2`.`a`))) on((`test`.`t3`.`a` = `test`.`t1`.`a`)) where 1
create view v1 (a) as select a from t1;
@@ -1406,9 +1406,9 @@ a a b
4 NULL NULL
explain extended select * from t3 left join v4 on (t3.a = v4.a);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
-1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00
-1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `b` from `test`.`t3` left join (`test`.`t1` left join (`test`.`t2`) on((`test`.`t1`.`a` = `test`.`t2`.`a`))) on((`test`.`t3`.`a` = `test`.`t1`.`a`)) where 1
prepare stmt1 from "select * from t3 left join v4 on (t3.a = v4.a);";
@@ -2321,12 +2321,12 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ref a a 10 const,test.t1.b 2 Using where; Using index
EXPLAIN SELECT * FROM v1 WHERE a=1;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ref a a 5 const 1 Using where; Using index
-1 PRIMARY t2 ref a a 10 const,test.t1.b 2 Using where; Using index
+1 SIMPLE t1 ref a a 5 const 1 Using where; Using index
+1 SIMPLE t2 ref a a 10 const,test.t1.b 2 Using where; Using index
EXPLAIN SELECT * FROM v2 WHERE a=1;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ref a a 5 const 1 Using where; Using index
-1 PRIMARY t3 ALL NULL NULL NULL NULL 3 Using where
+1 SIMPLE t1 ref a a 5 const 1 Using where; Using index
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where
DROP VIEW v1,v2;
DROP TABLE t1,t2,t3;
create table t1 (f1 int);
@@ -2409,7 +2409,7 @@ insert into t1 values (1),(2);
create view v1 as select * from t1;
explain select id from v1 order by id;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 index NULL PRIMARY 4 NULL 2 Using index
+1 SIMPLE t1 index NULL PRIMARY 4 NULL 2 Using index
drop view v1;
drop table t1;
create table t1(f1 int, f2 int);
@@ -2480,7 +2480,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
EXPLAIN SELECT MAX(a) FROM v1;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
SELECT MIN(a) FROM t1;
MIN(a)
0
@@ -2492,7 +2492,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
EXPLAIN SELECT MIN(a) FROM v1;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
DROP VIEW v1;
DROP TABLE t1;
CREATE TABLE t1 (x varchar(10));
@@ -2586,13 +2586,13 @@ INSERT INTO t1 VALUES
(4, '2005-01-03'), (5, '2005-01-04'), (6, '2005-01-05'),
(7, '2005-01-05'), (8, '2005-01-05'), (9, '2005-01-06');
CREATE VIEW v1 AS SELECT * FROM t1;
-SELECT * FROM t1 WHERE td BETWEEN '2005.01.02' AND '2005.01.04';
+SELECT * FROM t1 WHERE td BETWEEN CAST('2005.01.02' AS DATE) AND CAST('2005.01.04' AS DATE);
id td
2 2005-01-02
3 2005-01-02
4 2005-01-03
5 2005-01-04
-SELECT * FROM v1 WHERE td BETWEEN '2005.01.02' AND '2005.01.04';
+SELECT * FROM v1 WHERE td BETWEEN CAST('2005.01.02' AS DATE) AND CAST('2005.01.04' AS DATE);
id td
2 2005-01-02
3 2005-01-02
@@ -2916,4 +2916,23 @@ DROP FUNCTION f1;
DROP FUNCTION f2;
DROP VIEW v1, v2;
DROP TABLE t1;
+CREATE TABLE t1 (s1 int);
+CREATE VIEW v1 AS SELECT * FROM t1;
+EXPLAIN SELECT * FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 system NULL NULL NULL NULL 0 const row not found
+EXPLAIN SELECT * FROM v1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 system NULL NULL NULL NULL 0 const row not found
+INSERT INTO t1 VALUES (1), (3), (2);
+EXPLAIN SELECT * FROM t1 t WHERE t.s1+1 < (SELECT MAX(t1.s1) FROM t1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t ALL NULL NULL NULL NULL 3 Using where
+2 SUBQUERY t1 ALL NULL NULL NULL NULL 3
+EXPLAIN SELECT * FROM v1 t WHERE t.s1+1 < (SELECT MAX(t1.s1) FROM t1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 SUBQUERY t1 ALL NULL NULL NULL NULL 3
+DROP VIEW v1;
+DROP TABLE t1;
End of 5.0 tests.
diff --git a/mysql-test/r/view_grant.result b/mysql-test/r/view_grant.result
index 30e9d1010ba..f325d1ed7b6 100644
--- a/mysql-test/r/view_grant.result
+++ b/mysql-test/r/view_grant.result
@@ -105,7 +105,7 @@ ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for tabl
grant select on mysqltest.t1 to mysqltest_1@localhost;
explain select c from mysqltest.v1;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 system NULL NULL NULL NULL 0 const row not found
+1 SIMPLE t1 system NULL NULL NULL NULL 0 const row not found
show create view mysqltest.v1;
ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v1'
explain select c from mysqltest.v2;
@@ -125,7 +125,7 @@ ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for tabl
grant show view on mysqltest.* to mysqltest_1@localhost;
explain select c from mysqltest.v1;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 system NULL NULL NULL NULL 0 const row not found
+1 SIMPLE t1 system NULL NULL NULL NULL 0 const row not found
show create view mysqltest.v1;
View Create View
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v1` AS select (`mysqltest`.`t1`.`a` + 1) AS `c`,(`mysqltest`.`t1`.`b` + 1) AS `d` from `mysqltest`.`t1`
@@ -138,7 +138,7 @@ View Create View
v2 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v2` AS select (`mysqltest`.`t1`.`a` + 1) AS `c`,(`mysqltest`.`t1`.`b` + 1) AS `d` from `mysqltest`.`t1`
explain select c from mysqltest.v3;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t2 system NULL NULL NULL NULL 0 const row not found
+1 SIMPLE t2 system NULL NULL NULL NULL 0 const row not found
show create view mysqltest.v3;
View Create View
v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v3` AS select (`mysqltest`.`t2`.`a` + 1) AS `c`,(`mysqltest`.`t2`.`b` + 1) AS `d` from `mysqltest`.`t2`