5.3.4 merge
This commit is contained in:
commit
25609313ff
@ -71,9 +71,9 @@ void get_tty_password_buff(const char *opt_message, char *to, size_t length)
|
||||
_cputs(opt_message ? opt_message : "Enter password: ");
|
||||
for (;;)
|
||||
{
|
||||
char tmp;
|
||||
int tmp;
|
||||
tmp=_getch();
|
||||
if (tmp == '\b' || (int) tmp == 127)
|
||||
if (tmp == '\b' || tmp == 127)
|
||||
{
|
||||
if (pos != to)
|
||||
{
|
||||
@ -82,15 +82,13 @@ void get_tty_password_buff(const char *opt_message, char *to, size_t length)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (tmp == '\n' || tmp == '\r' || tmp == 3)
|
||||
if (tmp == -1 || tmp == '\n' || tmp == '\r' || tmp == 3)
|
||||
break;
|
||||
if (iscntrl(tmp) || pos == end)
|
||||
continue;
|
||||
_cputs("*");
|
||||
*(pos++) = tmp;
|
||||
*(pos++) = (char)tmp;
|
||||
}
|
||||
while (pos != to && isspace(pos[-1]) == ' ')
|
||||
pos--; /* Allow dummy space at end */
|
||||
*pos=0;
|
||||
_cputs("\n");
|
||||
}
|
||||
@ -137,8 +135,6 @@ static void get_password(char *to,uint length,int fd, my_bool echo)
|
||||
}
|
||||
*(pos++) = tmp;
|
||||
}
|
||||
while (pos != to && isspace(pos[-1]) == ' ')
|
||||
pos--; /* Allow dummy space at end */
|
||||
*pos=0;
|
||||
return;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ while (!$mysql_errno)
|
||||
# Strangely enough, the server might return "Too many connections"
|
||||
# while being shutdown, thus 1040 is an "allowed" error.
|
||||
# See BUG#36228.
|
||||
--error 0,1040,1053,2002,2003,2006,2013
|
||||
--error 0,1040,1053,2002,2003,2005,2006,2013
|
||||
show status;
|
||||
|
||||
dec $counter;
|
||||
|
@ -1562,6 +1562,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 7
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1(c1 VARCHAR(33), KEY USING BTREE (c1));
|
||||
|
@ -273,4 +273,13 @@ ON alias3.f4 != 0
|
||||
) ON alias3.f4 != 0;
|
||||
f4 f4 f2 f4
|
||||
drop table t1,t2,t3,t4;
|
||||
#
|
||||
# LP BUG#910123 MariaDB 5.3.3 causes 1093 error on Drupal
|
||||
# Fix: force materialization in case of conflict
|
||||
#
|
||||
SET optimizer_switch='derived_merge=on';
|
||||
CREATE TABLE t1 ( i INT );
|
||||
INSERT INTO t1 VALUES ( (SELECT 1 FROM ( SELECT * FROM t1 ) as a) );
|
||||
drop table t1;
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
set optimizer_switch=@exit_optimizer_switch;
|
||||
|
@ -80,6 +80,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
flush status;
|
||||
select * from (select * from t1 where f1 in (2,3)) tt where f11=2;
|
||||
@ -93,6 +94,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 12
|
||||
for merged views
|
||||
create view v1 as select * from t1;
|
||||
@ -165,6 +167,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
flush status;
|
||||
select * from v4 where f2 in (1,3);
|
||||
@ -178,6 +181,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 12
|
||||
for materialized derived tables
|
||||
explain for simple derived
|
||||
@ -229,6 +233,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
flush status;
|
||||
select * from t1 join (select * from t2 group by f2) tt on f1=f2;
|
||||
@ -244,6 +249,7 @@ Handler_read_last 0
|
||||
Handler_read_next 3
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 11
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 36
|
||||
for materialized views
|
||||
drop view v1,v2,v3;
|
||||
@ -318,6 +324,7 @@ Handler_read_last 0
|
||||
Handler_read_next 22
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 60
|
||||
explain showing late materialization
|
||||
flush status;
|
||||
@ -334,6 +341,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
flush status;
|
||||
select * from t1 join v2 on f1=f2;
|
||||
@ -349,6 +357,7 @@ Handler_read_last 0
|
||||
Handler_read_next 3
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 11
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 36
|
||||
explain extended select * from v1 join v4 on f1=f2;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
@ -443,6 +452,7 @@ Handler_read_last 0
|
||||
Handler_read_next 2
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 8
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 39
|
||||
flush status;
|
||||
merged in merged derived join merged in merged derived
|
||||
@ -1089,7 +1099,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t system NULL NULL NULL NULL 1 100.00
|
||||
1 PRIMARY t2 system NULL NULL NULL NULL 1 100.00
|
||||
1 PRIMARY t3 system NULL NULL NULL NULL 1 100.00
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select 6 AS `a`,5 AS `b` from `test`.`t3` where (not(<expr_cache><6,5>(<in_optimizer>((6,5),<exists>(select 7,5 having (trigcond(((<cache>(6) = 7) or isnull(7))) and trigcond(((<cache>(5) = 5) or isnull(5))) and trigcond(<is_not_null_test>(7)) and trigcond(<is_not_null_test>(5))))))))
|
||||
SELECT t.a,t.b FROM t3 RIGHT JOIN ((SELECT * FROM t1) AS t, t2) ON t2.b != 0
|
||||
@ -1103,7 +1113,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00
|
||||
1 PRIMARY t2 system NULL NULL NULL NULL 1 100.00
|
||||
1 PRIMARY t3 system NULL NULL NULL NULL 1 100.00
|
||||
3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select 6 AS `a`,5 AS `b` from `test`.`t3` where (not(<expr_cache><6,5>(<in_optimizer>((6,5),<exists>(select 7,5 having (trigcond(((<cache>(6) = 7) or isnull(7))) and trigcond(((<cache>(5) = 5) or isnull(5))) and trigcond(<is_not_null_test>(7)) and trigcond(<is_not_null_test>(5))))))))
|
||||
SELECT t.a,t.b FROM t3 RIGHT JOIN (v1 AS t, t2) ON t2.b != 0
|
||||
@ -1117,7 +1127,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00
|
||||
1 PRIMARY t2 system NULL NULL NULL NULL 1 100.00
|
||||
1 PRIMARY t3 system NULL NULL NULL NULL 1 100.00
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select 6 AS `a`,5 AS `b` from `test`.`t3` where (not(<expr_cache><6,5>(<in_optimizer>((6,5),<exists>(select 7,5 having (trigcond(((<cache>(6) = 7) or isnull(7))) and trigcond(((<cache>(5) = 5) or isnull(5))) and trigcond(<is_not_null_test>(7)) and trigcond(<is_not_null_test>(5))))))))
|
||||
DROP VIEW v1;
|
||||
@ -1800,6 +1810,7 @@ INSERT INTO t2 VALUES (7), (4);
|
||||
CREATE TABLE t1 (b int NOT NULL);
|
||||
INSERT INTO t1 VALUES (5), (7);
|
||||
CREATE ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t1;
|
||||
SET @save_optimizer_switch=@@optimizer_switch;
|
||||
SET SESSION optimizer_switch='derived_merge=off';
|
||||
PREPARE st1 FROM
|
||||
'SELECT * FROM (SELECT * FROM t2 LEFT JOIN v1 ON t2.a = v1.b) AS t';
|
||||
@ -1812,9 +1823,9 @@ a b
|
||||
7 7
|
||||
4 NULL
|
||||
DEALLOCATE PREPARE st1;
|
||||
set SESSION optimizer_switch= @save_optimizer_switch;
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1,t2;
|
||||
SET SESSION optimizer_switch='derived_merge=on';
|
||||
#
|
||||
# LP bug #879939: assertion in ha_maria::enable_indexes
|
||||
# with derived_with_keys=on
|
||||
@ -1832,6 +1843,7 @@ INSERT INTO t1 VALUES
|
||||
('USA','Mesquite'), ('USA','Metairie'), ('USA','Miami');
|
||||
CREATE TABLE t3 (a varchar(35));
|
||||
INSERT INTO t3 VALUES ('Miami');
|
||||
SET @save_optimizer_switch=@@optimizer_switch;
|
||||
SET optimizer_switch = 'derived_with_keys=on';
|
||||
SET @@tmp_table_size=1024*4;
|
||||
explain SELECT * FROM (SELECT t1.* FROM t1, t2) AS t JOIN t3 ON t3.a = t.b;
|
||||
@ -1855,6 +1867,7 @@ USA Miami Miami
|
||||
USA Miami Miami
|
||||
USA Miami Miami
|
||||
SET @@tmp_table_size=default;
|
||||
set SESSION optimizer_switch= @save_optimizer_switch;
|
||||
drop table t1,t2,t3;
|
||||
#
|
||||
# BUG#882994: Crash in QUICK_RANGE_SELECT::reset with derived_with_keys
|
||||
@ -1889,5 +1902,42 @@ ORDER BY CONCAT(alias2.col_varchar_nokey);
|
||||
col_varchar_key pk col_varchar_key col_varchar_nokey
|
||||
set max_heap_table_size= @tmp_882994;
|
||||
drop table t1,t2,t3;
|
||||
#
|
||||
# LP bug #917990: Bad estimate of #rows for derived table with LIMIT
|
||||
#
|
||||
CREATE TABLE t1 (a int);
|
||||
INSERT INTO t1 VALUES
|
||||
(8), (3), (4), (7), (9), (5), (1), (2);
|
||||
SELECT * FROM (SELECT * FROM t1 LIMIT 3) t;
|
||||
a
|
||||
8
|
||||
3
|
||||
4
|
||||
EXPLAIN
|
||||
SELECT * FROM (SELECT * FROM t1 LIMIT 3) t;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 8
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# LP BUG#921878 incorrect check of items during columns union types
|
||||
# aggregation for merged derived tables
|
||||
#
|
||||
SET @save_optimizer_switch=@@optimizer_switch;
|
||||
SET SESSION optimizer_switch='derived_merge=on';
|
||||
CREATE TABLE t1 ( a ENUM( 'x', 'y' ) );
|
||||
insert into t1 values ('x');
|
||||
CREATE TABLE t2 LIKE t1;
|
||||
insert into t1 values ('y');
|
||||
CREATE TABLE t3 LIKE t1;
|
||||
INSERT INTO t3
|
||||
SELECT * FROM ( SELECT * FROM t1 ) AS A
|
||||
UNION SELECT * FROM t2;
|
||||
select * from t3;
|
||||
a
|
||||
x
|
||||
y
|
||||
drop table t1,t2,t3;
|
||||
set SESSION optimizer_switch= @save_optimizer_switch;
|
||||
set optimizer_switch=@exit_optimizer_switch;
|
||||
set join_cache_level=@exit_join_cache_level;
|
||||
|
@ -1825,6 +1825,70 @@ drop table t1;
|
||||
#
|
||||
End of 5.1 tests
|
||||
#
|
||||
# Bug #904345: MIN/MAX optimization with constant FALSE condition
|
||||
#
|
||||
CREATE TABLE t1 (a int NOT NULL, KEY(a));
|
||||
INSERT INTO t1 VALUES (10), (8), (11), (7), (15), (12), (9);
|
||||
CREATE TABLE t2 (a int, b int);
|
||||
INSERT INTO t2 VALUES
|
||||
(8,2), (6,9), (8,4), (5,3), (9,1);
|
||||
EXPLAIN EXTENDED
|
||||
SELECT MAX(a) FROM t1 WHERE (1,2) IN (SELECT 3,4) AND a<10;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 range a a 4 NULL 4 100.00 Using where; Using index
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select max(`test`.`t1`.`a`) AS `MAX(a)` from `test`.`t1` where (<expr_cache><<cache>(1),<cache>(2)>(<in_optimizer>(<cache>((1,2)),<exists>(select 3,4 having (((1 = 3) or isnull(3)) and ((2 = 4) or isnull(4)) and <is_not_null_test>(3) and <is_not_null_test>(4))))) and (`test`.`t1`.`a` < 10))
|
||||
SELECT MAX(a) FROM t1 WHERE (1,2) IN (SELECT 3,4) AND a<10;
|
||||
MAX(a)
|
||||
NULL
|
||||
EXPLAIN EXTENDED
|
||||
SELECT MAX(a) FROM t1 WHERE (1,2) IN (SELECT a,b FROM t2 WHERE b<5) and a<10;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 10 func,func 1 100.00
|
||||
1 PRIMARY t1 range a a 4 NULL 4 100.00 Using where; Using index; Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select max(`test`.`t1`.`a`) AS `MAX(a)` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = 2) and (`test`.`t2`.`a` = 1) and (`test`.`t1`.`a` < 10))
|
||||
SELECT MAX(a) FROM t1 WHERE (1,2) IN (SELECT a,b FROM t2 WHERE b<5) and a<10;
|
||||
MAX(a)
|
||||
NULL
|
||||
EXPLAIN EXTENDED
|
||||
SELECT MAX(a) FROM t1 WHERE RAND()*0<>0 AND a<10;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 range a a 4 NULL 4 100.00 Using where; Using index
|
||||
Warnings:
|
||||
Note 1003 select max(`test`.`t1`.`a`) AS `MAX(a)` from `test`.`t1` where (((rand() * 0) <> 0) and (`test`.`t1`.`a` < 10))
|
||||
SELECT MAX(a) FROM t1 WHERE RAND()*0<>0 AND a<10;
|
||||
MAX(a)
|
||||
NULL
|
||||
DROP TABLE t1,t2;
|
||||
#
|
||||
# Bug #879860: MIN/MAX for subquery returning empty set
|
||||
#
|
||||
CREATE TABLE t1 (a int PRIMARY KEY);
|
||||
INSERT INTO t1 VALUES (1);
|
||||
CREATE TABLE t2 (a int NOT NULL);
|
||||
INSERT INTO t2 VALUES (10);
|
||||
CREATE TABLE t3 ( a int, b int);
|
||||
INSERT INTO t3 VALUES (19,1), (20,5);
|
||||
EXPLAIN EXTENDED
|
||||
SELECT (SELECT MIN(t1.a) FROM t1,t2 WHERE t2.a = t3.b) FROM t3;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 2 100.00
|
||||
2 DEPENDENT SUBQUERY t1 system NULL NULL NULL NULL 1 100.00
|
||||
2 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 1 100.00
|
||||
Warnings:
|
||||
Note 1276 Field or reference 'test.t3.b' of SELECT #2 was resolved in SELECT #1
|
||||
Note 1003 select <expr_cache><`test`.`t3`.`b`>((select min(1) from dual where (10 = `test`.`t3`.`b`))) AS `(SELECT MIN(t1.a) FROM t1,t2 WHERE t2.a = t3.b)` from `test`.`t3`
|
||||
SELECT (SELECT MIN(t1.a) FROM t1,t2 WHERE t2.a = t3.b) FROM t3;
|
||||
(SELECT MIN(t1.a) FROM t1,t2 WHERE t2.a = t3.b)
|
||||
NULL
|
||||
NULL
|
||||
DROP TABLE t1,t2,t3;
|
||||
#
|
||||
End of 5.2 tests
|
||||
#
|
||||
# BUG#46680 - Assertion failed in file item_subselect.cc,
|
||||
# line 305 crashing on HAVING subquery
|
||||
#
|
||||
|
@ -13,6 +13,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
FLUSH STATUS;
|
||||
SELECT a FROM t1 ORDER BY a DESC LIMIT 1;
|
||||
@ -26,6 +27,7 @@ Handler_read_last 1
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
FLUSH STATUS;
|
||||
SELECT a FROM t1 ORDER BY a LIMIT 3;
|
||||
@ -41,6 +43,7 @@ Handler_read_last 0
|
||||
Handler_read_next 2
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
FLUSH STATUS;
|
||||
SELECT a FROM t1 ORDER BY a DESC LIMIT 3;
|
||||
@ -56,5 +59,6 @@ Handler_read_last 1
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 2
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
DROP TABLE t1;
|
||||
|
@ -698,6 +698,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 1
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (
|
||||
|
@ -861,6 +861,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 5
|
||||
drop table t1, t2, t3;
|
||||
create table t1 (a int);
|
||||
@ -1271,6 +1272,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 1
|
||||
DROP TABLE t1, t2;
|
||||
End of 5.1 tests
|
||||
|
@ -5392,4 +5392,184 @@ x 5 5 4
|
||||
SET join_cache_level = DEFAULT;
|
||||
SET optimizer_switch=@tmp_optimizer_switch;
|
||||
DROP TABLE t1,t2,t3,t4;
|
||||
#
|
||||
# Bug#53305 Duplicate weedout + join buffer (join cache --level=7,8)
|
||||
#
|
||||
create table t1 (uid int, fid int, index(uid));
|
||||
insert into t1 values
|
||||
(1,1), (1,2), (1,3), (1,4),
|
||||
(2,5), (2,6), (2,7), (2,8),
|
||||
(3,1), (3,2), (3,9);
|
||||
create table t2 (uid int primary key, name varchar(128), index(name));
|
||||
insert into t2 values
|
||||
(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"),
|
||||
(6, "F"), (7, "G"), (8, "H"), (9, "I");
|
||||
create table t3 (uid int, fid int, index(uid));
|
||||
insert into t3 values
|
||||
(1,1), (1,2), (1,3),(1,4),
|
||||
(2,5), (2,6), (2,7), (2,8),
|
||||
(3,1), (3,2), (3,9);
|
||||
set @tmp_optimizer_switch=@@optimizer_switch;
|
||||
set @@optimizer_switch='semijoin=on';
|
||||
set optimizer_switch='materialization=off';
|
||||
set optimizer_switch='loosescan=off,firstmatch=off';
|
||||
set optimizer_switch='mrr_sort_keys=off';
|
||||
set join_cache_level=7;
|
||||
create table t4 (uid int primary key, name varchar(128), index(name));
|
||||
insert into t4 values
|
||||
(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"),
|
||||
(6, "F"), (7, "G"), (8, "H"), (9, "I");
|
||||
explain select name from t2, t1
|
||||
where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid)
|
||||
and t2.uid=t1.fid;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t3 ref uid uid 5 const 4 Using where; Start temporary
|
||||
1 PRIMARY t4 eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 Using index
|
||||
1 PRIMARY t1 ALL uid NULL NULL NULL 11 Using where; End temporary; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 Using join buffer (flat, BKAH join); Rowid-ordered scan
|
||||
select name from t2, t1
|
||||
where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid)
|
||||
and t2.uid=t1.fid;
|
||||
name
|
||||
A
|
||||
A
|
||||
B
|
||||
B
|
||||
C
|
||||
D
|
||||
E
|
||||
F
|
||||
G
|
||||
H
|
||||
I
|
||||
set join_cache_level = default;
|
||||
set optimizer_switch=@tmp_optimizer_switch;
|
||||
drop table t1,t2,t3,t4;
|
||||
#
|
||||
# Bug#50358 - semijoin execution of subquery with outerjoin
|
||||
# emplying join buffer
|
||||
#
|
||||
CREATE TABLE t1 (i int);
|
||||
CREATE TABLE t2 (i int);
|
||||
CREATE TABLE t3 (i int);
|
||||
INSERT INTO t1 VALUES (1), (2);
|
||||
INSERT INTO t2 VALUES (6);
|
||||
INSERT INTO t3 VALUES (1), (2);
|
||||
set @tmp_optimizer_switch=@@optimizer_switch;
|
||||
set @@optimizer_switch='semijoin=on';
|
||||
set optimizer_switch='materialization=on';
|
||||
set join_cache_level=0;
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE t1.i IN
|
||||
(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 2
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 Using where
|
||||
SELECT * FROM t1 WHERE t1.i IN
|
||||
(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i);
|
||||
i
|
||||
1
|
||||
2
|
||||
set join_cache_level=2;
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE t1.i IN
|
||||
(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 2
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (flat, BNL join)
|
||||
SELECT * FROM t1 WHERE t1.i IN
|
||||
(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i);
|
||||
i
|
||||
1
|
||||
2
|
||||
set join_cache_level = default;
|
||||
set optimizer_switch=@tmp_optimizer_switch;
|
||||
DROP TABLE t1,t2,t3;
|
||||
#
|
||||
# Bug #12546542: missing row with semijoin=off + join cache
|
||||
# (LP bug #922971)
|
||||
#
|
||||
CREATE TABLE t1 (a varchar(1024));
|
||||
INSERT INTO t1 VALUES ('v'), ('we');
|
||||
CREATE TABLE t2 (
|
||||
a varchar(1024) CHARACTER SET utf8 DEFAULT NULL, b int, c int
|
||||
);
|
||||
INSERT INTO t2 VALUES ('we',4,NULL), ('v',1305673728,6);
|
||||
CREATE TABLE t3 (b int, c int);
|
||||
INSERT INTO t3 VALUES (4,4);
|
||||
set @tmp_optimizer_switch=@@optimizer_switch;
|
||||
set optimizer_switch='semijoin=off';
|
||||
set optimizer_switch='materialization=off';
|
||||
set join_cache_level=0;
|
||||
EXPLAIN
|
||||
SELECT * FROM t1
|
||||
WHERE a IN (SELECT t2.a FROM t2 LEFT JOIN t3 ON t2.b = t3.b
|
||||
WHERE t2.c < 10 OR t3.c > 1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 1 Using where
|
||||
SELECT * FROM t1
|
||||
WHERE a IN (SELECT t2.a FROM t2 LEFT JOIN t3 ON t2.b = t3.b
|
||||
WHERE t2.c < 10 OR t3.c > 1);
|
||||
a
|
||||
v
|
||||
we
|
||||
set join_cache_level=2;
|
||||
EXPLAIN
|
||||
SELECT * FROM t1
|
||||
WHERE a IN (SELECT t2.a FROM t2 LEFT JOIN t3 ON t2.b = t3.b
|
||||
WHERE t2.c < 10 OR t3.c > 1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (flat, BNL join)
|
||||
SELECT * FROM t1
|
||||
WHERE a IN (SELECT t2.a FROM t2 LEFT JOIN t3 ON t2.b = t3.b
|
||||
WHERE t2.c < 10 OR t3.c > 1);
|
||||
a
|
||||
v
|
||||
we
|
||||
set join_cache_level = default;
|
||||
set optimizer_switch=@tmp_optimizer_switch;
|
||||
DROP TABLE t1,t2,t3;
|
||||
#
|
||||
# Bug #925985: LEFT JOIN with optimize_join_buffer_size=off +
|
||||
# join_buffer_size > join_buffer_space_limit
|
||||
#
|
||||
CREATE TABLE t1 (a int);
|
||||
INSERT INTO t1 VALUES (5), (3);
|
||||
CREATE TABLE t2 (a int, b int);
|
||||
INSERT INTO t2 VALUES
|
||||
(3,30), (1,10), (7,70), (2,20),
|
||||
(3,31), (1,11), (7,71), (2,21),
|
||||
(3,32), (1,12), (7,72), (2,22);
|
||||
CREATE TABLE t3 (b int, c int);
|
||||
INSERT INTO t3 VALUES (32, 302), (42,400), (30,300);
|
||||
set @tmp_optimizer_switch=@@optimizer_switch;
|
||||
set optimizer_switch='optimize_join_buffer_size=off';
|
||||
set join_buffer_space_limit=4096;
|
||||
set join_buffer_size=4096*2;
|
||||
set join_cache_level=2;
|
||||
set optimizer_switch='outer_join_with_cache=on';
|
||||
EXPLAIN
|
||||
SELECT * FROM t1, t2 LEFT JOIN t3 ON t2.b=t3.b WHERE 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 2
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
|
||||
SELECT * FROM t1, t2 LEFT JOIN t3 ON t2.b=t3.b WHERE t1.a=t2.a;
|
||||
a a b b c
|
||||
3 3 30 30 300
|
||||
3 3 31 NULL NULL
|
||||
3 3 32 32 302
|
||||
set join_buffer_space_limit=default;
|
||||
set join_buffer_size=default;
|
||||
set join_cache_level=default;
|
||||
set optimizer_switch=@tmp_optimizer_switch;
|
||||
DROP TABLE t1,t2,t3;
|
||||
set @@optimizer_switch=@save_optimizer_switch;
|
||||
|
@ -1245,6 +1245,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 6
|
||||
DROP TABLE t1,t2;
|
||||
CREATE TABLE t1 (c int PRIMARY KEY, e int NOT NULL);
|
||||
@ -1747,6 +1748,7 @@ Handler_read_last 0
|
||||
Handler_read_next 5
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 1048581
|
||||
flush status;
|
||||
select sum(t3.b) from t2 left join t3 on t3.a=t2.a and t2.a <> 10;
|
||||
@ -1760,6 +1762,7 @@ Handler_read_last 0
|
||||
Handler_read_next 5
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 1048581
|
||||
drop table t1,t2,t3;
|
||||
#
|
||||
|
@ -52,3 +52,11 @@ pk
|
||||
|
||||
DROP TABLE t1,t2;
|
||||
# End BUG#58456
|
||||
CREATE TABLE t1(a int, b int, KEY (a), PRIMARY KEY (b)) ENGINE=InnoDB;
|
||||
CREATE TABLE t2 (b int, PRIMARY KEY (b));
|
||||
INSERT INTO t2 VALUES (4),(9);
|
||||
SELECT STRAIGHT_JOIN t1.a FROM t1 RIGHT JOIN t2 ON t1.b = t2.b
|
||||
WHERE (t1.b NOT BETWEEN 1 AND 7 OR t1.a IS NULL AND t1.b = t2.b) AND t2.b = 4
|
||||
GROUP BY 1;
|
||||
a
|
||||
DROP TABLE t1,t2;
|
||||
|
@ -1256,6 +1256,7 @@ Handler_read_last 0
|
||||
Handler_read_next 9
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 3
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 6
|
||||
DROP TABLE t1,t2;
|
||||
CREATE TABLE t1 (c int PRIMARY KEY, e int NOT NULL);
|
||||
@ -1758,6 +1759,7 @@ Handler_read_last 0
|
||||
Handler_read_next 5
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 5
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 1048581
|
||||
flush status;
|
||||
select sum(t3.b) from t2 left join t3 on t3.a=t2.a and t2.a <> 10;
|
||||
@ -1771,6 +1773,7 @@ Handler_read_last 0
|
||||
Handler_read_next 5
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 5
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 1048581
|
||||
drop table t1,t2,t3;
|
||||
#
|
||||
|
@ -557,4 +557,66 @@ COUNT(alias2.f2)
|
||||
set @@join_cache_level= @tmp_730133_jcl;
|
||||
set @@optimizer_switch= @tmp_730133_os;
|
||||
drop table t1;
|
||||
#
|
||||
# Test of MRR handler counters
|
||||
#
|
||||
flush status;
|
||||
show status like 'Handler_mrr%';
|
||||
Variable_name Value
|
||||
create table t0 (a int);
|
||||
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
create table t1 (a int, b int, filler char(200), key(a));
|
||||
insert into t1
|
||||
select A.a+10*B.a+100*C.a+1000*D.a, 123,'filler' from t0 A, t0 B, t0 C, t0 D;
|
||||
explain select sum(b) from t1 where a < 10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 8 Using index condition; Rowid-ordered scan
|
||||
# This should show one MRR scan and no re-fills:
|
||||
flush status;
|
||||
select sum(b) from t1 where a < 10;
|
||||
sum(b)
|
||||
1230
|
||||
show status like 'handler_mrr%';
|
||||
Variable_name Value
|
||||
set @mrr_buffer_size_save= @@mrr_buffer_size;
|
||||
set mrr_buffer_size=128;
|
||||
explain select sum(b) from t1 where a < 1600;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 1380 Using index condition; Rowid-ordered scan
|
||||
# This should show one MRR scan and one extra rowid sort:
|
||||
flush status;
|
||||
select sum(b) from t1 where a < 1600;
|
||||
sum(b)
|
||||
196800
|
||||
show status like 'handler_mrr%';
|
||||
Variable_name Value
|
||||
set @@mrr_buffer_size= @mrr_buffer_size_save;
|
||||
#Now, let's check BKA:
|
||||
set @join_cache_level_save= @@join_cache_level;
|
||||
set @join_buffer_size_save= @@join_buffer_size;
|
||||
set join_cache_level=6;
|
||||
explain select sum(t1.b) from t0,t1 where t0.a=t1.a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where
|
||||
1 SIMPLE t1 ref a a 5 test.t0.a 1 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
|
||||
flush status;
|
||||
select sum(t1.b) from t0,t1 where t0.a=t1.a;
|
||||
sum(t1.b)
|
||||
1230
|
||||
show status like 'handler_mrr%';
|
||||
Variable_name Value
|
||||
set join_buffer_size=10;
|
||||
explain select sum(t1.b) from t0,t1 where t0.a=t1.a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where
|
||||
1 SIMPLE t1 ref a a 5 test.t0.a 1 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
|
||||
flush status;
|
||||
select sum(t1.b) from t0,t1 where t0.a=t1.a;
|
||||
sum(t1.b)
|
||||
1230
|
||||
show status like 'handler_mrr%';
|
||||
Variable_name Value
|
||||
set join_cache_level= @join_cache_level_save;
|
||||
set join_buffer_size= @join_buffer_size_save;
|
||||
drop table t0, t1;
|
||||
set optimizer_switch= @myisam_mrr_tmp;
|
||||
|
@ -428,6 +428,7 @@ Handler_read_last 0
|
||||
Handler_read_next 2
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 5
|
||||
DROP TABLE t1,t2,t3,t4;
|
||||
CREATE TABLE t1 (
|
||||
|
@ -1759,3 +1759,57 @@ i1 i2
|
||||
4 4
|
||||
5 5
|
||||
DROP TABLE t1, t2, t3;
|
||||
#
|
||||
# Fix of LP BUG#793589 Wrong result with double ORDER BY
|
||||
#
|
||||
CREATE TABLE t1 ( b int) ;
|
||||
INSERT INTO t1 VALUES (8),(9);
|
||||
CREATE TABLE t2 ( a int, b int, PRIMARY KEY (a)) ;
|
||||
INSERT INTO t2 VALUES (6,7),(7,7),(8,1),(9,7),(10,1),(11,5),(12,2),(13,0),(14,1),(15,8),(16,1),(17,1),(18,9),(19,1),(20,5);
|
||||
SELECT t2.b AS field1 FROM t1, t2 WHERE t1.b = t2.a GROUP BY field1 ORDER BY t1.b, field1;
|
||||
field1
|
||||
1
|
||||
7
|
||||
SELECT t2.b, t1.b FROM t1, t2 WHERE t1.b = t2.a GROUP BY t2.b ORDER BY t1.b, t2.b;
|
||||
b b
|
||||
1 8
|
||||
7 9
|
||||
SELECT t2.b,t1.b FROM t1, t2 WHERE t1.b = t2.a GROUP BY t2.b ORDER BY t1.b;
|
||||
b b
|
||||
1 8
|
||||
7 9
|
||||
SELECT t2.b FROM t1, t2 WHERE t1.b = t2.a GROUP BY t2.b ORDER BY t1.b;
|
||||
b
|
||||
1
|
||||
7
|
||||
# field1 removed from ORDER BY
|
||||
explain extended
|
||||
SELECT t2.b AS field1 FROM t1, t2 WHERE t1.b = t2.a GROUP BY field1 ORDER BY t1.b, field1;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
|
||||
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`b` AS `field1` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`b`) group by `test`.`t2`.`b` order by `test`.`t1`.`b`
|
||||
explain extended
|
||||
SELECT t2.b, t1.b FROM t1, t2 WHERE t1.b = t2.a GROUP BY t2.b ORDER BY t1.b, t2.b;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
|
||||
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`b` AS `b`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`b`) group by `test`.`t2`.`b` order by `test`.`t1`.`b`
|
||||
explain extended
|
||||
SELECT t2.b,t1.b FROM t1, t2 WHERE t1.b = t2.a GROUP BY t2.b ORDER BY t1.b;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
|
||||
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`b` AS `b`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`b`) group by `test`.`t2`.`b` order by `test`.`t1`.`b`
|
||||
explain extended
|
||||
SELECT t2.b FROM t1, t2 WHERE t1.b = t2.a GROUP BY t2.b ORDER BY t1.b;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
|
||||
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`b`) group by `test`.`t2`.`b` order by `test`.`t1`.`b`
|
||||
drop table t1,t2;
|
||||
End of 5.2 tests
|
||||
|
@ -521,6 +521,7 @@ Handler_read_last 0
|
||||
Handler_read_next 4
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
EXPLAIN PARTITIONS SELECT c1 FROM t2 WHERE (c1 > 10 AND c1 < 13) OR (c1 > 17 AND c1 < 20);
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
@ -540,6 +541,7 @@ Handler_read_last 0
|
||||
Handler_read_next 4
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
DROP TABLE t1,t2;
|
||||
CREATE TABLE `t1` (
|
||||
@ -571,6 +573,7 @@ Handler_read_last 0
|
||||
Handler_read_next 2
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
EXPLAIN PARTITIONS SELECT c1 FROM t2 WHERE (c1 > 2 AND c1 < 5);
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
@ -588,6 +591,7 @@ Handler_read_last 0
|
||||
Handler_read_next 2
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
EXPLAIN PARTITIONS SELECT c1 FROM t1 WHERE (c1 > 12 AND c1 < 15);
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
@ -605,6 +609,7 @@ Handler_read_last 0
|
||||
Handler_read_next 2
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
EXPLAIN PARTITIONS SELECT c1 FROM t2 WHERE (c1 > 12 AND c1 < 15);
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
@ -622,6 +627,7 @@ Handler_read_last 0
|
||||
Handler_read_next 2
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
DROP TABLE t1,t2;
|
||||
create table t1 (a int) partition by list ((a/3)*10 div 1)
|
||||
|
@ -2968,7 +2968,10 @@ flush status;
|
||||
delete from t2 where b > 5;
|
||||
show status like 'Handler_read_rnd_next';
|
||||
Variable_name Value
|
||||
Handler_read_rnd_next 1215
|
||||
Handler_read_rnd_next 815
|
||||
show status like 'Handler_read_rnd_deleted';
|
||||
Variable_name Value
|
||||
Handler_read_rnd_deleted 400
|
||||
show status like 'Handler_read_key';
|
||||
Variable_name Value
|
||||
Handler_read_key 0
|
||||
@ -2982,7 +2985,10 @@ flush status;
|
||||
delete from t2 where b < 5 or b > 3;
|
||||
show status like 'Handler_read_rnd_next';
|
||||
Variable_name Value
|
||||
Handler_read_rnd_next 1215
|
||||
Handler_read_rnd_next 515
|
||||
show status like 'Handler_read_rnd_deleted';
|
||||
Variable_name Value
|
||||
Handler_read_rnd_deleted 700
|
||||
show status like 'Handler_read_key';
|
||||
Variable_name Value
|
||||
Handler_read_key 0
|
||||
|
@ -3790,6 +3790,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
flush status;
|
||||
execute st;
|
||||
@ -3803,6 +3804,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
flush status;
|
||||
select * from t1 use index() where a=3;
|
||||
@ -3816,6 +3818,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 8
|
||||
flush status;
|
||||
execute st;
|
||||
@ -3829,6 +3832,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
deallocate prepare st;
|
||||
drop table t1;
|
||||
|
@ -121,8 +121,8 @@ insert into t1 values (1);
|
||||
explain select * from t1 where 3 in (select (1+1) union select 1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 1
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
3 UNION NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
select * from t1 where 3 in (select (1+1) union select 1);
|
||||
a
|
||||
|
@ -2783,10 +2783,10 @@ 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(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
|
||||
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
|
||||
1 SIMPLE t1 index key1 key1 5 NULL 4 Using where; Using index
|
||||
explain select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
|
||||
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
|
||||
1 SIMPLE t1 range key1 key1 5 NULL 3 Using where; Using index
|
||||
select max(key1) from t1 where key1 <= 0.6158;
|
||||
max(key1)
|
||||
0.6158000230789185
|
||||
@ -2805,10 +2805,10 @@ max(key1) min(key2)
|
||||
0.6158000230789185 1.3761999607086182
|
||||
select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
|
||||
max(key1)
|
||||
0.6158000230789185
|
||||
0.38449999690055847
|
||||
select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
|
||||
min(key1)
|
||||
0.37619999051094055
|
||||
0.38449999690055847
|
||||
DROP TABLE t1,t2;
|
||||
CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL);
|
||||
INSERT INTO t1 VALUES (10);
|
||||
@ -4346,6 +4346,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 6
|
||||
DROP TABLE t1, t2;
|
||||
CREATE TABLE t1 (f1 bigint(20) NOT NULL default '0',
|
||||
|
@ -2794,10 +2794,10 @@ 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(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
|
||||
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
|
||||
1 SIMPLE t1 index key1 key1 5 NULL 4 Using where; Using index
|
||||
explain select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
|
||||
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
|
||||
1 SIMPLE t1 range key1 key1 5 NULL 3 Using where; Using index
|
||||
select max(key1) from t1 where key1 <= 0.6158;
|
||||
max(key1)
|
||||
0.6158000230789185
|
||||
@ -2816,10 +2816,10 @@ max(key1) min(key2)
|
||||
0.6158000230789185 1.3761999607086182
|
||||
select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
|
||||
max(key1)
|
||||
0.6158000230789185
|
||||
0.38449999690055847
|
||||
select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
|
||||
min(key1)
|
||||
0.37619999051094055
|
||||
0.38449999690055847
|
||||
DROP TABLE t1,t2;
|
||||
CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL);
|
||||
INSERT INTO t1 VALUES (10);
|
||||
@ -4357,7 +4357,8 @@ Handler_read_last 0
|
||||
Handler_read_next 10
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 10
|
||||
Handler_read_rnd_next 7
|
||||
Handler_read_rnd_deleted 1
|
||||
Handler_read_rnd_next 6
|
||||
DROP TABLE t1, t2;
|
||||
CREATE TABLE t1 (f1 bigint(20) NOT NULL default '0',
|
||||
f2 int(11) NOT NULL default '0',
|
||||
|
@ -2783,10 +2783,10 @@ 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(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
|
||||
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
|
||||
1 SIMPLE t1 index key1 key1 5 NULL 4 Using where; Using index
|
||||
explain select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
|
||||
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
|
||||
1 SIMPLE t1 range key1 key1 5 NULL 3 Using where; Using index
|
||||
select max(key1) from t1 where key1 <= 0.6158;
|
||||
max(key1)
|
||||
0.6158000230789185
|
||||
@ -2805,10 +2805,10 @@ max(key1) min(key2)
|
||||
0.6158000230789185 1.3761999607086182
|
||||
select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
|
||||
max(key1)
|
||||
0.6158000230789185
|
||||
0.38449999690055847
|
||||
select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
|
||||
min(key1)
|
||||
0.37619999051094055
|
||||
0.38449999690055847
|
||||
DROP TABLE t1,t2;
|
||||
CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL);
|
||||
INSERT INTO t1 VALUES (10);
|
||||
@ -4346,6 +4346,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 6
|
||||
DROP TABLE t1, t2;
|
||||
CREATE TABLE t1 (f1 bigint(20) NOT NULL default '0',
|
||||
|
@ -29,6 +29,7 @@ Handler_read_last 0
|
||||
Handler_read_next 4
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
FLUSH STATUS;
|
||||
DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;
|
||||
@ -46,6 +47,7 @@ Handler_read_last 0
|
||||
Handler_read_next 4
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i;
|
||||
a i
|
||||
@ -80,6 +82,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 17
|
||||
FLUSH STATUS;
|
||||
DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;
|
||||
@ -97,6 +100,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 5
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 17
|
||||
SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i;
|
||||
a i
|
||||
@ -128,6 +132,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 17
|
||||
FLUSH STATUS;
|
||||
DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;
|
||||
@ -145,6 +150,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 1
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 17
|
||||
## should be 5 (previous LIMIT)
|
||||
SELECT 1 - COUNT(*) FROM t2 WHERE b = 10;
|
||||
@ -180,6 +186,7 @@ Handler_read_last 0
|
||||
Handler_read_next 4
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
FLUSH STATUS;
|
||||
DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;
|
||||
@ -197,6 +204,7 @@ Handler_read_last 0
|
||||
Handler_read_next 4
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
## should be 5 (previous LIMIT)
|
||||
SELECT 257 - COUNT(*) FROM t2 WHERE b = 10;
|
||||
@ -226,6 +234,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 17
|
||||
FLUSH STATUS;
|
||||
DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;
|
||||
@ -243,6 +252,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 1
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 17
|
||||
SELECT * FROM t2 WHERE b = 10 ORDER BY a, c;
|
||||
a b c d
|
||||
@ -270,6 +280,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 1
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 17
|
||||
FLUSH STATUS;
|
||||
DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;
|
||||
@ -287,6 +298,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 1
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 17
|
||||
SELECT * FROM t2 WHERE b = 10 ORDER BY a, c;
|
||||
a b c d
|
||||
@ -317,6 +329,7 @@ Handler_read_last 0
|
||||
Handler_read_next 7
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 4
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
EXPLAIN EXTENDED SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
@ -339,6 +352,7 @@ Handler_read_last 0
|
||||
Handler_read_next 7
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 8
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;
|
||||
i key1 key2
|
||||
@ -375,6 +389,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 4
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
FLUSH STATUS;
|
||||
DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 5;
|
||||
@ -392,6 +407,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 4
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i;
|
||||
a i
|
||||
@ -426,6 +442,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 17
|
||||
FLUSH STATUS;
|
||||
DELETE FROM t2 ORDER BY a, b DESC LIMIT 5;
|
||||
@ -443,6 +460,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 5
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 17
|
||||
SELECT * FROM t2 ORDER BY a, b DESC;
|
||||
a b c
|
||||
@ -486,6 +504,7 @@ Handler_read_last 0
|
||||
Handler_read_next 4
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
FLUSH STATUS;
|
||||
SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5;
|
||||
@ -509,6 +528,7 @@ Handler_read_last 1
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 4
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
FLUSH STATUS;
|
||||
DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5;
|
||||
@ -526,6 +546,7 @@ Handler_read_last 1
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 4
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
SELECT * FROM t2 WHERE c = 10 ORDER BY a DESC, b DESC;
|
||||
a b c
|
||||
@ -561,6 +582,7 @@ Handler_read_last 0
|
||||
Handler_read_next 4
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
FLUSH STATUS;
|
||||
UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;
|
||||
@ -578,6 +600,7 @@ Handler_read_last 0
|
||||
Handler_read_next 4
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 5
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i;
|
||||
a i
|
||||
@ -617,6 +640,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 17
|
||||
FLUSH STATUS;
|
||||
UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;
|
||||
@ -634,6 +658,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 5
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 17
|
||||
SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i;
|
||||
a i
|
||||
@ -670,6 +695,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 17
|
||||
FLUSH STATUS;
|
||||
UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;
|
||||
@ -687,6 +713,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 1
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 17
|
||||
## should be 5 (previous LIMIT)
|
||||
SELECT COUNT(*) FROM t2 WHERE b = 10 AND d = 10 ORDER BY a, c;
|
||||
@ -722,6 +749,7 @@ Handler_read_last 0
|
||||
Handler_read_next 4
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
FLUSH STATUS;
|
||||
UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;
|
||||
@ -739,6 +767,7 @@ Handler_read_last 0
|
||||
Handler_read_next 4
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 5
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
## should be 5 (previous LIMIT)
|
||||
SELECT COUNT(*) FROM t2 WHERE b = 10 AND d = 10 ORDER BY a, c;
|
||||
@ -768,6 +797,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 17
|
||||
FLUSH STATUS;
|
||||
UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;
|
||||
@ -785,6 +815,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 1
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 17
|
||||
SELECT * FROM t2 WHERE b = 10 ORDER BY a, c;
|
||||
a b c d
|
||||
@ -813,6 +844,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 1
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 17
|
||||
FLUSH STATUS;
|
||||
UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;
|
||||
@ -830,6 +862,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 1
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 17
|
||||
SELECT * FROM t2 WHERE b = 10 ORDER BY a, c;
|
||||
a b c d
|
||||
@ -861,6 +894,7 @@ Handler_read_last 0
|
||||
Handler_read_next 7
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 4
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
EXPLAIN EXTENDED SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
@ -883,6 +917,7 @@ Handler_read_last 0
|
||||
Handler_read_next 7
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 8
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;
|
||||
i key1 key2
|
||||
@ -923,6 +958,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 4
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
FLUSH STATUS;
|
||||
UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 5;
|
||||
@ -940,6 +976,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 4
|
||||
Handler_read_rnd 5
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i;
|
||||
a i
|
||||
@ -979,6 +1016,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 17
|
||||
FLUSH STATUS;
|
||||
UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5;
|
||||
@ -996,6 +1034,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 5
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 17
|
||||
SELECT * FROM t2 WHERE c = 10 ORDER BY a, b DESC;
|
||||
a b c
|
||||
@ -1033,6 +1072,7 @@ Handler_read_last 0
|
||||
Handler_read_next 4
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
FLUSH STATUS;
|
||||
SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5;
|
||||
@ -1056,6 +1096,7 @@ Handler_read_last 1
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 4
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
FLUSH STATUS;
|
||||
UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5;
|
||||
@ -1073,6 +1114,7 @@ Handler_read_last 1
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 4
|
||||
Handler_read_rnd 5
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
SELECT * FROM t2 WHERE c = 10 ORDER BY a DESC, b DESC;
|
||||
a b c
|
||||
|
@ -282,6 +282,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 7
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 23
|
||||
Handler_rollback 0
|
||||
Handler_savepoint 0
|
||||
@ -297,7 +298,35 @@ Created_tmp_files 0
|
||||
Created_tmp_tables 2
|
||||
Handler_tmp_update 2
|
||||
Handler_tmp_write 7
|
||||
Rows_tmp_read 35
|
||||
Rows_tmp_read 36
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (i int(11) DEFAULT NULL, KEY i (i) ) ENGINE=MyISAM;
|
||||
insert into t1 values (1),(2),(3),(4),(5);
|
||||
flush status;
|
||||
select * from t1 where i=5 union select * from t1 where i=5;
|
||||
i
|
||||
5
|
||||
show status like "handler%";
|
||||
Variable_name Value
|
||||
Handler_commit 0
|
||||
Handler_delete 0
|
||||
Handler_discover 0
|
||||
Handler_prepare 0
|
||||
Handler_read_first 0
|
||||
Handler_read_key 2
|
||||
Handler_read_last 0
|
||||
Handler_read_next 2
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 1
|
||||
Handler_read_rnd_next 2
|
||||
Handler_rollback 0
|
||||
Handler_savepoint 0
|
||||
Handler_savepoint_rollback 0
|
||||
Handler_tmp_update 0
|
||||
Handler_tmp_write 2
|
||||
Handler_update 0
|
||||
Handler_write 0
|
||||
drop table t1;
|
||||
set @@global.concurrent_insert= @old_concurrent_insert;
|
||||
SET GLOBAL log_output = @old_log_output;
|
||||
|
@ -107,6 +107,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 5
|
||||
Handler_rollback 2
|
||||
Handler_savepoint 0
|
||||
|
@ -4620,6 +4620,13 @@ CREATE TABLE t1(a1 int);
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
SELECT @@session.sql_mode INTO @old_sql_mode;
|
||||
SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
|
||||
EXPLAIN EXTENDED
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t1);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
Warnings:
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where <nop>(<in_optimizer>(1,((select max(`test`.`t1`.`a1`) from `test`.`t1`) > 1)))
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t1);
|
||||
1
|
||||
1
|
||||
@ -5322,7 +5329,6 @@ EXPLAIN EXTENDED SELECT DISTINCT 1 FROM t1,
|
||||
WHERE t1.a = d1.a;
|
||||
ERROR 42S22: Unknown column 'd1.a' in 'where clause'
|
||||
DROP TABLE t1;
|
||||
End of 5.1 tests.
|
||||
Set up test tables.
|
||||
CREATE TABLE t1 (
|
||||
t1_id INT UNSIGNED,
|
||||
@ -5847,10 +5853,161 @@ NULL
|
||||
NULL
|
||||
5
|
||||
DROP TABLE t1, t2, t3;
|
||||
#
|
||||
# Bug#12763207 - ASSERT IN SUBSELECT::SINGLE_VALUE_TRANSFORMER
|
||||
#
|
||||
CREATE TABLE t1(a1 int);
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
CREATE TABLE t2(a1 int);
|
||||
INSERT INTO t2 VALUES (3);
|
||||
SELECT @@session.sql_mode INTO @old_sql_mode;
|
||||
SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2 FROM t2);
|
||||
1
|
||||
1
|
||||
1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2.0 FROM t2);
|
||||
1
|
||||
1
|
||||
1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 'a' FROM t2);
|
||||
1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t2);
|
||||
1
|
||||
1
|
||||
1
|
||||
SET SESSION sql_mode=@old_sql_mode;
|
||||
DROP TABLE t1, t2;
|
||||
create table t2(i int);
|
||||
insert into t2 values(0);
|
||||
SELECT @@session.sql_mode INTO @old_sql_mode;
|
||||
SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
|
||||
CREATE VIEW v1 AS
|
||||
SELECT 'f' FROM t2 UNION SELECT 'x' FROM t2
|
||||
;
|
||||
CREATE TABLE t1 (
|
||||
pk int NOT NULL,
|
||||
col_varchar_key varchar(1) DEFAULT NULL,
|
||||
PRIMARY KEY (pk),
|
||||
KEY col_varchar_key (col_varchar_key)
|
||||
);
|
||||
SELECT t1.pk
|
||||
FROM t1
|
||||
WHERE t1.col_varchar_key < ALL ( SELECT * FROM v1 )
|
||||
;
|
||||
pk
|
||||
SET SESSION sql_mode=@old_sql_mode;
|
||||
drop table t2, t1;
|
||||
drop view v1;
|
||||
#
|
||||
# BUG#50257: Missing info in REF column of the EXPLAIN
|
||||
# lines for subselects
|
||||
#
|
||||
CREATE TABLE t1 (a INT, b INT, INDEX (a));
|
||||
INSERT INTO t1 VALUES (3, 10), (2, 20), (7, 10), (5, 20);
|
||||
EXPLAIN SELECT * FROM (SELECT * FROM t1 WHERE a=7) t;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 5 const 1
|
||||
EXPLAIN SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t1 WHERE a=7);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
|
||||
2 SUBQUERY t1 ref a a 5 const 1 Using index
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# BUG#12616253 - WRONG RESULT WITH EXISTS(SUBQUERY) (MISSING ROWS)
|
||||
# (duplicate of LP bug #888456)
|
||||
#
|
||||
CREATE TABLE t1 (f1 varchar(1));
|
||||
INSERT INTO t1 VALUES ('v'),('s');
|
||||
CREATE TABLE t2 (f1_key varchar(1), KEY (f1_key));
|
||||
INSERT INTO t2 VALUES ('j'),('v'),('c'),('m'),('d'),
|
||||
('d'),('y'),('t'),('d'),('s');
|
||||
EXPLAIN
|
||||
SELECT table1.f1, table2.f1_key FROM t1 AS table1, t2 AS table2
|
||||
WHERE EXISTS (SELECT DISTINCT f1_key FROM t2
|
||||
WHERE f1_key != table2.f1_key AND f1_key >= table1.f1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY table1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY table2 index NULL f1_key 4 NULL 10 Using where; Using index; Using join buffer (flat, BNL join)
|
||||
2 DEPENDENT SUBQUERY t2 index f1_key f1_key 4 NULL 10 Using where; Using index
|
||||
SELECT table1.f1, table2.f1_key FROM t1 AS table1, t2 AS table2
|
||||
WHERE EXISTS (SELECT DISTINCT f1_key FROM t2
|
||||
WHERE f1_key != table2.f1_key AND f1_key >= table1.f1);
|
||||
f1 f1_key
|
||||
v j
|
||||
s j
|
||||
v v
|
||||
s v
|
||||
v c
|
||||
s c
|
||||
v m
|
||||
s m
|
||||
v d
|
||||
s d
|
||||
v d
|
||||
s d
|
||||
v y
|
||||
s y
|
||||
v t
|
||||
s t
|
||||
v d
|
||||
s d
|
||||
v s
|
||||
s s
|
||||
DROP TABLE t1,t2;
|
||||
#
|
||||
# LP bug 919427: EXPLAIN for a query over a single-row table
|
||||
# with IN subquery in WHERE condition
|
||||
#
|
||||
CREATE TABLE ot (
|
||||
col_int_nokey int(11),
|
||||
col_varchar_nokey varchar(1)
|
||||
) ;
|
||||
INSERT INTO ot VALUES (1,'x');
|
||||
CREATE TABLE it1(
|
||||
col_int_key int(11),
|
||||
col_varchar_key varchar(1),
|
||||
KEY idx_cvk_cik (col_varchar_key,col_int_key)
|
||||
);
|
||||
INSERT INTO it1 VALUES (NULL,'x'), (NULL,'f');
|
||||
CREATE TABLE it2 (
|
||||
col_int_key int(11),
|
||||
col_varchar_key varchar(1),
|
||||
col_varchar_key2 varchar(1),
|
||||
KEY idx_cvk_cvk2_cik (col_varchar_key, col_varchar_key2, col_int_key),
|
||||
KEY idx_cvk_cik (col_varchar_key, col_int_key)
|
||||
);
|
||||
INSERT INTO it2 VALUES (NULL,'x','x'), (NULL,'f','f');
|
||||
EXPLAIN
|
||||
SELECT col_int_nokey FROM ot
|
||||
WHERE col_varchar_nokey IN
|
||||
(SELECT col_varchar_key FROM it1 WHERE col_int_key IS NULL);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY ot system NULL NULL NULL NULL 1
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 5 func 1
|
||||
2 MATERIALIZED it1 ref idx_cvk_cik idx_cvk_cik 9 const,const 1 Using where; Using index
|
||||
SELECT col_int_nokey FROM ot
|
||||
WHERE col_varchar_nokey IN
|
||||
(SELECT col_varchar_key FROM it1 WHERE col_int_key IS NULL);
|
||||
col_int_nokey
|
||||
1
|
||||
EXPLAIN
|
||||
SELECT col_int_nokey FROM ot
|
||||
WHERE (col_varchar_nokey, 'x') IN
|
||||
(SELECT col_varchar_key, col_varchar_key2 FROM it2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY ot system NULL NULL NULL NULL 1
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 10 func,func 1
|
||||
2 MATERIALIZED it2 ref idx_cvk_cvk2_cik,idx_cvk_cik idx_cvk_cvk2_cik 8 const,const 1 Using where; Using index
|
||||
SELECT col_int_nokey FROM ot
|
||||
WHERE (col_varchar_nokey, 'x') IN
|
||||
(SELECT col_varchar_key, col_varchar_key2 FROM it2);
|
||||
col_int_nokey
|
||||
1
|
||||
DROP TABLE ot,it1,it2;
|
||||
End of 5.2 tests
|
||||
#
|
||||
# BUG#779885: Crash in eliminate_item_equal with materialization=on in
|
||||
# maria-5.3
|
||||
#
|
||||
CREATE TABLE t1 ( f1 int );
|
||||
INSERT INTO t1 VALUES (19), (20);
|
||||
@ -5897,32 +6054,6 @@ b c
|
||||
9 NULL
|
||||
SET optimizer_switch=@save_optimizer_switch;
|
||||
drop table t1, t2, t3;
|
||||
End of 5.3 tests
|
||||
#
|
||||
# Bug#12763207 - ASSERT IN SUBSELECT::SINGLE_VALUE_TRANSFORMER
|
||||
#
|
||||
CREATE TABLE t1(a1 int);
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
CREATE TABLE t2(a1 int);
|
||||
INSERT INTO t2 VALUES (3);
|
||||
SELECT @@session.sql_mode INTO @old_sql_mode;
|
||||
SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2 FROM t2);
|
||||
1
|
||||
1
|
||||
1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2.0 FROM t2);
|
||||
1
|
||||
1
|
||||
1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 'a' FROM t2);
|
||||
1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t2);
|
||||
1
|
||||
1
|
||||
1
|
||||
SET SESSION sql_mode=@old_sql_mode;
|
||||
DROP TABLE t1, t2;
|
||||
#
|
||||
# BUG#50257: Missing info in REF column of the EXPLAIN
|
||||
# lines for subselects
|
||||
@ -5945,6 +6076,54 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug#11764086: Null left operand to NOT IN in WHERE clause
|
||||
# behaves differently than real NULL
|
||||
#
|
||||
CREATE TABLE parent (id int);
|
||||
INSERT INTO parent VALUES (1), (2);
|
||||
CREATE TABLE child (parent_id int, other int);
|
||||
INSERT INTO child VALUES (1,NULL);
|
||||
# Offending query (c.parent_id is NULL for null-complemented rows only)
|
||||
SELECT p.id, c.parent_id
|
||||
FROM parent p
|
||||
LEFT JOIN child c
|
||||
ON p.id = c.parent_id
|
||||
WHERE c.parent_id NOT IN (
|
||||
SELECT parent_id
|
||||
FROM child
|
||||
WHERE parent_id = 3
|
||||
);
|
||||
id parent_id
|
||||
1 1
|
||||
2 NULL
|
||||
# Some syntactic variations with IS FALSE and IS NOT TRUE
|
||||
SELECT p.id, c.parent_id
|
||||
FROM parent p
|
||||
LEFT JOIN child c
|
||||
ON p.id = c.parent_id
|
||||
WHERE c.parent_id IN (
|
||||
SELECT parent_id
|
||||
FROM child
|
||||
WHERE parent_id = 3
|
||||
) IS NOT TRUE;
|
||||
id parent_id
|
||||
1 1
|
||||
2 NULL
|
||||
SELECT p.id, c.parent_id
|
||||
FROM parent p
|
||||
LEFT JOIN child c
|
||||
ON p.id = c.parent_id
|
||||
WHERE c.parent_id IN (
|
||||
SELECT parent_id
|
||||
FROM child
|
||||
WHERE parent_id = 3
|
||||
) IS FALSE;
|
||||
id parent_id
|
||||
1 1
|
||||
2 NULL
|
||||
DROP TABLE parent, child;
|
||||
# End of test for bug#11764086.
|
||||
#
|
||||
# Bug 11765699 - 58690: !TABLE || (!TABLE->READ_SET ||
|
||||
# BITMAP_IS_SET(TABLE->READ_SET, FIELD_INDEX
|
||||
#
|
||||
@ -6283,5 +6462,14 @@ SELECT ( SELECT b FROM t2 WHERE b = a OR rand() * 0) FROM t1;
|
||||
1
|
||||
NULL
|
||||
drop table t1,t2,t3;
|
||||
#
|
||||
# LP BUG#905353 Wrong non-empty result with a constant table,
|
||||
# aggregate function in subquery, MyISAM or Aria
|
||||
#
|
||||
CREATE TABLE t1 ( a INT ) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (1);
|
||||
SELECT a FROM t1 WHERE ( SELECT MIN(a) = 100 );
|
||||
a
|
||||
drop table t1;
|
||||
# return optimizer switch changed in the beginning of this test
|
||||
set optimizer_switch=@subselect_tmp;
|
||||
|
@ -125,6 +125,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 50
|
||||
select 'No key lookups, seq reads: 29= 5 reads from t2 + 4 * 6 reads from t1.' Z;
|
||||
Z
|
||||
|
@ -135,6 +135,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 50
|
||||
select 'No key lookups, seq reads: 29= 5 reads from t2 + 4 * 6 reads from t1.' Z;
|
||||
Z
|
||||
@ -1153,7 +1154,7 @@ insert into t4 select a from t3;
|
||||
explain select * from t3 where a in (select t1.kp1 from t1,t4 where kp1<20
|
||||
and t4.pk=t1.c);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 range kp1 kp1 5 NULL 48 Using index condition; Using where; Rowid-ordered scan; LooseScan
|
||||
1 PRIMARY t1 range kp1 kp1 5 NULL 48 Using index condition; Using where; LooseScan
|
||||
1 PRIMARY t4 eq_ref PRIMARY PRIMARY 4 test.t1.c 1 Using index; FirstMatch(t1)
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 100 Using where; Using join buffer (flat, BNL join)
|
||||
drop table t1, t3, t4;
|
||||
|
@ -711,7 +711,7 @@ EXPLAIN
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT min(f3)+f3, min(f4)+f3+max(f4) FROM t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No matching min/max row
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No matching min/max row
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT min(f3)+f3, min(f4)+f3+max(f4) FROM t2);
|
||||
f1 f2
|
||||
SET @@optimizer_switch = 'materialization=off,in_to_exists=on,semijoin=off';
|
||||
@ -802,7 +802,7 @@ EXPLAIN
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT min(f3)+f3, min(f4)+f3+max(f4) FROM t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No matching min/max row
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No matching min/max row
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT min(f3)+f3, min(f4)+f3+max(f4) FROM t2);
|
||||
f1 f2
|
||||
INSERT INTO t1 VALUES (1, 2);
|
||||
@ -897,7 +897,7 @@ EXPLAIN
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT min(f3)+f3, min(f4)+f3+max(f4) FROM t2 WHERE f3 > 10);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No matching min/max row
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No matching min/max row
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT min(f3)+f3, min(f4)+f3+max(f4) FROM t2 WHERE f3 > 10);
|
||||
f1 f2
|
||||
SET @@optimizer_switch = 'materialization=off,in_to_exists=on,semijoin=off';
|
||||
@ -988,7 +988,7 @@ EXPLAIN
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT min(f3)+f3, min(f4)+f3+max(f4) FROM t2 WHERE f3 > 10);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No matching min/max row
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No matching min/max row
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT min(f3)+f3, min(f4)+f3+max(f4) FROM t2 WHERE f3 > 10);
|
||||
f1 f2
|
||||
set @@optimizer_switch=@save_optimizer_switch;
|
||||
|
@ -37,6 +37,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 31
|
||||
set optimizer_switch='subquery_cache=off';
|
||||
flush status;
|
||||
@ -64,6 +65,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 61
|
||||
set optimizer_switch='subquery_cache=on';
|
||||
#single value subquery test (where)
|
||||
@ -90,6 +92,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 31
|
||||
set optimizer_switch='subquery_cache=off';
|
||||
flush status;
|
||||
@ -115,6 +118,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 61
|
||||
set optimizer_switch='subquery_cache=on';
|
||||
#single value subquery test (having)
|
||||
@ -141,6 +145,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 31
|
||||
set optimizer_switch='subquery_cache=off';
|
||||
flush status;
|
||||
@ -166,6 +171,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 61
|
||||
set optimizer_switch='subquery_cache=on';
|
||||
#single value subquery test (OUTER JOIN ON)
|
||||
@ -264,6 +270,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 442
|
||||
set optimizer_switch='subquery_cache=off';
|
||||
flush status;
|
||||
@ -361,6 +368,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 472
|
||||
set optimizer_switch='subquery_cache=on';
|
||||
#single value subquery test (GROUP BY)
|
||||
@ -383,6 +391,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 4
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 36
|
||||
set optimizer_switch='subquery_cache=off';
|
||||
flush status;
|
||||
@ -404,6 +413,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 4
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 86
|
||||
set optimizer_switch='subquery_cache=on';
|
||||
#single value subquery test (distinct GROUP BY)
|
||||
@ -426,6 +436,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 4
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 41
|
||||
set optimizer_switch='subquery_cache=off';
|
||||
flush status;
|
||||
@ -447,6 +458,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 4
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 91
|
||||
set optimizer_switch='subquery_cache=on';
|
||||
#single value subquery test (ORDER BY)
|
||||
@ -475,6 +487,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 10
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 42
|
||||
set optimizer_switch='subquery_cache=off';
|
||||
flush status;
|
||||
@ -502,6 +515,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 10
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 72
|
||||
set optimizer_switch='subquery_cache=on';
|
||||
#single value subquery test (distinct ORDER BY)
|
||||
@ -524,7 +538,8 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 4
|
||||
Handler_read_rnd_next 37
|
||||
Handler_read_rnd_deleted 1
|
||||
Handler_read_rnd_next 36
|
||||
set optimizer_switch='subquery_cache=off';
|
||||
flush status;
|
||||
select distinct a from t1 ORDER BY (select d from t2 where b=c);
|
||||
@ -545,7 +560,8 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 4
|
||||
Handler_read_rnd_next 67
|
||||
Handler_read_rnd_deleted 1
|
||||
Handler_read_rnd_next 66
|
||||
set optimizer_switch='subquery_cache=on';
|
||||
#single value subquery test (LEFT JOIN ON)
|
||||
flush status;
|
||||
@ -643,6 +659,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 141
|
||||
set optimizer_switch='subquery_cache=off';
|
||||
flush status;
|
||||
@ -740,6 +757,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 671
|
||||
set optimizer_switch='subquery_cache=on';
|
||||
#single value subquery test (PS)
|
||||
@ -1364,6 +1382,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 145
|
||||
set optimizer_switch='subquery_cache=on';
|
||||
flush status;
|
||||
@ -1393,6 +1412,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 84
|
||||
#several subqueries (several levels)
|
||||
set optimizer_switch='subquery_cache=off';
|
||||
@ -1425,6 +1445,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 127
|
||||
set optimizer_switch='subquery_cache=on';
|
||||
flush status;
|
||||
@ -1454,6 +1475,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 69
|
||||
#clean up
|
||||
drop table t1,t2;
|
||||
@ -1644,6 +1666,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 8
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 57
|
||||
set optimizer_switch='subquery_cache=on';
|
||||
flush status;
|
||||
@ -1669,6 +1692,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 8
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 37
|
||||
argument of aggregate function as parameter of subquery (illegal use)
|
||||
set optimizer_switch='subquery_cache=off';
|
||||
@ -1695,6 +1719,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 8
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 57
|
||||
set optimizer_switch='subquery_cache=on';
|
||||
flush status;
|
||||
@ -1720,6 +1745,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 8
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 41
|
||||
drop table t1,t2;
|
||||
#test of flattening subquery optimisations and cache
|
||||
@ -1761,6 +1787,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 16
|
||||
alter table t2 drop primary key;
|
||||
set optimizer_switch='default,semijoin=off,materialization=off,subquery_cache=off';
|
||||
@ -1798,6 +1825,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 151
|
||||
set optimizer_switch='default,semijoin=off,materialization=off,subquery_cache=on';
|
||||
explain select * from t1 where a in (select pk from t2);
|
||||
@ -1834,6 +1862,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 43
|
||||
set optimizer_switch='default,semijoin=off,materialization=on,subquery_cache=on';
|
||||
explain select * from t1 where a in (select pk from t2);
|
||||
@ -1870,6 +1899,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 27
|
||||
drop table t0,t1,t2;
|
||||
set optimizer_switch='default';
|
||||
|
@ -1793,7 +1793,7 @@ SELECT * FROM t1
|
||||
WHERE a IN ( SELECT MIN(a) FROM t1 );
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
Warnings:
|
||||
Note 1003 select 8 AS `a` from dual where <expr_cache><8>(<in_optimizer>(8,<exists>(select min(`test`.`t1`.`a`) from `test`.`t1` having (<cache>(8) = <ref_null_helper>(min(`test`.`t1`.`a`))))))
|
||||
DROP TABLE t1;
|
||||
@ -1811,6 +1811,43 @@ a b c
|
||||
4 4 2
|
||||
4 4 4
|
||||
DROP TABLE t1,t2;
|
||||
#
|
||||
# BUG#922254: Assertion `0' failed at item_cmpfunc.cc:5899: Item* Item_equal::get_first(JOIN_TAB*, Item*)
|
||||
#
|
||||
CREATE TABLE t1 ( a VARCHAR(3) );
|
||||
CREATE TABLE t2 ( b VARCHAR(3), c VARCHAR(8), KEY(c) );
|
||||
INSERT INTO t2 VALUES ('USA','Abilene'),('USA','Akron');
|
||||
EXPLAIN
|
||||
SELECT * FROM
|
||||
( SELECT * FROM t1 ) AS alias1,
|
||||
t2 AS alias2
|
||||
WHERE b = a AND a IN (
|
||||
SELECT alias3.c
|
||||
FROM t2 AS alias3, t2 AS alias4
|
||||
WHERE alias4.c = alias3.b
|
||||
);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
3 MATERIALIZED alias3 ALL NULL NULL NULL NULL 2
|
||||
3 MATERIALIZED alias4 index c c 11 NULL 2 Using where; Using index; Using join buffer (flat, BNL join)
|
||||
DROP TABLE t1,t2;
|
||||
#
|
||||
# BUG#928048: Query containing IN subquery with OR in the where clause returns a wrong result
|
||||
#
|
||||
create table t1 (a int, b int);
|
||||
insert into t1 values (7,5), (3,3), (5,4), (9,3);
|
||||
create table t2 (a int, b int, index i_a(a));
|
||||
insert into t2 values
|
||||
(4,2), (7,9), (7,4), (3,1), (5,3), (3,1), (9,4), (8,1);
|
||||
explain select * from t1 where t1.a in (select a from t2 where t2.a=7 or t2.b<=1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where
|
||||
2 MATERIALIZED t2 ALL i_a NULL NULL NULL 8 Using where
|
||||
select * from t1 where t1.a in (select a from t2 where t2.a=7 or t2.b<=1);
|
||||
a b
|
||||
7 5
|
||||
3 3
|
||||
drop table t1,t2;
|
||||
# This must be at the end:
|
||||
set optimizer_switch=@subselect_sj_mat_tmp;
|
||||
set join_cache_level=@save_join_cache_level;
|
||||
|
@ -4622,6 +4622,13 @@ CREATE TABLE t1(a1 int);
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
SELECT @@session.sql_mode INTO @old_sql_mode;
|
||||
SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
|
||||
EXPLAIN EXTENDED
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t1);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
Warnings:
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where <nop>(<in_optimizer>(1,((select max(`test`.`t1`.`a1`) from `test`.`t1`) > 1)))
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t1);
|
||||
1
|
||||
1
|
||||
@ -5324,7 +5331,6 @@ EXPLAIN EXTENDED SELECT DISTINCT 1 FROM t1,
|
||||
WHERE t1.a = d1.a;
|
||||
ERROR 42S22: Unknown column 'd1.a' in 'where clause'
|
||||
DROP TABLE t1;
|
||||
End of 5.1 tests.
|
||||
Set up test tables.
|
||||
CREATE TABLE t1 (
|
||||
t1_id INT UNSIGNED,
|
||||
@ -5848,10 +5854,159 @@ NULL
|
||||
NULL
|
||||
5
|
||||
DROP TABLE t1, t2, t3;
|
||||
#
|
||||
# Bug#12763207 - ASSERT IN SUBSELECT::SINGLE_VALUE_TRANSFORMER
|
||||
#
|
||||
CREATE TABLE t1(a1 int);
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
CREATE TABLE t2(a1 int);
|
||||
INSERT INTO t2 VALUES (3);
|
||||
SELECT @@session.sql_mode INTO @old_sql_mode;
|
||||
SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2 FROM t2);
|
||||
1
|
||||
1
|
||||
1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2.0 FROM t2);
|
||||
1
|
||||
1
|
||||
1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 'a' FROM t2);
|
||||
1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t2);
|
||||
1
|
||||
1
|
||||
1
|
||||
SET SESSION sql_mode=@old_sql_mode;
|
||||
DROP TABLE t1, t2;
|
||||
create table t2(i int);
|
||||
insert into t2 values(0);
|
||||
SELECT @@session.sql_mode INTO @old_sql_mode;
|
||||
SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
|
||||
CREATE VIEW v1 AS
|
||||
SELECT 'f' FROM t2 UNION SELECT 'x' FROM t2
|
||||
;
|
||||
CREATE TABLE t1 (
|
||||
pk int NOT NULL,
|
||||
col_varchar_key varchar(1) DEFAULT NULL,
|
||||
PRIMARY KEY (pk),
|
||||
KEY col_varchar_key (col_varchar_key)
|
||||
);
|
||||
SELECT t1.pk
|
||||
FROM t1
|
||||
WHERE t1.col_varchar_key < ALL ( SELECT * FROM v1 )
|
||||
;
|
||||
pk
|
||||
SET SESSION sql_mode=@old_sql_mode;
|
||||
drop table t2, t1;
|
||||
drop view v1;
|
||||
#
|
||||
# BUG#50257: Missing info in REF column of the EXPLAIN
|
||||
# lines for subselects
|
||||
#
|
||||
CREATE TABLE t1 (a INT, b INT, INDEX (a));
|
||||
INSERT INTO t1 VALUES (3, 10), (2, 20), (7, 10), (5, 20);
|
||||
EXPLAIN SELECT * FROM (SELECT * FROM t1 WHERE a=7) t;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 5 const 1
|
||||
EXPLAIN SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t1 WHERE a=7);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
|
||||
2 SUBQUERY t1 ref a a 5 const 1 Using index
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# BUG#12616253 - WRONG RESULT WITH EXISTS(SUBQUERY) (MISSING ROWS)
|
||||
# (duplicate of LP bug #888456)
|
||||
#
|
||||
CREATE TABLE t1 (f1 varchar(1));
|
||||
INSERT INTO t1 VALUES ('v'),('s');
|
||||
CREATE TABLE t2 (f1_key varchar(1), KEY (f1_key));
|
||||
INSERT INTO t2 VALUES ('j'),('v'),('c'),('m'),('d'),
|
||||
('d'),('y'),('t'),('d'),('s');
|
||||
EXPLAIN
|
||||
SELECT table1.f1, table2.f1_key FROM t1 AS table1, t2 AS table2
|
||||
WHERE EXISTS (SELECT DISTINCT f1_key FROM t2
|
||||
WHERE f1_key != table2.f1_key AND f1_key >= table1.f1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY table1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY table2 index NULL f1_key 4 NULL 10 Using where; Using index; Using join buffer (flat, BNL join)
|
||||
2 DEPENDENT SUBQUERY t2 index f1_key f1_key 4 NULL 10 Using where; Using index
|
||||
SELECT table1.f1, table2.f1_key FROM t1 AS table1, t2 AS table2
|
||||
WHERE EXISTS (SELECT DISTINCT f1_key FROM t2
|
||||
WHERE f1_key != table2.f1_key AND f1_key >= table1.f1);
|
||||
f1 f1_key
|
||||
v j
|
||||
s j
|
||||
v v
|
||||
s v
|
||||
v c
|
||||
s c
|
||||
v m
|
||||
s m
|
||||
v d
|
||||
s d
|
||||
v d
|
||||
s d
|
||||
v y
|
||||
s y
|
||||
v t
|
||||
s t
|
||||
v d
|
||||
s d
|
||||
v s
|
||||
s s
|
||||
DROP TABLE t1,t2;
|
||||
#
|
||||
# LP bug 919427: EXPLAIN for a query over a single-row table
|
||||
# with IN subquery in WHERE condition
|
||||
#
|
||||
CREATE TABLE ot (
|
||||
col_int_nokey int(11),
|
||||
col_varchar_nokey varchar(1)
|
||||
) ;
|
||||
INSERT INTO ot VALUES (1,'x');
|
||||
CREATE TABLE it1(
|
||||
col_int_key int(11),
|
||||
col_varchar_key varchar(1),
|
||||
KEY idx_cvk_cik (col_varchar_key,col_int_key)
|
||||
);
|
||||
INSERT INTO it1 VALUES (NULL,'x'), (NULL,'f');
|
||||
CREATE TABLE it2 (
|
||||
col_int_key int(11),
|
||||
col_varchar_key varchar(1),
|
||||
col_varchar_key2 varchar(1),
|
||||
KEY idx_cvk_cvk2_cik (col_varchar_key, col_varchar_key2, col_int_key),
|
||||
KEY idx_cvk_cik (col_varchar_key, col_int_key)
|
||||
);
|
||||
INSERT INTO it2 VALUES (NULL,'x','x'), (NULL,'f','f');
|
||||
EXPLAIN
|
||||
SELECT col_int_nokey FROM ot
|
||||
WHERE col_varchar_nokey IN
|
||||
(SELECT col_varchar_key FROM it1 WHERE col_int_key IS NULL);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY ot system NULL NULL NULL NULL 1
|
||||
1 PRIMARY it1 ref idx_cvk_cik idx_cvk_cik 9 const,const 1 Using where; Using index; FirstMatch(ot)
|
||||
SELECT col_int_nokey FROM ot
|
||||
WHERE col_varchar_nokey IN
|
||||
(SELECT col_varchar_key FROM it1 WHERE col_int_key IS NULL);
|
||||
col_int_nokey
|
||||
1
|
||||
EXPLAIN
|
||||
SELECT col_int_nokey FROM ot
|
||||
WHERE (col_varchar_nokey, 'x') IN
|
||||
(SELECT col_varchar_key, col_varchar_key2 FROM it2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY ot system NULL NULL NULL NULL 1
|
||||
1 PRIMARY it2 ref idx_cvk_cvk2_cik,idx_cvk_cik idx_cvk_cvk2_cik 8 const,const 1 Using where; Using index; FirstMatch(ot)
|
||||
SELECT col_int_nokey FROM ot
|
||||
WHERE (col_varchar_nokey, 'x') IN
|
||||
(SELECT col_varchar_key, col_varchar_key2 FROM it2);
|
||||
col_int_nokey
|
||||
1
|
||||
DROP TABLE ot,it1,it2;
|
||||
End of 5.2 tests
|
||||
#
|
||||
# BUG#779885: Crash in eliminate_item_equal with materialization=on in
|
||||
# maria-5.3
|
||||
#
|
||||
CREATE TABLE t1 ( f1 int );
|
||||
INSERT INTO t1 VALUES (19), (20);
|
||||
@ -5898,32 +6053,6 @@ b c
|
||||
9 NULL
|
||||
SET optimizer_switch=@save_optimizer_switch;
|
||||
drop table t1, t2, t3;
|
||||
End of 5.3 tests
|
||||
#
|
||||
# Bug#12763207 - ASSERT IN SUBSELECT::SINGLE_VALUE_TRANSFORMER
|
||||
#
|
||||
CREATE TABLE t1(a1 int);
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
CREATE TABLE t2(a1 int);
|
||||
INSERT INTO t2 VALUES (3);
|
||||
SELECT @@session.sql_mode INTO @old_sql_mode;
|
||||
SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2 FROM t2);
|
||||
1
|
||||
1
|
||||
1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2.0 FROM t2);
|
||||
1
|
||||
1
|
||||
1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 'a' FROM t2);
|
||||
1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t2);
|
||||
1
|
||||
1
|
||||
1
|
||||
SET SESSION sql_mode=@old_sql_mode;
|
||||
DROP TABLE t1, t2;
|
||||
#
|
||||
# BUG#50257: Missing info in REF column of the EXPLAIN
|
||||
# lines for subselects
|
||||
@ -5946,6 +6075,54 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug#11764086: Null left operand to NOT IN in WHERE clause
|
||||
# behaves differently than real NULL
|
||||
#
|
||||
CREATE TABLE parent (id int);
|
||||
INSERT INTO parent VALUES (1), (2);
|
||||
CREATE TABLE child (parent_id int, other int);
|
||||
INSERT INTO child VALUES (1,NULL);
|
||||
# Offending query (c.parent_id is NULL for null-complemented rows only)
|
||||
SELECT p.id, c.parent_id
|
||||
FROM parent p
|
||||
LEFT JOIN child c
|
||||
ON p.id = c.parent_id
|
||||
WHERE c.parent_id NOT IN (
|
||||
SELECT parent_id
|
||||
FROM child
|
||||
WHERE parent_id = 3
|
||||
);
|
||||
id parent_id
|
||||
1 1
|
||||
2 NULL
|
||||
# Some syntactic variations with IS FALSE and IS NOT TRUE
|
||||
SELECT p.id, c.parent_id
|
||||
FROM parent p
|
||||
LEFT JOIN child c
|
||||
ON p.id = c.parent_id
|
||||
WHERE c.parent_id IN (
|
||||
SELECT parent_id
|
||||
FROM child
|
||||
WHERE parent_id = 3
|
||||
) IS NOT TRUE;
|
||||
id parent_id
|
||||
1 1
|
||||
2 NULL
|
||||
SELECT p.id, c.parent_id
|
||||
FROM parent p
|
||||
LEFT JOIN child c
|
||||
ON p.id = c.parent_id
|
||||
WHERE c.parent_id IN (
|
||||
SELECT parent_id
|
||||
FROM child
|
||||
WHERE parent_id = 3
|
||||
) IS FALSE;
|
||||
id parent_id
|
||||
1 1
|
||||
2 NULL
|
||||
DROP TABLE parent, child;
|
||||
# End of test for bug#11764086.
|
||||
#
|
||||
# Bug 11765699 - 58690: !TABLE || (!TABLE->READ_SET ||
|
||||
# BITMAP_IS_SET(TABLE->READ_SET, FIELD_INDEX
|
||||
#
|
||||
@ -6284,6 +6461,15 @@ SELECT ( SELECT b FROM t2 WHERE b = a OR rand() * 0) FROM t1;
|
||||
1
|
||||
NULL
|
||||
drop table t1,t2,t3;
|
||||
#
|
||||
# LP BUG#905353 Wrong non-empty result with a constant table,
|
||||
# aggregate function in subquery, MyISAM or Aria
|
||||
#
|
||||
CREATE TABLE t1 ( a INT ) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (1);
|
||||
SELECT a FROM t1 WHERE ( SELECT MIN(a) = 100 );
|
||||
a
|
||||
drop table t1;
|
||||
# return optimizer switch changed in the beginning of this test
|
||||
set optimizer_switch=@subselect_tmp;
|
||||
set optimizer_switch=default;
|
||||
|
@ -4618,6 +4618,13 @@ CREATE TABLE t1(a1 int);
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
SELECT @@session.sql_mode INTO @old_sql_mode;
|
||||
SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
|
||||
EXPLAIN EXTENDED
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t1);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
Warnings:
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where <nop>(<in_optimizer>(1,((select max(`test`.`t1`.`a1`) from `test`.`t1`) > 1)))
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t1);
|
||||
1
|
||||
1
|
||||
@ -5320,7 +5327,6 @@ EXPLAIN EXTENDED SELECT DISTINCT 1 FROM t1,
|
||||
WHERE t1.a = d1.a;
|
||||
ERROR 42S22: Unknown column 'd1.a' in 'where clause'
|
||||
DROP TABLE t1;
|
||||
End of 5.1 tests.
|
||||
Set up test tables.
|
||||
CREATE TABLE t1 (
|
||||
t1_id INT UNSIGNED,
|
||||
@ -5844,10 +5850,159 @@ NULL
|
||||
NULL
|
||||
5
|
||||
DROP TABLE t1, t2, t3;
|
||||
#
|
||||
# Bug#12763207 - ASSERT IN SUBSELECT::SINGLE_VALUE_TRANSFORMER
|
||||
#
|
||||
CREATE TABLE t1(a1 int);
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
CREATE TABLE t2(a1 int);
|
||||
INSERT INTO t2 VALUES (3);
|
||||
SELECT @@session.sql_mode INTO @old_sql_mode;
|
||||
SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2 FROM t2);
|
||||
1
|
||||
1
|
||||
1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2.0 FROM t2);
|
||||
1
|
||||
1
|
||||
1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 'a' FROM t2);
|
||||
1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t2);
|
||||
1
|
||||
1
|
||||
1
|
||||
SET SESSION sql_mode=@old_sql_mode;
|
||||
DROP TABLE t1, t2;
|
||||
create table t2(i int);
|
||||
insert into t2 values(0);
|
||||
SELECT @@session.sql_mode INTO @old_sql_mode;
|
||||
SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
|
||||
CREATE VIEW v1 AS
|
||||
SELECT 'f' FROM t2 UNION SELECT 'x' FROM t2
|
||||
;
|
||||
CREATE TABLE t1 (
|
||||
pk int NOT NULL,
|
||||
col_varchar_key varchar(1) DEFAULT NULL,
|
||||
PRIMARY KEY (pk),
|
||||
KEY col_varchar_key (col_varchar_key)
|
||||
);
|
||||
SELECT t1.pk
|
||||
FROM t1
|
||||
WHERE t1.col_varchar_key < ALL ( SELECT * FROM v1 )
|
||||
;
|
||||
pk
|
||||
SET SESSION sql_mode=@old_sql_mode;
|
||||
drop table t2, t1;
|
||||
drop view v1;
|
||||
#
|
||||
# BUG#50257: Missing info in REF column of the EXPLAIN
|
||||
# lines for subselects
|
||||
#
|
||||
CREATE TABLE t1 (a INT, b INT, INDEX (a));
|
||||
INSERT INTO t1 VALUES (3, 10), (2, 20), (7, 10), (5, 20);
|
||||
EXPLAIN SELECT * FROM (SELECT * FROM t1 WHERE a=7) t;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 5 const 1
|
||||
EXPLAIN SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t1 WHERE a=7);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
|
||||
2 SUBQUERY t1 ref a a 5 const 1 Using index
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# BUG#12616253 - WRONG RESULT WITH EXISTS(SUBQUERY) (MISSING ROWS)
|
||||
# (duplicate of LP bug #888456)
|
||||
#
|
||||
CREATE TABLE t1 (f1 varchar(1));
|
||||
INSERT INTO t1 VALUES ('v'),('s');
|
||||
CREATE TABLE t2 (f1_key varchar(1), KEY (f1_key));
|
||||
INSERT INTO t2 VALUES ('j'),('v'),('c'),('m'),('d'),
|
||||
('d'),('y'),('t'),('d'),('s');
|
||||
EXPLAIN
|
||||
SELECT table1.f1, table2.f1_key FROM t1 AS table1, t2 AS table2
|
||||
WHERE EXISTS (SELECT DISTINCT f1_key FROM t2
|
||||
WHERE f1_key != table2.f1_key AND f1_key >= table1.f1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY table1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY table2 index NULL f1_key 4 NULL 10 Using where; Using index; Using join buffer (flat, BNL join)
|
||||
2 DEPENDENT SUBQUERY t2 index f1_key f1_key 4 NULL 10 Using where; Using index
|
||||
SELECT table1.f1, table2.f1_key FROM t1 AS table1, t2 AS table2
|
||||
WHERE EXISTS (SELECT DISTINCT f1_key FROM t2
|
||||
WHERE f1_key != table2.f1_key AND f1_key >= table1.f1);
|
||||
f1 f1_key
|
||||
v j
|
||||
s j
|
||||
v v
|
||||
s v
|
||||
v c
|
||||
s c
|
||||
v m
|
||||
s m
|
||||
v d
|
||||
s d
|
||||
v d
|
||||
s d
|
||||
v y
|
||||
s y
|
||||
v t
|
||||
s t
|
||||
v d
|
||||
s d
|
||||
v s
|
||||
s s
|
||||
DROP TABLE t1,t2;
|
||||
#
|
||||
# LP bug 919427: EXPLAIN for a query over a single-row table
|
||||
# with IN subquery in WHERE condition
|
||||
#
|
||||
CREATE TABLE ot (
|
||||
col_int_nokey int(11),
|
||||
col_varchar_nokey varchar(1)
|
||||
) ;
|
||||
INSERT INTO ot VALUES (1,'x');
|
||||
CREATE TABLE it1(
|
||||
col_int_key int(11),
|
||||
col_varchar_key varchar(1),
|
||||
KEY idx_cvk_cik (col_varchar_key,col_int_key)
|
||||
);
|
||||
INSERT INTO it1 VALUES (NULL,'x'), (NULL,'f');
|
||||
CREATE TABLE it2 (
|
||||
col_int_key int(11),
|
||||
col_varchar_key varchar(1),
|
||||
col_varchar_key2 varchar(1),
|
||||
KEY idx_cvk_cvk2_cik (col_varchar_key, col_varchar_key2, col_int_key),
|
||||
KEY idx_cvk_cik (col_varchar_key, col_int_key)
|
||||
);
|
||||
INSERT INTO it2 VALUES (NULL,'x','x'), (NULL,'f','f');
|
||||
EXPLAIN
|
||||
SELECT col_int_nokey FROM ot
|
||||
WHERE col_varchar_nokey IN
|
||||
(SELECT col_varchar_key FROM it1 WHERE col_int_key IS NULL);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY ot system NULL NULL NULL NULL 1
|
||||
2 DEPENDENT SUBQUERY it1 index_subquery idx_cvk_cik idx_cvk_cik 9 func,const 2 Using index; Using where
|
||||
SELECT col_int_nokey FROM ot
|
||||
WHERE col_varchar_nokey IN
|
||||
(SELECT col_varchar_key FROM it1 WHERE col_int_key IS NULL);
|
||||
col_int_nokey
|
||||
1
|
||||
EXPLAIN
|
||||
SELECT col_int_nokey FROM ot
|
||||
WHERE (col_varchar_nokey, 'x') IN
|
||||
(SELECT col_varchar_key, col_varchar_key2 FROM it2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY ot system NULL NULL NULL NULL 1
|
||||
2 DEPENDENT SUBQUERY it2 index_subquery idx_cvk_cvk2_cik,idx_cvk_cik idx_cvk_cvk2_cik 8 func,const 1 Using index; Using where
|
||||
SELECT col_int_nokey FROM ot
|
||||
WHERE (col_varchar_nokey, 'x') IN
|
||||
(SELECT col_varchar_key, col_varchar_key2 FROM it2);
|
||||
col_int_nokey
|
||||
1
|
||||
DROP TABLE ot,it1,it2;
|
||||
End of 5.2 tests
|
||||
#
|
||||
# BUG#779885: Crash in eliminate_item_equal with materialization=on in
|
||||
# maria-5.3
|
||||
#
|
||||
CREATE TABLE t1 ( f1 int );
|
||||
INSERT INTO t1 VALUES (19), (20);
|
||||
@ -5894,32 +6049,6 @@ b c
|
||||
9 NULL
|
||||
SET optimizer_switch=@save_optimizer_switch;
|
||||
drop table t1, t2, t3;
|
||||
End of 5.3 tests
|
||||
#
|
||||
# Bug#12763207 - ASSERT IN SUBSELECT::SINGLE_VALUE_TRANSFORMER
|
||||
#
|
||||
CREATE TABLE t1(a1 int);
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
CREATE TABLE t2(a1 int);
|
||||
INSERT INTO t2 VALUES (3);
|
||||
SELECT @@session.sql_mode INTO @old_sql_mode;
|
||||
SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2 FROM t2);
|
||||
1
|
||||
1
|
||||
1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2.0 FROM t2);
|
||||
1
|
||||
1
|
||||
1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 'a' FROM t2);
|
||||
1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t2);
|
||||
1
|
||||
1
|
||||
1
|
||||
SET SESSION sql_mode=@old_sql_mode;
|
||||
DROP TABLE t1, t2;
|
||||
#
|
||||
# BUG#50257: Missing info in REF column of the EXPLAIN
|
||||
# lines for subselects
|
||||
@ -5942,6 +6071,54 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug#11764086: Null left operand to NOT IN in WHERE clause
|
||||
# behaves differently than real NULL
|
||||
#
|
||||
CREATE TABLE parent (id int);
|
||||
INSERT INTO parent VALUES (1), (2);
|
||||
CREATE TABLE child (parent_id int, other int);
|
||||
INSERT INTO child VALUES (1,NULL);
|
||||
# Offending query (c.parent_id is NULL for null-complemented rows only)
|
||||
SELECT p.id, c.parent_id
|
||||
FROM parent p
|
||||
LEFT JOIN child c
|
||||
ON p.id = c.parent_id
|
||||
WHERE c.parent_id NOT IN (
|
||||
SELECT parent_id
|
||||
FROM child
|
||||
WHERE parent_id = 3
|
||||
);
|
||||
id parent_id
|
||||
1 1
|
||||
2 NULL
|
||||
# Some syntactic variations with IS FALSE and IS NOT TRUE
|
||||
SELECT p.id, c.parent_id
|
||||
FROM parent p
|
||||
LEFT JOIN child c
|
||||
ON p.id = c.parent_id
|
||||
WHERE c.parent_id IN (
|
||||
SELECT parent_id
|
||||
FROM child
|
||||
WHERE parent_id = 3
|
||||
) IS NOT TRUE;
|
||||
id parent_id
|
||||
1 1
|
||||
2 NULL
|
||||
SELECT p.id, c.parent_id
|
||||
FROM parent p
|
||||
LEFT JOIN child c
|
||||
ON p.id = c.parent_id
|
||||
WHERE c.parent_id IN (
|
||||
SELECT parent_id
|
||||
FROM child
|
||||
WHERE parent_id = 3
|
||||
) IS FALSE;
|
||||
id parent_id
|
||||
1 1
|
||||
2 NULL
|
||||
DROP TABLE parent, child;
|
||||
# End of test for bug#11764086.
|
||||
#
|
||||
# Bug 11765699 - 58690: !TABLE || (!TABLE->READ_SET ||
|
||||
# BITMAP_IS_SET(TABLE->READ_SET, FIELD_INDEX
|
||||
#
|
||||
@ -6280,6 +6457,15 @@ SELECT ( SELECT b FROM t2 WHERE b = a OR rand() * 0) FROM t1;
|
||||
1
|
||||
NULL
|
||||
drop table t1,t2,t3;
|
||||
#
|
||||
# LP BUG#905353 Wrong non-empty result with a constant table,
|
||||
# aggregate function in subquery, MyISAM or Aria
|
||||
#
|
||||
CREATE TABLE t1 ( a INT ) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (1);
|
||||
SELECT a FROM t1 WHERE ( SELECT MIN(a) = 100 );
|
||||
a
|
||||
drop table t1;
|
||||
# return optimizer switch changed in the beginning of this test
|
||||
set optimizer_switch=@subselect_tmp;
|
||||
set @optimizer_switch_for_subselect_test=null;
|
||||
|
@ -4626,6 +4626,13 @@ CREATE TABLE t1(a1 int);
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
SELECT @@session.sql_mode INTO @old_sql_mode;
|
||||
SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
|
||||
EXPLAIN EXTENDED
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t1);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
Warnings:
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where <nop>(<in_optimizer>(1,((select max(`test`.`t1`.`a1`) from `test`.`t1`) > 1)))
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t1);
|
||||
1
|
||||
1
|
||||
@ -5328,7 +5335,6 @@ EXPLAIN EXTENDED SELECT DISTINCT 1 FROM t1,
|
||||
WHERE t1.a = d1.a;
|
||||
ERROR 42S22: Unknown column 'd1.a' in 'where clause'
|
||||
DROP TABLE t1;
|
||||
End of 5.1 tests.
|
||||
Set up test tables.
|
||||
CREATE TABLE t1 (
|
||||
t1_id INT UNSIGNED,
|
||||
@ -5853,10 +5859,161 @@ NULL
|
||||
NULL
|
||||
5
|
||||
DROP TABLE t1, t2, t3;
|
||||
#
|
||||
# Bug#12763207 - ASSERT IN SUBSELECT::SINGLE_VALUE_TRANSFORMER
|
||||
#
|
||||
CREATE TABLE t1(a1 int);
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
CREATE TABLE t2(a1 int);
|
||||
INSERT INTO t2 VALUES (3);
|
||||
SELECT @@session.sql_mode INTO @old_sql_mode;
|
||||
SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2 FROM t2);
|
||||
1
|
||||
1
|
||||
1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2.0 FROM t2);
|
||||
1
|
||||
1
|
||||
1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 'a' FROM t2);
|
||||
1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t2);
|
||||
1
|
||||
1
|
||||
1
|
||||
SET SESSION sql_mode=@old_sql_mode;
|
||||
DROP TABLE t1, t2;
|
||||
create table t2(i int);
|
||||
insert into t2 values(0);
|
||||
SELECT @@session.sql_mode INTO @old_sql_mode;
|
||||
SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
|
||||
CREATE VIEW v1 AS
|
||||
SELECT 'f' FROM t2 UNION SELECT 'x' FROM t2
|
||||
;
|
||||
CREATE TABLE t1 (
|
||||
pk int NOT NULL,
|
||||
col_varchar_key varchar(1) DEFAULT NULL,
|
||||
PRIMARY KEY (pk),
|
||||
KEY col_varchar_key (col_varchar_key)
|
||||
);
|
||||
SELECT t1.pk
|
||||
FROM t1
|
||||
WHERE t1.col_varchar_key < ALL ( SELECT * FROM v1 )
|
||||
;
|
||||
pk
|
||||
SET SESSION sql_mode=@old_sql_mode;
|
||||
drop table t2, t1;
|
||||
drop view v1;
|
||||
#
|
||||
# BUG#50257: Missing info in REF column of the EXPLAIN
|
||||
# lines for subselects
|
||||
#
|
||||
CREATE TABLE t1 (a INT, b INT, INDEX (a));
|
||||
INSERT INTO t1 VALUES (3, 10), (2, 20), (7, 10), (5, 20);
|
||||
EXPLAIN SELECT * FROM (SELECT * FROM t1 WHERE a=7) t;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 5 const 1
|
||||
EXPLAIN SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t1 WHERE a=7);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
|
||||
2 SUBQUERY t1 ref a a 5 const 1 Using index
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# BUG#12616253 - WRONG RESULT WITH EXISTS(SUBQUERY) (MISSING ROWS)
|
||||
# (duplicate of LP bug #888456)
|
||||
#
|
||||
CREATE TABLE t1 (f1 varchar(1));
|
||||
INSERT INTO t1 VALUES ('v'),('s');
|
||||
CREATE TABLE t2 (f1_key varchar(1), KEY (f1_key));
|
||||
INSERT INTO t2 VALUES ('j'),('v'),('c'),('m'),('d'),
|
||||
('d'),('y'),('t'),('d'),('s');
|
||||
EXPLAIN
|
||||
SELECT table1.f1, table2.f1_key FROM t1 AS table1, t2 AS table2
|
||||
WHERE EXISTS (SELECT DISTINCT f1_key FROM t2
|
||||
WHERE f1_key != table2.f1_key AND f1_key >= table1.f1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY table1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY table2 index NULL f1_key 4 NULL 10 Using where; Using index; Using join buffer (flat, BNL join)
|
||||
2 DEPENDENT SUBQUERY t2 index f1_key f1_key 4 NULL 10 Using where; Using index
|
||||
SELECT table1.f1, table2.f1_key FROM t1 AS table1, t2 AS table2
|
||||
WHERE EXISTS (SELECT DISTINCT f1_key FROM t2
|
||||
WHERE f1_key != table2.f1_key AND f1_key >= table1.f1);
|
||||
f1 f1_key
|
||||
v j
|
||||
s j
|
||||
v v
|
||||
s v
|
||||
v c
|
||||
s c
|
||||
v m
|
||||
s m
|
||||
v d
|
||||
s d
|
||||
v d
|
||||
s d
|
||||
v y
|
||||
s y
|
||||
v t
|
||||
s t
|
||||
v d
|
||||
s d
|
||||
v s
|
||||
s s
|
||||
DROP TABLE t1,t2;
|
||||
#
|
||||
# LP bug 919427: EXPLAIN for a query over a single-row table
|
||||
# with IN subquery in WHERE condition
|
||||
#
|
||||
CREATE TABLE ot (
|
||||
col_int_nokey int(11),
|
||||
col_varchar_nokey varchar(1)
|
||||
) ;
|
||||
INSERT INTO ot VALUES (1,'x');
|
||||
CREATE TABLE it1(
|
||||
col_int_key int(11),
|
||||
col_varchar_key varchar(1),
|
||||
KEY idx_cvk_cik (col_varchar_key,col_int_key)
|
||||
);
|
||||
INSERT INTO it1 VALUES (NULL,'x'), (NULL,'f');
|
||||
CREATE TABLE it2 (
|
||||
col_int_key int(11),
|
||||
col_varchar_key varchar(1),
|
||||
col_varchar_key2 varchar(1),
|
||||
KEY idx_cvk_cvk2_cik (col_varchar_key, col_varchar_key2, col_int_key),
|
||||
KEY idx_cvk_cik (col_varchar_key, col_int_key)
|
||||
);
|
||||
INSERT INTO it2 VALUES (NULL,'x','x'), (NULL,'f','f');
|
||||
EXPLAIN
|
||||
SELECT col_int_nokey FROM ot
|
||||
WHERE col_varchar_nokey IN
|
||||
(SELECT col_varchar_key FROM it1 WHERE col_int_key IS NULL);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY ot system NULL NULL NULL NULL 1
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 5 func 1
|
||||
2 MATERIALIZED it1 ref idx_cvk_cik idx_cvk_cik 9 const,const 1 Using where; Using index
|
||||
SELECT col_int_nokey FROM ot
|
||||
WHERE col_varchar_nokey IN
|
||||
(SELECT col_varchar_key FROM it1 WHERE col_int_key IS NULL);
|
||||
col_int_nokey
|
||||
1
|
||||
EXPLAIN
|
||||
SELECT col_int_nokey FROM ot
|
||||
WHERE (col_varchar_nokey, 'x') IN
|
||||
(SELECT col_varchar_key, col_varchar_key2 FROM it2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY ot system NULL NULL NULL NULL 1
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 10 func,func 1
|
||||
2 MATERIALIZED it2 ref idx_cvk_cvk2_cik,idx_cvk_cik idx_cvk_cvk2_cik 8 const,const 1 Using where; Using index
|
||||
SELECT col_int_nokey FROM ot
|
||||
WHERE (col_varchar_nokey, 'x') IN
|
||||
(SELECT col_varchar_key, col_varchar_key2 FROM it2);
|
||||
col_int_nokey
|
||||
1
|
||||
DROP TABLE ot,it1,it2;
|
||||
End of 5.2 tests
|
||||
#
|
||||
# BUG#779885: Crash in eliminate_item_equal with materialization=on in
|
||||
# maria-5.3
|
||||
#
|
||||
CREATE TABLE t1 ( f1 int );
|
||||
INSERT INTO t1 VALUES (19), (20);
|
||||
@ -5903,32 +6060,6 @@ b c
|
||||
9 NULL
|
||||
SET optimizer_switch=@save_optimizer_switch;
|
||||
drop table t1, t2, t3;
|
||||
End of 5.3 tests
|
||||
#
|
||||
# Bug#12763207 - ASSERT IN SUBSELECT::SINGLE_VALUE_TRANSFORMER
|
||||
#
|
||||
CREATE TABLE t1(a1 int);
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
CREATE TABLE t2(a1 int);
|
||||
INSERT INTO t2 VALUES (3);
|
||||
SELECT @@session.sql_mode INTO @old_sql_mode;
|
||||
SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2 FROM t2);
|
||||
1
|
||||
1
|
||||
1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2.0 FROM t2);
|
||||
1
|
||||
1
|
||||
1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 'a' FROM t2);
|
||||
1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t2);
|
||||
1
|
||||
1
|
||||
1
|
||||
SET SESSION sql_mode=@old_sql_mode;
|
||||
DROP TABLE t1, t2;
|
||||
#
|
||||
# BUG#50257: Missing info in REF column of the EXPLAIN
|
||||
# lines for subselects
|
||||
@ -5951,6 +6082,54 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug#11764086: Null left operand to NOT IN in WHERE clause
|
||||
# behaves differently than real NULL
|
||||
#
|
||||
CREATE TABLE parent (id int);
|
||||
INSERT INTO parent VALUES (1), (2);
|
||||
CREATE TABLE child (parent_id int, other int);
|
||||
INSERT INTO child VALUES (1,NULL);
|
||||
# Offending query (c.parent_id is NULL for null-complemented rows only)
|
||||
SELECT p.id, c.parent_id
|
||||
FROM parent p
|
||||
LEFT JOIN child c
|
||||
ON p.id = c.parent_id
|
||||
WHERE c.parent_id NOT IN (
|
||||
SELECT parent_id
|
||||
FROM child
|
||||
WHERE parent_id = 3
|
||||
);
|
||||
id parent_id
|
||||
1 1
|
||||
2 NULL
|
||||
# Some syntactic variations with IS FALSE and IS NOT TRUE
|
||||
SELECT p.id, c.parent_id
|
||||
FROM parent p
|
||||
LEFT JOIN child c
|
||||
ON p.id = c.parent_id
|
||||
WHERE c.parent_id IN (
|
||||
SELECT parent_id
|
||||
FROM child
|
||||
WHERE parent_id = 3
|
||||
) IS NOT TRUE;
|
||||
id parent_id
|
||||
1 1
|
||||
2 NULL
|
||||
SELECT p.id, c.parent_id
|
||||
FROM parent p
|
||||
LEFT JOIN child c
|
||||
ON p.id = c.parent_id
|
||||
WHERE c.parent_id IN (
|
||||
SELECT parent_id
|
||||
FROM child
|
||||
WHERE parent_id = 3
|
||||
) IS FALSE;
|
||||
id parent_id
|
||||
1 1
|
||||
2 NULL
|
||||
DROP TABLE parent, child;
|
||||
# End of test for bug#11764086.
|
||||
#
|
||||
# Bug 11765699 - 58690: !TABLE || (!TABLE->READ_SET ||
|
||||
# BITMAP_IS_SET(TABLE->READ_SET, FIELD_INDEX
|
||||
#
|
||||
@ -6289,6 +6468,15 @@ SELECT ( SELECT b FROM t2 WHERE b = a OR rand() * 0) FROM t1;
|
||||
1
|
||||
NULL
|
||||
drop table t1,t2,t3;
|
||||
#
|
||||
# LP BUG#905353 Wrong non-empty result with a constant table,
|
||||
# aggregate function in subquery, MyISAM or Aria
|
||||
#
|
||||
CREATE TABLE t1 ( a INT ) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (1);
|
||||
SELECT a FROM t1 WHERE ( SELECT MIN(a) = 100 );
|
||||
a
|
||||
drop table t1;
|
||||
# return optimizer switch changed in the beginning of this test
|
||||
set optimizer_switch=@subselect_tmp;
|
||||
set optimizer_switch=default;
|
||||
|
@ -4618,6 +4618,13 @@ CREATE TABLE t1(a1 int);
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
SELECT @@session.sql_mode INTO @old_sql_mode;
|
||||
SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
|
||||
EXPLAIN EXTENDED
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t1);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
Warnings:
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where <nop>(<in_optimizer>(1,((select max(`test`.`t1`.`a1`) from `test`.`t1`) > 1)))
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t1);
|
||||
1
|
||||
1
|
||||
@ -5320,7 +5327,6 @@ EXPLAIN EXTENDED SELECT DISTINCT 1 FROM t1,
|
||||
WHERE t1.a = d1.a;
|
||||
ERROR 42S22: Unknown column 'd1.a' in 'where clause'
|
||||
DROP TABLE t1;
|
||||
End of 5.1 tests.
|
||||
Set up test tables.
|
||||
CREATE TABLE t1 (
|
||||
t1_id INT UNSIGNED,
|
||||
@ -5844,10 +5850,159 @@ NULL
|
||||
NULL
|
||||
5
|
||||
DROP TABLE t1, t2, t3;
|
||||
#
|
||||
# Bug#12763207 - ASSERT IN SUBSELECT::SINGLE_VALUE_TRANSFORMER
|
||||
#
|
||||
CREATE TABLE t1(a1 int);
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
CREATE TABLE t2(a1 int);
|
||||
INSERT INTO t2 VALUES (3);
|
||||
SELECT @@session.sql_mode INTO @old_sql_mode;
|
||||
SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2 FROM t2);
|
||||
1
|
||||
1
|
||||
1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2.0 FROM t2);
|
||||
1
|
||||
1
|
||||
1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 'a' FROM t2);
|
||||
1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t2);
|
||||
1
|
||||
1
|
||||
1
|
||||
SET SESSION sql_mode=@old_sql_mode;
|
||||
DROP TABLE t1, t2;
|
||||
create table t2(i int);
|
||||
insert into t2 values(0);
|
||||
SELECT @@session.sql_mode INTO @old_sql_mode;
|
||||
SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
|
||||
CREATE VIEW v1 AS
|
||||
SELECT 'f' FROM t2 UNION SELECT 'x' FROM t2
|
||||
;
|
||||
CREATE TABLE t1 (
|
||||
pk int NOT NULL,
|
||||
col_varchar_key varchar(1) DEFAULT NULL,
|
||||
PRIMARY KEY (pk),
|
||||
KEY col_varchar_key (col_varchar_key)
|
||||
);
|
||||
SELECT t1.pk
|
||||
FROM t1
|
||||
WHERE t1.col_varchar_key < ALL ( SELECT * FROM v1 )
|
||||
;
|
||||
pk
|
||||
SET SESSION sql_mode=@old_sql_mode;
|
||||
drop table t2, t1;
|
||||
drop view v1;
|
||||
#
|
||||
# BUG#50257: Missing info in REF column of the EXPLAIN
|
||||
# lines for subselects
|
||||
#
|
||||
CREATE TABLE t1 (a INT, b INT, INDEX (a));
|
||||
INSERT INTO t1 VALUES (3, 10), (2, 20), (7, 10), (5, 20);
|
||||
EXPLAIN SELECT * FROM (SELECT * FROM t1 WHERE a=7) t;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 5 const 1
|
||||
EXPLAIN SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t1 WHERE a=7);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
|
||||
2 SUBQUERY t1 ref a a 5 const 1 Using index
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# BUG#12616253 - WRONG RESULT WITH EXISTS(SUBQUERY) (MISSING ROWS)
|
||||
# (duplicate of LP bug #888456)
|
||||
#
|
||||
CREATE TABLE t1 (f1 varchar(1));
|
||||
INSERT INTO t1 VALUES ('v'),('s');
|
||||
CREATE TABLE t2 (f1_key varchar(1), KEY (f1_key));
|
||||
INSERT INTO t2 VALUES ('j'),('v'),('c'),('m'),('d'),
|
||||
('d'),('y'),('t'),('d'),('s');
|
||||
EXPLAIN
|
||||
SELECT table1.f1, table2.f1_key FROM t1 AS table1, t2 AS table2
|
||||
WHERE EXISTS (SELECT DISTINCT f1_key FROM t2
|
||||
WHERE f1_key != table2.f1_key AND f1_key >= table1.f1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY table1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY table2 index NULL f1_key 4 NULL 10 Using where; Using index; Using join buffer (flat, BNL join)
|
||||
2 DEPENDENT SUBQUERY t2 index f1_key f1_key 4 NULL 10 Using where; Using index
|
||||
SELECT table1.f1, table2.f1_key FROM t1 AS table1, t2 AS table2
|
||||
WHERE EXISTS (SELECT DISTINCT f1_key FROM t2
|
||||
WHERE f1_key != table2.f1_key AND f1_key >= table1.f1);
|
||||
f1 f1_key
|
||||
v j
|
||||
s j
|
||||
v v
|
||||
s v
|
||||
v c
|
||||
s c
|
||||
v m
|
||||
s m
|
||||
v d
|
||||
s d
|
||||
v d
|
||||
s d
|
||||
v y
|
||||
s y
|
||||
v t
|
||||
s t
|
||||
v d
|
||||
s d
|
||||
v s
|
||||
s s
|
||||
DROP TABLE t1,t2;
|
||||
#
|
||||
# LP bug 919427: EXPLAIN for a query over a single-row table
|
||||
# with IN subquery in WHERE condition
|
||||
#
|
||||
CREATE TABLE ot (
|
||||
col_int_nokey int(11),
|
||||
col_varchar_nokey varchar(1)
|
||||
) ;
|
||||
INSERT INTO ot VALUES (1,'x');
|
||||
CREATE TABLE it1(
|
||||
col_int_key int(11),
|
||||
col_varchar_key varchar(1),
|
||||
KEY idx_cvk_cik (col_varchar_key,col_int_key)
|
||||
);
|
||||
INSERT INTO it1 VALUES (NULL,'x'), (NULL,'f');
|
||||
CREATE TABLE it2 (
|
||||
col_int_key int(11),
|
||||
col_varchar_key varchar(1),
|
||||
col_varchar_key2 varchar(1),
|
||||
KEY idx_cvk_cvk2_cik (col_varchar_key, col_varchar_key2, col_int_key),
|
||||
KEY idx_cvk_cik (col_varchar_key, col_int_key)
|
||||
);
|
||||
INSERT INTO it2 VALUES (NULL,'x','x'), (NULL,'f','f');
|
||||
EXPLAIN
|
||||
SELECT col_int_nokey FROM ot
|
||||
WHERE col_varchar_nokey IN
|
||||
(SELECT col_varchar_key FROM it1 WHERE col_int_key IS NULL);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY ot system NULL NULL NULL NULL 1
|
||||
2 DEPENDENT SUBQUERY it1 index_subquery idx_cvk_cik idx_cvk_cik 9 func,const 2 Using index; Using where
|
||||
SELECT col_int_nokey FROM ot
|
||||
WHERE col_varchar_nokey IN
|
||||
(SELECT col_varchar_key FROM it1 WHERE col_int_key IS NULL);
|
||||
col_int_nokey
|
||||
1
|
||||
EXPLAIN
|
||||
SELECT col_int_nokey FROM ot
|
||||
WHERE (col_varchar_nokey, 'x') IN
|
||||
(SELECT col_varchar_key, col_varchar_key2 FROM it2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY ot system NULL NULL NULL NULL 1
|
||||
2 DEPENDENT SUBQUERY it2 index_subquery idx_cvk_cvk2_cik,idx_cvk_cik idx_cvk_cvk2_cik 8 func,const 1 Using index; Using where
|
||||
SELECT col_int_nokey FROM ot
|
||||
WHERE (col_varchar_nokey, 'x') IN
|
||||
(SELECT col_varchar_key, col_varchar_key2 FROM it2);
|
||||
col_int_nokey
|
||||
1
|
||||
DROP TABLE ot,it1,it2;
|
||||
End of 5.2 tests
|
||||
#
|
||||
# BUG#779885: Crash in eliminate_item_equal with materialization=on in
|
||||
# maria-5.3
|
||||
#
|
||||
CREATE TABLE t1 ( f1 int );
|
||||
INSERT INTO t1 VALUES (19), (20);
|
||||
@ -5894,32 +6049,6 @@ b c
|
||||
9 NULL
|
||||
SET optimizer_switch=@save_optimizer_switch;
|
||||
drop table t1, t2, t3;
|
||||
End of 5.3 tests
|
||||
#
|
||||
# Bug#12763207 - ASSERT IN SUBSELECT::SINGLE_VALUE_TRANSFORMER
|
||||
#
|
||||
CREATE TABLE t1(a1 int);
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
CREATE TABLE t2(a1 int);
|
||||
INSERT INTO t2 VALUES (3);
|
||||
SELECT @@session.sql_mode INTO @old_sql_mode;
|
||||
SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2 FROM t2);
|
||||
1
|
||||
1
|
||||
1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2.0 FROM t2);
|
||||
1
|
||||
1
|
||||
1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 'a' FROM t2);
|
||||
1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t2);
|
||||
1
|
||||
1
|
||||
1
|
||||
SET SESSION sql_mode=@old_sql_mode;
|
||||
DROP TABLE t1, t2;
|
||||
#
|
||||
# BUG#50257: Missing info in REF column of the EXPLAIN
|
||||
# lines for subselects
|
||||
@ -5942,6 +6071,54 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug#11764086: Null left operand to NOT IN in WHERE clause
|
||||
# behaves differently than real NULL
|
||||
#
|
||||
CREATE TABLE parent (id int);
|
||||
INSERT INTO parent VALUES (1), (2);
|
||||
CREATE TABLE child (parent_id int, other int);
|
||||
INSERT INTO child VALUES (1,NULL);
|
||||
# Offending query (c.parent_id is NULL for null-complemented rows only)
|
||||
SELECT p.id, c.parent_id
|
||||
FROM parent p
|
||||
LEFT JOIN child c
|
||||
ON p.id = c.parent_id
|
||||
WHERE c.parent_id NOT IN (
|
||||
SELECT parent_id
|
||||
FROM child
|
||||
WHERE parent_id = 3
|
||||
);
|
||||
id parent_id
|
||||
1 1
|
||||
2 NULL
|
||||
# Some syntactic variations with IS FALSE and IS NOT TRUE
|
||||
SELECT p.id, c.parent_id
|
||||
FROM parent p
|
||||
LEFT JOIN child c
|
||||
ON p.id = c.parent_id
|
||||
WHERE c.parent_id IN (
|
||||
SELECT parent_id
|
||||
FROM child
|
||||
WHERE parent_id = 3
|
||||
) IS NOT TRUE;
|
||||
id parent_id
|
||||
1 1
|
||||
2 NULL
|
||||
SELECT p.id, c.parent_id
|
||||
FROM parent p
|
||||
LEFT JOIN child c
|
||||
ON p.id = c.parent_id
|
||||
WHERE c.parent_id IN (
|
||||
SELECT parent_id
|
||||
FROM child
|
||||
WHERE parent_id = 3
|
||||
) IS FALSE;
|
||||
id parent_id
|
||||
1 1
|
||||
2 NULL
|
||||
DROP TABLE parent, child;
|
||||
# End of test for bug#11764086.
|
||||
#
|
||||
# Bug 11765699 - 58690: !TABLE || (!TABLE->READ_SET ||
|
||||
# BITMAP_IS_SET(TABLE->READ_SET, FIELD_INDEX
|
||||
#
|
||||
@ -6280,6 +6457,15 @@ SELECT ( SELECT b FROM t2 WHERE b = a OR rand() * 0) FROM t1;
|
||||
1
|
||||
NULL
|
||||
drop table t1,t2,t3;
|
||||
#
|
||||
# LP BUG#905353 Wrong non-empty result with a constant table,
|
||||
# aggregate function in subquery, MyISAM or Aria
|
||||
#
|
||||
CREATE TABLE t1 ( a INT ) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (1);
|
||||
SELECT a FROM t1 WHERE ( SELECT MIN(a) = 100 );
|
||||
a
|
||||
drop table t1;
|
||||
# return optimizer switch changed in the beginning of this test
|
||||
set optimizer_switch=@subselect_tmp;
|
||||
set @optimizer_switch_for_subselect_test=null;
|
||||
|
@ -1231,6 +1231,364 @@ IN (SELECT t3.pk, t3.pk FROM t2 LEFT JOIN t3 ON t3.varchar_key)
|
||||
AND pk = 9;
|
||||
datetime_key
|
||||
DROP TABLE t1, t2, t3;
|
||||
#
|
||||
# BUG#53060: LooseScan semijoin strategy does not return all rows
|
||||
#
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
set optimizer_switch='semijoin=on,materialization=off';
|
||||
set optimizer_switch='firstmatch=off,loosescan=on';
|
||||
CREATE TABLE t1 (i INTEGER);
|
||||
INSERT INTO t1 VALUES (1), (2), (3), (4), (5);
|
||||
CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j));
|
||||
INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1);
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 index k k 10 NULL 4 Using where; Using index; LooseScan
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
|
||||
SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0);
|
||||
i
|
||||
1
|
||||
2
|
||||
DROP TABLE t1, t2;
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
#
|
||||
# BUG#49453: re-execution of prepared statement with view
|
||||
# and semijoin crashes
|
||||
#
|
||||
CREATE TABLE t1 (city VARCHAR(50), country_id INT);
|
||||
CREATE TABLE t2 (country_id INT, country VARCHAR(50));
|
||||
INSERT INTO t1 VALUES
|
||||
('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ;
|
||||
INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa');
|
||||
CREATE VIEW v1 AS
|
||||
SELECT country_id as vf_country_id
|
||||
FROM t2
|
||||
WHERE LEFT(country,1) = "A";
|
||||
PREPARE stmt FROM "
|
||||
SELECT city, country_id
|
||||
FROM t1
|
||||
WHERE country_id IN (SELECT vf_country_id FROM v1);
|
||||
";
|
||||
|
||||
EXECUTE stmt;
|
||||
city country_id
|
||||
Batna 2
|
||||
Bchar 2
|
||||
Skikda 2
|
||||
Algeria 2
|
||||
EXECUTE stmt;
|
||||
city country_id
|
||||
Batna 2
|
||||
Bchar 2
|
||||
Skikda 2
|
||||
Algeria 2
|
||||
DROP TABLE t1,t2;
|
||||
DROP VIEW v1;
|
||||
#
|
||||
# Bug#54437 Extra rows with LEFT JOIN + semijoin
|
||||
#
|
||||
create table t1 (a int);
|
||||
create table t2 (a int);
|
||||
create table t3 (a int);
|
||||
insert into t1 values(1),(1);
|
||||
insert into t2 values(1),(1),(1),(1);
|
||||
insert into t3 values(2),(2);
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
set optimizer_switch='materialization=off';
|
||||
set optimizer_switch='semijoin=off';
|
||||
explain
|
||||
select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 4 Using where
|
||||
2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where
|
||||
select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a);
|
||||
a
|
||||
1
|
||||
1
|
||||
set optimizer_switch='semijoin=on';
|
||||
explain
|
||||
select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 4 Using where; Start temporary
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where; End temporary
|
||||
select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a);
|
||||
a
|
||||
1
|
||||
1
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
drop table t1,t2,t3;
|
||||
#
|
||||
# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN))
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
CREATE TABLE t2 (a INT);
|
||||
CREATE TABLE t3 (a INT);
|
||||
INSERT INTO t1 VALUES(1),(1);
|
||||
INSERT INTO t2 VALUES(1),(1);
|
||||
INSERT INTO t3 VALUES(2),(2);
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
set optimizer_switch='semijoin=off,materialization=off';
|
||||
EXPLAIN
|
||||
SELECT * FROM t1
|
||||
WHERE t1.a IN (SELECT t2.a
|
||||
FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY t2inner ALL NULL NULL NULL NULL 2
|
||||
2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where
|
||||
SELECT * FROM t1
|
||||
WHERE t1.a IN (SELECT t2.a
|
||||
FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a);
|
||||
a
|
||||
1
|
||||
1
|
||||
set optimizer_switch='semijoin=off,materialization=on';
|
||||
EXPLAIN
|
||||
SELECT * FROM t1
|
||||
WHERE t1.a IN (SELECT t2.a
|
||||
FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2
|
||||
2 MATERIALIZED t2inner ALL NULL NULL NULL NULL 2
|
||||
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 Using where
|
||||
SELECT * FROM t1
|
||||
WHERE t1.a IN (SELECT t2.a
|
||||
FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a);
|
||||
a
|
||||
1
|
||||
1
|
||||
set optimizer_switch='semijoin=on,materialization=off';
|
||||
EXPLAIN
|
||||
SELECT * FROM t1
|
||||
WHERE t1.a IN (SELECT t2.a
|
||||
FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Start temporary
|
||||
1 PRIMARY t2inner ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where; End temporary
|
||||
SELECT * FROM t1
|
||||
WHERE t1.a IN (SELECT t2.a
|
||||
FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a);
|
||||
a
|
||||
1
|
||||
1
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
DROP TABLE t1,t2,t3;
|
||||
#
|
||||
# BUG#52329 - Wrong result: subquery materialization, IN,
|
||||
# non-null field followed by nullable
|
||||
#
|
||||
CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL);
|
||||
CREATE TABLE t2a (b1 char(8), b2 char(8));
|
||||
CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL);
|
||||
CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8));
|
||||
INSERT INTO t1 VALUES ('1 - 12', '2 - 22');
|
||||
INSERT INTO t2a VALUES ('1 - 11', '2 - 21'),
|
||||
('1 - 11', '2 - 21'),
|
||||
('1 - 12', '2 - 22'),
|
||||
('1 - 12', '2 - 22'),
|
||||
('1 - 13', '2 - 23');
|
||||
INSERT INTO t2b SELECT * FROM t2a;
|
||||
INSERT INTO t2c SELECT * FROM t2a;
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
set optimizer_switch='semijoin=off,materialization=on';
|
||||
SELECT * FROM t1
|
||||
WHERE (a1, a2) IN (
|
||||
SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2);
|
||||
a1 a2
|
||||
1 - 12 2 - 22
|
||||
SELECT * FROM t1
|
||||
WHERE (a1, a2) IN (
|
||||
SELECT b1, b2 FROM t2a WHERE b1 > '0');
|
||||
a1 a2
|
||||
1 - 12 2 - 22
|
||||
SELECT * FROM t1
|
||||
WHERE (a1, a2) IN (
|
||||
SELECT b1, b2 FROM t2b WHERE b1 > '0');
|
||||
a1 a2
|
||||
1 - 12 2 - 22
|
||||
SELECT * FROM t1
|
||||
WHERE (a1, a2) IN (
|
||||
SELECT b1, b2 FROM t2c WHERE b1 > '0');
|
||||
a1 a2
|
||||
1 - 12 2 - 22
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
DROP TABLE t1,t2a,t2b,t2c;
|
||||
#
|
||||
# Bug#57623: subquery within before insert trigger causes crash (sj=on)
|
||||
#
|
||||
CREATE TABLE ot1(a INT);
|
||||
CREATE TABLE ot2(a INT);
|
||||
CREATE TABLE ot3(a INT);
|
||||
CREATE TABLE it1(a INT);
|
||||
INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7);
|
||||
INSERT INTO ot2 VALUES(0),(2),(4),(6);
|
||||
INSERT INTO ot3 VALUES(0),(3),(6);
|
||||
INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7);
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
set optimizer_switch='semijoin=on';
|
||||
set optimizer_switch='materialization=off';
|
||||
explain SELECT *
|
||||
FROM ot1
|
||||
LEFT JOIN
|
||||
(ot2 JOIN ot3 on ot2.a=ot3.a)
|
||||
ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY ot1 ALL NULL NULL NULL NULL 8
|
||||
1 PRIMARY ot3 ALL NULL NULL NULL NULL 3 Using where
|
||||
1 PRIMARY ot2 ALL NULL NULL NULL NULL 4 Using where
|
||||
2 DEPENDENT SUBQUERY it1 ALL NULL NULL NULL NULL 8 Using where
|
||||
SELECT *
|
||||
FROM ot1
|
||||
LEFT JOIN
|
||||
(ot2 JOIN ot3 on ot2.a=ot3.a)
|
||||
ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1);
|
||||
a a a
|
||||
0 0 0
|
||||
1 NULL NULL
|
||||
2 NULL NULL
|
||||
3 NULL NULL
|
||||
4 NULL NULL
|
||||
5 NULL NULL
|
||||
6 6 6
|
||||
7 NULL NULL
|
||||
prepare s from 'SELECT *
|
||||
FROM ot1
|
||||
LEFT JOIN
|
||||
(ot2 JOIN ot3 on ot2.a=ot3.a)
|
||||
ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)';
|
||||
execute s;
|
||||
a a a
|
||||
0 0 0
|
||||
1 NULL NULL
|
||||
2 NULL NULL
|
||||
3 NULL NULL
|
||||
4 NULL NULL
|
||||
5 NULL NULL
|
||||
6 6 6
|
||||
7 NULL NULL
|
||||
execute s;
|
||||
a a a
|
||||
0 0 0
|
||||
1 NULL NULL
|
||||
2 NULL NULL
|
||||
3 NULL NULL
|
||||
4 NULL NULL
|
||||
5 NULL NULL
|
||||
6 6 6
|
||||
7 NULL NULL
|
||||
deallocate prepare s;
|
||||
set optimizer_switch='materialization=on';
|
||||
explain SELECT *
|
||||
FROM ot1
|
||||
LEFT JOIN
|
||||
(ot2 JOIN ot3 on ot2.a=ot3.a)
|
||||
ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY ot1 ALL NULL NULL NULL NULL 8
|
||||
1 PRIMARY ot3 ALL NULL NULL NULL NULL 3 Using where
|
||||
1 PRIMARY ot2 ALL NULL NULL NULL NULL 4 Using where
|
||||
2 MATERIALIZED it1 ALL NULL NULL NULL NULL 8
|
||||
SELECT *
|
||||
FROM ot1
|
||||
LEFT JOIN
|
||||
(ot2 JOIN ot3 on ot2.a=ot3.a)
|
||||
ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1);
|
||||
a a a
|
||||
0 0 0
|
||||
1 NULL NULL
|
||||
2 NULL NULL
|
||||
3 NULL NULL
|
||||
4 NULL NULL
|
||||
5 NULL NULL
|
||||
6 6 6
|
||||
7 NULL NULL
|
||||
prepare s from 'SELECT *
|
||||
FROM ot1
|
||||
LEFT JOIN
|
||||
(ot2 JOIN ot3 on ot2.a=ot3.a)
|
||||
ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)';
|
||||
execute s;
|
||||
a a a
|
||||
0 0 0
|
||||
1 NULL NULL
|
||||
2 NULL NULL
|
||||
3 NULL NULL
|
||||
4 NULL NULL
|
||||
5 NULL NULL
|
||||
6 6 6
|
||||
7 NULL NULL
|
||||
execute s;
|
||||
a a a
|
||||
0 0 0
|
||||
1 NULL NULL
|
||||
2 NULL NULL
|
||||
3 NULL NULL
|
||||
4 NULL NULL
|
||||
5 NULL NULL
|
||||
6 6 6
|
||||
7 NULL NULL
|
||||
deallocate prepare s;
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
DROP TABLE ot1, ot2, ot3, it1;
|
||||
#
|
||||
# Bug#59919/11766739: Crash in tmp_table_param::init() with semijoin=on
|
||||
#
|
||||
CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM;
|
||||
CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM;
|
||||
CREATE TABLE t3 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (1);
|
||||
INSERT INTO t2 VALUES (1,1), (2,1);
|
||||
INSERT INTO t3 VALUES
|
||||
(1,1), (2,1), (5,4), (7,3), (8,2), (8,1), (7,3),
|
||||
(9,5), (4,3), (7,2), (7,7), (3,1), (5,8), (9,7);
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
set optimizer_switch='semijoin=off,materialization=on';
|
||||
EXPLAIN
|
||||
SELECT * FROM t3
|
||||
WHERE f2 IN (SELECT t1.f1
|
||||
FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 14 Using where
|
||||
2 MATERIALIZED t1 system NULL NULL NULL NULL 1
|
||||
2 MATERIALIZED b1 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 MATERIALIZED b2 ALL NULL NULL NULL NULL 2
|
||||
SELECT * FROM t3
|
||||
WHERE f2 IN (SELECT t1.f1
|
||||
FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE);
|
||||
f1 f2
|
||||
1 1
|
||||
2 1
|
||||
8 1
|
||||
3 1
|
||||
set optimizer_switch='semijoin=on,materialization=on';
|
||||
EXPLAIN
|
||||
SELECT * FROM t3
|
||||
WHERE f2 IN (SELECT t1.f1
|
||||
FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 1
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 1
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 14 Using where; Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED b1 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 MATERIALIZED b2 ALL NULL NULL NULL NULL 2
|
||||
SELECT * FROM t3
|
||||
WHERE f2 IN (SELECT t1.f1
|
||||
FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE);
|
||||
f1 f2
|
||||
1 1
|
||||
2 1
|
||||
8 1
|
||||
3 1
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
DROP TABLE t1, t2, t3 ;
|
||||
#
|
||||
#
|
||||
# BUG#784723: Wrong result with semijoin + nested subqueries in maria-5.3
|
||||
#
|
||||
@ -2179,4 +2537,105 @@ WHERE c = b AND b = a
|
||||
a COUNT(*)
|
||||
NULL 0
|
||||
DROP TABLE t1, t2, t3;
|
||||
#
|
||||
# BUG#920255: Wrong result (extra rows) with loosescan and IN subquery
|
||||
#
|
||||
CREATE TABLE t1 ( a INT PRIMARY KEY, b INT, KEY(b) );
|
||||
INSERT INTO t1 VALUES
|
||||
(1,2),(2,1),(3,3),(4,2),(5,5),
|
||||
(6,3),(7,1),(8,4),(9,3),(10,2);
|
||||
CREATE TABLE t2 ( c INT, d INT, UNIQUE KEY(c) );
|
||||
INSERT INTO t2 VALUES
|
||||
(1,2),(2,1),(3,3),(4,2),(5,5),(6,3),(7,1);
|
||||
SELECT a, b, d FROM t1, t2
|
||||
WHERE ( b, d ) IN
|
||||
( SELECT b, d FROM t1, t2 WHERE b = c );
|
||||
a b d
|
||||
2 1 2
|
||||
7 1 2
|
||||
2 1 2
|
||||
7 1 2
|
||||
1 2 1
|
||||
4 2 1
|
||||
10 2 1
|
||||
1 2 1
|
||||
4 2 1
|
||||
10 2 1
|
||||
3 3 3
|
||||
6 3 3
|
||||
9 3 3
|
||||
3 3 3
|
||||
6 3 3
|
||||
9 3 3
|
||||
8 4 2
|
||||
8 4 2
|
||||
5 5 5
|
||||
DROP TABLE t1, t2;
|
||||
#
|
||||
# BUG#920713: Wrong result (missing rows) with firstmatch+BNL, IN subquery, ...
|
||||
#
|
||||
CREATE TABLE t1 ( a VARCHAR(1) ) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES ('e'),('w'),('a'),('h'),('x'),('k'),('g');
|
||||
CREATE TABLE t2 ( b INT, c VARCHAR(1) );
|
||||
INSERT INTO t2 VALUES (0,'j'),(8,'v');
|
||||
SELECT * FROM t1 alias1, t2 alias2
|
||||
WHERE alias2.c IN (
|
||||
SELECT alias4.c FROM t1 alias3, t2 alias4
|
||||
);
|
||||
a b c
|
||||
e 0 j
|
||||
e 8 v
|
||||
w 0 j
|
||||
w 8 v
|
||||
a 0 j
|
||||
a 8 v
|
||||
h 0 j
|
||||
h 8 v
|
||||
x 0 j
|
||||
x 8 v
|
||||
k 0 j
|
||||
k 8 v
|
||||
g 0 j
|
||||
g 8 v
|
||||
DROP TABLE t1, t2;
|
||||
#
|
||||
# BUG#923246: Loosescan reports different result than other semijoin methods
|
||||
#
|
||||
set @tmp_923246= @@optimizer_switch;
|
||||
set optimizer_switch='mrr=on,materialization=off';
|
||||
create table t0 (a int);
|
||||
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2));
|
||||
insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C;
|
||||
insert into t1 select * from t1 where kp1 < 20;
|
||||
create table t3 (a int);
|
||||
insert into t3 select A.a + 10*B.a from t0 A, t0 B;
|
||||
select * from t3 where a in (select kp1 from t1 where kp1<20);
|
||||
a
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10
|
||||
11
|
||||
12
|
||||
13
|
||||
14
|
||||
15
|
||||
16
|
||||
17
|
||||
18
|
||||
19
|
||||
explain select * from t3 where a in (select kp1 from t1 where kp1<20);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 range kp1 kp1 5 NULL 48 Using where; Using index; LooseScan
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 100 Using where; Using join buffer (flat, BNL join)
|
||||
drop table t0,t1,t3;
|
||||
set optimizer_switch= @tmp_923246;
|
||||
set optimizer_switch=@subselect_sj_tmp;
|
||||
|
@ -886,5 +886,19 @@ a b b a
|
||||
c c NULL NULL
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1,t2,t3,t4;
|
||||
#
|
||||
# BUG#912538: Wrong result (missing rows) with semijoin=on, firstmatch=on, ...
|
||||
#
|
||||
CREATE TABLE t1 ( a INT NOT NULL, UNIQUE KEY(a) );
|
||||
INSERT INTO t1 VALUES (1),(2),(3),(4);
|
||||
CREATE TABLE t2 ( b INT, c INT ) ENGINE=InnoDB;
|
||||
INSERT INTO t2 VALUES (1,1);
|
||||
SELECT * FROM t1, t2 WHERE c IN (SELECT c FROM t1, t2 WHERE a = b);
|
||||
a b c
|
||||
1 1 1
|
||||
2 1 1
|
||||
3 1 1
|
||||
4 1 1
|
||||
DROP TABLE t1,t2;
|
||||
# This must be the last in the file:
|
||||
set optimizer_switch=@subselect_sj2_tmp;
|
||||
|
@ -900,6 +900,20 @@ a b b a
|
||||
c c NULL NULL
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1,t2,t3,t4;
|
||||
#
|
||||
# BUG#912538: Wrong result (missing rows) with semijoin=on, firstmatch=on, ...
|
||||
#
|
||||
CREATE TABLE t1 ( a INT NOT NULL, UNIQUE KEY(a) );
|
||||
INSERT INTO t1 VALUES (1),(2),(3),(4);
|
||||
CREATE TABLE t2 ( b INT, c INT ) ENGINE=InnoDB;
|
||||
INSERT INTO t2 VALUES (1,1);
|
||||
SELECT * FROM t1, t2 WHERE c IN (SELECT c FROM t1, t2 WHERE a = b);
|
||||
a b c
|
||||
1 1 1
|
||||
2 1 1
|
||||
3 1 1
|
||||
4 1 1
|
||||
DROP TABLE t1,t2;
|
||||
# This must be the last in the file:
|
||||
set optimizer_switch=@subselect_sj2_tmp;
|
||||
#
|
||||
@ -921,9 +935,9 @@ SELECT t3.* FROM t1 JOIN t3 ON t3.b = t1.b
|
||||
WHERE c IN (SELECT t4.b FROM t4 JOIN t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 1 Using where
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 1
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 1 FirstMatch(t3)
|
||||
1 PRIMARY t1 ref b b 4 test.t3.b 1 Using index
|
||||
1 PRIMARY t4 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t2)
|
||||
1 PRIMARY t4 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
|
||||
SELECT t3.* FROM t1 JOIN t3 ON t3.b = t1.b
|
||||
WHERE c IN (SELECT t4.b FROM t4 JOIN t2);
|
||||
b c
|
||||
@ -949,12 +963,13 @@ EXPLAIN
|
||||
SELECT * FROM t1, t2 WHERE b IN (SELECT a FROM t3, t4 WHERE b = pk);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 1
|
||||
1 PRIMARY t4 ALL NULL NULL NULL NULL 1 Using where
|
||||
1 PRIMARY t4 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t2)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t4.b 1 Using where; FirstMatch(t4)
|
||||
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t4.b 1 Using where; FirstMatch(t1)
|
||||
SELECT * FROM t1, t2 WHERE b IN (SELECT a FROM t3, t4 WHERE b = pk);
|
||||
pk a b
|
||||
1 6 8
|
||||
2 8 8
|
||||
set optimizer_switch=@tmp_optimizer_switch;
|
||||
set join_cache_level=default;
|
||||
DROP TABLE t1,t2,t3,t4;
|
||||
|
@ -888,6 +888,20 @@ a b b a
|
||||
c c NULL NULL
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1,t2,t3,t4;
|
||||
#
|
||||
# BUG#912538: Wrong result (missing rows) with semijoin=on, firstmatch=on, ...
|
||||
#
|
||||
CREATE TABLE t1 ( a INT NOT NULL, UNIQUE KEY(a) );
|
||||
INSERT INTO t1 VALUES (1),(2),(3),(4);
|
||||
CREATE TABLE t2 ( b INT, c INT ) ENGINE=InnoDB;
|
||||
INSERT INTO t2 VALUES (1,1);
|
||||
SELECT * FROM t1, t2 WHERE c IN (SELECT c FROM t1, t2 WHERE a = b);
|
||||
a b c
|
||||
1 1 1
|
||||
2 1 1
|
||||
3 1 1
|
||||
4 1 1
|
||||
DROP TABLE t1,t2;
|
||||
# This must be the last in the file:
|
||||
set optimizer_switch=@subselect_sj2_tmp;
|
||||
set optimizer_switch=default;
|
||||
|
@ -1244,6 +1244,364 @@ IN (SELECT t3.pk, t3.pk FROM t2 LEFT JOIN t3 ON t3.varchar_key)
|
||||
AND pk = 9;
|
||||
datetime_key
|
||||
DROP TABLE t1, t2, t3;
|
||||
#
|
||||
# BUG#53060: LooseScan semijoin strategy does not return all rows
|
||||
#
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
set optimizer_switch='semijoin=on,materialization=off';
|
||||
set optimizer_switch='firstmatch=off,loosescan=on';
|
||||
CREATE TABLE t1 (i INTEGER);
|
||||
INSERT INTO t1 VALUES (1), (2), (3), (4), (5);
|
||||
CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j));
|
||||
INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1);
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 index k k 10 NULL 4 Using where; Using index; LooseScan
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
|
||||
SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0);
|
||||
i
|
||||
1
|
||||
2
|
||||
DROP TABLE t1, t2;
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
#
|
||||
# BUG#49453: re-execution of prepared statement with view
|
||||
# and semijoin crashes
|
||||
#
|
||||
CREATE TABLE t1 (city VARCHAR(50), country_id INT);
|
||||
CREATE TABLE t2 (country_id INT, country VARCHAR(50));
|
||||
INSERT INTO t1 VALUES
|
||||
('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ;
|
||||
INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa');
|
||||
CREATE VIEW v1 AS
|
||||
SELECT country_id as vf_country_id
|
||||
FROM t2
|
||||
WHERE LEFT(country,1) = "A";
|
||||
PREPARE stmt FROM "
|
||||
SELECT city, country_id
|
||||
FROM t1
|
||||
WHERE country_id IN (SELECT vf_country_id FROM v1);
|
||||
";
|
||||
|
||||
EXECUTE stmt;
|
||||
city country_id
|
||||
Batna 2
|
||||
Bchar 2
|
||||
Skikda 2
|
||||
Algeria 2
|
||||
EXECUTE stmt;
|
||||
city country_id
|
||||
Batna 2
|
||||
Bchar 2
|
||||
Skikda 2
|
||||
Algeria 2
|
||||
DROP TABLE t1,t2;
|
||||
DROP VIEW v1;
|
||||
#
|
||||
# Bug#54437 Extra rows with LEFT JOIN + semijoin
|
||||
#
|
||||
create table t1 (a int);
|
||||
create table t2 (a int);
|
||||
create table t3 (a int);
|
||||
insert into t1 values(1),(1);
|
||||
insert into t2 values(1),(1),(1),(1);
|
||||
insert into t3 values(2),(2);
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
set optimizer_switch='materialization=off';
|
||||
set optimizer_switch='semijoin=off';
|
||||
explain
|
||||
select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 4 Using where
|
||||
2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
|
||||
select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a);
|
||||
a
|
||||
1
|
||||
1
|
||||
set optimizer_switch='semijoin=on';
|
||||
explain
|
||||
select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 4 Using where; Start temporary; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (incremental, BNL join)
|
||||
select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a);
|
||||
a
|
||||
1
|
||||
1
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
drop table t1,t2,t3;
|
||||
#
|
||||
# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN))
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
CREATE TABLE t2 (a INT);
|
||||
CREATE TABLE t3 (a INT);
|
||||
INSERT INTO t1 VALUES(1),(1);
|
||||
INSERT INTO t2 VALUES(1),(1);
|
||||
INSERT INTO t3 VALUES(2),(2);
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
set optimizer_switch='semijoin=off,materialization=off';
|
||||
EXPLAIN
|
||||
SELECT * FROM t1
|
||||
WHERE t1.a IN (SELECT t2.a
|
||||
FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY t2inner ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
|
||||
2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
|
||||
SELECT * FROM t1
|
||||
WHERE t1.a IN (SELECT t2.a
|
||||
FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a);
|
||||
a
|
||||
1
|
||||
1
|
||||
set optimizer_switch='semijoin=off,materialization=on';
|
||||
EXPLAIN
|
||||
SELECT * FROM t1
|
||||
WHERE t1.a IN (SELECT t2.a
|
||||
FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2
|
||||
2 MATERIALIZED t2inner ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
|
||||
SELECT * FROM t1
|
||||
WHERE t1.a IN (SELECT t2.a
|
||||
FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a);
|
||||
a
|
||||
1
|
||||
1
|
||||
set optimizer_switch='semijoin=on,materialization=off';
|
||||
EXPLAIN
|
||||
SELECT * FROM t1
|
||||
WHERE t1.a IN (SELECT t2.a
|
||||
FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Start temporary; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t2inner ALL NULL NULL NULL NULL 2 Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (incremental, BNL join)
|
||||
SELECT * FROM t1
|
||||
WHERE t1.a IN (SELECT t2.a
|
||||
FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a);
|
||||
a
|
||||
1
|
||||
1
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
DROP TABLE t1,t2,t3;
|
||||
#
|
||||
# BUG#52329 - Wrong result: subquery materialization, IN,
|
||||
# non-null field followed by nullable
|
||||
#
|
||||
CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL);
|
||||
CREATE TABLE t2a (b1 char(8), b2 char(8));
|
||||
CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL);
|
||||
CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8));
|
||||
INSERT INTO t1 VALUES ('1 - 12', '2 - 22');
|
||||
INSERT INTO t2a VALUES ('1 - 11', '2 - 21'),
|
||||
('1 - 11', '2 - 21'),
|
||||
('1 - 12', '2 - 22'),
|
||||
('1 - 12', '2 - 22'),
|
||||
('1 - 13', '2 - 23');
|
||||
INSERT INTO t2b SELECT * FROM t2a;
|
||||
INSERT INTO t2c SELECT * FROM t2a;
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
set optimizer_switch='semijoin=off,materialization=on';
|
||||
SELECT * FROM t1
|
||||
WHERE (a1, a2) IN (
|
||||
SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2);
|
||||
a1 a2
|
||||
1 - 12 2 - 22
|
||||
SELECT * FROM t1
|
||||
WHERE (a1, a2) IN (
|
||||
SELECT b1, b2 FROM t2a WHERE b1 > '0');
|
||||
a1 a2
|
||||
1 - 12 2 - 22
|
||||
SELECT * FROM t1
|
||||
WHERE (a1, a2) IN (
|
||||
SELECT b1, b2 FROM t2b WHERE b1 > '0');
|
||||
a1 a2
|
||||
1 - 12 2 - 22
|
||||
SELECT * FROM t1
|
||||
WHERE (a1, a2) IN (
|
||||
SELECT b1, b2 FROM t2c WHERE b1 > '0');
|
||||
a1 a2
|
||||
1 - 12 2 - 22
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
DROP TABLE t1,t2a,t2b,t2c;
|
||||
#
|
||||
# Bug#57623: subquery within before insert trigger causes crash (sj=on)
|
||||
#
|
||||
CREATE TABLE ot1(a INT);
|
||||
CREATE TABLE ot2(a INT);
|
||||
CREATE TABLE ot3(a INT);
|
||||
CREATE TABLE it1(a INT);
|
||||
INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7);
|
||||
INSERT INTO ot2 VALUES(0),(2),(4),(6);
|
||||
INSERT INTO ot3 VALUES(0),(3),(6);
|
||||
INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7);
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
set optimizer_switch='semijoin=on';
|
||||
set optimizer_switch='materialization=off';
|
||||
explain SELECT *
|
||||
FROM ot1
|
||||
LEFT JOIN
|
||||
(ot2 JOIN ot3 on ot2.a=ot3.a)
|
||||
ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY ot1 ALL NULL NULL NULL NULL 8
|
||||
1 PRIMARY ot3 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY ot2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (incremental, BNL join)
|
||||
2 DEPENDENT SUBQUERY it1 ALL NULL NULL NULL NULL 8 Using where
|
||||
SELECT *
|
||||
FROM ot1
|
||||
LEFT JOIN
|
||||
(ot2 JOIN ot3 on ot2.a=ot3.a)
|
||||
ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1);
|
||||
a a a
|
||||
0 0 0
|
||||
6 6 6
|
||||
1 NULL NULL
|
||||
2 NULL NULL
|
||||
3 NULL NULL
|
||||
4 NULL NULL
|
||||
5 NULL NULL
|
||||
7 NULL NULL
|
||||
prepare s from 'SELECT *
|
||||
FROM ot1
|
||||
LEFT JOIN
|
||||
(ot2 JOIN ot3 on ot2.a=ot3.a)
|
||||
ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)';
|
||||
execute s;
|
||||
a a a
|
||||
0 0 0
|
||||
6 6 6
|
||||
1 NULL NULL
|
||||
2 NULL NULL
|
||||
3 NULL NULL
|
||||
4 NULL NULL
|
||||
5 NULL NULL
|
||||
7 NULL NULL
|
||||
execute s;
|
||||
a a a
|
||||
0 0 0
|
||||
6 6 6
|
||||
1 NULL NULL
|
||||
2 NULL NULL
|
||||
3 NULL NULL
|
||||
4 NULL NULL
|
||||
5 NULL NULL
|
||||
7 NULL NULL
|
||||
deallocate prepare s;
|
||||
set optimizer_switch='materialization=on';
|
||||
explain SELECT *
|
||||
FROM ot1
|
||||
LEFT JOIN
|
||||
(ot2 JOIN ot3 on ot2.a=ot3.a)
|
||||
ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY ot1 ALL NULL NULL NULL NULL 8
|
||||
1 PRIMARY ot3 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY ot2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (incremental, BNL join)
|
||||
2 MATERIALIZED it1 ALL NULL NULL NULL NULL 8
|
||||
SELECT *
|
||||
FROM ot1
|
||||
LEFT JOIN
|
||||
(ot2 JOIN ot3 on ot2.a=ot3.a)
|
||||
ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1);
|
||||
a a a
|
||||
0 0 0
|
||||
6 6 6
|
||||
1 NULL NULL
|
||||
2 NULL NULL
|
||||
3 NULL NULL
|
||||
4 NULL NULL
|
||||
5 NULL NULL
|
||||
7 NULL NULL
|
||||
prepare s from 'SELECT *
|
||||
FROM ot1
|
||||
LEFT JOIN
|
||||
(ot2 JOIN ot3 on ot2.a=ot3.a)
|
||||
ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)';
|
||||
execute s;
|
||||
a a a
|
||||
0 0 0
|
||||
6 6 6
|
||||
1 NULL NULL
|
||||
2 NULL NULL
|
||||
3 NULL NULL
|
||||
4 NULL NULL
|
||||
5 NULL NULL
|
||||
7 NULL NULL
|
||||
execute s;
|
||||
a a a
|
||||
0 0 0
|
||||
6 6 6
|
||||
1 NULL NULL
|
||||
2 NULL NULL
|
||||
3 NULL NULL
|
||||
4 NULL NULL
|
||||
5 NULL NULL
|
||||
7 NULL NULL
|
||||
deallocate prepare s;
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
DROP TABLE ot1, ot2, ot3, it1;
|
||||
#
|
||||
# Bug#59919/11766739: Crash in tmp_table_param::init() with semijoin=on
|
||||
#
|
||||
CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM;
|
||||
CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM;
|
||||
CREATE TABLE t3 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (1);
|
||||
INSERT INTO t2 VALUES (1,1), (2,1);
|
||||
INSERT INTO t3 VALUES
|
||||
(1,1), (2,1), (5,4), (7,3), (8,2), (8,1), (7,3),
|
||||
(9,5), (4,3), (7,2), (7,7), (3,1), (5,8), (9,7);
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
set optimizer_switch='semijoin=off,materialization=on';
|
||||
EXPLAIN
|
||||
SELECT * FROM t3
|
||||
WHERE f2 IN (SELECT t1.f1
|
||||
FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 14 Using where
|
||||
2 MATERIALIZED t1 system NULL NULL NULL NULL 1
|
||||
2 MATERIALIZED b1 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 MATERIALIZED b2 ALL NULL NULL NULL NULL 2
|
||||
SELECT * FROM t3
|
||||
WHERE f2 IN (SELECT t1.f1
|
||||
FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE);
|
||||
f1 f2
|
||||
1 1
|
||||
2 1
|
||||
8 1
|
||||
3 1
|
||||
set optimizer_switch='semijoin=on,materialization=on';
|
||||
EXPLAIN
|
||||
SELECT * FROM t3
|
||||
WHERE f2 IN (SELECT t1.f1
|
||||
FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 1
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 1
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 14 Using where; Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED b1 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 MATERIALIZED b2 ALL NULL NULL NULL NULL 2
|
||||
SELECT * FROM t3
|
||||
WHERE f2 IN (SELECT t1.f1
|
||||
FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE);
|
||||
f1 f2
|
||||
1 1
|
||||
2 1
|
||||
8 1
|
||||
3 1
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
DROP TABLE t1, t2, t3 ;
|
||||
#
|
||||
#
|
||||
# BUG#784723: Wrong result with semijoin + nested subqueries in maria-5.3
|
||||
#
|
||||
@ -2193,6 +2551,107 @@ WHERE c = b AND b = a
|
||||
a COUNT(*)
|
||||
NULL 0
|
||||
DROP TABLE t1, t2, t3;
|
||||
#
|
||||
# BUG#920255: Wrong result (extra rows) with loosescan and IN subquery
|
||||
#
|
||||
CREATE TABLE t1 ( a INT PRIMARY KEY, b INT, KEY(b) );
|
||||
INSERT INTO t1 VALUES
|
||||
(1,2),(2,1),(3,3),(4,2),(5,5),
|
||||
(6,3),(7,1),(8,4),(9,3),(10,2);
|
||||
CREATE TABLE t2 ( c INT, d INT, UNIQUE KEY(c) );
|
||||
INSERT INTO t2 VALUES
|
||||
(1,2),(2,1),(3,3),(4,2),(5,5),(6,3),(7,1);
|
||||
SELECT a, b, d FROM t1, t2
|
||||
WHERE ( b, d ) IN
|
||||
( SELECT b, d FROM t1, t2 WHERE b = c );
|
||||
a b d
|
||||
1 2 1
|
||||
1 2 1
|
||||
2 1 2
|
||||
2 1 2
|
||||
3 3 3
|
||||
3 3 3
|
||||
4 2 1
|
||||
4 2 1
|
||||
5 5 5
|
||||
6 3 3
|
||||
6 3 3
|
||||
7 1 2
|
||||
7 1 2
|
||||
8 4 2
|
||||
8 4 2
|
||||
9 3 3
|
||||
9 3 3
|
||||
10 2 1
|
||||
10 2 1
|
||||
DROP TABLE t1, t2;
|
||||
#
|
||||
# BUG#920713: Wrong result (missing rows) with firstmatch+BNL, IN subquery, ...
|
||||
#
|
||||
CREATE TABLE t1 ( a VARCHAR(1) ) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES ('e'),('w'),('a'),('h'),('x'),('k'),('g');
|
||||
CREATE TABLE t2 ( b INT, c VARCHAR(1) );
|
||||
INSERT INTO t2 VALUES (0,'j'),(8,'v');
|
||||
SELECT * FROM t1 alias1, t2 alias2
|
||||
WHERE alias2.c IN (
|
||||
SELECT alias4.c FROM t1 alias3, t2 alias4
|
||||
);
|
||||
a b c
|
||||
e 0 j
|
||||
e 8 v
|
||||
w 0 j
|
||||
w 8 v
|
||||
a 0 j
|
||||
a 8 v
|
||||
h 0 j
|
||||
h 8 v
|
||||
x 0 j
|
||||
x 8 v
|
||||
k 0 j
|
||||
k 8 v
|
||||
g 0 j
|
||||
g 8 v
|
||||
DROP TABLE t1, t2;
|
||||
#
|
||||
# BUG#923246: Loosescan reports different result than other semijoin methods
|
||||
#
|
||||
set @tmp_923246= @@optimizer_switch;
|
||||
set optimizer_switch='mrr=on,materialization=off';
|
||||
create table t0 (a int);
|
||||
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2));
|
||||
insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C;
|
||||
insert into t1 select * from t1 where kp1 < 20;
|
||||
create table t3 (a int);
|
||||
insert into t3 select A.a + 10*B.a from t0 A, t0 B;
|
||||
select * from t3 where a in (select kp1 from t1 where kp1<20);
|
||||
a
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10
|
||||
11
|
||||
12
|
||||
13
|
||||
14
|
||||
15
|
||||
16
|
||||
17
|
||||
18
|
||||
19
|
||||
explain select * from t3 where a in (select kp1 from t1 where kp1<20);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 range kp1 kp1 5 NULL 48 Using where; Using index; LooseScan
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 100 Using where; Using join buffer (flat, BNL join)
|
||||
drop table t0,t1,t3;
|
||||
set optimizer_switch= @tmp_923246;
|
||||
set optimizer_switch=@subselect_sj_tmp;
|
||||
#
|
||||
# BUG#49129: Wrong result with IN-subquery with join_cache_level=6 and firstmatch=off
|
||||
@ -2274,6 +2733,35 @@ w 5 19:11:10
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
set join_cache_level=default;
|
||||
DROP TABLE t1,t2,t3;
|
||||
#
|
||||
# BUG#912513: Wrong result (missing rows) with join_cache_hashed+materialization+semijoin=on
|
||||
#
|
||||
set @os_912513= @@optimizer_switch;
|
||||
set @jcl_912513= @@join_cache_level;
|
||||
SET optimizer_switch = 'semijoin=on,materialization=on,join_cache_hashed=on';
|
||||
SET join_cache_level = 3;
|
||||
CREATE TABLE t1 ( a INT, b INT, KEY(a) );
|
||||
INSERT INTO t1 VALUES
|
||||
(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7);
|
||||
CREATE TABLE t2 ( c INT );
|
||||
INSERT INTO t2 VALUES (1),(2),(3),(4),(5),(6),(7);
|
||||
SELECT alias1.* FROM
|
||||
t1 AS alias1 INNER JOIN t1 AS alias2
|
||||
ON alias2.a = alias1.b
|
||||
WHERE alias1.b IN (
|
||||
SELECT a FROM t1, t2
|
||||
);
|
||||
a b
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
4 4
|
||||
5 5
|
||||
6 6
|
||||
7 7
|
||||
DROP table t1, t2;
|
||||
set @@optimizer_switch= @os_912513;
|
||||
set @@join_cache_level= @jcl_912513;
|
||||
# End
|
||||
set join_cache_level=default;
|
||||
show variables like 'join_cache_level';
|
||||
|
@ -1849,6 +1849,42 @@ a b c
|
||||
4 4 2
|
||||
4 4 4
|
||||
DROP TABLE t1,t2;
|
||||
#
|
||||
# BUG#922254: Assertion `0' failed at item_cmpfunc.cc:5899: Item* Item_equal::get_first(JOIN_TAB*, Item*)
|
||||
#
|
||||
CREATE TABLE t1 ( a VARCHAR(3) );
|
||||
CREATE TABLE t2 ( b VARCHAR(3), c VARCHAR(8), KEY(c) );
|
||||
INSERT INTO t2 VALUES ('USA','Abilene'),('USA','Akron');
|
||||
EXPLAIN
|
||||
SELECT * FROM
|
||||
( SELECT * FROM t1 ) AS alias1,
|
||||
t2 AS alias2
|
||||
WHERE b = a AND a IN (
|
||||
SELECT alias3.c
|
||||
FROM t2 AS alias3, t2 AS alias4
|
||||
WHERE alias4.c = alias3.b
|
||||
);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
DROP TABLE t1,t2;
|
||||
#
|
||||
# BUG#928048: Query containing IN subquery with OR in the where clause returns a wrong result
|
||||
#
|
||||
create table t1 (a int, b int);
|
||||
insert into t1 values (7,5), (3,3), (5,4), (9,3);
|
||||
create table t2 (a int, b int, index i_a(a));
|
||||
insert into t2 values
|
||||
(4,2), (7,9), (7,4), (3,1), (5,3), (3,1), (9,4), (8,1);
|
||||
explain select * from t1 where t1.a in (select a from t2 where t2.a=7 or t2.b<=1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 5 func 1
|
||||
2 MATERIALIZED t2 ALL i_a NULL NULL NULL 8 Using where
|
||||
select * from t1 where t1.a in (select a from t2 where t2.a=7 or t2.b<=1);
|
||||
a b
|
||||
7 5
|
||||
3 3
|
||||
drop table t1,t2;
|
||||
# This must be at the end:
|
||||
set optimizer_switch=@subselect_sj_mat_tmp;
|
||||
set join_cache_level=@save_join_cache_level;
|
||||
|
@ -95,3 +95,15 @@ SELECT SUM(DISTINCT id % 11) FROM t1;
|
||||
SUM(DISTINCT id % 11)
|
||||
55
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug #777654: empty subselect in FROM clause returning
|
||||
# SUM(DISTINCT) over non-nullable field
|
||||
#
|
||||
CREATE TABLE t1 (a int NOT NULL) ;
|
||||
SELECT SUM(DISTINCT a) FROM t1;
|
||||
SUM(DISTINCT a)
|
||||
NULL
|
||||
SELECT * FROM (SELECT SUM(DISTINCT a) FROM t1) AS t;
|
||||
SUM(DISTINCT a)
|
||||
NULL
|
||||
DROP TABLE t1;
|
||||
|
@ -277,6 +277,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
flush status;
|
||||
update t1 set a=9999 order by a limit 1;
|
||||
@ -289,6 +290,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 2
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 9
|
||||
flush status;
|
||||
delete from t1 order by a limit 1;
|
||||
@ -300,6 +302,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
flush status;
|
||||
delete from t1 order by a desc limit 1;
|
||||
@ -311,6 +314,7 @@ Handler_read_last 1
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
alter table t1 disable keys;
|
||||
flush status;
|
||||
@ -323,7 +327,8 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 1
|
||||
Handler_read_rnd_next 9
|
||||
Handler_read_rnd_deleted 2
|
||||
Handler_read_rnd_next 7
|
||||
select * from t1;
|
||||
a b
|
||||
0 0
|
||||
@ -377,6 +382,7 @@ Handler_read_last 0
|
||||
Handler_read_next 1
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 1
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
drop table t1, t2;
|
||||
create table t1(f1 int, `*f2` int);
|
||||
@ -415,6 +421,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
SELECT user_id FROM t1 WHERE request_id=999999999999999999999999999999;
|
||||
user_id
|
||||
@ -426,6 +433,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
UPDATE t1 SET user_id=null WHERE request_id=9999999999999;
|
||||
show status like '%Handler_read%';
|
||||
@ -436,6 +444,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
UPDATE t1 SET user_id=null WHERE request_id=999999999999999999999999999999;
|
||||
show status like '%Handler_read%';
|
||||
@ -446,6 +455,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (
|
||||
|
@ -304,7 +304,7 @@ a+1
|
||||
4
|
||||
explain select * from v1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 4 Using filesort
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
@ -4045,6 +4045,63 @@ drop table t1,t2;
|
||||
# -- End of 5.1 tests.
|
||||
# -----------------------------------------------------------------
|
||||
#
|
||||
# Bug #794005: crash in st_table::mark_virtual_columns_for_write
|
||||
#
|
||||
CREATE TABLE t1 (a int);
|
||||
insert into t1 values (1);
|
||||
CREATE TABLE t2 (a int);
|
||||
insert into t2 values (1);
|
||||
CREATE VIEW v2 AS SELECT * FROM t2;
|
||||
CREATE VIEW v1 AS SELECT * FROM v2;
|
||||
CREATE VIEW v3 AS SELECT t2.a,v1.a as b FROM t2,v1 where t2.a=v1.a;
|
||||
CREATE OR REPLACE ALGORITHM = TEMPTABLE VIEW v2 AS SELECT * FROM t1;
|
||||
UPDATE v1 SET a = 10;
|
||||
ERROR HY000: The target table v1 of the UPDATE is not updatable
|
||||
REPLACE v1 SET a = 10;
|
||||
ERROR HY000: The target table v1 of the INSERT is not insertable-into
|
||||
INSERT into v1 values (20);
|
||||
ERROR HY000: The target table v1 of the INSERT is not insertable-into
|
||||
DELETE from v1;
|
||||
ERROR HY000: The target table v1 of the DELETE is not updatable
|
||||
UPDATE v3 SET b= 10;
|
||||
ERROR HY000: The target table v2 of the UPDATE is not updatable
|
||||
REPLACE v3 SET b= 10;
|
||||
ERROR HY000: The target table v3 of the INSERT is not insertable-into
|
||||
INSERT into v3(b) values (20);
|
||||
ERROR HY000: The target table v3 of the INSERT is not insertable-into
|
||||
DELETE from v3 where b=20;
|
||||
ERROR HY000: Can not delete from join view 'test.v3'
|
||||
DELETE from v3 where a=20;
|
||||
ERROR HY000: Can not delete from join view 'test.v3'
|
||||
DELETE v1 from v1,t1 where v1.a=t1.a;
|
||||
ERROR HY000: The target table v1 of the DELETE is not updatable
|
||||
UPDATE v3 SET a = 10;
|
||||
REPLACE v3 SET a = 11;
|
||||
INSERT INTO v3(a) values (20);
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
select * from t2;
|
||||
a
|
||||
10
|
||||
11
|
||||
20
|
||||
CREATE OR REPLACE ALGORITHM = MERGE VIEW v2 AS SELECT * FROM t2;
|
||||
DELETE from v1 where a=11;
|
||||
DELETE v1 from v1,t1 where v1.a=t1.a;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
select * from t2;
|
||||
a
|
||||
10
|
||||
20
|
||||
DROP VIEW v1,v2,v3;
|
||||
DROP TABLE t1,t2;
|
||||
# -----------------------------------------------------------------
|
||||
# -- End of 5.2 tests.
|
||||
# -----------------------------------------------------------------
|
||||
#
|
||||
# Bug #59696 Optimizer does not use equalities for conditions over view
|
||||
#
|
||||
CREATE TABLE t1 (a int NOT NULL);
|
||||
@ -4075,6 +4132,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 17
|
||||
CREATE VIEW v AS SELECT * FROM t2;
|
||||
EXPLAIN EXTENDED
|
||||
@ -4097,6 +4155,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 17
|
||||
DROP VIEW v;
|
||||
DROP TABLE t1, t2;
|
||||
@ -4569,4 +4628,7 @@ NULL NULL 1 0
|
||||
NULL NULL 1 0
|
||||
DROP VIEW v2;
|
||||
DROP TABLE t1, t2, t3;
|
||||
# -----------------------------------------------------------------
|
||||
# -- End of 5.3 tests.
|
||||
# -----------------------------------------------------------------
|
||||
SET optimizer_switch=@save_optimizer_switch;
|
||||
|
66
mysql-test/suite/maria/r/maria-gis-recovery.result
Normal file
66
mysql-test/suite/maria/r/maria-gis-recovery.result
Normal file
@ -0,0 +1,66 @@
|
||||
set global aria_log_file_size=4294967295;
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect aria_log_file_size value: '4294967295'
|
||||
drop database if exists mysqltest;
|
||||
create database mysqltest;
|
||||
use mysqltest;
|
||||
* shut down mysqld, removed logs, restarted it
|
||||
CREATE TABLE t1 (
|
||||
i int,
|
||||
shape GEOMETRY NOT NULL,
|
||||
SPATIAL (shape)
|
||||
) ENGINE=ARIA;
|
||||
insert into t1 values(1,POINT(1, 1));
|
||||
* copied t1 for feeding_recovery
|
||||
insert into t1 values(2,POINT(2, 2)), (3,POINT(3, 3)), (4,POINT(4, 4));
|
||||
flush table t1;
|
||||
* copied t1 for comparison
|
||||
SET SESSION debug_dbug="+d,maria_flush_whole_log,maria_crash";
|
||||
* crashing mysqld intentionally
|
||||
set global aria_checkpoint_interval=1;
|
||||
ERROR HY000: Lost connection to MySQL server during query
|
||||
* copied t1 back for feeding_recovery
|
||||
* recovery happens
|
||||
check table t1 extended;
|
||||
Table Op Msg_type Msg_text
|
||||
mysqltest.t1 check status OK
|
||||
* testing that checksum after recovery is as expected
|
||||
Checksum-check
|
||||
ok
|
||||
use mysqltest;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`i` int(11) DEFAULT NULL,
|
||||
`shape` geometry NOT NULL,
|
||||
SPATIAL KEY `shape` (`shape`)
|
||||
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
|
||||
* TEST of UPDATE vs state.auto_increment
|
||||
* copied t1 for feeding_recovery
|
||||
update t1 set shape=POINT(5, 5) where i=2;
|
||||
flush table t1;
|
||||
* copied t1 for comparison
|
||||
SET SESSION debug_dbug="+d,maria_flush_whole_log,maria_crash";
|
||||
* crashing mysqld intentionally
|
||||
set global aria_checkpoint_interval=1;
|
||||
ERROR HY000: Lost connection to MySQL server during query
|
||||
* copied t1 back for feeding_recovery
|
||||
* recovery happens
|
||||
check table t1 extended;
|
||||
Table Op Msg_type Msg_text
|
||||
mysqltest.t1 check status OK
|
||||
* testing that checksum after recovery is as expected
|
||||
Checksum-check
|
||||
ok
|
||||
use mysqltest;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`i` int(11) DEFAULT NULL,
|
||||
`shape` geometry NOT NULL,
|
||||
SPATIAL KEY `shape` (`shape`)
|
||||
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
|
||||
drop table t1;
|
||||
drop database mysqltest_for_feeding_recovery;
|
||||
drop database mysqltest_for_comparison;
|
||||
drop database mysqltest;
|
1
mysql-test/suite/maria/t/maria-gis-recovery.opt
Normal file
1
mysql-test/suite/maria/t/maria-gis-recovery.opt
Normal file
@ -0,0 +1 @@
|
||||
--skip-stack-trace --skip-core-file --loose-aria-log-dir-path=$MYSQLTEST_VARDIR/tmp
|
64
mysql-test/suite/maria/t/maria-gis-recovery.test
Normal file
64
mysql-test/suite/maria/t/maria-gis-recovery.test
Normal file
@ -0,0 +1,64 @@
|
||||
--source include/not_embedded.inc
|
||||
# Don't test this under valgrind, memory leaks will occur as we crash
|
||||
--source include/not_valgrind.inc
|
||||
# Binary must be compiled with debug for crash to occur
|
||||
--source include/have_debug.inc
|
||||
--source include/have_maria.inc
|
||||
--source include/have_geometry.inc
|
||||
|
||||
set global aria_log_file_size=4294967295;
|
||||
let $MARIA_LOG=../../tmp;
|
||||
|
||||
--disable_warnings
|
||||
drop database if exists mysqltest;
|
||||
--enable_warnings
|
||||
create database mysqltest;
|
||||
let $mms_tname=t;
|
||||
|
||||
# Include scripts can perform SQL. For it to not influence the main test
|
||||
# they use a separate connection. This way if they use a DDL it would
|
||||
# not autocommit in the main test.
|
||||
connect (admin, localhost, root,,mysqltest,,);
|
||||
--enable_reconnect
|
||||
|
||||
connection default;
|
||||
use mysqltest;
|
||||
--enable_reconnect
|
||||
|
||||
-- source include/maria_empty_logs.inc
|
||||
let $mms_tables=1;
|
||||
CREATE TABLE t1 (
|
||||
i int,
|
||||
shape GEOMETRY NOT NULL,
|
||||
SPATIAL (shape)
|
||||
) ENGINE=ARIA;
|
||||
insert into t1 values(1,POINT(1, 1));
|
||||
-- source include/maria_make_snapshot_for_feeding_recovery.inc
|
||||
insert into t1 values(2,POINT(2, 2)), (3,POINT(3, 3)), (4,POINT(4, 4));
|
||||
-- source include/maria_make_snapshot_for_comparison.inc
|
||||
let $mvr_restore_old_snapshot=1;
|
||||
let $mms_compare_physically=0;
|
||||
let $mvr_debug_option="+d,maria_flush_whole_log,maria_crash";
|
||||
let $mvr_crash_statement= set global aria_checkpoint_interval=1;
|
||||
-- source include/maria_verify_recovery.inc
|
||||
show create table t1;
|
||||
|
||||
# Test that UPDATE's effect on auto-increment is recovered
|
||||
--echo * TEST of UPDATE vs state.auto_increment
|
||||
-- source include/maria_make_snapshot_for_feeding_recovery.inc
|
||||
update t1 set shape=POINT(5, 5) where i=2;
|
||||
-- source include/maria_make_snapshot_for_comparison.inc
|
||||
let $mvr_restore_old_snapshot=1;
|
||||
let $mms_compare_physically=0;
|
||||
let $mvr_debug_option="+d,maria_flush_whole_log,maria_crash";
|
||||
let $mvr_crash_statement= set global aria_checkpoint_interval=1;
|
||||
-- source include/maria_verify_recovery.inc
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
|
||||
# clean up everything
|
||||
let $mms_purpose=feeding_recovery;
|
||||
eval drop database mysqltest_for_$mms_purpose;
|
||||
let $mms_purpose=comparison;
|
||||
eval drop database mysqltest_for_$mms_purpose;
|
||||
drop database mysqltest;
|
@ -1,733 +0,0 @@
|
||||
drop table if exists t1,t2,t3;
|
||||
create table t1 (a int not null,b int not null, primary key (a)) engine=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100;
|
||||
insert into t1 values(1,1),(2,2),(3,3),(4,4);
|
||||
delete from t1 where a=1 or a=0;
|
||||
show keys from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 0 PRIMARY 1 a NULL 3 NULL NULL HASH
|
||||
select * from t1;
|
||||
a b
|
||||
2 2
|
||||
3 3
|
||||
4 4
|
||||
select * from t1 where a=4;
|
||||
a b
|
||||
4 4
|
||||
update t1 set b=5 where a=4;
|
||||
update t1 set b=b+1 where a>=3;
|
||||
replace t1 values (3,3);
|
||||
select * from t1;
|
||||
a b
|
||||
2 2
|
||||
3 3
|
||||
4 6
|
||||
alter table t1 add c int not null, add key (c,a);
|
||||
drop table t1;
|
||||
create table t1 (a int not null,b int not null, primary key (a)) engine=memory comment="testing heaps";
|
||||
insert into t1 values(1,1),(2,2),(3,3),(4,4);
|
||||
delete from t1 where a > 0;
|
||||
select * from t1;
|
||||
a b
|
||||
drop table t1;
|
||||
create table t1 (a int not null,b int not null, primary key (a)) engine=heap comment="testing heaps";
|
||||
insert into t1 values(1,1),(2,2),(3,3),(4,4);
|
||||
alter table t1 modify a int not null auto_increment, engine=myisam, comment="new myisam table";
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
4 4
|
||||
drop table t1;
|
||||
create table t1 (a int not null) engine=heap;
|
||||
insert into t1 values (869751),(736494),(226312),(802616),(728912);
|
||||
select * from t1 where a > 736494;
|
||||
a
|
||||
869751
|
||||
802616
|
||||
alter table t1 add unique uniq_id(a);
|
||||
select * from t1 where a > 736494;
|
||||
a
|
||||
869751
|
||||
802616
|
||||
select * from t1 where a = 736494;
|
||||
a
|
||||
736494
|
||||
select * from t1 where a=869751 or a=736494;
|
||||
a
|
||||
736494
|
||||
869751
|
||||
select * from t1 where a in (869751,736494,226312,802616);
|
||||
a
|
||||
226312
|
||||
736494
|
||||
802616
|
||||
869751
|
||||
alter table t1 engine=myisam;
|
||||
explain select * from t1 where a in (869751,736494,226312,802616);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range uniq_id uniq_id 4 NULL 4 Using where; Using index
|
||||
drop table t1;
|
||||
create table t1 (x int not null, y int not null, key x (x), unique y (y))
|
||||
engine=heap;
|
||||
insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
|
||||
select * from t1 where x=1;
|
||||
x y
|
||||
1 3
|
||||
1 1
|
||||
select * from t1,t1 as t2 where t1.x=t2.y;
|
||||
x y x y
|
||||
1 1 1 1
|
||||
2 2 2 2
|
||||
1 3 1 1
|
||||
2 4 2 2
|
||||
2 5 2 2
|
||||
2 6 2 2
|
||||
explain select * from t1,t1 as t2 where t1.x=t2.y;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL x NULL NULL NULL 6
|
||||
1 SIMPLE t2 eq_ref y y 4 test.t1.x 1
|
||||
drop table t1;
|
||||
create table t1 (a int) engine=heap;
|
||||
insert into t1 values(1);
|
||||
select max(a) from t1;
|
||||
max(a)
|
||||
1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 ( a int not null default 0, b int not null default 0, key(a), key(b) ) ENGINE=HEAP;
|
||||
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
|
||||
select * from t1 where a=1;
|
||||
a b
|
||||
1 6
|
||||
1 5
|
||||
1 4
|
||||
1 3
|
||||
1 2
|
||||
1 1
|
||||
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
|
||||
select * from t1 where a=1;
|
||||
a b
|
||||
1 6
|
||||
1 5
|
||||
1 4
|
||||
1 3
|
||||
1 2
|
||||
1 1
|
||||
1 6
|
||||
1 5
|
||||
1 4
|
||||
1 3
|
||||
1 2
|
||||
1 1
|
||||
drop table t1;
|
||||
create table t1 (id int unsigned not null, primary key (id)) engine=HEAP;
|
||||
insert into t1 values(1);
|
||||
select max(id) from t1;
|
||||
max(id)
|
||||
1
|
||||
insert into t1 values(2);
|
||||
select max(id) from t1;
|
||||
max(id)
|
||||
2
|
||||
replace into t1 values(1);
|
||||
drop table t1;
|
||||
create table t1 (n int) engine=heap;
|
||||
drop table t1;
|
||||
create table t1 (n int) engine=heap;
|
||||
drop table if exists t1;
|
||||
CREATE table t1(f1 int not null,f2 char(20) not
|
||||
null,index(f2)) engine=heap;
|
||||
INSERT into t1 set f1=12,f2="bill";
|
||||
INSERT into t1 set f1=13,f2="bill";
|
||||
INSERT into t1 set f1=14,f2="bill";
|
||||
INSERT into t1 set f1=15,f2="bill";
|
||||
INSERT into t1 set f1=16,f2="ted";
|
||||
INSERT into t1 set f1=12,f2="ted";
|
||||
INSERT into t1 set f1=12,f2="ted";
|
||||
INSERT into t1 set f1=12,f2="ted";
|
||||
INSERT into t1 set f1=12,f2="ted";
|
||||
delete from t1 where f2="bill";
|
||||
select * from t1;
|
||||
f1 f2
|
||||
16 ted
|
||||
12 ted
|
||||
12 ted
|
||||
12 ted
|
||||
12 ted
|
||||
drop table t1;
|
||||
create table t1 (btn char(10) not null, key(btn)) engine=heap;
|
||||
insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
|
||||
explain select * from t1 where btn like "q%";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL btn NULL NULL NULL 14 Using where
|
||||
select * from t1 where btn like "q%";
|
||||
btn
|
||||
alter table t1 add column new_col char(1) not null, add key (btn,new_col), drop key btn;
|
||||
update t1 set new_col=left(btn,1);
|
||||
explain select * from t1 where btn="a";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL btn NULL NULL NULL 14 Using where
|
||||
explain select * from t1 where btn="a" and new_col="a";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref btn btn 11 const,const 2 Using where
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
a int default NULL,
|
||||
b int default NULL,
|
||||
KEY a (a),
|
||||
UNIQUE b (b)
|
||||
) engine=heap;
|
||||
INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3);
|
||||
SELECT * FROM t1 WHERE a=NULL;
|
||||
a b
|
||||
explain SELECT * FROM t1 WHERE a IS NULL;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 5 const 2 Using where
|
||||
SELECT * FROM t1 WHERE a<=>NULL;
|
||||
a b
|
||||
NULL 99
|
||||
SELECT * FROM t1 WHERE b=NULL;
|
||||
a b
|
||||
explain SELECT * FROM t1 WHERE b IS NULL;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref b b 5 const 1 Using where
|
||||
SELECT * FROM t1 WHERE b<=>NULL;
|
||||
a b
|
||||
99 NULL
|
||||
INSERT INTO t1 VALUES (1,3);
|
||||
ERROR 23000: Duplicate entry '3' for key 'b'
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (
|
||||
a int default NULL,
|
||||
key a (a)
|
||||
) ENGINE=HEAP;
|
||||
INSERT INTO t1 VALUES (10), (10), (10);
|
||||
EXPLAIN SELECT * FROM t1 WHERE a=10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 5 const 3
|
||||
SELECT * FROM t1 WHERE a=10;
|
||||
a
|
||||
10
|
||||
10
|
||||
10
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a int not null, primary key(a)) engine=heap;
|
||||
INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
|
||||
DELETE from t1 where a < 100;
|
||||
SELECT * from t1;
|
||||
a
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE `job_titles` (
|
||||
`job_title_id` int(6) unsigned NOT NULL default '0',
|
||||
`job_title` char(18) NOT NULL default '',
|
||||
PRIMARY KEY (`job_title_id`),
|
||||
UNIQUE KEY `job_title_id` (`job_title_id`,`job_title`)
|
||||
) ENGINE=HEAP;
|
||||
SELECT MAX(job_title_id) FROM job_titles;
|
||||
MAX(job_title_id)
|
||||
NULL
|
||||
DROP TABLE job_titles;
|
||||
CREATE TABLE t1 (a INT NOT NULL, B INT, KEY(B)) ENGINE=HEAP;
|
||||
INSERT INTO t1 VALUES(1,1), (1,NULL);
|
||||
SELECT * FROM t1 WHERE B is not null;
|
||||
a B
|
||||
1 1
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (pseudo char(35) PRIMARY KEY, date int(10) unsigned NOT NULL) ENGINE=HEAP;
|
||||
INSERT INTO t1 VALUES ('massecot',1101106491),('altec',1101106492),('stitch+',1101106304),('Seb Corgan',1101106305),('beerfilou',1101106263),('flaker',1101106529),('joce8',5),('M4vrick',1101106418),('gabay008',1101106525),('Vamp irX',1101106291),('ZoomZip',1101106546),('rip666',1101106502),('CBP ',1101106397),('guezpard',1101106496);
|
||||
DELETE FROM t1 WHERE date<1101106546;
|
||||
SELECT * FROM t1;
|
||||
pseudo date
|
||||
ZoomZip 1101106546
|
||||
DROP TABLE t1;
|
||||
create table t1(a char(2)) engine=memory;
|
||||
insert into t1 values (NULL), (NULL);
|
||||
delete from t1 where a is null;
|
||||
insert into t1 values ('2'), ('3');
|
||||
select * from t1;
|
||||
a
|
||||
3
|
||||
2
|
||||
drop table t1;
|
||||
set storage_engine=HEAP;
|
||||
create table t1 (v varchar(10), c char(10), t varchar(50));
|
||||
insert into t1 values('+ ', '+ ', '+ ');
|
||||
set @a=repeat(' ',20);
|
||||
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'v' at row 1
|
||||
select concat('*',v,'*',c,'*',t,'*') from t1;
|
||||
concat('*',v,'*',c,'*',t,'*')
|
||||
*+ *+*+ *
|
||||
*+ *+*+ *
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`v` varchar(10) DEFAULT NULL,
|
||||
`c` char(10) DEFAULT NULL,
|
||||
`t` varchar(50) DEFAULT NULL
|
||||
) ENGINE=MEMORY DEFAULT CHARSET=latin1
|
||||
create table t2 like t1;
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`v` varchar(10) DEFAULT NULL,
|
||||
`c` char(10) DEFAULT NULL,
|
||||
`t` varchar(50) DEFAULT NULL
|
||||
) ENGINE=MEMORY DEFAULT CHARSET=latin1
|
||||
create table t3 select * from t1;
|
||||
show create table t3;
|
||||
Table Create Table
|
||||
t3 CREATE TABLE `t3` (
|
||||
`v` varchar(10) DEFAULT NULL,
|
||||
`c` char(10) DEFAULT NULL,
|
||||
`t` varchar(50) DEFAULT NULL
|
||||
) ENGINE=MEMORY DEFAULT CHARSET=latin1
|
||||
alter table t1 modify c varchar(10);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`v` varchar(10) DEFAULT NULL,
|
||||
`c` varchar(10) DEFAULT NULL,
|
||||
`t` varchar(50) DEFAULT NULL
|
||||
) ENGINE=MEMORY DEFAULT CHARSET=latin1
|
||||
alter table t1 modify v char(10);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`v` char(10) DEFAULT NULL,
|
||||
`c` varchar(10) DEFAULT NULL,
|
||||
`t` varchar(50) DEFAULT NULL
|
||||
) ENGINE=MEMORY DEFAULT CHARSET=latin1
|
||||
alter table t1 modify t varchar(10);
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 't' at row 2
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`v` char(10) DEFAULT NULL,
|
||||
`c` varchar(10) DEFAULT NULL,
|
||||
`t` varchar(10) DEFAULT NULL
|
||||
) ENGINE=MEMORY DEFAULT CHARSET=latin1
|
||||
select concat('*',v,'*',c,'*',t,'*') from t1;
|
||||
concat('*',v,'*',c,'*',t,'*')
|
||||
*+*+*+ *
|
||||
*+*+*+ *
|
||||
drop table t1,t2,t3;
|
||||
create table t1 (v varchar(10), c char(10), t varchar(50), key(v), key(c), key(t(10)));
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`v` varchar(10) DEFAULT NULL,
|
||||
`c` char(10) DEFAULT NULL,
|
||||
`t` varchar(50) DEFAULT NULL,
|
||||
KEY `v` (`v`),
|
||||
KEY `c` (`c`),
|
||||
KEY `t` (`t`(10))
|
||||
) ENGINE=MEMORY DEFAULT CHARSET=latin1
|
||||
select count(*) from t1;
|
||||
count(*)
|
||||
270
|
||||
insert into t1 values(concat('a',char(1)),concat('a',char(1)),concat('a',char(1)));
|
||||
select count(*) from t1 where v='a';
|
||||
count(*)
|
||||
10
|
||||
select count(*) from t1 where c='a';
|
||||
count(*)
|
||||
10
|
||||
select count(*) from t1 where t='a';
|
||||
count(*)
|
||||
10
|
||||
select count(*) from t1 where v='a ';
|
||||
count(*)
|
||||
10
|
||||
select count(*) from t1 where c='a ';
|
||||
count(*)
|
||||
10
|
||||
select count(*) from t1 where t='a ';
|
||||
count(*)
|
||||
10
|
||||
select count(*) from t1 where v between 'a' and 'a ';
|
||||
count(*)
|
||||
10
|
||||
select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
|
||||
count(*)
|
||||
10
|
||||
select count(*) from t1 where v like 'a%';
|
||||
count(*)
|
||||
11
|
||||
select count(*) from t1 where c like 'a%';
|
||||
count(*)
|
||||
11
|
||||
select count(*) from t1 where t like 'a%';
|
||||
count(*)
|
||||
11
|
||||
select count(*) from t1 where v like 'a %';
|
||||
count(*)
|
||||
9
|
||||
explain select count(*) from t1 where v='a ';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref v v 13 const 10 Using where
|
||||
explain select count(*) from t1 where c='a ';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref c c 11 const 10 Using where
|
||||
explain select count(*) from t1 where t='a ';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref t t 13 const 10 Using where
|
||||
explain select count(*) from t1 where v like 'a%';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL v NULL NULL NULL 271 Using where
|
||||
explain select count(*) from t1 where v between 'a' and 'a ';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref v v 13 const 10 Using where
|
||||
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref v v 13 const 10 Using where
|
||||
alter table t1 add unique(v);
|
||||
ERROR 23000: Duplicate entry '{ ' for key 'v_2'
|
||||
select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a' order by length(concat('*',v,'*',c,'*',t,'*'));
|
||||
qq
|
||||
*a*a*a*
|
||||
*a *a*a *
|
||||
*a *a*a *
|
||||
*a *a*a *
|
||||
*a *a*a *
|
||||
*a *a*a *
|
||||
*a *a*a *
|
||||
*a *a*a *
|
||||
*a *a*a *
|
||||
*a *a*a *
|
||||
explain select * from t1 where v='a';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref v v 13 const 10 Using where
|
||||
select v,count(*) from t1 group by v limit 10;
|
||||
v count(*)
|
||||
a 1
|
||||
a 10
|
||||
b 10
|
||||
c 10
|
||||
d 10
|
||||
e 10
|
||||
f 10
|
||||
g 10
|
||||
h 10
|
||||
i 10
|
||||
select v,count(t) from t1 group by v limit 10;
|
||||
v count(t)
|
||||
a 1
|
||||
a 10
|
||||
b 10
|
||||
c 10
|
||||
d 10
|
||||
e 10
|
||||
f 10
|
||||
g 10
|
||||
h 10
|
||||
i 10
|
||||
select v,count(c) from t1 group by v limit 10;
|
||||
v count(c)
|
||||
a 1
|
||||
a 10
|
||||
b 10
|
||||
c 10
|
||||
d 10
|
||||
e 10
|
||||
f 10
|
||||
g 10
|
||||
h 10
|
||||
i 10
|
||||
select sql_big_result trim(v),count(t) from t1 group by v limit 10;
|
||||
trim(v) count(t)
|
||||
a 1
|
||||
a 10
|
||||
b 10
|
||||
c 10
|
||||
d 10
|
||||
e 10
|
||||
f 10
|
||||
g 10
|
||||
h 10
|
||||
i 10
|
||||
select sql_big_result trim(v),count(c) from t1 group by v limit 10;
|
||||
trim(v) count(c)
|
||||
a 1
|
||||
a 10
|
||||
b 10
|
||||
c 10
|
||||
d 10
|
||||
e 10
|
||||
f 10
|
||||
g 10
|
||||
h 10
|
||||
i 10
|
||||
select c,count(*) from t1 group by c limit 10;
|
||||
c count(*)
|
||||
a 1
|
||||
a 10
|
||||
b 10
|
||||
c 10
|
||||
d 10
|
||||
e 10
|
||||
f 10
|
||||
g 10
|
||||
h 10
|
||||
i 10
|
||||
select c,count(t) from t1 group by c limit 10;
|
||||
c count(t)
|
||||
a 1
|
||||
a 10
|
||||
b 10
|
||||
c 10
|
||||
d 10
|
||||
e 10
|
||||
f 10
|
||||
g 10
|
||||
h 10
|
||||
i 10
|
||||
select sql_big_result c,count(t) from t1 group by c limit 10;
|
||||
c count(t)
|
||||
a 1
|
||||
a 10
|
||||
b 10
|
||||
c 10
|
||||
d 10
|
||||
e 10
|
||||
f 10
|
||||
g 10
|
||||
h 10
|
||||
i 10
|
||||
select t,count(*) from t1 group by t limit 10;
|
||||
t count(*)
|
||||
a 1
|
||||
a 10
|
||||
b 10
|
||||
c 10
|
||||
d 10
|
||||
e 10
|
||||
f 10
|
||||
g 10
|
||||
h 10
|
||||
i 10
|
||||
select t,count(t) from t1 group by t limit 10;
|
||||
t count(t)
|
||||
a 1
|
||||
a 10
|
||||
b 10
|
||||
c 10
|
||||
d 10
|
||||
e 10
|
||||
f 10
|
||||
g 10
|
||||
h 10
|
||||
i 10
|
||||
select sql_big_result trim(t),count(t) from t1 group by t limit 10;
|
||||
trim(t) count(t)
|
||||
a 1
|
||||
a 10
|
||||
b 10
|
||||
c 10
|
||||
d 10
|
||||
e 10
|
||||
f 10
|
||||
g 10
|
||||
h 10
|
||||
i 10
|
||||
drop table t1;
|
||||
create table t1 (a char(10), unique (a));
|
||||
insert into t1 values ('a');
|
||||
insert into t1 values ('a ');
|
||||
ERROR 23000: Duplicate entry 'a' for key 'a'
|
||||
alter table t1 modify a varchar(10);
|
||||
insert into t1 values ('a '),('a '),('a '),('a ');
|
||||
ERROR 23000: Duplicate entry 'a ' for key 'a'
|
||||
insert into t1 values ('a ');
|
||||
ERROR 23000: Duplicate entry 'a ' for key 'a'
|
||||
insert into t1 values ('a ');
|
||||
ERROR 23000: Duplicate entry 'a ' for key 'a'
|
||||
insert into t1 values ('a ');
|
||||
ERROR 23000: Duplicate entry 'a ' for key 'a'
|
||||
update t1 set a='a ' where a like 'a ';
|
||||
update t1 set a='a ' where a like 'a ';
|
||||
drop table t1;
|
||||
create table t1 (v varchar(10), c char(10), t varchar(50), key using btree (v), key using btree (c), key using btree (t(10)));
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`v` varchar(10) DEFAULT NULL,
|
||||
`c` char(10) DEFAULT NULL,
|
||||
`t` varchar(50) DEFAULT NULL,
|
||||
KEY `v` (`v`) USING BTREE,
|
||||
KEY `c` (`c`) USING BTREE,
|
||||
KEY `t` (`t`(10)) USING BTREE
|
||||
) ENGINE=MEMORY DEFAULT CHARSET=latin1
|
||||
select count(*) from t1;
|
||||
count(*)
|
||||
270
|
||||
insert into t1 values(concat('a',char(1)),concat('a',char(1)),concat('a',char(1)));
|
||||
select count(*) from t1 where v='a';
|
||||
count(*)
|
||||
10
|
||||
select count(*) from t1 where c='a';
|
||||
count(*)
|
||||
10
|
||||
select count(*) from t1 where t='a';
|
||||
count(*)
|
||||
10
|
||||
select count(*) from t1 where v='a ';
|
||||
count(*)
|
||||
10
|
||||
select count(*) from t1 where c='a ';
|
||||
count(*)
|
||||
10
|
||||
select count(*) from t1 where t='a ';
|
||||
count(*)
|
||||
10
|
||||
select count(*) from t1 where v between 'a' and 'a ';
|
||||
count(*)
|
||||
10
|
||||
select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
|
||||
count(*)
|
||||
10
|
||||
explain select count(*) from t1 where v='a ';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref v v 13 const # Using where
|
||||
explain select count(*) from t1 where c='a ';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref c c 11 const # Using where
|
||||
explain select count(*) from t1 where t='a ';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref t t 13 const # Using where
|
||||
explain select count(*) from t1 where v like 'a%';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range v v 13 NULL # Using where
|
||||
explain select count(*) from t1 where v between 'a' and 'a ';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref v v 13 const # Using where
|
||||
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref v v 13 const # Using where
|
||||
alter table t1 add unique(v);
|
||||
ERROR 23000: Duplicate entry '{ ' for key 'v_2'
|
||||
select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a' order by length(concat('*',v,'*',c,'*',t,'*'));
|
||||
qq
|
||||
*a*a*a*
|
||||
*a *a*a *
|
||||
*a *a*a *
|
||||
*a *a*a *
|
||||
*a *a*a *
|
||||
*a *a*a *
|
||||
*a *a*a *
|
||||
*a *a*a *
|
||||
*a *a*a *
|
||||
*a *a*a *
|
||||
explain select * from t1 where v='a';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref v v 13 const # Using where
|
||||
drop table t1;
|
||||
create table t1 (a char(10), unique using btree (a)) engine=heap;
|
||||
insert into t1 values ('a');
|
||||
insert into t1 values ('a ');
|
||||
ERROR 23000: Duplicate entry 'a' for key 'a'
|
||||
alter table t1 modify a varchar(10);
|
||||
insert into t1 values ('a '),('a '),('a '),('a ');
|
||||
ERROR 23000: Duplicate entry 'a ' for key 'a'
|
||||
insert into t1 values ('a ');
|
||||
ERROR 23000: Duplicate entry 'a ' for key 'a'
|
||||
insert into t1 values ('a ');
|
||||
ERROR 23000: Duplicate entry 'a ' for key 'a'
|
||||
insert into t1 values ('a ');
|
||||
ERROR 23000: Duplicate entry 'a ' for key 'a'
|
||||
update t1 set a='a ' where a like 'a ';
|
||||
update t1 set a='a ' where a like 'a ';
|
||||
drop table t1;
|
||||
create table t1 (v varchar(10), c char(10), t varchar(50), key(v(5)), key(c(5)), key(t(5)));
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`v` varchar(10) DEFAULT NULL,
|
||||
`c` char(10) DEFAULT NULL,
|
||||
`t` varchar(50) DEFAULT NULL,
|
||||
KEY `v` (`v`(5)),
|
||||
KEY `c` (`c`(5)),
|
||||
KEY `t` (`t`(5))
|
||||
) ENGINE=MEMORY DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
create table t1 (v varchar(65530), key(v(10)));
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`v` varchar(65530) DEFAULT NULL,
|
||||
KEY `v` (`v`(10))
|
||||
) ENGINE=MEMORY DEFAULT CHARSET=latin1
|
||||
insert into t1 values(repeat('a',65530));
|
||||
select length(v) from t1 where v=repeat('a',65530);
|
||||
length(v)
|
||||
65530
|
||||
drop table t1;
|
||||
set storage_engine=PBXT;
|
||||
create table t1 (a bigint unsigned auto_increment primary key, b int,
|
||||
key (b, a)) engine=heap;
|
||||
insert t1 (b) values (1),(1),(1),(1),(1),(1),(1),(1);
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
2 1
|
||||
3 1
|
||||
4 1
|
||||
5 1
|
||||
6 1
|
||||
7 1
|
||||
8 1
|
||||
drop table t1;
|
||||
create table t1 (a int not null, b int not null auto_increment,
|
||||
primary key(a, b), key(b)) engine=heap;
|
||||
insert t1 (a) values (1),(1),(1),(1),(1),(1),(1),(1);
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
1 2
|
||||
1 3
|
||||
1 4
|
||||
1 5
|
||||
1 6
|
||||
1 7
|
||||
1 8
|
||||
drop table t1;
|
||||
create table t1 (a int not null, b int not null auto_increment,
|
||||
primary key(a, b)) engine=heap;
|
||||
ERROR 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key
|
||||
create table t1 (c char(255), primary key(c(90)));
|
||||
insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
|
||||
insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
|
||||
ERROR 23000: Duplicate entry 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl' for key 'PRIMARY'
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a int, key(a)) engine=heap;
|
||||
insert into t1 values (0);
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a
|
||||
insert into t1 values (0), (1);
|
||||
select * from t1 where a = 0;
|
||||
a
|
||||
0
|
||||
drop table t1;
|
||||
create table t1 (c char(10)) engine=memory;
|
||||
create table t2 (c varchar(10)) engine=memory;
|
||||
show table status like 't_';
|
||||
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 MEMORY 10 Fixed 0 11 0 # 0 0 NULL # NULL NULL latin1_swedish_ci NULL
|
||||
t2 MEMORY 10 Fixed 0 12 0 # 0 0 NULL # NULL NULL latin1_swedish_ci NULL
|
||||
drop table t1, t2;
|
||||
CREATE TABLE t1(a VARCHAR(1), b VARCHAR(2), c VARCHAR(256),
|
||||
KEY(a), KEY(b), KEY(c)) ENGINE=MEMORY;
|
||||
INSERT INTO t1 VALUES('a','aa',REPEAT('a', 256)),('a','aa',REPEAT('a',256));
|
||||
SELECT COUNT(*) FROM t1 WHERE a='a';
|
||||
COUNT(*)
|
||||
2
|
||||
SELECT COUNT(*) FROM t1 WHERE b='aa';
|
||||
COUNT(*)
|
||||
2
|
||||
SELECT COUNT(*) FROM t1 WHERE c=REPEAT('a',256);
|
||||
COUNT(*)
|
||||
2
|
||||
DROP TABLE t1;
|
@ -428,5 +428,6 @@ Handler_read_last 0
|
||||
Handler_read_next 2
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 5
|
||||
DROP TABLE t1,t2,t3,t4;
|
||||
|
@ -121,8 +121,8 @@ insert into t1 values (1);
|
||||
explain select * from t1 where 3 in (select (1+1) union select 1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 index NULL PRIMARY 4 NULL 1 Using index
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
3 UNION NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
select * from t1 where 3 in (select (1+1) union select 1);
|
||||
a
|
||||
|
@ -2789,10 +2789,10 @@ 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(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
|
||||
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
|
||||
1 SIMPLE t1 index key1 key1 5 NULL 4 Using where; Using index
|
||||
explain select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
|
||||
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
|
||||
1 SIMPLE t1 index key1 key1 5 NULL 4 Using where; Using index
|
||||
select max(key1) from t1 where key1 <= 0.6158;
|
||||
max(key1)
|
||||
0.6158000230789185
|
||||
@ -2811,10 +2811,18 @@ max(key1) min(key2)
|
||||
0.6158000230789185 1.3761999607086182
|
||||
select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
|
||||
max(key1)
|
||||
<<<<<<< TREE
|
||||
0.6158000230789185
|
||||
=======
|
||||
0.384499996900558
|
||||
>>>>>>> MERGE-SOURCE
|
||||
select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
|
||||
min(key1)
|
||||
<<<<<<< TREE
|
||||
0.37619999051094055
|
||||
=======
|
||||
0.384499996900558
|
||||
>>>>>>> MERGE-SOURCE
|
||||
DROP TABLE t1,t2;
|
||||
CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL);
|
||||
INSERT INTO t1 VALUES (10);
|
||||
|
@ -277,6 +277,7 @@ Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
flush status;
|
||||
update t1 set a=9999 order by a limit 1;
|
||||
@ -292,6 +293,21 @@ Handler_read_last 1
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 2
|
||||
<<<<<<< TREE
|
||||
=======
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 18
|
||||
flush status;
|
||||
delete from t1 order by a limit 1;
|
||||
show status like 'handler_read%';
|
||||
Variable_name Value
|
||||
Handler_read_first 0
|
||||
Handler_read_key 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 1
|
||||
Handler_read_rnd_deleted 0
|
||||
>>>>>>> MERGE-SOURCE
|
||||
Handler_read_rnd_next 9
|
||||
flush status;
|
||||
delete from t1 order by a limit 1;
|
||||
@ -313,8 +329,14 @@ Handler_read_key 0
|
||||
Handler_read_last 1
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
<<<<<<< TREE
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_next 0
|
||||
=======
|
||||
Handler_read_rnd 1
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 8
|
||||
>>>>>>> MERGE-SOURCE
|
||||
alter table t1 disable keys;
|
||||
Warnings:
|
||||
Note 1031 Table storage engine for 't1' doesn't have this option
|
||||
@ -327,8 +349,14 @@ Handler_read_key 0
|
||||
Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
<<<<<<< TREE
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_next 0
|
||||
=======
|
||||
Handler_read_rnd 1
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 7
|
||||
>>>>>>> MERGE-SOURCE
|
||||
select * from t1;
|
||||
a b
|
||||
0 0
|
||||
@ -382,6 +410,7 @@ Handler_read_last 0
|
||||
Handler_read_next 1
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 1
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
drop table t1, t2;
|
||||
create table t1(f1 int, `*f2` int);
|
||||
|
@ -1,959 +0,0 @@
|
||||
drop database if exists mysqltest;
|
||||
drop view if exists v1,v2,v3;
|
||||
grant create view on test.* to test@localhost;
|
||||
show grants for test@localhost;
|
||||
Grants for test@localhost
|
||||
GRANT USAGE ON *.* TO 'test'@'localhost'
|
||||
GRANT CREATE VIEW ON `test`.* TO 'test'@'localhost'
|
||||
revoke create view on test.* from test@localhost;
|
||||
show grants for test@localhost;
|
||||
Grants for test@localhost
|
||||
GRANT USAGE ON *.* TO 'test'@'localhost'
|
||||
drop user test@localhost;
|
||||
create database mysqltest;
|
||||
create table mysqltest.t1 (a int, b int);
|
||||
create table mysqltest.t2 (a int, b int);
|
||||
grant select on mysqltest.t1 to mysqltest_1@localhost;
|
||||
grant create view,select on test.* to mysqltest_1@localhost;
|
||||
create definer=root@localhost view v1 as select * from mysqltest.t1;
|
||||
ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation
|
||||
create view v1 as select * from mysqltest.t1;
|
||||
alter view v1 as select * from mysqltest.t1;
|
||||
ERROR 42000: DROP command denied to user 'mysqltest_1'@'localhost' for table 'v1'
|
||||
create or replace view v1 as select * from mysqltest.t1;
|
||||
ERROR 42000: DROP command denied to user 'mysqltest_1'@'localhost' for table 'v1'
|
||||
create view mysqltest.v2 as select * from mysqltest.t1;
|
||||
ERROR 42000: CREATE VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v2'
|
||||
create view v2 as select * from mysqltest.t2;
|
||||
ERROR 42000: ANY command denied to user 'mysqltest_1'@'localhost' for table 't2'
|
||||
show create view v1;
|
||||
View Create View character_set_client collation_connection
|
||||
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqltest_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `mysqltest`.`t1`.`a` AS `a`,`mysqltest`.`t1`.`b` AS `b` from `mysqltest`.`t1` latin1 latin1_swedish_ci
|
||||
grant create view,drop,select on test.* to mysqltest_1@localhost;
|
||||
use test;
|
||||
alter view v1 as select * from mysqltest.t1;
|
||||
create or replace view v1 as select * from mysqltest.t1;
|
||||
revoke all privileges on mysqltest.t1 from mysqltest_1@localhost;
|
||||
revoke all privileges on test.* from mysqltest_1@localhost;
|
||||
drop database mysqltest;
|
||||
drop view test.v1;
|
||||
create database mysqltest;
|
||||
create table mysqltest.t1 (a int, b int);
|
||||
create view mysqltest.v1 (c,d) as select a+1,b+1 from mysqltest.t1;
|
||||
grant select (c) on mysqltest.v1 to mysqltest_1@localhost;
|
||||
select c from mysqltest.v1;
|
||||
c
|
||||
select d from mysqltest.v1;
|
||||
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'd' in table 'v1'
|
||||
revoke all privileges on mysqltest.v1 from mysqltest_1@localhost;
|
||||
delete from mysql.user where user='mysqltest_1';
|
||||
drop database mysqltest;
|
||||
create database mysqltest;
|
||||
create table mysqltest.t1 (a int, b int);
|
||||
create algorithm=temptable view mysqltest.v1 (c,d) as select a+1,b+1 from mysqltest.t1;
|
||||
grant select (c) on mysqltest.v1 to mysqltest_1@localhost;
|
||||
select c from mysqltest.v1;
|
||||
c
|
||||
select d from mysqltest.v1;
|
||||
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'd' in table 'v1'
|
||||
revoke all privileges on mysqltest.v1 from mysqltest_1@localhost;
|
||||
delete from mysql.user where user='mysqltest_1';
|
||||
drop database mysqltest;
|
||||
create database mysqltest;
|
||||
create table mysqltest.t1 (a int, b int);
|
||||
create table mysqltest.t2 (a int, b int);
|
||||
create view mysqltest.v1 (c,d) as select a+1,b+1 from mysqltest.t1;
|
||||
create algorithm=temptable view mysqltest.v2 (c,d) as select a+1,b+1 from mysqltest.t1;
|
||||
create view mysqltest.v3 (c,d) as select a+1,b+1 from mysqltest.t2;
|
||||
create algorithm=temptable view mysqltest.v4 (c,d) as select a+1,b+1 from mysqltest.t2;
|
||||
grant select on mysqltest.v1 to mysqltest_1@localhost;
|
||||
grant select on mysqltest.v2 to mysqltest_1@localhost;
|
||||
grant select on mysqltest.v3 to mysqltest_1@localhost;
|
||||
grant select on mysqltest.v4 to mysqltest_1@localhost;
|
||||
select c from mysqltest.v1;
|
||||
c
|
||||
select c from mysqltest.v2;
|
||||
c
|
||||
select c from mysqltest.v3;
|
||||
c
|
||||
select c from mysqltest.v4;
|
||||
c
|
||||
show columns from mysqltest.v1;
|
||||
Field Type Null Key Default Extra
|
||||
c bigint(12) YES NULL
|
||||
d bigint(12) YES NULL
|
||||
show columns from mysqltest.v2;
|
||||
Field Type Null Key Default Extra
|
||||
c bigint(12) YES NULL
|
||||
d bigint(12) YES NULL
|
||||
explain select c from mysqltest.v1;
|
||||
ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
|
||||
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;
|
||||
ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
|
||||
show create view mysqltest.v2;
|
||||
ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v2'
|
||||
explain select c from mysqltest.v3;
|
||||
ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
|
||||
show create view mysqltest.v3;
|
||||
ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v3'
|
||||
explain select c from mysqltest.v4;
|
||||
ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
|
||||
show create view mysqltest.v4;
|
||||
ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v4'
|
||||
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 SIMPLE t1 ALL NULL NULL NULL NULL 0
|
||||
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;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 0
|
||||
show create view mysqltest.v2;
|
||||
ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v2'
|
||||
explain select c from mysqltest.v3;
|
||||
ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
|
||||
show create view mysqltest.v3;
|
||||
ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v3'
|
||||
explain select c from mysqltest.v4;
|
||||
ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
|
||||
show create view mysqltest.v4;
|
||||
ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v4'
|
||||
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 SIMPLE t1 ALL NULL NULL NULL NULL 0
|
||||
show create view mysqltest.v1;
|
||||
View Create View character_set_client collation_connection
|
||||
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` latin1 latin1_swedish_ci
|
||||
explain select c from mysqltest.v2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 0
|
||||
show create view mysqltest.v2;
|
||||
View Create View character_set_client collation_connection
|
||||
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` latin1 latin1_swedish_ci
|
||||
explain select c from mysqltest.v3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 0
|
||||
show create view mysqltest.v3;
|
||||
View Create View character_set_client collation_connection
|
||||
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` latin1 latin1_swedish_ci
|
||||
explain select c from mysqltest.v4;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
|
||||
2 DERIVED t2 ALL NULL NULL NULL NULL 0
|
||||
show create view mysqltest.v4;
|
||||
View Create View character_set_client collation_connection
|
||||
v4 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v4` AS select (`mysqltest`.`t2`.`a` + 1) AS `c`,(`mysqltest`.`t2`.`b` + 1) AS `d` from `mysqltest`.`t2` latin1 latin1_swedish_ci
|
||||
revoke all privileges on mysqltest.* from mysqltest_1@localhost;
|
||||
delete from mysql.user where user='mysqltest_1';
|
||||
drop database mysqltest;
|
||||
create database mysqltest;
|
||||
create table mysqltest.t1 (a int, b int, primary key(a));
|
||||
insert into mysqltest.t1 values (10,2), (20,3), (30,4), (40,5), (50,10);
|
||||
create table mysqltest.t2 (x int);
|
||||
insert into mysqltest.t2 values (3), (4), (5), (6);
|
||||
create view mysqltest.v1 (a,c) as select a, b+1 from mysqltest.t1;
|
||||
create view mysqltest.v2 (a,c) as select a, b from mysqltest.t1;
|
||||
create view mysqltest.v3 (a,c) as select a, b+1 from mysqltest.t1;
|
||||
grant update (a) on mysqltest.v2 to mysqltest_1@localhost;
|
||||
grant update on mysqltest.v1 to mysqltest_1@localhost;
|
||||
grant select on mysqltest.* to mysqltest_1@localhost;
|
||||
use mysqltest;
|
||||
update t2,v1 set v1.a=v1.a+v1.c where t2.x=v1.c;
|
||||
select * from t1 order by a;
|
||||
a b
|
||||
13 2
|
||||
24 3
|
||||
35 4
|
||||
46 5
|
||||
50 10
|
||||
update v1 set a=a+c;
|
||||
select * from t1 order by a;
|
||||
a b
|
||||
16 2
|
||||
28 3
|
||||
40 4
|
||||
52 5
|
||||
61 10
|
||||
update t2,v2 set v2.a=v2.a+v2.c where t2.x=v2.c;
|
||||
select * from t1 order by a;
|
||||
a b
|
||||
16 2
|
||||
31 3
|
||||
44 4
|
||||
57 5
|
||||
61 10
|
||||
update v2 set a=a+c;
|
||||
select * from t1 order by a;
|
||||
a b
|
||||
18 2
|
||||
34 3
|
||||
48 4
|
||||
62 5
|
||||
71 10
|
||||
update t2,v2 set v2.c=v2.a+v2.c where t2.x=v2.c;
|
||||
ERROR 42000: UPDATE command denied to user 'mysqltest_1'@'localhost' for column 'c' in table 'v2'
|
||||
update v2 set c=a+c;
|
||||
ERROR 42000: UPDATE command denied to user 'mysqltest_1'@'localhost' for column 'c' in table 'v2'
|
||||
update t2,v3 set v3.a=v3.a+v3.c where t2.x=v3.c;
|
||||
ERROR 42000: UPDATE command denied to user 'mysqltest_1'@'localhost' for table 'v3'
|
||||
update v3 set a=a+c;
|
||||
ERROR 42000: UPDATE command denied to user 'mysqltest_1'@'localhost' for table 'v3'
|
||||
use test;
|
||||
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost;
|
||||
drop database mysqltest;
|
||||
create database mysqltest;
|
||||
create table mysqltest.t1 (a int, b int, primary key(a));
|
||||
insert into mysqltest.t1 values (1,2), (2,3), (3,4), (4,5), (5,10);
|
||||
create table mysqltest.t2 (x int);
|
||||
insert into mysqltest.t2 values (3), (4), (5), (6);
|
||||
create view mysqltest.v1 (a,c) as select a, b+1 from mysqltest.t1;
|
||||
create view mysqltest.v2 (a,c) as select a, b+1 from mysqltest.t1;
|
||||
grant delete on mysqltest.v1 to mysqltest_1@localhost;
|
||||
grant select on mysqltest.* to mysqltest_1@localhost;
|
||||
use mysqltest;
|
||||
delete from v1 where c < 4;
|
||||
select * from t1;
|
||||
a b
|
||||
2 3
|
||||
3 4
|
||||
4 5
|
||||
5 10
|
||||
delete v1 from t2,v1 where t2.x=v1.c;
|
||||
select * from t1;
|
||||
a b
|
||||
5 10
|
||||
delete v2 from t2,v2 where t2.x=v2.c;
|
||||
ERROR 42000: DELETE command denied to user 'mysqltest_1'@'localhost' for table 'v2'
|
||||
delete from v2 where c < 4;
|
||||
ERROR 42000: DELETE command denied to user 'mysqltest_1'@'localhost' for table 'v2'
|
||||
use test;
|
||||
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost;
|
||||
drop database mysqltest;
|
||||
create database mysqltest;
|
||||
create table mysqltest.t1 (a int, b int, primary key(a));
|
||||
insert into mysqltest.t1 values (1,2), (2,3);
|
||||
create table mysqltest.t2 (x int, y int);
|
||||
insert into mysqltest.t2 values (3,4);
|
||||
create view mysqltest.v1 (a,c) as select a, b from mysqltest.t1;
|
||||
create view mysqltest.v2 (a,c) as select a, b from mysqltest.t1;
|
||||
grant insert on mysqltest.v1 to mysqltest_1@localhost;
|
||||
grant select on mysqltest.* to mysqltest_1@localhost;
|
||||
use mysqltest;
|
||||
insert into v1 values (5,6);
|
||||
select * from t1;
|
||||
a b
|
||||
1 2
|
||||
2 3
|
||||
5 6
|
||||
insert into v1 select x,y from t2;
|
||||
select * from t1;
|
||||
a b
|
||||
1 2
|
||||
2 3
|
||||
5 6
|
||||
3 4
|
||||
insert into v2 values (5,6);
|
||||
ERROR 42000: INSERT command denied to user 'mysqltest_1'@'localhost' for table 'v2'
|
||||
insert into v2 select x,y from t2;
|
||||
ERROR 42000: INSERT command denied to user 'mysqltest_1'@'localhost' for table 'v2'
|
||||
use test;
|
||||
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost;
|
||||
drop database mysqltest;
|
||||
create database mysqltest;
|
||||
create table mysqltest.t1 (a int, b int);
|
||||
create table mysqltest.t2 (a int, b int);
|
||||
grant update on mysqltest.t1 to mysqltest_1@localhost;
|
||||
grant update(b) on mysqltest.t2 to mysqltest_1@localhost;
|
||||
grant create view,update on test.* to mysqltest_1@localhost;
|
||||
create view v1 as select * from mysqltest.t1;
|
||||
create view v2 as select b from mysqltest.t2;
|
||||
create view mysqltest.v1 as select * from mysqltest.t1;
|
||||
ERROR 42000: CREATE VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v1'
|
||||
create view v3 as select a from mysqltest.t2;
|
||||
ERROR 42000: ANY command denied to user 'mysqltest_1'@'localhost' for column 'a' in table 't2'
|
||||
create table mysqltest.v3 (b int);
|
||||
grant create view on mysqltest.v3 to mysqltest_1@localhost;
|
||||
drop table mysqltest.v3;
|
||||
create view mysqltest.v3 as select b from mysqltest.t2;
|
||||
grant create view, update on mysqltest.v3 to mysqltest_1@localhost;
|
||||
drop view mysqltest.v3;
|
||||
create view mysqltest.v3 as select b from mysqltest.t2;
|
||||
create view v4 as select b+1 from mysqltest.t2;
|
||||
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 't2'
|
||||
grant create view,update,select on test.* to mysqltest_1@localhost;
|
||||
create view v4 as select b+1 from mysqltest.t2;
|
||||
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 't2'
|
||||
grant update,select(b) on mysqltest.t2 to mysqltest_1@localhost;
|
||||
create view v4 as select b+1 from mysqltest.t2;
|
||||
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost;
|
||||
drop database mysqltest;
|
||||
drop view v1,v2,v4;
|
||||
create database mysqltest;
|
||||
create table mysqltest.t1 (a int);
|
||||
grant all privileges on mysqltest.* to mysqltest_1@localhost;
|
||||
use mysqltest;
|
||||
create view v1 as select * from t1;
|
||||
use test;
|
||||
revoke all privileges on mysqltest.* from mysqltest_1@localhost;
|
||||
drop database mysqltest;
|
||||
create database mysqltest;
|
||||
create table mysqltest.t1 (a int, b int);
|
||||
grant select on mysqltest.t1 to mysqltest_1@localhost;
|
||||
grant create view,select on test.* to mysqltest_1@localhost;
|
||||
create view v1 as select * from mysqltest.t1;
|
||||
show create view v1;
|
||||
View Create View character_set_client collation_connection
|
||||
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqltest_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `mysqltest`.`t1`.`a` AS `a`,`mysqltest`.`t1`.`b` AS `b` from `mysqltest`.`t1` latin1 latin1_swedish_ci
|
||||
revoke select on mysqltest.t1 from mysqltest_1@localhost;
|
||||
select * from v1;
|
||||
ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
|
||||
grant select on mysqltest.t1 to mysqltest_1@localhost;
|
||||
select * from v1;
|
||||
a b
|
||||
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost;
|
||||
drop view v1;
|
||||
drop database mysqltest;
|
||||
create database mysqltest;
|
||||
use mysqltest;
|
||||
create table t1 (a int);
|
||||
insert into t1 values (1);
|
||||
create table t2 (s1 int);
|
||||
drop function if exists f2;
|
||||
create function f2 () returns int begin declare v int; select s1 from t2
|
||||
into v; return v; end//
|
||||
create algorithm=TEMPTABLE view v1 as select f2() from t1;
|
||||
create algorithm=MERGE view v2 as select f2() from t1;
|
||||
create algorithm=TEMPTABLE SQL SECURITY INVOKER view v3 as select f2() from t1;
|
||||
create algorithm=MERGE SQL SECURITY INVOKER view v4 as select f2() from t1;
|
||||
create SQL SECURITY INVOKER view v5 as select * from v4;
|
||||
grant select on v1 to mysqltest_1@localhost;
|
||||
grant select on v2 to mysqltest_1@localhost;
|
||||
grant select on v3 to mysqltest_1@localhost;
|
||||
grant select on v4 to mysqltest_1@localhost;
|
||||
grant select on v5 to mysqltest_1@localhost;
|
||||
use mysqltest;
|
||||
select * from v1;
|
||||
f2()
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 1329 No data - zero rows fetched, selected, or processed
|
||||
select * from v2;
|
||||
f2()
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 1329 No data - zero rows fetched, selected, or processed
|
||||
select * from v3;
|
||||
ERROR HY000: View 'mysqltest.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
|
||||
select * from v4;
|
||||
ERROR HY000: View 'mysqltest.v4' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
|
||||
select * from v5;
|
||||
ERROR HY000: View 'mysqltest.v5' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
|
||||
use test;
|
||||
drop view v1, v2, v3, v4, v5;
|
||||
drop function f2;
|
||||
drop table t1, t2;
|
||||
use test;
|
||||
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost;
|
||||
drop database mysqltest;
|
||||
create database mysqltest;
|
||||
use mysqltest;
|
||||
create table t1 (a int);
|
||||
insert into t1 values (1);
|
||||
create table t2 (s1 int);
|
||||
drop function if exists f2;
|
||||
create function f2 () returns int begin declare v int; select s1 from t2
|
||||
into v; return v; end//
|
||||
grant select on t1 to mysqltest_1@localhost;
|
||||
grant execute on function f2 to mysqltest_1@localhost;
|
||||
grant create view on mysqltest.* to mysqltest_1@localhost;
|
||||
use mysqltest;
|
||||
create algorithm=TEMPTABLE view v1 as select f2() from t1;
|
||||
create algorithm=MERGE view v2 as select f2() from t1;
|
||||
create algorithm=TEMPTABLE SQL SECURITY INVOKER view v3 as select f2() from t1;
|
||||
create algorithm=MERGE SQL SECURITY INVOKER view v4 as select f2() from t1;
|
||||
use test;
|
||||
create view v5 as select * from v1;
|
||||
revoke execute on function f2 from mysqltest_1@localhost;
|
||||
select * from v1;
|
||||
ERROR HY000: View 'mysqltest.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
|
||||
select * from v2;
|
||||
ERROR HY000: View 'mysqltest.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
|
||||
select * from v3;
|
||||
f2()
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 1329 No data - zero rows fetched, selected, or processed
|
||||
select * from v4;
|
||||
f2()
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 1329 No data - zero rows fetched, selected, or processed
|
||||
select * from v5;
|
||||
ERROR HY000: View 'mysqltest.v5' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
|
||||
drop view v1, v2, v3, v4, v5;
|
||||
drop function f2;
|
||||
drop table t1, t2;
|
||||
use test;
|
||||
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost;
|
||||
drop database mysqltest;
|
||||
create database mysqltest;
|
||||
use mysqltest;
|
||||
create table t1 (a int);
|
||||
create table v1 (a int);
|
||||
insert into t1 values (1);
|
||||
grant select on t1 to mysqltest_1@localhost;
|
||||
grant select on v1 to mysqltest_1@localhost;
|
||||
grant create view on mysqltest.* to mysqltest_1@localhost;
|
||||
drop table v1;
|
||||
use mysqltest;
|
||||
create algorithm=TEMPTABLE view v1 as select *, a as b from t1;
|
||||
create algorithm=MERGE view v2 as select *, a as b from t1;
|
||||
create algorithm=TEMPTABLE SQL SECURITY INVOKER view v3 as select *, a as b from t1;
|
||||
create algorithm=MERGE SQL SECURITY INVOKER view v4 as select *, a as b from t1;
|
||||
create view v5 as select * from v1;
|
||||
use test;
|
||||
revoke select on t1 from mysqltest_1@localhost;
|
||||
select * from v1;
|
||||
ERROR HY000: View 'mysqltest.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
|
||||
select * from v2;
|
||||
ERROR HY000: View 'mysqltest.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
|
||||
select * from v3;
|
||||
a b
|
||||
1 1
|
||||
select * from v4;
|
||||
a b
|
||||
1 1
|
||||
select * from v5;
|
||||
ERROR HY000: View 'mysqltest.v5' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
|
||||
drop table t1;
|
||||
use test;
|
||||
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost;
|
||||
drop database mysqltest;
|
||||
create database mysqltest;
|
||||
use mysqltest;
|
||||
create table t1 (a int);
|
||||
insert into t1 values (1);
|
||||
create algorithm=TEMPTABLE view v1 as select *, a as b from t1;
|
||||
create algorithm=MERGE view v2 as select *, a as b from t1;
|
||||
create algorithm=TEMPTABLE SQL SECURITY INVOKER view v3 as select *, a as b from t1;
|
||||
create algorithm=MERGE SQL SECURITY INVOKER view v4 as select *, a as b from t1;
|
||||
create SQL SECURITY INVOKER view v5 as select * from v4;
|
||||
grant select on v1 to mysqltest_1@localhost;
|
||||
grant select on v2 to mysqltest_1@localhost;
|
||||
grant select on v3 to mysqltest_1@localhost;
|
||||
grant select on v4 to mysqltest_1@localhost;
|
||||
grant select on v5 to mysqltest_1@localhost;
|
||||
use mysqltest;
|
||||
select * from v1;
|
||||
a b
|
||||
1 1
|
||||
select * from v2;
|
||||
a b
|
||||
1 1
|
||||
select * from v3;
|
||||
ERROR HY000: View 'mysqltest.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
|
||||
select * from v4;
|
||||
ERROR HY000: View 'mysqltest.v4' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
|
||||
select * from v5;
|
||||
ERROR HY000: View 'mysqltest.v5' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
|
||||
use test;
|
||||
drop view v1, v2, v3, v4, v5;
|
||||
drop table t1;
|
||||
use test;
|
||||
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost;
|
||||
drop database mysqltest;
|
||||
drop view if exists v1;
|
||||
drop table if exists t1;
|
||||
create table t1 as select * from mysql.user where user='';
|
||||
delete from mysql.user where user='';
|
||||
flush privileges;
|
||||
grant all on test.* to 'test14256'@'%';
|
||||
use test;
|
||||
create view v1 as select 42;
|
||||
show create view v1;
|
||||
View Create View character_set_client collation_connection
|
||||
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`test14256`@`%` SQL SECURITY DEFINER VIEW `v1` AS select 42 AS `42` latin1 latin1_swedish_ci
|
||||
select definer into @v1def1 from information_schema.views
|
||||
where table_schema = 'test' and table_name='v1';
|
||||
drop view v1;
|
||||
create definer=`test14256`@`%` view v1 as select 42;
|
||||
show create view v1;
|
||||
View Create View character_set_client collation_connection
|
||||
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`test14256`@`%` SQL SECURITY DEFINER VIEW `v1` AS select 42 AS `42` latin1 latin1_swedish_ci
|
||||
select definer into @v1def2 from information_schema.views
|
||||
where table_schema = 'test' and table_name='v1';
|
||||
drop view v1;
|
||||
select @v1def1, @v1def2, @v1def1=@v1def2;
|
||||
@v1def1 @v1def2 @v1def1=@v1def2
|
||||
test14256@% test14256@% 1
|
||||
drop user test14256;
|
||||
insert into mysql.user select * from t1;
|
||||
flush privileges;
|
||||
drop table t1;
|
||||
create database mysqltest;
|
||||
use mysqltest;
|
||||
CREATE TABLE t1 (i INT);
|
||||
CREATE VIEW v1 AS SELECT * FROM t1;
|
||||
SHOW CREATE VIEW v1;
|
||||
View Create View character_set_client collation_connection
|
||||
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci
|
||||
GRANT SELECT, LOCK TABLES ON mysqltest.* TO mysqltest_1@localhost;
|
||||
use mysqltest;
|
||||
LOCK TABLES v1 READ;
|
||||
SHOW CREATE TABLE v1;
|
||||
ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v1'
|
||||
UNLOCK TABLES;
|
||||
use test;
|
||||
use test;
|
||||
drop user mysqltest_1@localhost;
|
||||
drop database mysqltest;
|
||||
create definer=some_user@`` sql security invoker view v1 as select 1;
|
||||
Warnings:
|
||||
Note 1449 The user specified as a definer ('some_user'@'') does not exist
|
||||
create definer=some_user@localhost sql security invoker view v2 as select 1;
|
||||
Warnings:
|
||||
Note 1449 The user specified as a definer ('some_user'@'localhost') does not exist
|
||||
show create view v1;
|
||||
View Create View character_set_client collation_connection
|
||||
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`some_user`@`` SQL SECURITY INVOKER VIEW `v1` AS select 1 AS `1` latin1 latin1_swedish_ci
|
||||
show create view v2;
|
||||
View Create View character_set_client collation_connection
|
||||
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`some_user`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select 1 AS `1` latin1 latin1_swedish_ci
|
||||
drop view v1;
|
||||
drop view v2;
|
||||
CREATE DATABASE mysqltest1;
|
||||
CREATE USER readonly@localhost;
|
||||
CREATE TABLE mysqltest1.t1 (x INT);
|
||||
INSERT INTO mysqltest1.t1 VALUES (1), (2);
|
||||
CREATE SQL SECURITY INVOKER VIEW mysqltest1.v_t1 AS SELECT * FROM mysqltest1.t1;
|
||||
CREATE SQL SECURITY DEFINER VIEW mysqltest1.v_ts AS SELECT * FROM mysqltest1.t1;
|
||||
CREATE SQL SECURITY DEFINER VIEW mysqltest1.v_ti AS SELECT * FROM mysqltest1.t1;
|
||||
CREATE SQL SECURITY DEFINER VIEW mysqltest1.v_tu AS SELECT * FROM mysqltest1.t1;
|
||||
CREATE SQL SECURITY DEFINER VIEW mysqltest1.v_tus AS SELECT * FROM mysqltest1.t1;
|
||||
CREATE SQL SECURITY DEFINER VIEW mysqltest1.v_td AS SELECT * FROM mysqltest1.t1;
|
||||
CREATE SQL SECURITY DEFINER VIEW mysqltest1.v_tds AS SELECT * FROM mysqltest1.t1;
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE ON mysqltest1.v_t1 TO readonly@localhost;
|
||||
GRANT SELECT ON mysqltest1.v_ts TO readonly@localhost;
|
||||
GRANT INSERT ON mysqltest1.v_ti TO readonly@localhost;
|
||||
GRANT UPDATE ON mysqltest1.v_tu TO readonly@localhost;
|
||||
GRANT UPDATE,SELECT ON mysqltest1.v_tus TO readonly@localhost;
|
||||
GRANT DELETE ON mysqltest1.v_td TO readonly@localhost;
|
||||
GRANT DELETE,SELECT ON mysqltest1.v_tds TO readonly@localhost;
|
||||
SELECT * FROM mysqltest1.v_t1;
|
||||
ERROR HY000: View 'mysqltest1.v_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
|
||||
INSERT INTO mysqltest1.v_t1 VALUES(4);
|
||||
ERROR HY000: View 'mysqltest1.v_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
|
||||
DELETE FROM mysqltest1.v_t1 WHERE x = 1;
|
||||
ERROR HY000: View 'mysqltest1.v_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
|
||||
UPDATE mysqltest1.v_t1 SET x = 3 WHERE x = 2;
|
||||
ERROR HY000: View 'mysqltest1.v_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
|
||||
UPDATE mysqltest1.v_t1 SET x = 3;
|
||||
ERROR HY000: View 'mysqltest1.v_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
|
||||
DELETE FROM mysqltest1.v_t1;
|
||||
ERROR HY000: View 'mysqltest1.v_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
|
||||
SELECT 1 FROM mysqltest1.v_t1;
|
||||
ERROR HY000: View 'mysqltest1.v_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
|
||||
SELECT * FROM mysqltest1.t1;
|
||||
ERROR 42000: SELECT command denied to user 'readonly'@'localhost' for table 't1'
|
||||
SELECT * FROM mysqltest1.v_ts;
|
||||
x
|
||||
1
|
||||
2
|
||||
SELECT * FROM mysqltest1.v_ts, mysqltest1.t1 WHERE mysqltest1.t1.x = mysqltest1.v_ts.x;
|
||||
ERROR 42000: SELECT command denied to user 'readonly'@'localhost' for table 't1'
|
||||
SELECT * FROM mysqltest1.v_ti;
|
||||
ERROR 42000: SELECT command denied to user 'readonly'@'localhost' for table 'v_ti'
|
||||
INSERT INTO mysqltest1.v_ts VALUES (100);
|
||||
ERROR 42000: INSERT command denied to user 'readonly'@'localhost' for table 'v_ts'
|
||||
INSERT INTO mysqltest1.v_ti VALUES (100);
|
||||
UPDATE mysqltest1.v_ts SET x= 200 WHERE x = 100;
|
||||
ERROR 42000: UPDATE command denied to user 'readonly'@'localhost' for table 'v_ts'
|
||||
UPDATE mysqltest1.v_ts SET x= 200;
|
||||
ERROR 42000: UPDATE command denied to user 'readonly'@'localhost' for table 'v_ts'
|
||||
UPDATE mysqltest1.v_tu SET x= 200 WHERE x = 100;
|
||||
UPDATE mysqltest1.v_tus SET x= 200 WHERE x = 100;
|
||||
UPDATE mysqltest1.v_tu SET x= 200;
|
||||
DELETE FROM mysqltest1.v_ts WHERE x= 200;
|
||||
ERROR 42000: DELETE command denied to user 'readonly'@'localhost' for table 'v_ts'
|
||||
DELETE FROM mysqltest1.v_ts;
|
||||
ERROR 42000: DELETE command denied to user 'readonly'@'localhost' for table 'v_ts'
|
||||
DELETE FROM mysqltest1.v_td WHERE x= 200;
|
||||
ERROR 42000: SELECT command denied to user 'readonly'@'localhost' for column 'x' in table 'v_td'
|
||||
DELETE FROM mysqltest1.v_tds WHERE x= 200;
|
||||
DELETE FROM mysqltest1.v_td;
|
||||
DROP VIEW mysqltest1.v_tds;
|
||||
DROP VIEW mysqltest1.v_td;
|
||||
DROP VIEW mysqltest1.v_tus;
|
||||
DROP VIEW mysqltest1.v_tu;
|
||||
DROP VIEW mysqltest1.v_ti;
|
||||
DROP VIEW mysqltest1.v_ts;
|
||||
DROP VIEW mysqltest1.v_t1;
|
||||
DROP TABLE mysqltest1.t1;
|
||||
DROP USER readonly@localhost;
|
||||
DROP DATABASE mysqltest1;
|
||||
CREATE TABLE t1 (a INT PRIMARY KEY);
|
||||
INSERT INTO t1 VALUES (1), (2), (3);
|
||||
CREATE DEFINER = 'no-such-user'@localhost VIEW v AS SELECT a from t1;
|
||||
Warnings:
|
||||
Note 1449 The user specified as a definer ('no-such-user'@'localhost') does not exist
|
||||
SHOW CREATE VIEW v;
|
||||
View Create View character_set_client collation_connection
|
||||
v CREATE ALGORITHM=UNDEFINED DEFINER=`no-such-user`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select `test`.`t1`.`a` AS `a` from `t1` latin1 latin1_swedish_ci
|
||||
Warnings:
|
||||
Note 1449 The user specified as a definer ('no-such-user'@'localhost') does not exist
|
||||
SELECT * FROM v;
|
||||
ERROR HY000: The user specified as a definer ('no-such-user'@'localhost') does not exist
|
||||
DROP VIEW v;
|
||||
DROP TABLE t1;
|
||||
USE test;
|
||||
CREATE USER mysqltest_db1@localhost identified by 'PWD';
|
||||
GRANT ALL ON mysqltest_db1.* TO mysqltest_db1@localhost WITH GRANT OPTION;
|
||||
CREATE SCHEMA mysqltest_db1 ;
|
||||
USE mysqltest_db1 ;
|
||||
CREATE TABLE t1 (f1 INTEGER);
|
||||
CREATE VIEW view1 AS
|
||||
SELECT * FROM t1;
|
||||
SHOW CREATE VIEW view1;
|
||||
View Create View character_set_client collation_connection
|
||||
view1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqltest_db1`@`localhost` SQL SECURITY DEFINER VIEW `view1` AS select `t1`.`f1` AS `f1` from `t1` latin1 latin1_swedish_ci
|
||||
CREATE VIEW view2 AS
|
||||
SELECT * FROM view1;
|
||||
# Here comes a suspicious warning
|
||||
SHOW CREATE VIEW view2;
|
||||
View Create View character_set_client collation_connection
|
||||
view2 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqltest_db1`@`localhost` SQL SECURITY DEFINER VIEW `view2` AS select `view1`.`f1` AS `f1` from `view1` latin1 latin1_swedish_ci
|
||||
# But the view view2 is usable
|
||||
SELECT * FROM view2;
|
||||
f1
|
||||
CREATE VIEW view3 AS
|
||||
SELECT * FROM view2;
|
||||
SELECT * from view3;
|
||||
f1
|
||||
DROP VIEW mysqltest_db1.view3;
|
||||
DROP VIEW mysqltest_db1.view2;
|
||||
DROP VIEW mysqltest_db1.view1;
|
||||
DROP TABLE mysqltest_db1.t1;
|
||||
DROP SCHEMA mysqltest_db1;
|
||||
DROP USER mysqltest_db1@localhost;
|
||||
CREATE DATABASE test1;
|
||||
CREATE DATABASE test2;
|
||||
CREATE TABLE test1.t0 (a VARCHAR(20)) engine=myisam;
|
||||
CREATE TABLE test2.t1 (a VARCHAR(20));
|
||||
CREATE VIEW test2.t3 AS SELECT * FROM test1.t0;
|
||||
CREATE OR REPLACE VIEW test.v1 AS
|
||||
SELECT ta.a AS col1, tb.a AS col2 FROM test2.t3 ta, test2.t1 tb;
|
||||
DROP VIEW test.v1;
|
||||
DROP VIEW test2.t3;
|
||||
DROP TABLE test2.t1, test1.t0;
|
||||
DROP DATABASE test2;
|
||||
DROP DATABASE test1;
|
||||
DROP VIEW IF EXISTS v1;
|
||||
DROP VIEW IF EXISTS v2;
|
||||
DROP VIEW IF EXISTS v3;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP FUNCTION IF EXISTS f2;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
CREATE SQL SECURITY DEFINER VIEW v1 AS SELECT CURRENT_USER() AS cu;
|
||||
CREATE FUNCTION f1() RETURNS VARCHAR(77) SQL SECURITY INVOKER
|
||||
RETURN CURRENT_USER();
|
||||
CREATE SQL SECURITY DEFINER VIEW v2 AS SELECT f1() AS cu;
|
||||
CREATE PROCEDURE p1(OUT cu VARCHAR(77)) SQL SECURITY INVOKER
|
||||
SET cu= CURRENT_USER();
|
||||
CREATE FUNCTION f2() RETURNS VARCHAR(77) SQL SECURITY INVOKER
|
||||
BEGIN
|
||||
DECLARE cu VARCHAR(77);
|
||||
CALL p1(cu);
|
||||
RETURN cu;
|
||||
END|
|
||||
CREATE SQL SECURITY DEFINER VIEW v3 AS SELECT f2() AS cu;
|
||||
CREATE USER mysqltest_u1@localhost;
|
||||
GRANT ALL ON test.* TO mysqltest_u1@localhost;
|
||||
|
||||
The following tests should all return 1.
|
||||
|
||||
SELECT CURRENT_USER() = 'mysqltest_u1@localhost';
|
||||
CURRENT_USER() = 'mysqltest_u1@localhost'
|
||||
1
|
||||
SELECT f1() = 'mysqltest_u1@localhost';
|
||||
f1() = 'mysqltest_u1@localhost'
|
||||
1
|
||||
CALL p1(@cu);
|
||||
SELECT @cu = 'mysqltest_u1@localhost';
|
||||
@cu = 'mysqltest_u1@localhost'
|
||||
1
|
||||
SELECT f2() = 'mysqltest_u1@localhost';
|
||||
f2() = 'mysqltest_u1@localhost'
|
||||
1
|
||||
SELECT cu = 'root@localhost' FROM v1;
|
||||
cu = 'root@localhost'
|
||||
1
|
||||
SELECT cu = 'root@localhost' FROM v2;
|
||||
cu = 'root@localhost'
|
||||
1
|
||||
SELECT cu = 'root@localhost' FROM v3;
|
||||
cu = 'root@localhost'
|
||||
1
|
||||
DROP VIEW v3;
|
||||
DROP FUNCTION f2;
|
||||
DROP PROCEDURE p1;
|
||||
DROP FUNCTION f1;
|
||||
DROP VIEW v2;
|
||||
DROP VIEW v1;
|
||||
DROP USER mysqltest_u1@localhost;
|
||||
CREATE DATABASE db17254;
|
||||
USE db17254;
|
||||
CREATE TABLE t1 (f1 INT);
|
||||
INSERT INTO t1 VALUES (10),(20);
|
||||
CREATE USER def_17254@localhost;
|
||||
GRANT SELECT ON db17254.* TO def_17254@localhost;
|
||||
CREATE USER inv_17254@localhost;
|
||||
GRANT SELECT ON db17254.t1 TO inv_17254@localhost;
|
||||
GRANT CREATE VIEW ON db17254.* TO def_17254@localhost;
|
||||
CREATE VIEW v1 AS SELECT * FROM t1;
|
||||
DROP USER def_17254@localhost;
|
||||
for a user
|
||||
SELECT * FROM v1;
|
||||
ERROR 42000: SELECT command denied to user 'inv_17254'@'localhost' for table 'v1'
|
||||
for a superuser
|
||||
SELECT * FROM v1;
|
||||
ERROR HY000: The user specified as a definer ('def_17254'@'localhost') does not exist
|
||||
DROP USER inv_17254@localhost;
|
||||
DROP DATABASE db17254;
|
||||
DROP DATABASE IF EXISTS mysqltest_db1;
|
||||
DROP DATABASE IF EXISTS mysqltest_db2;
|
||||
DROP USER mysqltest_u1;
|
||||
DROP USER mysqltest_u2;
|
||||
CREATE USER mysqltest_u1@localhost;
|
||||
CREATE USER mysqltest_u2@localhost;
|
||||
CREATE DATABASE mysqltest_db1;
|
||||
CREATE DATABASE mysqltest_db2;
|
||||
GRANT ALL ON mysqltest_db1.* TO mysqltest_u1@localhost WITH GRANT OPTION;
|
||||
GRANT ALL ON mysqltest_db2.* TO mysqltest_u2@localhost;
|
||||
CREATE TABLE t1 (i INT);
|
||||
INSERT INTO t1 VALUES (1);
|
||||
CREATE VIEW v1 AS SELECT i FROM t1 WHERE 1 IN (SELECT * FROM t1);
|
||||
CREATE TABLE t2 (s CHAR(7));
|
||||
INSERT INTO t2 VALUES ('public');
|
||||
GRANT SELECT ON v1 TO mysqltest_u2@localhost;
|
||||
GRANT SELECT ON t2 TO mysqltest_u2@localhost;
|
||||
SELECT * FROM mysqltest_db1.v1, mysqltest_db1.t2;
|
||||
i s
|
||||
1 public
|
||||
PREPARE stmt1 FROM "SELECT * FROM mysqltest_db1.t2";
|
||||
EXECUTE stmt1;
|
||||
s
|
||||
public
|
||||
PREPARE stmt2 FROM "SELECT * FROM mysqltest_db1.v1, mysqltest_db1.t2";
|
||||
EXECUTE stmt2;
|
||||
i s
|
||||
1 public
|
||||
REVOKE SELECT ON t2 FROM mysqltest_u2@localhost;
|
||||
UPDATE t2 SET s = 'private' WHERE s = 'public';
|
||||
SELECT * FROM mysqltest_db1.v1, mysqltest_db1.t2;
|
||||
ERROR 42000: SELECT command denied to user 'mysqltest_u2'@'localhost' for table 't2'
|
||||
EXECUTE stmt1;
|
||||
ERROR 42000: SELECT command denied to user 'mysqltest_u2'@'localhost' for table 't2'
|
||||
EXECUTE stmt2;
|
||||
ERROR 42000: SELECT command denied to user 'mysqltest_u2'@'localhost' for table 't2'
|
||||
REVOKE ALL ON mysqltest_db1.* FROM mysqltest_u1@localhost;
|
||||
REVOKE ALL ON mysqltest_db2.* FROM mysqltest_u2@localhost;
|
||||
DROP DATABASE mysqltest_db1;
|
||||
DROP DATABASE mysqltest_db2;
|
||||
DROP USER mysqltest_u1@localhost;
|
||||
DROP USER mysqltest_u2@localhost;
|
||||
CREATE DATABASE db26813;
|
||||
USE db26813;
|
||||
CREATE TABLE t1(f1 INT, f2 INT);
|
||||
CREATE VIEW v1 AS SELECT f1 FROM t1;
|
||||
CREATE VIEW v2 AS SELECT f1 FROM t1;
|
||||
CREATE VIEW v3 AS SELECT f1 FROM t1;
|
||||
CREATE USER u26813@localhost;
|
||||
GRANT DROP ON db26813.v1 TO u26813@localhost;
|
||||
GRANT CREATE VIEW ON db26813.v2 TO u26813@localhost;
|
||||
GRANT DROP, CREATE VIEW ON db26813.v3 TO u26813@localhost;
|
||||
GRANT SELECT ON db26813.t1 TO u26813@localhost;
|
||||
ALTER VIEW v1 AS SELECT f2 FROM t1;
|
||||
ERROR 42000: CREATE VIEW command denied to user 'u26813'@'localhost' for table 'v1'
|
||||
ALTER VIEW v2 AS SELECT f2 FROM t1;
|
||||
ERROR 42000: DROP command denied to user 'u26813'@'localhost' for table 'v2'
|
||||
ALTER VIEW v3 AS SELECT f2 FROM t1;
|
||||
ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation
|
||||
SHOW CREATE VIEW v3;
|
||||
View Create View character_set_client collation_connection
|
||||
v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`f1` AS `f1` from `t1` latin1 latin1_swedish_ci
|
||||
DROP USER u26813@localhost;
|
||||
DROP DATABASE db26813;
|
||||
#
|
||||
# Bug#29908 A user can gain additional access through the ALTER VIEW.
|
||||
#
|
||||
CREATE DATABASE mysqltest_29908;
|
||||
USE mysqltest_29908;
|
||||
CREATE TABLE t1(f1 INT, f2 INT);
|
||||
CREATE USER u29908_1@localhost;
|
||||
CREATE DEFINER = u29908_1@localhost VIEW v1 AS SELECT f1 FROM t1;
|
||||
CREATE DEFINER = u29908_1@localhost SQL SECURITY INVOKER VIEW v2 AS
|
||||
SELECT f1 FROM t1;
|
||||
GRANT SELECT, DROP, CREATE VIEW, SHOW VIEW ON mysqltest_29908.v1 TO u29908_1@localhost;
|
||||
GRANT SELECT, DROP, CREATE VIEW, SHOW VIEW ON mysqltest_29908.v2 TO u29908_1@localhost;
|
||||
GRANT SELECT ON mysqltest_29908.t1 TO u29908_1@localhost;
|
||||
CREATE USER u29908_2@localhost;
|
||||
GRANT SELECT, DROP, CREATE VIEW ON mysqltest_29908.v1 TO u29908_2@localhost;
|
||||
GRANT SELECT, DROP, CREATE VIEW, SHOW VIEW ON mysqltest_29908.v2 TO u29908_2@localhost;
|
||||
GRANT SELECT ON mysqltest_29908.t1 TO u29908_2@localhost;
|
||||
ALTER VIEW v1 AS SELECT f2 FROM t1;
|
||||
ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation
|
||||
ALTER VIEW v2 AS SELECT f2 FROM t1;
|
||||
ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation
|
||||
SHOW CREATE VIEW v2;
|
||||
View Create View character_set_client collation_connection
|
||||
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f1` AS `f1` from `t1` latin1 latin1_swedish_ci
|
||||
ALTER VIEW v1 AS SELECT f2 FROM t1;
|
||||
SHOW CREATE VIEW v1;
|
||||
View Create View character_set_client collation_connection
|
||||
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`f2` AS `f2` from `t1` latin1 latin1_swedish_ci
|
||||
ALTER VIEW v2 AS SELECT f2 FROM t1;
|
||||
SHOW CREATE VIEW v2;
|
||||
View Create View character_set_client collation_connection
|
||||
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f2` AS `f2` from `t1` latin1 latin1_swedish_ci
|
||||
ALTER VIEW v1 AS SELECT f1 FROM t1;
|
||||
SHOW CREATE VIEW v1;
|
||||
View Create View character_set_client collation_connection
|
||||
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`f1` AS `f1` from `t1` latin1 latin1_swedish_ci
|
||||
ALTER VIEW v2 AS SELECT f1 FROM t1;
|
||||
SHOW CREATE VIEW v2;
|
||||
View Create View character_set_client collation_connection
|
||||
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f1` AS `f1` from `t1` latin1 latin1_swedish_ci
|
||||
DROP USER u29908_1@localhost;
|
||||
DROP USER u29908_2@localhost;
|
||||
DROP DATABASE mysqltest_29908;
|
||||
#######################################################################
|
||||
DROP DATABASE IF EXISTS mysqltest1;
|
||||
DROP DATABASE IF EXISTS mysqltest2;
|
||||
CREATE DATABASE mysqltest1;
|
||||
CREATE DATABASE mysqltest2;
|
||||
CREATE TABLE mysqltest1.t1(c1 INT);
|
||||
CREATE TABLE mysqltest1.t2(c2 INT);
|
||||
CREATE TABLE mysqltest1.t3(c3 INT);
|
||||
CREATE TABLE mysqltest1.t4(c4 INT);
|
||||
INSERT INTO mysqltest1.t1 VALUES (11), (12), (13), (14);
|
||||
INSERT INTO mysqltest1.t2 VALUES (21), (22), (23), (24);
|
||||
INSERT INTO mysqltest1.t3 VALUES (31), (32), (33), (34);
|
||||
INSERT INTO mysqltest1.t4 VALUES (41), (42), (43), (44);
|
||||
GRANT SELECT ON mysqltest1.t1 TO mysqltest_u1@localhost;
|
||||
GRANT INSERT ON mysqltest1.t2 TO mysqltest_u1@localhost;
|
||||
GRANT SELECT, UPDATE ON mysqltest1.t3 TO mysqltest_u1@localhost;
|
||||
GRANT SELECT, DELETE ON mysqltest1.t4 TO mysqltest_u1@localhost;
|
||||
GRANT ALL PRIVILEGES ON mysqltest2.* TO mysqltest_u1@localhost;
|
||||
|
||||
---> connection: bug24040_con
|
||||
SELECT * FROM mysqltest1.t1;
|
||||
c1
|
||||
11
|
||||
12
|
||||
13
|
||||
14
|
||||
INSERT INTO mysqltest1.t2 VALUES(25);
|
||||
UPDATE mysqltest1.t3 SET c3 = 331 WHERE c3 = 31;
|
||||
DELETE FROM mysqltest1.t4 WHERE c4 = 44;
|
||||
CREATE VIEW v1 AS SELECT * FROM mysqltest1.t1;
|
||||
CREATE VIEW v2 AS SELECT * FROM mysqltest1.t2;
|
||||
CREATE VIEW v3 AS SELECT * FROM mysqltest1.t3;
|
||||
CREATE VIEW v4 AS SELECT * FROM mysqltest1.t4;
|
||||
SELECT * FROM v1;
|
||||
c1
|
||||
11
|
||||
12
|
||||
13
|
||||
14
|
||||
INSERT INTO v2 VALUES(26);
|
||||
UPDATE v3 SET c3 = 332 WHERE c3 = 32;
|
||||
DELETE FROM v4 WHERE c4 = 43;
|
||||
CREATE VIEW v12 AS SELECT c1, c2 FROM mysqltest1.t1, mysqltest1.t2;
|
||||
ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c2' in table 'v12'
|
||||
CREATE VIEW v13 AS SELECT c1, c3 FROM mysqltest1.t1, mysqltest1.t3;
|
||||
CREATE VIEW v14 AS SELECT c1, c4 FROM mysqltest1.t1, mysqltest1.t4;
|
||||
CREATE VIEW v21 AS SELECT c2, c1 FROM mysqltest1.t2, mysqltest1.t1;
|
||||
ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c1' in table 'v21'
|
||||
CREATE VIEW v23 AS SELECT c2, c3 FROM mysqltest1.t2, mysqltest1.t3;
|
||||
ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c3' in table 'v23'
|
||||
CREATE VIEW v24 AS SELECT c2, c4 FROM mysqltest1.t2, mysqltest1.t4;
|
||||
ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c4' in table 'v24'
|
||||
CREATE VIEW v31 AS SELECT c3, c1 FROM mysqltest1.t3, mysqltest1.t1;
|
||||
CREATE VIEW v32 AS SELECT c3, c2 FROM mysqltest1.t3, mysqltest1.t2;
|
||||
ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c2' in table 'v32'
|
||||
CREATE VIEW v34 AS SELECT c3, c4 FROM mysqltest1.t3, mysqltest1.t4;
|
||||
CREATE VIEW v41 AS SELECT c4, c1 FROM mysqltest1.t4, mysqltest1.t1;
|
||||
CREATE VIEW v42 AS SELECT c4, c2 FROM mysqltest1.t4, mysqltest1.t2;
|
||||
ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c2' in table 'v42'
|
||||
CREATE VIEW v43 AS SELECT c4, c3 FROM mysqltest1.t4, mysqltest1.t3;
|
||||
|
||||
---> connection: default
|
||||
SELECT * FROM mysqltest1.t1;
|
||||
c1
|
||||
11
|
||||
12
|
||||
13
|
||||
14
|
||||
SELECT * FROM mysqltest1.t2;
|
||||
c2
|
||||
21
|
||||
22
|
||||
23
|
||||
24
|
||||
25
|
||||
26
|
||||
SELECT * FROM mysqltest1.t3 order by c3;
|
||||
c3
|
||||
33
|
||||
34
|
||||
331
|
||||
332
|
||||
SELECT * FROM mysqltest1.t4;
|
||||
c4
|
||||
41
|
||||
42
|
||||
DROP DATABASE mysqltest1;
|
||||
DROP DATABASE mysqltest2;
|
||||
DROP USER mysqltest_u1@localhost;
|
||||
End of 5.0 tests.
|
||||
DROP VIEW IF EXISTS v1;
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1 (i INT);
|
||||
CREATE VIEW v1 AS SELECT * FROM t1;
|
||||
ALTER VIEW v1 AS SELECT * FROM t1;
|
||||
SHOW CREATE VIEW v1;
|
||||
View Create View character_set_client collation_connection
|
||||
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci
|
||||
ALTER DEFINER=no_such@user_1 VIEW v1 AS SELECT * FROM t1;
|
||||
Warnings:
|
||||
Note 1449 The user specified as a definer ('no_such'@'user_1') does not exist
|
||||
SHOW CREATE VIEW v1;
|
||||
View Create View character_set_client collation_connection
|
||||
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`no_such`@`user_1` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci
|
||||
Warnings:
|
||||
Note 1449 The user specified as a definer ('no_such'@'user_1') does not exist
|
||||
ALTER ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t1;
|
||||
Warnings:
|
||||
Note 1449 The user specified as a definer ('no_such'@'user_1') does not exist
|
||||
SHOW CREATE VIEW v1;
|
||||
View Create View character_set_client collation_connection
|
||||
v1 CREATE ALGORITHM=MERGE DEFINER=`no_such`@`user_1` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci
|
||||
Warnings:
|
||||
Note 1449 The user specified as a definer ('no_such'@'user_1') does not exist
|
||||
ALTER ALGORITHM=TEMPTABLE DEFINER=no_such@user_2 VIEW v1 AS SELECT * FROM t1;
|
||||
Warnings:
|
||||
Note 1449 The user specified as a definer ('no_such'@'user_2') does not exist
|
||||
SHOW CREATE VIEW v1;
|
||||
View Create View character_set_client collation_connection
|
||||
v1 CREATE ALGORITHM=TEMPTABLE DEFINER=`no_such`@`user_2` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci
|
||||
Warnings:
|
||||
Note 1449 The user specified as a definer ('no_such'@'user_2') does not exist
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
End of 5.1 tests.
|
@ -53,7 +53,6 @@ wait/synch/mutex/sql/LOCK_global_index_stats
|
||||
wait/synch/mutex/sql/LOCK_global_system_variables
|
||||
wait/synch/mutex/sql/LOCK_global_table_stats
|
||||
wait/synch/mutex/sql/LOCK_global_user_client_stats
|
||||
wait/synch/mutex/sql/LOCK_manager
|
||||
wait/synch/mutex/sql/LOCK_open
|
||||
wait/synch/mutex/sql/LOCK_plugin
|
||||
wait/synch/mutex/sql/LOCK_prepared_stmt_count
|
||||
@ -114,7 +113,6 @@ wait/synch/cond/mysys/COND_alarm
|
||||
wait/synch/cond/mysys/my_thread_var::suspend
|
||||
wait/synch/cond/mysys/THR_COND_threads
|
||||
wait/synch/cond/sql/COND_flush_thread_cache
|
||||
wait/synch/cond/sql/COND_manager
|
||||
wait/synch/cond/sql/COND_queue_state
|
||||
wait/synch/cond/sql/COND_rpl_status
|
||||
wait/synch/cond/sql/COND_server_started
|
||||
|
@ -82,7 +82,7 @@ count(name)
|
||||
select count(name) from mutex_instances
|
||||
where name like "wait/synch/mutex/sql/LOCK_manager";
|
||||
count(name)
|
||||
1
|
||||
0
|
||||
select count(name) from mutex_instances
|
||||
where name like "wait/synch/mutex/sql/LOCK_global_system_variables";
|
||||
count(name)
|
||||
@ -170,7 +170,7 @@ count(name)
|
||||
select count(name) from cond_instances
|
||||
where name like "wait/synch/cond/sql/COND_manager";
|
||||
count(name)
|
||||
1
|
||||
0
|
||||
select count(name) from cond_instances
|
||||
where name like "wait/synch/cond/sql/COND_thread_cache";
|
||||
count(name)
|
||||
|
30
mysql-test/suite/plugins/r/unix_socket.result
Normal file
30
mysql-test/suite/plugins/r/unix_socket.result
Normal file
@ -0,0 +1,30 @@
|
||||
install plugin unix_socket soname 'auth_socket.so';
|
||||
#
|
||||
# with named user
|
||||
#
|
||||
create user USER identified via unix_socket;
|
||||
#
|
||||
# name match = ok
|
||||
#
|
||||
select user(), current_user(), database();
|
||||
user() current_user() database()
|
||||
USER@localhost USER@% test
|
||||
#
|
||||
# name does not match = failure
|
||||
#
|
||||
drop user USER;
|
||||
#
|
||||
# and now with anonymous user
|
||||
#
|
||||
grant SELECT ON test.* TO '' identified via unix_socket;
|
||||
#
|
||||
# name match = ok
|
||||
#
|
||||
select user(), current_user(), database();
|
||||
user() current_user() database()
|
||||
USER@localhost @% test
|
||||
#
|
||||
# name does not match = failure
|
||||
#
|
||||
delete from mysql.user where user='';
|
||||
uninstall plugin unix_socket;
|
56
mysql-test/suite/plugins/t/unix_socket.test
Normal file
56
mysql-test/suite/plugins/t/unix_socket.test
Normal file
@ -0,0 +1,56 @@
|
||||
--source include/not_embedded.inc
|
||||
|
||||
if (!$AUTH_SOCKET_SO) {
|
||||
skip No auth_socket plugin;
|
||||
}
|
||||
|
||||
let $plugindir=`SELECT @@global.plugin_dir`;
|
||||
|
||||
eval install plugin unix_socket soname '$AUTH_SOCKET_SO';
|
||||
|
||||
--echo #
|
||||
--echo # with named user
|
||||
--echo #
|
||||
|
||||
--replace_result $USER USER
|
||||
eval create user $USER identified via unix_socket;
|
||||
|
||||
--write_file $MYSQLTEST_VARDIR/tmp/peercred_test.txt
|
||||
--replace_result $USER USER
|
||||
select user(), current_user(), database();
|
||||
EOF
|
||||
|
||||
--echo #
|
||||
--echo # name match = ok
|
||||
--echo #
|
||||
--exec $MYSQL_TEST -u $USER --plugin-dir=$plugindir < $MYSQLTEST_VARDIR/tmp/peercred_test.txt
|
||||
|
||||
--echo #
|
||||
--echo # name does not match = failure
|
||||
--echo #
|
||||
--error 1
|
||||
--exec $MYSQL_TEST -u foobar --plugin-dir=$plugindir < $MYSQLTEST_VARDIR/tmp/peercred_test.txt
|
||||
|
||||
--replace_result $USER USER
|
||||
eval drop user $USER;
|
||||
|
||||
--echo #
|
||||
--echo # and now with anonymous user
|
||||
--echo #
|
||||
grant SELECT ON test.* TO '' identified via unix_socket;
|
||||
--echo #
|
||||
--echo # name match = ok
|
||||
--echo #
|
||||
--exec $MYSQL_TEST -u $USER --plugin-dir=$plugindir < $MYSQLTEST_VARDIR/tmp/peercred_test.txt
|
||||
|
||||
--echo #
|
||||
--echo # name does not match = failure
|
||||
--echo #
|
||||
--error 1
|
||||
--exec $MYSQL_TEST -u foobar --plugin-dir=$plugindir < $MYSQLTEST_VARDIR/tmp/peercred_test.txt
|
||||
|
||||
# restoring mysql.user to the original state.
|
||||
delete from mysql.user where user='';
|
||||
uninstall plugin unix_socket;
|
||||
--remove_file $MYSQLTEST_VARDIR/tmp/peercred_test.txt
|
||||
|
@ -265,3 +265,33 @@ NULL
|
||||
explain select sum(c) from t1 group by b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort
|
||||
#
|
||||
# Bug #806057: join with USING over a virtual column
|
||||
#
|
||||
CREATE TABLE t1 (b int);
|
||||
INSERT INTO t1 VALUES (NULL),( 78), (185), (0), (154);
|
||||
CREATE TABLE t2 (a int, b int AS (a) VIRTUAL);
|
||||
INSERT INTO t2 VALUES (187,187), (9,9), (187,187);
|
||||
Warnings:
|
||||
Warning 1906 The value specified for computed column 'b' in table 't2' ignored
|
||||
Warning 1906 The value specified for computed column 'b' in table 't2' ignored
|
||||
Warning 1906 The value specified for computed column 'b' in table 't2' ignored
|
||||
EXPLAIN EXTENDED
|
||||
SELECT * FROM t1 JOIN t2 USING (b);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`b` = `test`.`t2`.`b`)
|
||||
SELECT * FROM t1 JOIN t2 USING (b);
|
||||
b a
|
||||
EXPLAIN EXTENDED
|
||||
SELECT * FROM t1 NATURAL JOIN t2;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`b` = `test`.`t2`.`b`)
|
||||
SELECT * FROM t1 NATURAL JOIN t2;
|
||||
b a
|
||||
DROP TABLE t1,t2;
|
||||
|
@ -107,7 +107,7 @@ MariaDB-5.3: the following EXPLAIN produces incorrect #rows for table t1.
|
||||
MariaDB-5.3: this is expected to go away when FROM subquery optimizations are pushed
|
||||
explain select * from v1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 4 Using filesort
|
||||
drop view v1;
|
||||
create view v1 as select c+1 from t1 order by 1 desc limit 2;
|
||||
@ -119,7 +119,7 @@ MariaDB-5.3: the following EXPLAIN produces incorrect #rows for table t1.
|
||||
MariaDB-5.3: this is expected to go away when FROM subquery optimizations are pushed
|
||||
explain select * from v1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 4 Using filesort
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
|
@ -107,7 +107,7 @@ MariaDB-5.3: the following EXPLAIN produces incorrect #rows for table t1.
|
||||
MariaDB-5.3: this is expected to go away when FROM subquery optimizations are pushed
|
||||
explain select * from v1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 4 Using filesort
|
||||
drop view v1;
|
||||
create view v1 as select c+1 from t1 order by 1 desc limit 2;
|
||||
@ -119,7 +119,7 @@ MariaDB-5.3: the following EXPLAIN produces incorrect #rows for table t1.
|
||||
MariaDB-5.3: this is expected to go away when FROM subquery optimizations are pushed
|
||||
explain select * from v1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 4 Using filesort
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
|
@ -48,3 +48,23 @@ eval SET @@session.storage_engine = 'MyISAM';
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
||||
|
||||
--echo #
|
||||
--echo # Bug #806057: join with USING over a virtual column
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (b int);
|
||||
INSERT INTO t1 VALUES (NULL),( 78), (185), (0), (154);
|
||||
|
||||
CREATE TABLE t2 (a int, b int AS (a) VIRTUAL);
|
||||
INSERT INTO t2 VALUES (187,187), (9,9), (187,187);
|
||||
|
||||
EXPLAIN EXTENDED
|
||||
SELECT * FROM t1 JOIN t2 USING (b);
|
||||
SELECT * FROM t1 JOIN t2 USING (b);
|
||||
|
||||
EXPLAIN EXTENDED
|
||||
SELECT * FROM t1 NATURAL JOIN t2;
|
||||
SELECT * FROM t1 NATURAL JOIN t2;
|
||||
|
||||
DROP TABLE t1,t2;
|
||||
|
@ -202,5 +202,15 @@ RIGHT JOIN (
|
||||
|
||||
drop table t1,t2,t3,t4;
|
||||
|
||||
--echo #
|
||||
--echo # LP BUG#910123 MariaDB 5.3.3 causes 1093 error on Drupal
|
||||
--echo # Fix: force materialization in case of conflict
|
||||
--echo #
|
||||
SET optimizer_switch='derived_merge=on';
|
||||
CREATE TABLE t1 ( i INT );
|
||||
INSERT INTO t1 VALUES ( (SELECT 1 FROM ( SELECT * FROM t1 ) as a) );
|
||||
drop table t1;
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
|
||||
# The following command must be the last one the file
|
||||
set optimizer_switch=@exit_optimizer_switch;
|
||||
|
@ -1192,7 +1192,7 @@ INSERT INTO t2 VALUES (7), (4);
|
||||
CREATE TABLE t1 (b int NOT NULL);
|
||||
INSERT INTO t1 VALUES (5), (7);
|
||||
CREATE ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t1;
|
||||
|
||||
SET @save_optimizer_switch=@@optimizer_switch;
|
||||
SET SESSION optimizer_switch='derived_merge=off';
|
||||
|
||||
PREPARE st1 FROM
|
||||
@ -1201,10 +1201,12 @@ EXECUTE st1;
|
||||
EXECUTE st1;
|
||||
DEALLOCATE PREPARE st1;
|
||||
|
||||
set SESSION optimizer_switch= @save_optimizer_switch;
|
||||
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
SET SESSION optimizer_switch='derived_merge=on';
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # LP bug #879939: assertion in ha_maria::enable_indexes
|
||||
@ -1226,7 +1228,7 @@ INSERT INTO t1 VALUES
|
||||
|
||||
CREATE TABLE t3 (a varchar(35));
|
||||
INSERT INTO t3 VALUES ('Miami');
|
||||
|
||||
SET @save_optimizer_switch=@@optimizer_switch;
|
||||
SET optimizer_switch = 'derived_with_keys=on';
|
||||
SET @@tmp_table_size=1024*4;
|
||||
explain SELECT * FROM (SELECT t1.* FROM t1, t2) AS t JOIN t3 ON t3.a = t.b;
|
||||
@ -1234,7 +1236,7 @@ SELECT * FROM (SELECT t1.* FROM t1, t2) AS t JOIN t3 ON t3.a = t.b;
|
||||
SET @@tmp_table_size=1024*1024*16;
|
||||
SELECT * FROM (SELECT t1.* FROM t1, t2) AS t JOIN t3 ON t3.a = t.b;
|
||||
SET @@tmp_table_size=default;
|
||||
|
||||
set SESSION optimizer_switch= @save_optimizer_switch;
|
||||
drop table t1,t2,t3;
|
||||
|
||||
--echo #
|
||||
@ -1277,6 +1279,40 @@ ORDER BY CONCAT(alias2.col_varchar_nokey);
|
||||
set max_heap_table_size= @tmp_882994;
|
||||
drop table t1,t2,t3;
|
||||
|
||||
--echo #
|
||||
--echo # LP bug #917990: Bad estimate of #rows for derived table with LIMIT
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (a int);
|
||||
INSERT INTO t1 VALUES
|
||||
(8), (3), (4), (7), (9), (5), (1), (2);
|
||||
|
||||
SELECT * FROM (SELECT * FROM t1 LIMIT 3) t;
|
||||
EXPLAIN
|
||||
SELECT * FROM (SELECT * FROM t1 LIMIT 3) t;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # LP BUG#921878 incorrect check of items during columns union types
|
||||
--echo # aggregation for merged derived tables
|
||||
--echo #
|
||||
SET @save_optimizer_switch=@@optimizer_switch;
|
||||
SET SESSION optimizer_switch='derived_merge=on';
|
||||
CREATE TABLE t1 ( a ENUM( 'x', 'y' ) );
|
||||
insert into t1 values ('x');
|
||||
CREATE TABLE t2 LIKE t1;
|
||||
insert into t1 values ('y');
|
||||
CREATE TABLE t3 LIKE t1;
|
||||
INSERT INTO t3
|
||||
SELECT * FROM ( SELECT * FROM t1 ) AS A
|
||||
UNION SELECT * FROM t2;
|
||||
select * from t3;
|
||||
|
||||
drop table t1,t2,t3;
|
||||
|
||||
set SESSION optimizer_switch= @save_optimizer_switch;
|
||||
|
||||
# The following command must be the last one the file
|
||||
set optimizer_switch=@exit_optimizer_switch;
|
||||
set join_cache_level=@exit_join_cache_level;
|
||||
|
@ -1153,6 +1153,53 @@ drop table t1;
|
||||
--echo #
|
||||
--echo End of 5.1 tests
|
||||
|
||||
--echo #
|
||||
--echo # Bug #904345: MIN/MAX optimization with constant FALSE condition
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (a int NOT NULL, KEY(a));
|
||||
INSERT INTO t1 VALUES (10), (8), (11), (7), (15), (12), (9);
|
||||
|
||||
CREATE TABLE t2 (a int, b int);
|
||||
INSERT INTO t2 VALUES
|
||||
(8,2), (6,9), (8,4), (5,3), (9,1);
|
||||
|
||||
EXPLAIN EXTENDED
|
||||
SELECT MAX(a) FROM t1 WHERE (1,2) IN (SELECT 3,4) AND a<10;
|
||||
SELECT MAX(a) FROM t1 WHERE (1,2) IN (SELECT 3,4) AND a<10;
|
||||
|
||||
EXPLAIN EXTENDED
|
||||
SELECT MAX(a) FROM t1 WHERE (1,2) IN (SELECT a,b FROM t2 WHERE b<5) and a<10;
|
||||
SELECT MAX(a) FROM t1 WHERE (1,2) IN (SELECT a,b FROM t2 WHERE b<5) and a<10;
|
||||
|
||||
EXPLAIN EXTENDED
|
||||
SELECT MAX(a) FROM t1 WHERE RAND()*0<>0 AND a<10;
|
||||
SELECT MAX(a) FROM t1 WHERE RAND()*0<>0 AND a<10;
|
||||
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
--echo #
|
||||
--echo # Bug #879860: MIN/MAX for subquery returning empty set
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (a int PRIMARY KEY);
|
||||
INSERT INTO t1 VALUES (1);
|
||||
|
||||
CREATE TABLE t2 (a int NOT NULL);
|
||||
INSERT INTO t2 VALUES (10);
|
||||
|
||||
CREATE TABLE t3 ( a int, b int);
|
||||
INSERT INTO t3 VALUES (19,1), (20,5);
|
||||
|
||||
EXPLAIN EXTENDED
|
||||
SELECT (SELECT MIN(t1.a) FROM t1,t2 WHERE t2.a = t3.b) FROM t3;
|
||||
SELECT (SELECT MIN(t1.a) FROM t1,t2 WHERE t2.a = t3.b) FROM t3;
|
||||
|
||||
DROP TABLE t1,t2,t3;
|
||||
|
||||
--echo #
|
||||
--echo End of 5.2 tests
|
||||
|
||||
--echo #
|
||||
--echo # BUG#46680 - Assertion failed in file item_subselect.cc,
|
||||
--echo # line 305 crashing on HAVING subquery
|
||||
|
@ -3423,5 +3423,164 @@ SET optimizer_switch=@tmp_optimizer_switch;
|
||||
|
||||
DROP TABLE t1,t2,t3,t4;
|
||||
|
||||
--echo #
|
||||
--echo # Bug#53305 Duplicate weedout + join buffer (join cache --level=7,8)
|
||||
--echo #
|
||||
|
||||
create table t1 (uid int, fid int, index(uid));
|
||||
insert into t1 values
|
||||
(1,1), (1,2), (1,3), (1,4),
|
||||
(2,5), (2,6), (2,7), (2,8),
|
||||
(3,1), (3,2), (3,9);
|
||||
|
||||
create table t2 (uid int primary key, name varchar(128), index(name));
|
||||
insert into t2 values
|
||||
(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"),
|
||||
(6, "F"), (7, "G"), (8, "H"), (9, "I");
|
||||
|
||||
create table t3 (uid int, fid int, index(uid));
|
||||
insert into t3 values
|
||||
(1,1), (1,2), (1,3),(1,4),
|
||||
(2,5), (2,6), (2,7), (2,8),
|
||||
(3,1), (3,2), (3,9);
|
||||
|
||||
set @tmp_optimizer_switch=@@optimizer_switch;
|
||||
set @@optimizer_switch='semijoin=on';
|
||||
set optimizer_switch='materialization=off';
|
||||
set optimizer_switch='loosescan=off,firstmatch=off';
|
||||
set optimizer_switch='mrr_sort_keys=off';
|
||||
set join_cache_level=7;
|
||||
|
||||
create table t4 (uid int primary key, name varchar(128), index(name));
|
||||
insert into t4 values
|
||||
(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"),
|
||||
(6, "F"), (7, "G"), (8, "H"), (9, "I");
|
||||
|
||||
explain select name from t2, t1
|
||||
where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid)
|
||||
and t2.uid=t1.fid;
|
||||
|
||||
--sorted_result
|
||||
select name from t2, t1
|
||||
where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid)
|
||||
and t2.uid=t1.fid;
|
||||
|
||||
set join_cache_level = default;
|
||||
set optimizer_switch=@tmp_optimizer_switch;
|
||||
|
||||
drop table t1,t2,t3,t4;
|
||||
|
||||
--echo #
|
||||
--echo # Bug#50358 - semijoin execution of subquery with outerjoin
|
||||
--echo # emplying join buffer
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (i int);
|
||||
CREATE TABLE t2 (i int);
|
||||
CREATE TABLE t3 (i int);
|
||||
INSERT INTO t1 VALUES (1), (2);
|
||||
INSERT INTO t2 VALUES (6);
|
||||
INSERT INTO t3 VALUES (1), (2);
|
||||
|
||||
set @tmp_optimizer_switch=@@optimizer_switch;
|
||||
set @@optimizer_switch='semijoin=on';
|
||||
set optimizer_switch='materialization=on';
|
||||
|
||||
set join_cache_level=0;
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE t1.i IN
|
||||
(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i);
|
||||
SELECT * FROM t1 WHERE t1.i IN
|
||||
(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i);
|
||||
|
||||
set join_cache_level=2;
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE t1.i IN
|
||||
(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i);
|
||||
SELECT * FROM t1 WHERE t1.i IN
|
||||
(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i);
|
||||
|
||||
set join_cache_level = default;
|
||||
set optimizer_switch=@tmp_optimizer_switch;
|
||||
|
||||
DROP TABLE t1,t2,t3;
|
||||
|
||||
--echo #
|
||||
--echo # Bug #12546542: missing row with semijoin=off + join cache
|
||||
--echo # (LP bug #922971)
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (a varchar(1024));
|
||||
INSERT INTO t1 VALUES ('v'), ('we');
|
||||
CREATE TABLE t2 (
|
||||
a varchar(1024) CHARACTER SET utf8 DEFAULT NULL, b int, c int
|
||||
);
|
||||
INSERT INTO t2 VALUES ('we',4,NULL), ('v',1305673728,6);
|
||||
CREATE TABLE t3 (b int, c int);
|
||||
INSERT INTO t3 VALUES (4,4);
|
||||
|
||||
set @tmp_optimizer_switch=@@optimizer_switch;
|
||||
set optimizer_switch='semijoin=off';
|
||||
set optimizer_switch='materialization=off';
|
||||
|
||||
set join_cache_level=0;
|
||||
EXPLAIN
|
||||
SELECT * FROM t1
|
||||
WHERE a IN (SELECT t2.a FROM t2 LEFT JOIN t3 ON t2.b = t3.b
|
||||
WHERE t2.c < 10 OR t3.c > 1);
|
||||
|
||||
SELECT * FROM t1
|
||||
WHERE a IN (SELECT t2.a FROM t2 LEFT JOIN t3 ON t2.b = t3.b
|
||||
WHERE t2.c < 10 OR t3.c > 1);
|
||||
|
||||
set join_cache_level=2;
|
||||
EXPLAIN
|
||||
SELECT * FROM t1
|
||||
WHERE a IN (SELECT t2.a FROM t2 LEFT JOIN t3 ON t2.b = t3.b
|
||||
WHERE t2.c < 10 OR t3.c > 1);
|
||||
SELECT * FROM t1
|
||||
WHERE a IN (SELECT t2.a FROM t2 LEFT JOIN t3 ON t2.b = t3.b
|
||||
WHERE t2.c < 10 OR t3.c > 1);
|
||||
|
||||
set join_cache_level = default;
|
||||
set optimizer_switch=@tmp_optimizer_switch;
|
||||
|
||||
DROP TABLE t1,t2,t3;
|
||||
|
||||
--echo #
|
||||
--echo # Bug #925985: LEFT JOIN with optimize_join_buffer_size=off +
|
||||
--echo # join_buffer_size > join_buffer_space_limit
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (a int);
|
||||
INSERT INTO t1 VALUES (5), (3);
|
||||
|
||||
CREATE TABLE t2 (a int, b int);
|
||||
INSERT INTO t2 VALUES
|
||||
(3,30), (1,10), (7,70), (2,20),
|
||||
(3,31), (1,11), (7,71), (2,21),
|
||||
(3,32), (1,12), (7,72), (2,22);
|
||||
|
||||
CREATE TABLE t3 (b int, c int);
|
||||
INSERT INTO t3 VALUES (32, 302), (42,400), (30,300);
|
||||
|
||||
set @tmp_optimizer_switch=@@optimizer_switch;
|
||||
set optimizer_switch='optimize_join_buffer_size=off';
|
||||
set join_buffer_space_limit=4096;
|
||||
set join_buffer_size=4096*2;
|
||||
set join_cache_level=2;
|
||||
set optimizer_switch='outer_join_with_cache=on';
|
||||
|
||||
EXPLAIN
|
||||
SELECT * FROM t1, t2 LEFT JOIN t3 ON t2.b=t3.b WHERE t1.a=t2.a;
|
||||
SELECT * FROM t1, t2 LEFT JOIN t3 ON t2.b=t3.b WHERE t1.a=t2.a;
|
||||
|
||||
set join_buffer_space_limit=default;
|
||||
set join_buffer_size=default;
|
||||
set join_cache_level=default;
|
||||
set optimizer_switch=@tmp_optimizer_switch;
|
||||
|
||||
DROP TABLE t1,t2,t3;
|
||||
|
||||
# this must be the last command in the file
|
||||
set @@optimizer_switch=@save_optimizer_switch;
|
||||
|
@ -61,3 +61,18 @@ ORDER BY pk;
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
--echo # End BUG#58456
|
||||
|
||||
#
|
||||
# Bug #848652: crash with RIGHT JOIN and GROUP BY
|
||||
#
|
||||
|
||||
CREATE TABLE t1(a int, b int, KEY (a), PRIMARY KEY (b)) ENGINE=InnoDB;
|
||||
|
||||
CREATE TABLE t2 (b int, PRIMARY KEY (b));
|
||||
INSERT INTO t2 VALUES (4),(9);
|
||||
|
||||
SELECT STRAIGHT_JOIN t1.a FROM t1 RIGHT JOIN t2 ON t1.b = t2.b
|
||||
WHERE (t1.b NOT BETWEEN 1 AND 7 OR t1.a IS NULL AND t1.b = t2.b) AND t2.b = 4
|
||||
GROUP BY 1;
|
||||
|
||||
DROP TABLE t1,t2;
|
||||
|
@ -268,5 +268,58 @@ set @@join_cache_level= @tmp_730133_jcl;
|
||||
set @@optimizer_switch= @tmp_730133_os;
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
--echo # Test of MRR handler counters
|
||||
--echo #
|
||||
flush status;
|
||||
show status like 'Handler_mrr%';
|
||||
create table t0 (a int);
|
||||
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
create table t1 (a int, b int, filler char(200), key(a));
|
||||
insert into t1
|
||||
select A.a+10*B.a+100*C.a+1000*D.a, 123,'filler' from t0 A, t0 B, t0 C, t0 D;
|
||||
|
||||
explain select sum(b) from t1 where a < 10;
|
||||
--echo # This should show one MRR scan and no re-fills:
|
||||
flush status;
|
||||
select sum(b) from t1 where a < 10;
|
||||
show status like 'handler_mrr%';
|
||||
|
||||
set @mrr_buffer_size_save= @@mrr_buffer_size;
|
||||
--disable_warnings
|
||||
set mrr_buffer_size=128;
|
||||
--enable_warnings
|
||||
|
||||
explain select sum(b) from t1 where a < 1600;
|
||||
--echo # This should show one MRR scan and one extra rowid sort:
|
||||
flush status;
|
||||
select sum(b) from t1 where a < 1600;
|
||||
show status like 'handler_mrr%';
|
||||
set @@mrr_buffer_size= @mrr_buffer_size_save;
|
||||
|
||||
--echo #Now, let's check BKA:
|
||||
set @join_cache_level_save= @@join_cache_level;
|
||||
set @join_buffer_size_save= @@join_buffer_size;
|
||||
set join_cache_level=6;
|
||||
|
||||
explain select sum(t1.b) from t0,t1 where t0.a=t1.a;
|
||||
flush status;
|
||||
select sum(t1.b) from t0,t1 where t0.a=t1.a;
|
||||
show status like 'handler_mrr%';
|
||||
|
||||
--disable_warnings
|
||||
set join_buffer_size=10;
|
||||
--enable_warnings
|
||||
explain select sum(t1.b) from t0,t1 where t0.a=t1.a;
|
||||
flush status;
|
||||
select sum(t1.b) from t0,t1 where t0.a=t1.a;
|
||||
--replace_result 1 1or2 2 1or2
|
||||
show status like 'handler_mrr%';
|
||||
|
||||
set join_cache_level= @join_cache_level_save;
|
||||
set join_buffer_size= @join_buffer_size_save;
|
||||
|
||||
drop table t0, t1;
|
||||
|
||||
## This must be last line in the file:
|
||||
set optimizer_switch= @myisam_mrr_tmp;
|
||||
|
@ -1562,7 +1562,6 @@ select 1 order by max(1) + min(1);
|
||||
|
||||
--echo End of 5.1 tests
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # Bug #38745: MySQL 5.1 optimizer uses filesort for ORDER BY
|
||||
--echo # when it should use index
|
||||
@ -1585,3 +1584,32 @@ SELECT t1.*, t2.* FROM t1 JOIN t2 ON t1.i1 = t2.i2
|
||||
ORDER BY t1.i1 LIMIT 5;
|
||||
|
||||
DROP TABLE t1, t2, t3;
|
||||
|
||||
--echo #
|
||||
--echo # Fix of LP BUG#793589 Wrong result with double ORDER BY
|
||||
--echo #
|
||||
CREATE TABLE t1 ( b int) ;
|
||||
INSERT INTO t1 VALUES (8),(9);
|
||||
|
||||
CREATE TABLE t2 ( a int, b int, PRIMARY KEY (a)) ;
|
||||
INSERT INTO t2 VALUES (6,7),(7,7),(8,1),(9,7),(10,1),(11,5),(12,2),(13,0),(14,1),(15,8),(16,1),(17,1),(18,9),(19,1),(20,5);
|
||||
|
||||
SELECT t2.b AS field1 FROM t1, t2 WHERE t1.b = t2.a GROUP BY field1 ORDER BY t1.b, field1;
|
||||
SELECT t2.b, t1.b FROM t1, t2 WHERE t1.b = t2.a GROUP BY t2.b ORDER BY t1.b, t2.b;
|
||||
SELECT t2.b,t1.b FROM t1, t2 WHERE t1.b = t2.a GROUP BY t2.b ORDER BY t1.b;
|
||||
SELECT t2.b FROM t1, t2 WHERE t1.b = t2.a GROUP BY t2.b ORDER BY t1.b;
|
||||
|
||||
--echo # field1 removed from ORDER BY
|
||||
explain extended
|
||||
SELECT t2.b AS field1 FROM t1, t2 WHERE t1.b = t2.a GROUP BY field1 ORDER BY t1.b, field1;
|
||||
explain extended
|
||||
SELECT t2.b, t1.b FROM t1, t2 WHERE t1.b = t2.a GROUP BY t2.b ORDER BY t1.b, t2.b;
|
||||
explain extended
|
||||
SELECT t2.b,t1.b FROM t1, t2 WHERE t1.b = t2.a GROUP BY t2.b ORDER BY t1.b;
|
||||
explain extended
|
||||
SELECT t2.b FROM t1, t2 WHERE t1.b = t2.a GROUP BY t2.b ORDER BY t1.b;
|
||||
|
||||
|
||||
drop table t1,t2;
|
||||
|
||||
--echo End of 5.2 tests
|
||||
|
@ -1106,12 +1106,14 @@ show status like 'Handler_read_key';
|
||||
flush status;
|
||||
delete from t2 where b > 5;
|
||||
show status like 'Handler_read_rnd_next';
|
||||
show status like 'Handler_read_rnd_deleted';
|
||||
show status like 'Handler_read_key';
|
||||
show status like 'Handler_read_prev';
|
||||
show status like 'Handler_read_next';
|
||||
flush status;
|
||||
delete from t2 where b < 5 or b > 3;
|
||||
show status like 'Handler_read_rnd_next';
|
||||
show status like 'Handler_read_rnd_deleted';
|
||||
show status like 'Handler_read_key';
|
||||
show status like 'Handler_read_prev';
|
||||
show status like 'Handler_read_next';
|
||||
|
@ -369,6 +369,16 @@ show status like 'Handler%';
|
||||
show status like '%tmp%';
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# Test of handler status counts
|
||||
#
|
||||
CREATE TABLE t1 (i int(11) DEFAULT NULL, KEY i (i) ) ENGINE=MyISAM;
|
||||
insert into t1 values (1),(2),(3),(4),(5);
|
||||
flush status;
|
||||
select * from t1 where i=5 union select * from t1 where i=5;
|
||||
show status like "handler%";
|
||||
drop table t1;
|
||||
|
||||
# End of 5.3 tests
|
||||
|
||||
# Restore global concurrent_insert value. Keep in the end of the test file.
|
||||
|
@ -3519,6 +3519,8 @@ SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
|
||||
|
||||
## First a simpler query, illustrating the transformation
|
||||
## '1 < some (...)' => '1 < max(...)'
|
||||
EXPLAIN EXTENDED
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t1);
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t1);
|
||||
|
||||
## The query which made the server crash.
|
||||
@ -4431,8 +4433,6 @@ WHERE t1.a = d1.a;
|
||||
DROP TABLE t1;
|
||||
|
||||
|
||||
--echo End of 5.1 tests.
|
||||
|
||||
#
|
||||
# Bug #47904 Incorrect results w/ table subquery, derived SQs, and LEFT JOIN on index
|
||||
#
|
||||
@ -4879,11 +4879,141 @@ INSERT INTO t3 VALUES (0),(0);
|
||||
SELECT a1.f3 AS r FROM t2 AS a1 , t1 WHERE a1.f3 < ALL ( SELECT f3 FROM t3 WHERE f3 = 1 ) ;
|
||||
DROP TABLE t1, t2, t3;
|
||||
|
||||
--echo #
|
||||
--echo # Bug#12763207 - ASSERT IN SUBSELECT::SINGLE_VALUE_TRANSFORMER
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1(a1 int);
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
|
||||
CREATE TABLE t2(a1 int);
|
||||
INSERT INTO t2 VALUES (3);
|
||||
|
||||
SELECT @@session.sql_mode INTO @old_sql_mode;
|
||||
SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
|
||||
|
||||
## All these are subject to the transformation
|
||||
## '1 < some (...)' => '1 < max(...)'
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2 FROM t2);
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2.0 FROM t2);
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 'a' FROM t2);
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t2);
|
||||
|
||||
SET SESSION sql_mode=@old_sql_mode;
|
||||
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
create table t2(i int);
|
||||
insert into t2 values(0);
|
||||
|
||||
SELECT @@session.sql_mode INTO @old_sql_mode;
|
||||
SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
|
||||
|
||||
CREATE VIEW v1 AS
|
||||
SELECT 'f' FROM t2 UNION SELECT 'x' FROM t2
|
||||
;
|
||||
|
||||
CREATE TABLE t1 (
|
||||
pk int NOT NULL,
|
||||
col_varchar_key varchar(1) DEFAULT NULL,
|
||||
PRIMARY KEY (pk),
|
||||
KEY col_varchar_key (col_varchar_key)
|
||||
);
|
||||
|
||||
SELECT t1.pk
|
||||
FROM t1
|
||||
WHERE t1.col_varchar_key < ALL ( SELECT * FROM v1 )
|
||||
;
|
||||
|
||||
SET SESSION sql_mode=@old_sql_mode;
|
||||
|
||||
drop table t2, t1;
|
||||
drop view v1;
|
||||
|
||||
--echo #
|
||||
--echo # BUG#50257: Missing info in REF column of the EXPLAIN
|
||||
--echo # lines for subselects
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (a INT, b INT, INDEX (a));
|
||||
INSERT INTO t1 VALUES (3, 10), (2, 20), (7, 10), (5, 20);
|
||||
|
||||
EXPLAIN SELECT * FROM (SELECT * FROM t1 WHERE a=7) t;
|
||||
EXPLAIN SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t1 WHERE a=7);
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # BUG#12616253 - WRONG RESULT WITH EXISTS(SUBQUERY) (MISSING ROWS)
|
||||
--echo # (duplicate of LP bug #888456)
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (f1 varchar(1));
|
||||
INSERT INTO t1 VALUES ('v'),('s');
|
||||
|
||||
CREATE TABLE t2 (f1_key varchar(1), KEY (f1_key));
|
||||
INSERT INTO t2 VALUES ('j'),('v'),('c'),('m'),('d'),
|
||||
('d'),('y'),('t'),('d'),('s');
|
||||
|
||||
EXPLAIN
|
||||
SELECT table1.f1, table2.f1_key FROM t1 AS table1, t2 AS table2
|
||||
WHERE EXISTS (SELECT DISTINCT f1_key FROM t2
|
||||
WHERE f1_key != table2.f1_key AND f1_key >= table1.f1);
|
||||
SELECT table1.f1, table2.f1_key FROM t1 AS table1, t2 AS table2
|
||||
WHERE EXISTS (SELECT DISTINCT f1_key FROM t2
|
||||
WHERE f1_key != table2.f1_key AND f1_key >= table1.f1);
|
||||
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
--echo #
|
||||
--echo # LP bug 919427: EXPLAIN for a query over a single-row table
|
||||
--echo # with IN subquery in WHERE condition
|
||||
--echo #
|
||||
|
||||
CREATE TABLE ot (
|
||||
col_int_nokey int(11),
|
||||
col_varchar_nokey varchar(1)
|
||||
) ;
|
||||
INSERT INTO ot VALUES (1,'x');
|
||||
|
||||
CREATE TABLE it1(
|
||||
col_int_key int(11),
|
||||
col_varchar_key varchar(1),
|
||||
KEY idx_cvk_cik (col_varchar_key,col_int_key)
|
||||
);
|
||||
INSERT INTO it1 VALUES (NULL,'x'), (NULL,'f');
|
||||
|
||||
CREATE TABLE it2 (
|
||||
col_int_key int(11),
|
||||
col_varchar_key varchar(1),
|
||||
col_varchar_key2 varchar(1),
|
||||
KEY idx_cvk_cvk2_cik (col_varchar_key, col_varchar_key2, col_int_key),
|
||||
KEY idx_cvk_cik (col_varchar_key, col_int_key)
|
||||
);
|
||||
INSERT INTO it2 VALUES (NULL,'x','x'), (NULL,'f','f');
|
||||
|
||||
EXPLAIN
|
||||
SELECT col_int_nokey FROM ot
|
||||
WHERE col_varchar_nokey IN
|
||||
(SELECT col_varchar_key FROM it1 WHERE col_int_key IS NULL);
|
||||
SELECT col_int_nokey FROM ot
|
||||
WHERE col_varchar_nokey IN
|
||||
(SELECT col_varchar_key FROM it1 WHERE col_int_key IS NULL);
|
||||
|
||||
EXPLAIN
|
||||
SELECT col_int_nokey FROM ot
|
||||
WHERE (col_varchar_nokey, 'x') IN
|
||||
(SELECT col_varchar_key, col_varchar_key2 FROM it2);
|
||||
SELECT col_int_nokey FROM ot
|
||||
WHERE (col_varchar_nokey, 'x') IN
|
||||
(SELECT col_varchar_key, col_varchar_key2 FROM it2);
|
||||
|
||||
DROP TABLE ot,it1,it2;
|
||||
|
||||
--echo End of 5.2 tests
|
||||
|
||||
--echo #
|
||||
--echo # BUG#779885: Crash in eliminate_item_equal with materialization=on in
|
||||
--echo # maria-5.3
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 ( f1 int );
|
||||
@ -4936,32 +5066,6 @@ SET optimizer_switch=@save_optimizer_switch;
|
||||
|
||||
drop table t1, t2, t3;
|
||||
|
||||
--echo End of 5.3 tests
|
||||
|
||||
--echo #
|
||||
--echo # Bug#12763207 - ASSERT IN SUBSELECT::SINGLE_VALUE_TRANSFORMER
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1(a1 int);
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
|
||||
CREATE TABLE t2(a1 int);
|
||||
INSERT INTO t2 VALUES (3);
|
||||
|
||||
SELECT @@session.sql_mode INTO @old_sql_mode;
|
||||
SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
|
||||
|
||||
## All these are subject to the transformation
|
||||
## '1 < some (...)' => '1 < max(...)'
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2 FROM t2);
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2.0 FROM t2);
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 'a' FROM t2);
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t2);
|
||||
|
||||
SET SESSION sql_mode=@old_sql_mode;
|
||||
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
--echo #
|
||||
--echo # BUG#50257: Missing info in REF column of the EXPLAIN
|
||||
--echo # lines for subselects
|
||||
@ -4981,6 +5085,55 @@ EXPLAIN SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t1 WHERE a=7);
|
||||
--echo
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # Bug#11764086: Null left operand to NOT IN in WHERE clause
|
||||
--echo # behaves differently than real NULL
|
||||
--echo #
|
||||
|
||||
CREATE TABLE parent (id int);
|
||||
INSERT INTO parent VALUES (1), (2);
|
||||
|
||||
CREATE TABLE child (parent_id int, other int);
|
||||
INSERT INTO child VALUES (1,NULL);
|
||||
|
||||
--echo # Offending query (c.parent_id is NULL for null-complemented rows only)
|
||||
|
||||
SELECT p.id, c.parent_id
|
||||
FROM parent p
|
||||
LEFT JOIN child c
|
||||
ON p.id = c.parent_id
|
||||
WHERE c.parent_id NOT IN (
|
||||
SELECT parent_id
|
||||
FROM child
|
||||
WHERE parent_id = 3
|
||||
);
|
||||
|
||||
--echo # Some syntactic variations with IS FALSE and IS NOT TRUE
|
||||
|
||||
SELECT p.id, c.parent_id
|
||||
FROM parent p
|
||||
LEFT JOIN child c
|
||||
ON p.id = c.parent_id
|
||||
WHERE c.parent_id IN (
|
||||
SELECT parent_id
|
||||
FROM child
|
||||
WHERE parent_id = 3
|
||||
) IS NOT TRUE;
|
||||
|
||||
SELECT p.id, c.parent_id
|
||||
FROM parent p
|
||||
LEFT JOIN child c
|
||||
ON p.id = c.parent_id
|
||||
WHERE c.parent_id IN (
|
||||
SELECT parent_id
|
||||
FROM child
|
||||
WHERE parent_id = 3
|
||||
) IS FALSE;
|
||||
|
||||
DROP TABLE parent, child;
|
||||
|
||||
--echo # End of test for bug#11764086.
|
||||
|
||||
--echo #
|
||||
--echo # Bug 11765699 - 58690: !TABLE || (!TABLE->READ_SET ||
|
||||
--echo # BITMAP_IS_SET(TABLE->READ_SET, FIELD_INDEX
|
||||
@ -5279,6 +5432,17 @@ SELECT ( SELECT b FROM t2 WHERE b = a OR rand() * 0) FROM t1;
|
||||
|
||||
drop table t1,t2,t3;
|
||||
|
||||
--echo #
|
||||
--echo # LP BUG#905353 Wrong non-empty result with a constant table,
|
||||
--echo # aggregate function in subquery, MyISAM or Aria
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 ( a INT ) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (1);
|
||||
|
||||
SELECT a FROM t1 WHERE ( SELECT MIN(a) = 100 );
|
||||
|
||||
drop table t1;
|
||||
|
||||
--echo # return optimizer switch changed in the beginning of this test
|
||||
set optimizer_switch=@subselect_tmp;
|
||||
|
@ -1136,6 +1136,262 @@ WHERE (int_nokey, pk)
|
||||
|
||||
DROP TABLE t1, t2, t3;
|
||||
|
||||
--echo #
|
||||
--echo # BUG#53060: LooseScan semijoin strategy does not return all rows
|
||||
--echo #
|
||||
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
set optimizer_switch='semijoin=on,materialization=off';
|
||||
set optimizer_switch='firstmatch=off,loosescan=on';
|
||||
|
||||
CREATE TABLE t1 (i INTEGER);
|
||||
INSERT INTO t1 VALUES (1), (2), (3), (4), (5);
|
||||
CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j));
|
||||
INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1);
|
||||
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0);
|
||||
SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0);
|
||||
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
|
||||
--echo #
|
||||
--echo # BUG#49453: re-execution of prepared statement with view
|
||||
--echo # and semijoin crashes
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (city VARCHAR(50), country_id INT);
|
||||
CREATE TABLE t2 (country_id INT, country VARCHAR(50));
|
||||
|
||||
INSERT INTO t1 VALUES
|
||||
('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ;
|
||||
INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa');
|
||||
|
||||
CREATE VIEW v1 AS
|
||||
SELECT country_id as vf_country_id
|
||||
FROM t2
|
||||
WHERE LEFT(country,1) = "A";
|
||||
|
||||
PREPARE stmt FROM "
|
||||
SELECT city, country_id
|
||||
FROM t1
|
||||
WHERE country_id IN (SELECT vf_country_id FROM v1);
|
||||
";
|
||||
|
||||
--echo
|
||||
EXECUTE stmt;
|
||||
EXECUTE stmt;
|
||||
|
||||
DROP TABLE t1,t2;
|
||||
DROP VIEW v1;
|
||||
|
||||
--echo #
|
||||
--echo # Bug#54437 Extra rows with LEFT JOIN + semijoin
|
||||
--echo #
|
||||
|
||||
create table t1 (a int);
|
||||
create table t2 (a int);
|
||||
create table t3 (a int);
|
||||
insert into t1 values(1),(1);
|
||||
insert into t2 values(1),(1),(1),(1);
|
||||
insert into t3 values(2),(2);
|
||||
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
|
||||
set optimizer_switch='materialization=off';
|
||||
|
||||
set optimizer_switch='semijoin=off';
|
||||
explain
|
||||
select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a);
|
||||
select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a);
|
||||
|
||||
set optimizer_switch='semijoin=on';
|
||||
explain
|
||||
select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a);
|
||||
select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a);
|
||||
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
|
||||
drop table t1,t2,t3;
|
||||
|
||||
--echo #
|
||||
--echo # Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN))
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (a INT);
|
||||
CREATE TABLE t2 (a INT);
|
||||
CREATE TABLE t3 (a INT);
|
||||
INSERT INTO t1 VALUES(1),(1);
|
||||
INSERT INTO t2 VALUES(1),(1);
|
||||
INSERT INTO t3 VALUES(2),(2);
|
||||
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
|
||||
set optimizer_switch='semijoin=off,materialization=off';
|
||||
EXPLAIN
|
||||
SELECT * FROM t1
|
||||
WHERE t1.a IN (SELECT t2.a
|
||||
FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a);
|
||||
SELECT * FROM t1
|
||||
WHERE t1.a IN (SELECT t2.a
|
||||
FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a);
|
||||
|
||||
set optimizer_switch='semijoin=off,materialization=on';
|
||||
EXPLAIN
|
||||
SELECT * FROM t1
|
||||
WHERE t1.a IN (SELECT t2.a
|
||||
FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a);
|
||||
SELECT * FROM t1
|
||||
WHERE t1.a IN (SELECT t2.a
|
||||
FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a);
|
||||
|
||||
set optimizer_switch='semijoin=on,materialization=off';
|
||||
EXPLAIN
|
||||
SELECT * FROM t1
|
||||
WHERE t1.a IN (SELECT t2.a
|
||||
FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a);
|
||||
SELECT * FROM t1
|
||||
WHERE t1.a IN (SELECT t2.a
|
||||
FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a);
|
||||
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
|
||||
DROP TABLE t1,t2,t3;
|
||||
|
||||
--echo #
|
||||
--echo # BUG#52329 - Wrong result: subquery materialization, IN,
|
||||
--echo # non-null field followed by nullable
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL);
|
||||
|
||||
CREATE TABLE t2a (b1 char(8), b2 char(8));
|
||||
CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL);
|
||||
CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8));
|
||||
|
||||
INSERT INTO t1 VALUES ('1 - 12', '2 - 22');
|
||||
|
||||
INSERT INTO t2a VALUES ('1 - 11', '2 - 21'),
|
||||
('1 - 11', '2 - 21'),
|
||||
('1 - 12', '2 - 22'),
|
||||
('1 - 12', '2 - 22'),
|
||||
('1 - 13', '2 - 23');
|
||||
|
||||
INSERT INTO t2b SELECT * FROM t2a;
|
||||
INSERT INTO t2c SELECT * FROM t2a;
|
||||
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
|
||||
set optimizer_switch='semijoin=off,materialization=on';
|
||||
|
||||
SELECT * FROM t1
|
||||
WHERE (a1, a2) IN (
|
||||
SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2);
|
||||
|
||||
SELECT * FROM t1
|
||||
WHERE (a1, a2) IN (
|
||||
SELECT b1, b2 FROM t2a WHERE b1 > '0');
|
||||
|
||||
|
||||
SELECT * FROM t1
|
||||
WHERE (a1, a2) IN (
|
||||
SELECT b1, b2 FROM t2b WHERE b1 > '0');
|
||||
|
||||
|
||||
SELECT * FROM t1
|
||||
WHERE (a1, a2) IN (
|
||||
SELECT b1, b2 FROM t2c WHERE b1 > '0');
|
||||
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
|
||||
DROP TABLE t1,t2a,t2b,t2c;
|
||||
|
||||
--echo #
|
||||
--echo # Bug#57623: subquery within before insert trigger causes crash (sj=on)
|
||||
--echo #
|
||||
|
||||
CREATE TABLE ot1(a INT);
|
||||
CREATE TABLE ot2(a INT);
|
||||
CREATE TABLE ot3(a INT);
|
||||
CREATE TABLE it1(a INT);
|
||||
|
||||
INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7);
|
||||
INSERT INTO ot2 VALUES(0),(2),(4),(6);
|
||||
INSERT INTO ot3 VALUES(0),(3),(6);
|
||||
INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7);
|
||||
|
||||
let $query=
|
||||
SELECT *
|
||||
FROM ot1
|
||||
LEFT JOIN
|
||||
(ot2 JOIN ot3 on ot2.a=ot3.a)
|
||||
ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1);
|
||||
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
|
||||
set optimizer_switch='semijoin=on';
|
||||
|
||||
set optimizer_switch='materialization=off';
|
||||
eval explain $query;
|
||||
eval $query;
|
||||
eval prepare s from '$query';
|
||||
execute s;
|
||||
execute s;
|
||||
deallocate prepare s;
|
||||
|
||||
set optimizer_switch='materialization=on';
|
||||
eval explain $query;
|
||||
eval $query;
|
||||
eval prepare s from '$query';
|
||||
execute s;
|
||||
execute s;
|
||||
deallocate prepare s;
|
||||
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
|
||||
DROP TABLE ot1, ot2, ot3, it1;
|
||||
|
||||
--echo #
|
||||
--echo # Bug#59919/11766739: Crash in tmp_table_param::init() with semijoin=on
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM;
|
||||
CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM;
|
||||
CREATE TABLE t3 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM;
|
||||
|
||||
INSERT INTO t1 VALUES (1);
|
||||
INSERT INTO t2 VALUES (1,1), (2,1);
|
||||
INSERT INTO t3 VALUES
|
||||
(1,1), (2,1), (5,4), (7,3), (8,2), (8,1), (7,3),
|
||||
(9,5), (4,3), (7,2), (7,7), (3,1), (5,8), (9,7);
|
||||
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
|
||||
set optimizer_switch='semijoin=off,materialization=on';
|
||||
EXPLAIN
|
||||
SELECT * FROM t3
|
||||
WHERE f2 IN (SELECT t1.f1
|
||||
FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE);
|
||||
SELECT * FROM t3
|
||||
WHERE f2 IN (SELECT t1.f1
|
||||
FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE);
|
||||
|
||||
set optimizer_switch='semijoin=on,materialization=on';
|
||||
EXPLAIN
|
||||
SELECT * FROM t3
|
||||
WHERE f2 IN (SELECT t1.f1
|
||||
FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE);
|
||||
SELECT * FROM t3
|
||||
WHERE f2 IN (SELECT t1.f1
|
||||
FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE);
|
||||
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
|
||||
DROP TABLE t1, t2, t3 ;
|
||||
|
||||
--echo #
|
||||
--echo #
|
||||
--echo # BUG#784723: Wrong result with semijoin + nested subqueries in maria-5.3
|
||||
--echo #
|
||||
@ -2017,5 +2273,63 @@ SELECT a, COUNT(*) FROM t1
|
||||
|
||||
DROP TABLE t1, t2, t3;
|
||||
|
||||
--echo #
|
||||
--echo # BUG#920255: Wrong result (extra rows) with loosescan and IN subquery
|
||||
--echo #
|
||||
CREATE TABLE t1 ( a INT PRIMARY KEY, b INT, KEY(b) );
|
||||
INSERT INTO t1 VALUES
|
||||
(1,2),(2,1),(3,3),(4,2),(5,5),
|
||||
(6,3),(7,1),(8,4),(9,3),(10,2);
|
||||
|
||||
CREATE TABLE t2 ( c INT, d INT, UNIQUE KEY(c) );
|
||||
INSERT INTO t2 VALUES
|
||||
(1,2),(2,1),(3,3),(4,2),(5,5),(6,3),(7,1);
|
||||
|
||||
SELECT a, b, d FROM t1, t2
|
||||
WHERE ( b, d ) IN
|
||||
( SELECT b, d FROM t1, t2 WHERE b = c );
|
||||
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
--echo #
|
||||
--echo # BUG#920713: Wrong result (missing rows) with firstmatch+BNL, IN subquery, ...
|
||||
--echo #
|
||||
# t1 should be MyISAM or InnoDB
|
||||
CREATE TABLE t1 ( a VARCHAR(1) ) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES ('e'),('w'),('a'),('h'),('x'),('k'),('g');
|
||||
CREATE TABLE t2 ( b INT, c VARCHAR(1) );
|
||||
INSERT INTO t2 VALUES (0,'j'),(8,'v');
|
||||
|
||||
#SET debug_optimizer_prefer_join_prefix= 'alias2,alias4,alias1,alias3';
|
||||
|
||||
SELECT * FROM t1 alias1, t2 alias2
|
||||
WHERE alias2.c IN (
|
||||
SELECT alias4.c FROM t1 alias3, t2 alias4
|
||||
);
|
||||
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
--echo #
|
||||
--echo # BUG#923246: Loosescan reports different result than other semijoin methods
|
||||
--echo #
|
||||
set @tmp_923246= @@optimizer_switch;
|
||||
set optimizer_switch='mrr=on,materialization=off';
|
||||
|
||||
create table t0 (a int);
|
||||
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
|
||||
create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2));
|
||||
insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C;
|
||||
insert into t1 select * from t1 where kp1 < 20;
|
||||
|
||||
create table t3 (a int);
|
||||
insert into t3 select A.a + 10*B.a from t0 A, t0 B;
|
||||
|
||||
select * from t3 where a in (select kp1 from t1 where kp1<20);
|
||||
explain select * from t3 where a in (select kp1 from t1 where kp1<20);
|
||||
|
||||
drop table t0,t1,t3;
|
||||
set optimizer_switch= @tmp_923246;
|
||||
|
||||
# The following command must be the last one the file
|
||||
set optimizer_switch=@subselect_sj_tmp;
|
||||
|
@ -1079,5 +1079,19 @@ SELECT * FROM t3 LEFT JOIN (v1,t2) ON t3.a = t2.a
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1,t2,t3,t4;
|
||||
|
||||
--echo #
|
||||
--echo # BUG#912538: Wrong result (missing rows) with semijoin=on, firstmatch=on, ...
|
||||
--echo #
|
||||
CREATE TABLE t1 ( a INT NOT NULL, UNIQUE KEY(a) );
|
||||
INSERT INTO t1 VALUES (1),(2),(3),(4);
|
||||
|
||||
# t2 needs to be InnoDB
|
||||
CREATE TABLE t2 ( b INT, c INT ) ENGINE=InnoDB;
|
||||
INSERT INTO t2 VALUES (1,1);
|
||||
|
||||
SELECT * FROM t1, t2 WHERE c IN (SELECT c FROM t1, t2 WHERE a = b);
|
||||
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
--echo # This must be the last in the file:
|
||||
set optimizer_switch=@subselect_sj2_tmp;
|
||||
|
@ -88,6 +88,32 @@ set join_cache_level=default;
|
||||
|
||||
DROP TABLE t1,t2,t3;
|
||||
|
||||
--echo #
|
||||
--echo # BUG#912513: Wrong result (missing rows) with join_cache_hashed+materialization+semijoin=on
|
||||
--echo #
|
||||
set @os_912513= @@optimizer_switch;
|
||||
set @jcl_912513= @@join_cache_level;
|
||||
SET optimizer_switch = 'semijoin=on,materialization=on,join_cache_hashed=on';
|
||||
SET join_cache_level = 3;
|
||||
|
||||
CREATE TABLE t1 ( a INT, b INT, KEY(a) );
|
||||
INSERT INTO t1 VALUES
|
||||
(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7);
|
||||
|
||||
CREATE TABLE t2 ( c INT );
|
||||
INSERT INTO t2 VALUES (1),(2),(3),(4),(5),(6),(7);
|
||||
|
||||
SELECT alias1.* FROM
|
||||
t1 AS alias1 INNER JOIN t1 AS alias2
|
||||
ON alias2.a = alias1.b
|
||||
WHERE alias1.b IN (
|
||||
SELECT a FROM t1, t2
|
||||
);
|
||||
|
||||
DROP table t1, t2;
|
||||
set @@optimizer_switch= @os_912513;
|
||||
set @@join_cache_level= @jcl_912513;
|
||||
|
||||
--echo # End
|
||||
|
||||
set join_cache_level=default;
|
||||
|
@ -1510,6 +1510,42 @@ SELECT * FROM t1 LEFT JOIN t2 ON ( a = b )
|
||||
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
--echo #
|
||||
--echo # BUG#922254: Assertion `0' failed at item_cmpfunc.cc:5899: Item* Item_equal::get_first(JOIN_TAB*, Item*)
|
||||
--echo #
|
||||
CREATE TABLE t1 ( a VARCHAR(3) );
|
||||
CREATE TABLE t2 ( b VARCHAR(3), c VARCHAR(8), KEY(c) );
|
||||
INSERT INTO t2 VALUES ('USA','Abilene'),('USA','Akron');
|
||||
|
||||
EXPLAIN
|
||||
SELECT * FROM
|
||||
( SELECT * FROM t1 ) AS alias1,
|
||||
t2 AS alias2
|
||||
WHERE b = a AND a IN (
|
||||
SELECT alias3.c
|
||||
FROM t2 AS alias3, t2 AS alias4
|
||||
WHERE alias4.c = alias3.b
|
||||
);
|
||||
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
--echo #
|
||||
--echo # BUG#928048: Query containing IN subquery with OR in the where clause returns a wrong result
|
||||
--echo #
|
||||
create table t1 (a int, b int);
|
||||
insert into t1 values (7,5), (3,3), (5,4), (9,3);
|
||||
|
||||
create table t2 (a int, b int, index i_a(a));
|
||||
|
||||
insert into t2 values
|
||||
(4,2), (7,9), (7,4), (3,1), (5,3), (3,1), (9,4), (8,1);
|
||||
|
||||
explain select * from t1 where t1.a in (select a from t2 where t2.a=7 or t2.b<=1);
|
||||
select * from t1 where t1.a in (select a from t2 where t2.a=7 or t2.b<=1);
|
||||
|
||||
drop table t1,t2;
|
||||
|
||||
|
||||
--echo # This must be at the end:
|
||||
set optimizer_switch=@subselect_sj_mat_tmp;
|
||||
set join_cache_level=@save_join_cache_level;
|
||||
|
@ -93,3 +93,15 @@ SELECT SUM(DISTINCT id) FROM t1;
|
||||
SELECT SUM(DISTINCT id % 11) FROM t1;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # Bug #777654: empty subselect in FROM clause returning
|
||||
--echo # SUM(DISTINCT) over non-nullable field
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (a int NOT NULL) ;
|
||||
|
||||
SELECT SUM(DISTINCT a) FROM t1;
|
||||
SELECT * FROM (SELECT SUM(DISTINCT a) FROM t1) AS t;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
@ -4018,6 +4018,59 @@ drop table t1,t2;
|
||||
--echo # -----------------------------------------------------------------
|
||||
--echo # -- End of 5.1 tests.
|
||||
--echo # -----------------------------------------------------------------
|
||||
--echo #
|
||||
--echo # Bug #794005: crash in st_table::mark_virtual_columns_for_write
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (a int);
|
||||
insert into t1 values (1);
|
||||
CREATE TABLE t2 (a int);
|
||||
insert into t2 values (1);
|
||||
|
||||
CREATE VIEW v2 AS SELECT * FROM t2;
|
||||
CREATE VIEW v1 AS SELECT * FROM v2;
|
||||
CREATE VIEW v3 AS SELECT t2.a,v1.a as b FROM t2,v1 where t2.a=v1.a;
|
||||
CREATE OR REPLACE ALGORITHM = TEMPTABLE VIEW v2 AS SELECT * FROM t1;
|
||||
|
||||
--error ER_NON_UPDATABLE_TABLE
|
||||
UPDATE v1 SET a = 10;
|
||||
--error ER_NON_INSERTABLE_TABLE
|
||||
REPLACE v1 SET a = 10;
|
||||
--error ER_NON_INSERTABLE_TABLE
|
||||
INSERT into v1 values (20);
|
||||
--error ER_NON_UPDATABLE_TABLE
|
||||
DELETE from v1;
|
||||
--error ER_NON_UPDATABLE_TABLE
|
||||
UPDATE v3 SET b= 10;
|
||||
--error ER_NON_INSERTABLE_TABLE
|
||||
REPLACE v3 SET b= 10;
|
||||
--error ER_NON_INSERTABLE_TABLE
|
||||
INSERT into v3(b) values (20);
|
||||
--error ER_VIEW_DELETE_MERGE_VIEW
|
||||
DELETE from v3 where b=20;
|
||||
--error ER_VIEW_DELETE_MERGE_VIEW
|
||||
DELETE from v3 where a=20;
|
||||
--error ER_NON_UPDATABLE_TABLE
|
||||
DELETE v1 from v1,t1 where v1.a=t1.a;
|
||||
UPDATE v3 SET a = 10;
|
||||
REPLACE v3 SET a = 11;
|
||||
INSERT INTO v3(a) values (20);
|
||||
|
||||
select * from t1;
|
||||
select * from t2;
|
||||
|
||||
CREATE OR REPLACE ALGORITHM = MERGE VIEW v2 AS SELECT * FROM t2;
|
||||
DELETE from v1 where a=11;
|
||||
DELETE v1 from v1,t1 where v1.a=t1.a;
|
||||
select * from t1;
|
||||
select * from t2;
|
||||
|
||||
DROP VIEW v1,v2,v3;
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
--echo # -----------------------------------------------------------------
|
||||
--echo # -- End of 5.2 tests.
|
||||
--echo # -----------------------------------------------------------------
|
||||
|
||||
--echo #
|
||||
--echo # Bug #59696 Optimizer does not use equalities for conditions over view
|
||||
@ -4493,4 +4546,8 @@ SELECT * FROM t1 RIGHT JOIN v2 ON ( v2.a = t1.a ) WHERE v2.b IN ( SELECT b FROM
|
||||
DROP VIEW v2;
|
||||
DROP TABLE t1, t2, t3;
|
||||
|
||||
--echo # -----------------------------------------------------------------
|
||||
--echo # -- End of 5.3 tests.
|
||||
--echo # -----------------------------------------------------------------
|
||||
|
||||
SET optimizer_switch=@save_optimizer_switch;
|
||||
|
@ -413,133 +413,19 @@
|
||||
fun:__libc_start_main
|
||||
}
|
||||
|
||||
{
|
||||
dlclose memory loss from udf_free
|
||||
Memcheck:Leak
|
||||
fun:calloc
|
||||
fun:_dlerror_run
|
||||
fun:dlclose
|
||||
fun:_Z8udf_freev
|
||||
}
|
||||
|
||||
#
|
||||
# dlclose can allocate memory for error message, the memory will be
|
||||
# freed by dlerror or other dl* function.
|
||||
#
|
||||
{
|
||||
dlsym memory loss from udf_free on SuSE 11.1 x64 variant 2
|
||||
memory "loss" from dlclose error messages
|
||||
Memcheck:Leak
|
||||
fun:calloc
|
||||
obj:/lib*/ld-*.so
|
||||
fun:dlclose
|
||||
fun:udf_free
|
||||
}
|
||||
|
||||
{
|
||||
dlclose memory loss from plugin variant 1
|
||||
Memcheck:Leak
|
||||
fun:calloc
|
||||
fun:_dlerror_run
|
||||
fun:dlclose
|
||||
fun:plugin_dl_del(st_mysql_lex_string const*)
|
||||
}
|
||||
|
||||
{
|
||||
dlclose memory loss from plugin variant 2
|
||||
Memcheck:Leak
|
||||
fun:malloc
|
||||
fun:_dl_close_worker
|
||||
fun:_dl_close
|
||||
fun:_dl_catch_error
|
||||
fun:_dlerror_run
|
||||
fun:dlclose
|
||||
fun:_Z15free_plugin_memP12st_plugin_dl
|
||||
fun:_Z13plugin_dl_delPK19st_mysql_lex_string
|
||||
}
|
||||
|
||||
{
|
||||
dlclose memory loss from plugin variant 3
|
||||
Memcheck:Leak
|
||||
fun:malloc
|
||||
fun:_dl_scope_free
|
||||
fun:_dl_close_worker
|
||||
fun:_dl_close
|
||||
fun:_dl_catch_error
|
||||
fun:_dlerror_run
|
||||
fun:dlclose
|
||||
fun:_Z15free_plugin_memP12st_plugin_dl
|
||||
fun:_Z13plugin_dl_delPK19st_mysql_lex_string
|
||||
}
|
||||
|
||||
{
|
||||
dlclose memory loss from plugin variant 4
|
||||
Memcheck:Leak
|
||||
fun:malloc
|
||||
obj:/lib*/ld-*.so
|
||||
obj:/lib*/ld-*.so
|
||||
obj:/lib*/ld-*.so
|
||||
obj:/lib*/libdl-*.so
|
||||
fun:dlclose
|
||||
fun:_ZL15free_plugin_memP12st_plugin_dl
|
||||
fun:_ZL13plugin_dl_delPK19st_mysql_lex_string
|
||||
}
|
||||
|
||||
{
|
||||
dlclose memory loss from plugin variant 5
|
||||
Memcheck:Leak
|
||||
fun:malloc
|
||||
obj:/lib*/ld-*.so
|
||||
obj:/lib*/ld-*.so
|
||||
obj:/lib*/ld-*.so
|
||||
obj:/lib*/ld-*.so
|
||||
obj:/lib*/libdl-*.so
|
||||
fun:*alloc
|
||||
...
|
||||
fun:dlclose
|
||||
}
|
||||
|
||||
{
|
||||
dlclose memory loss from plugin variant 6, seen on Ubuntu Jaunty i686
|
||||
Memcheck:Leak
|
||||
fun:malloc
|
||||
fun:_dl_scope_free
|
||||
fun:_dl_close_worker
|
||||
fun:_dl_close
|
||||
fun:dlclose_doit
|
||||
fun:_dl_catch_error
|
||||
fun:_dlerror_run
|
||||
fun:dlclose
|
||||
fun:_ZL15free_plugin_memP12st_plugin_dl
|
||||
fun:_ZL13plugin_dl_delPK19st_mysql_lex_string
|
||||
}
|
||||
|
||||
{
|
||||
dlclose memory loss from plugin variant 7, seen on Ubuntu Jaunty i686
|
||||
Memcheck:Leak
|
||||
fun:malloc
|
||||
fun:_dl_close_worker
|
||||
fun:_dl_close
|
||||
fun:dlclose_doit
|
||||
fun:_dl_catch_error
|
||||
fun:_dlerror_run
|
||||
fun:dlclose
|
||||
fun:_ZL15free_plugin_memP12st_plugin_dl
|
||||
fun:_ZL13plugin_dl_delPK19st_mysql_lex_string
|
||||
}
|
||||
|
||||
{
|
||||
dlclose memory loss from plugin variant 8
|
||||
Memcheck:Leak
|
||||
fun:calloc
|
||||
fun:_dlerror_run
|
||||
fun:dlclose
|
||||
fun:_Z15free_plugin_memP12st_plugin_dl
|
||||
fun:_Z13plugin_dl_delPK19st_mysql_lex_string
|
||||
}
|
||||
|
||||
{
|
||||
dlclose memory loss from plugin variant 9
|
||||
Memcheck:Leak
|
||||
fun:calloc
|
||||
fun:_dlerror_run
|
||||
fun:dlclose
|
||||
fun:_ZL15free_plugin_memP12st_plugin_dl
|
||||
fun:_ZL13plugin_dl_delPK19st_mysql_lex_string
|
||||
}
|
||||
|
||||
{
|
||||
dlclose memory loss from plugin variant 10
|
||||
|
@ -148,6 +148,8 @@ static int perform_dialog(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql)
|
||||
if (res)
|
||||
return CR_ERROR;
|
||||
|
||||
first= 0;
|
||||
|
||||
/* repeat unless it was the last question */
|
||||
} while ((cmd & 1) != 1);
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <mysql/plugin_auth.h>
|
||||
#include <string.h>
|
||||
#include <my_config.h>
|
||||
#include <security/pam_appl.h>
|
||||
#include <security/pam_modules.h>
|
||||
|
||||
@ -8,6 +9,24 @@ struct param {
|
||||
MYSQL_PLUGIN_VIO *vio;
|
||||
};
|
||||
|
||||
/* It least solaris doesn't have strndup */
|
||||
|
||||
#ifndef HAVE_STRNDUP
|
||||
char *strndup(const char *from, size_t length)
|
||||
{
|
||||
char *ptr;
|
||||
size_t max_length= strlen(from);
|
||||
if (length > max_length)
|
||||
length= max_length;
|
||||
if ((ptr= (char*) malloc(length+1)) != 0)
|
||||
{
|
||||
memcpy((char*) ptr, (char*) from, length);
|
||||
ptr[length]=0;
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int conv(int n, const struct pam_message **msg,
|
||||
struct pam_response **resp, void *data)
|
||||
{
|
||||
@ -71,13 +90,21 @@ static int conv(int n, const struct pam_message **msg,
|
||||
|
||||
#define DO(X) if ((status = (X)) != PAM_SUCCESS) goto end
|
||||
|
||||
#ifdef SOLARIS
|
||||
typedef void** pam_get_item_3_arg;
|
||||
#else
|
||||
typedef const void** pam_get_item_3_arg;
|
||||
#endif
|
||||
|
||||
static int pam_auth(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info)
|
||||
{
|
||||
pam_handle_t *pamh = NULL;
|
||||
int status;
|
||||
const char *new_username;
|
||||
struct param param;
|
||||
struct pam_conv c = { &conv, ¶m };
|
||||
/* The following is written in such a way to make also solaris happy */
|
||||
struct pam_conv pam_start_arg = { &conv, NULL };
|
||||
pam_start_arg.appdata_ptr= (char*) ¶m;
|
||||
|
||||
/*
|
||||
get the service name, as specified in
|
||||
@ -90,10 +117,10 @@ static int pam_auth(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info)
|
||||
param.ptr = param.buf + 1;
|
||||
param.vio = vio;
|
||||
|
||||
DO( pam_start(service, info->user_name, &c, &pamh) );
|
||||
DO( pam_start(service, info->user_name, &pam_start_arg, &pamh) );
|
||||
DO( pam_authenticate (pamh, 0) );
|
||||
DO( pam_acct_mgmt(pamh, 0) );
|
||||
DO( pam_get_item(pamh, PAM_USER, (const void**)&new_username) );
|
||||
DO( pam_get_item(pamh, PAM_USER, (pam_get_item_3_arg) &new_username) );
|
||||
|
||||
if (new_username && strcmp(new_username, info->user_name))
|
||||
strncpy(info->authenticated_as, new_username,
|
||||
@ -104,7 +131,7 @@ end:
|
||||
return status == PAM_SUCCESS ? CR_OK : CR_ERROR;
|
||||
}
|
||||
|
||||
static struct st_mysql_auth pam_info =
|
||||
static struct st_mysql_auth info =
|
||||
{
|
||||
MYSQL_AUTHENTICATION_INTERFACE_VERSION,
|
||||
"dialog",
|
||||
@ -114,7 +141,7 @@ static struct st_mysql_auth pam_info =
|
||||
maria_declare_plugin(pam)
|
||||
{
|
||||
MYSQL_AUTHENTICATION_PLUGIN,
|
||||
&pam_info,
|
||||
&info,
|
||||
"pam",
|
||||
"Sergei Golubchik",
|
||||
"PAM based authentication",
|
||||
|
@ -89,7 +89,7 @@ mysql_declare_plugin(socket_auth)
|
||||
{
|
||||
MYSQL_AUTHENTICATION_PLUGIN,
|
||||
&socket_auth_handler,
|
||||
"auth_socket",
|
||||
"unix_socket",
|
||||
"Sergei Golubchik",
|
||||
"Unix Socket based authentication",
|
||||
PLUGIN_LICENSE_GPL,
|
||||
@ -106,7 +106,7 @@ maria_declare_plugin(socket_auth)
|
||||
{
|
||||
MYSQL_AUTHENTICATION_PLUGIN,
|
||||
&socket_auth_handler,
|
||||
"auth_socket",
|
||||
"unix_socket",
|
||||
"Sergei Golubchik",
|
||||
"Unix Socket based authentication",
|
||||
PLUGIN_LICENSE_GPL,
|
||||
|
@ -4069,6 +4069,8 @@ int ha_partition::rnd_next(uchar *buf)
|
||||
int result= HA_ERR_END_OF_FILE;
|
||||
uint part_id= m_part_spec.start_part;
|
||||
DBUG_ENTER("ha_partition::rnd_next");
|
||||
|
||||
/* upper level will increment this once again at end of call */
|
||||
decrement_statistics(&SSV::ha_read_rnd_next_count);
|
||||
|
||||
if (NO_CURRENT_PART_ID == part_id)
|
||||
|
37
sql/item.cc
37
sql/item.cc
@ -5378,7 +5378,8 @@ bool Item_field::set_no_const_sub(uchar *arg)
|
||||
|
||||
Item *Item_field::replace_equal_field(uchar *arg)
|
||||
{
|
||||
if (item_equal && item_equal == (Item_equal *) arg)
|
||||
REPLACE_EQUAL_FIELD_ARG* param= (REPLACE_EQUAL_FIELD_ARG*)arg;
|
||||
if (item_equal && item_equal == param->item_equal)
|
||||
{
|
||||
Item *const_item= item_equal->get_const();
|
||||
if (const_item)
|
||||
@ -5387,7 +5388,8 @@ Item *Item_field::replace_equal_field(uchar *arg)
|
||||
return this;
|
||||
return const_item;
|
||||
}
|
||||
Item_field *subst= (Item_field *)(item_equal->get_first(this));
|
||||
Item_field *subst=
|
||||
(Item_field *)(item_equal->get_first(param->context_tab, this));
|
||||
if (subst)
|
||||
subst= (Item_field *) (subst->real_item());
|
||||
if (subst && !field->eq(subst->field))
|
||||
@ -9467,13 +9469,13 @@ void Item_type_holder::get_full_info(Item *item)
|
||||
DBUG_ASSERT((enum_set_typelib &&
|
||||
get_real_type(item) == MYSQL_TYPE_NULL) ||
|
||||
(!enum_set_typelib &&
|
||||
item->type() == Item::FIELD_ITEM &&
|
||||
(get_real_type(item) == MYSQL_TYPE_ENUM ||
|
||||
get_real_type(item) == MYSQL_TYPE_SET) &&
|
||||
((Field_enum*)((Item_field *) item)->field)->typelib));
|
||||
item->real_item()->type() == Item::FIELD_ITEM &&
|
||||
(get_real_type(item->real_item()) == MYSQL_TYPE_ENUM ||
|
||||
get_real_type(item->real_item()) == MYSQL_TYPE_SET) &&
|
||||
((Field_enum*)((Item_field *) item->real_item())->field)->typelib));
|
||||
if (!enum_set_typelib)
|
||||
{
|
||||
enum_set_typelib= ((Field_enum*)((Item_field *) item)->field)->typelib;
|
||||
enum_set_typelib= ((Field_enum*)((Item_field *) item->real_item())->field)->typelib;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -9558,18 +9560,22 @@ void Item_ref::update_used_tables()
|
||||
}
|
||||
|
||||
|
||||
table_map Item_direct_view_ref::used_tables() const
|
||||
table_map Item_direct_view_ref::used_tables() const
|
||||
{
|
||||
return get_depended_from() ?
|
||||
return get_depended_from() ?
|
||||
OUTER_REF_TABLE_BIT :
|
||||
(view->merged ? (*ref)->used_tables() : view->table->map);
|
||||
((view->merged || !view->table) ?
|
||||
(*ref)->used_tables() :
|
||||
view->table->map);
|
||||
}
|
||||
|
||||
table_map Item_direct_view_ref::not_null_tables() const
|
||||
table_map Item_direct_view_ref::not_null_tables() const
|
||||
{
|
||||
return get_depended_from() ?
|
||||
return get_depended_from() ?
|
||||
0 :
|
||||
(view->merged ? (*ref)->not_null_tables() : view->table->map);
|
||||
((view->merged || !view->table) ?
|
||||
(*ref)->not_null_tables() :
|
||||
view->table->map);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -9583,6 +9589,8 @@ table_map Item_ref_null_helper::used_tables() const
|
||||
}
|
||||
|
||||
|
||||
#ifndef DBUG_OFF
|
||||
|
||||
/* Debugger help function */
|
||||
static char dbug_item_print_buf[256];
|
||||
|
||||
@ -9599,6 +9607,9 @@ const char *dbug_print_item(Item *item)
|
||||
else
|
||||
return "Couldn't fit into buffer";
|
||||
}
|
||||
|
||||
#endif /*DBUG_OFF*/
|
||||
|
||||
/*****************************************************************************
|
||||
** Instantiate templates
|
||||
*****************************************************************************/
|
||||
|
11
sql/item.h
11
sql/item.h
@ -471,6 +471,16 @@ typedef enum monotonicity_info
|
||||
class sp_rcontext;
|
||||
|
||||
|
||||
class Item_equal;
|
||||
|
||||
struct st_join_table* const NO_PARTICULAR_TAB= (struct st_join_table*)0x1;
|
||||
|
||||
typedef struct replace_equal_field_arg
|
||||
{
|
||||
Item_equal *item_equal;
|
||||
struct st_join_table *context_tab;
|
||||
} REPLACE_EQUAL_FIELD_ARG;
|
||||
|
||||
class Settable_routine_parameter
|
||||
{
|
||||
public:
|
||||
@ -1283,6 +1293,7 @@ public:
|
||||
|
||||
virtual Item *equal_fields_propagator(uchar * arg) { return this; }
|
||||
virtual bool set_no_const_sub(uchar *arg) { return FALSE; }
|
||||
/* arg points to REPLACE_EQUAL_FIELD_ARG object */
|
||||
virtual Item *replace_equal_field(uchar * arg) { return this; }
|
||||
/*
|
||||
Check if an expression value has allowed arguments, like DATE/DATETIME
|
||||
|
@ -5804,7 +5804,7 @@ longlong Item_equal::val_int()
|
||||
|
||||
void Item_equal::fix_length_and_dec()
|
||||
{
|
||||
Item *item= get_first(NULL);
|
||||
Item *item= get_first(NO_PARTICULAR_TAB, NULL);
|
||||
eval_item= cmp_item::get_comparator(item->cmp_type(), item,
|
||||
item->collation.collation);
|
||||
}
|
||||
@ -5904,7 +5904,7 @@ CHARSET_INFO *Item_equal::compare_collation()
|
||||
@retval 0 if no field found.
|
||||
*/
|
||||
|
||||
Item* Item_equal::get_first(Item *field_item)
|
||||
Item* Item_equal::get_first(JOIN_TAB *context, Item *field_item)
|
||||
{
|
||||
Item_equal_fields_iterator it(*this);
|
||||
Item *item;
|
||||
@ -5932,18 +5932,24 @@ Item* Item_equal::get_first(Item *field_item)
|
||||
in presense of SJM nests.
|
||||
*/
|
||||
|
||||
TABLE_LIST *emb_nest= field->table->pos_in_table_list->embedding;
|
||||
TABLE_LIST *emb_nest;
|
||||
if (context != NO_PARTICULAR_TAB)
|
||||
emb_nest= context->emb_sj_nest;
|
||||
else
|
||||
emb_nest= field->table->pos_in_table_list->embedding;
|
||||
|
||||
if (emb_nest && emb_nest->sj_mat_info && emb_nest->sj_mat_info->is_used)
|
||||
{
|
||||
/*
|
||||
It's a field from an materialized semi-join. We can substitute it only
|
||||
for a field from the same semi-join. Find the first of such items.
|
||||
It's a field from an materialized semi-join. We can substitute it for
|
||||
- a constant item
|
||||
- a field from the same semi-join
|
||||
Find the first of such items:
|
||||
*/
|
||||
|
||||
while ((item= it++))
|
||||
{
|
||||
if (it.get_curr_field()->table->pos_in_table_list->embedding == emb_nest)
|
||||
if (item->const_item() ||
|
||||
it.get_curr_field()->table->pos_in_table_list->embedding == emb_nest)
|
||||
{
|
||||
/*
|
||||
If we found given field then return NULL to avoid unnecessary
|
||||
|
@ -1705,7 +1705,7 @@ public:
|
||||
/** Add a non-constant item to the multiple equality */
|
||||
void add(Item *f) { equal_items.push_back(f); }
|
||||
bool contains(Field *field);
|
||||
Item* get_first(Item *field);
|
||||
Item* get_first(struct st_join_table *context, Item *field);
|
||||
/** Get number of field items / references to field items in this object */
|
||||
uint n_field_items() { return equal_items.elements-test(with_const); }
|
||||
void merge(Item_equal *item);
|
||||
|
@ -1271,7 +1271,8 @@ void Item_exists_subselect::fix_length_and_dec()
|
||||
We need only 1 row to determine existence (i.e. any EXISTS that is not
|
||||
an IN always requires LIMIT 1)
|
||||
*/
|
||||
unit->global_parameters->select_limit= new Item_int((int32) 1);
|
||||
thd->change_item_tree(&unit->global_parameters->select_limit,
|
||||
new Item_int((int32) 1));
|
||||
DBUG_PRINT("info", ("Set limit to 1"));
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
@ -1597,7 +1598,6 @@ Item_in_subselect::single_value_transformer(JOIN *join)
|
||||
(Item**)optimizer->get_cache(),
|
||||
(char *)"<no matter>",
|
||||
(char *)in_left_expr_name);
|
||||
|
||||
}
|
||||
|
||||
DBUG_RETURN(false);
|
||||
@ -1684,10 +1684,6 @@ bool Item_allany_subselect::transform_into_max_min(JOIN *join)
|
||||
|
||||
DBUG_EXECUTE("where",
|
||||
print_where(item, "rewrite with MIN/MAX", QT_ORDINARY););
|
||||
if (thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY)
|
||||
{
|
||||
select_lex->set_non_agg_field_used(false);
|
||||
}
|
||||
|
||||
save_allow_sum_func= thd->lex->allow_sum_func;
|
||||
thd->lex->allow_sum_func|= 1 << thd->lex->current_select->nest_level;
|
||||
@ -2244,7 +2240,12 @@ bool Item_in_subselect::create_in_to_exists_cond(JOIN *join_arg)
|
||||
/*
|
||||
The IN=>EXISTS transformation makes non-correlated subqueries correlated.
|
||||
*/
|
||||
join_arg->select_lex->uncacheable|= UNCACHEABLE_DEPENDENT_INJECTED;
|
||||
if (!left_expr->const_item() || left_expr->is_expensive())
|
||||
{
|
||||
join_arg->select_lex->uncacheable|= UNCACHEABLE_DEPENDENT_INJECTED;
|
||||
join_arg->select_lex->master_unit()->uncacheable|=
|
||||
UNCACHEABLE_DEPENDENT_INJECTED;
|
||||
}
|
||||
/*
|
||||
The uncacheable property controls a number of actions, e.g. whether to
|
||||
save/restore (via init_save_join_tab/restore_tmp) the original JOIN for
|
||||
@ -2510,6 +2511,7 @@ bool Item_in_subselect::fix_fields(THD *thd_arg, Item **ref)
|
||||
left_expr && !left_expr->fixed &&
|
||||
left_expr->fix_fields(thd_arg, &left_expr))
|
||||
return TRUE;
|
||||
else
|
||||
if (Item_subselect::fix_fields(thd_arg, ref))
|
||||
return TRUE;
|
||||
fixed= TRUE;
|
||||
@ -3159,6 +3161,8 @@ bool subselect_uniquesubquery_engine::copy_ref_key()
|
||||
|
||||
for (store_key **copy= tab->ref.key_copy ; *copy ; copy++)
|
||||
{
|
||||
if ((*copy)->store_key_is_const())
|
||||
continue;
|
||||
tab->ref.key_err= (*copy)->copy();
|
||||
|
||||
/*
|
||||
|
@ -1129,13 +1129,12 @@ Item_sum_num::fix_fields(THD *thd, Item **ref)
|
||||
return TRUE;
|
||||
|
||||
decimals=0;
|
||||
maybe_null=0;
|
||||
maybe_null= sum_func() != COUNT_FUNC;
|
||||
for (uint i=0 ; i < arg_count ; i++)
|
||||
{
|
||||
if (args[i]->fix_fields(thd, args + i) || args[i]->check_cols(1))
|
||||
return TRUE;
|
||||
set_if_bigger(decimals, args[i]->decimals);
|
||||
maybe_null |= args[i]->maybe_null;
|
||||
}
|
||||
result_field=0;
|
||||
max_length=float_length(decimals);
|
||||
|
@ -482,6 +482,10 @@ void Mrr_ordered_index_reader::resume_read()
|
||||
|
||||
/**
|
||||
Fill the buffer with (lookup_tuple, range_id) pairs and sort
|
||||
|
||||
@return
|
||||
0 OK, the buffer is non-empty and sorted
|
||||
HA_ERR_END_OF_FILE Source exhausted, the buffer is empty.
|
||||
*/
|
||||
|
||||
int Mrr_ordered_index_reader::refill_buffer(bool initial)
|
||||
@ -518,6 +522,13 @@ int Mrr_ordered_index_reader::refill_buffer(bool initial)
|
||||
if (source_exhausted && key_buffer->is_empty())
|
||||
DBUG_RETURN(HA_ERR_END_OF_FILE);
|
||||
|
||||
if (!initial)
|
||||
{
|
||||
/* This is a non-initial buffer fill and we've got a non-empty buffer */
|
||||
THD *thd= current_thd;
|
||||
status_var_increment(thd->status_var.ha_mrr_extra_key_sorts);
|
||||
}
|
||||
|
||||
key_buffer->sort((key_buffer->type() == Lifo_buffer::FORWARD)?
|
||||
(qsort2_cmp)Mrr_ordered_index_reader::compare_keys_reverse :
|
||||
(qsort2_cmp)Mrr_ordered_index_reader::compare_keys,
|
||||
@ -592,6 +603,7 @@ int Mrr_ordered_rndpos_reader::init(handler *h_arg,
|
||||
int Mrr_ordered_rndpos_reader::refill_buffer(bool initial)
|
||||
{
|
||||
int res;
|
||||
bool first_call= initial;
|
||||
DBUG_ENTER("Mrr_ordered_rndpos_reader::refill_buffer");
|
||||
|
||||
if (index_reader_exhausted)
|
||||
@ -609,6 +621,14 @@ int Mrr_ordered_rndpos_reader::refill_buffer(bool initial)
|
||||
initial= FALSE;
|
||||
index_reader_needs_refill= FALSE;
|
||||
}
|
||||
|
||||
if (!first_call && !index_reader_exhausted)
|
||||
{
|
||||
/* Ok, this was a successful buffer refill operation */
|
||||
THD *thd= current_thd;
|
||||
status_var_increment(thd->status_var.ha_mrr_extra_rowid_sorts);
|
||||
}
|
||||
|
||||
DBUG_RETURN(res);
|
||||
}
|
||||
|
||||
@ -841,8 +861,7 @@ int DsMrr_impl::dsmrr_init(handler *h_arg, RANGE_SEQ_IF *seq_funcs,
|
||||
strategy= disk_strategy= &reader_factory.ordered_rndpos_reader;
|
||||
}
|
||||
|
||||
if (is_mrr_assoc)
|
||||
status_var_increment(thd->status_var.ha_multi_range_read_init_count);
|
||||
status_var_increment(thd->status_var.ha_multi_range_read_init_count);
|
||||
|
||||
full_buf= buf->buffer;
|
||||
full_buf_end= buf->buffer_end;
|
||||
|
@ -1883,7 +1883,6 @@ static void clean_up_mutexes()
|
||||
mysql_mutex_destroy(&LOCK_delayed_insert);
|
||||
mysql_mutex_destroy(&LOCK_delayed_status);
|
||||
mysql_mutex_destroy(&LOCK_delayed_create);
|
||||
mysql_mutex_destroy(&LOCK_manager);
|
||||
mysql_mutex_destroy(&LOCK_crypt);
|
||||
mysql_mutex_destroy(&LOCK_user_conn);
|
||||
mysql_mutex_destroy(&LOCK_connection_count);
|
||||
@ -1914,7 +1913,6 @@ static void clean_up_mutexes()
|
||||
mysql_cond_destroy(&COND_thread_count);
|
||||
mysql_cond_destroy(&COND_thread_cache);
|
||||
mysql_cond_destroy(&COND_flush_thread_cache);
|
||||
mysql_cond_destroy(&COND_manager);
|
||||
mysql_mutex_destroy(&LOCK_server_started);
|
||||
mysql_cond_destroy(&COND_server_started);
|
||||
mysql_mutex_destroy(&LOCK_prepare_ordered);
|
||||
@ -3776,8 +3774,6 @@ static int init_thread_environment()
|
||||
&LOCK_delayed_status, MY_MUTEX_INIT_FAST);
|
||||
mysql_mutex_init(key_LOCK_delayed_create,
|
||||
&LOCK_delayed_create, MY_MUTEX_INIT_SLOW);
|
||||
mysql_mutex_init(key_LOCK_manager,
|
||||
&LOCK_manager, MY_MUTEX_INIT_FAST);
|
||||
mysql_mutex_init(key_LOCK_crypt, &LOCK_crypt, MY_MUTEX_INIT_FAST);
|
||||
mysql_mutex_init(key_LOCK_user_conn, &LOCK_user_conn, MY_MUTEX_INIT_FAST);
|
||||
mysql_mutex_init(key_LOCK_active_mi, &LOCK_active_mi, MY_MUTEX_INIT_FAST);
|
||||
@ -3826,7 +3822,6 @@ static int init_thread_environment()
|
||||
mysql_cond_init(key_COND_thread_count, &COND_thread_count, NULL);
|
||||
mysql_cond_init(key_COND_thread_cache, &COND_thread_cache, NULL);
|
||||
mysql_cond_init(key_COND_flush_thread_cache, &COND_flush_thread_cache, NULL);
|
||||
mysql_cond_init(key_COND_manager, &COND_manager, NULL);
|
||||
#ifdef HAVE_REPLICATION
|
||||
mysql_mutex_init(key_LOCK_rpl_status, &LOCK_rpl_status, MY_MUTEX_INIT_FAST);
|
||||
mysql_cond_init(key_COND_rpl_status, &COND_rpl_status, NULL);
|
||||
@ -6874,6 +6869,12 @@ SHOW_VAR status_vars[]= {
|
||||
{"Handler_commit", (char*) offsetof(STATUS_VAR, ha_commit_count), SHOW_LONG_STATUS},
|
||||
{"Handler_delete", (char*) offsetof(STATUS_VAR, ha_delete_count), SHOW_LONG_STATUS},
|
||||
{"Handler_discover", (char*) offsetof(STATUS_VAR, ha_discover_count), SHOW_LONG_STATUS},
|
||||
#if 0
|
||||
/* Made 3 counters below temporarily invisible until we agree upon their names */
|
||||
{"Handler_mrr_extra_key_sorts", (char*) offsetof(STATUS_VAR, ha_mrr_extra_key_sorts), SHOW_LONG_STATUS},
|
||||
{"Handler_mrr_extra_rowid_sorts", (char*) offsetof(STATUS_VAR, ha_mrr_extra_rowid_sorts), SHOW_LONG_STATUS},
|
||||
{"Handler_mrr_init", (char*) offsetof(STATUS_VAR, ha_multi_range_read_init_count), SHOW_LONG_STATUS},
|
||||
#endif
|
||||
{"Handler_prepare", (char*) offsetof(STATUS_VAR, ha_prepare_count), SHOW_LONG_STATUS},
|
||||
{"Handler_read_first", (char*) offsetof(STATUS_VAR, ha_read_first_count), SHOW_LONG_STATUS},
|
||||
{"Handler_read_key", (char*) offsetof(STATUS_VAR, ha_read_key_count), SHOW_LONG_STATUS},
|
||||
@ -6881,14 +6882,15 @@ SHOW_VAR status_vars[]= {
|
||||
{"Handler_read_next", (char*) offsetof(STATUS_VAR, ha_read_next_count), SHOW_LONG_STATUS},
|
||||
{"Handler_read_prev", (char*) offsetof(STATUS_VAR, ha_read_prev_count), SHOW_LONG_STATUS},
|
||||
{"Handler_read_rnd", (char*) offsetof(STATUS_VAR, ha_read_rnd_count), SHOW_LONG_STATUS},
|
||||
{"Handler_read_rnd_deleted", (char*) offsetof(STATUS_VAR, ha_read_rnd_deleted_count), SHOW_LONG_STATUS},
|
||||
{"Handler_read_rnd_next", (char*) offsetof(STATUS_VAR, ha_read_rnd_next_count), SHOW_LONG_STATUS},
|
||||
{"Handler_rollback", (char*) offsetof(STATUS_VAR, ha_rollback_count), SHOW_LONG_STATUS},
|
||||
{"Handler_savepoint", (char*) offsetof(STATUS_VAR, ha_savepoint_count), SHOW_LONG_STATUS},
|
||||
{"Handler_savepoint_rollback",(char*) offsetof(STATUS_VAR, ha_savepoint_rollback_count), SHOW_LONG_STATUS},
|
||||
{"Handler_update", (char*) offsetof(STATUS_VAR, ha_update_count), SHOW_LONG_STATUS},
|
||||
{"Handler_write", (char*) offsetof(STATUS_VAR, ha_write_count), SHOW_LONG_STATUS},
|
||||
{"Handler_tmp_update", (char*) offsetof(STATUS_VAR, ha_tmp_update_count), SHOW_LONG_STATUS},
|
||||
{"Handler_tmp_write", (char*) offsetof(STATUS_VAR, ha_tmp_write_count), SHOW_LONG_STATUS},
|
||||
{"Handler_update", (char*) offsetof(STATUS_VAR, ha_update_count), SHOW_LONG_STATUS},
|
||||
{"Handler_write", (char*) offsetof(STATUS_VAR, ha_write_count), SHOW_LONG_STATUS},
|
||||
{"Key", (char*) &show_default_keycache, SHOW_FUNC},
|
||||
{"Last_query_cost", (char*) offsetof(STATUS_VAR, last_query_cost), SHOW_DOUBLE_STATUS},
|
||||
{"Max_used_connections", (char*) &max_used_connections, SHOW_LONG},
|
||||
|
@ -4080,7 +4080,8 @@ int setup_semijoin_dups_elimination(JOIN *join, ulonglong options,
|
||||
{
|
||||
uint i;
|
||||
DBUG_ENTER("setup_semijoin_dups_elimination");
|
||||
|
||||
|
||||
join->complex_firstmatch_tables= table_map(0);
|
||||
|
||||
POSITION *pos= join->best_positions + join->const_tables;
|
||||
for (i= join->const_tables ; i < join->top_join_tab_count; )
|
||||
@ -4099,6 +4100,11 @@ int setup_semijoin_dups_elimination(JOIN *join, ulonglong options,
|
||||
{
|
||||
/* We jump from the last table to the first one */
|
||||
tab->loosescan_match_tab= tab + pos->n_sj_tables - 1;
|
||||
|
||||
/* LooseScan requires records to be produced in order */
|
||||
if (tab->select && tab->select->quick)
|
||||
tab->select->quick->need_sorted_output();
|
||||
|
||||
for (uint j= i; j < i + pos->n_sj_tables; j++)
|
||||
join->join_tab[j].inside_loosescan_range= TRUE;
|
||||
|
||||
@ -4108,6 +4114,7 @@ int setup_semijoin_dups_elimination(JOIN *join, ulonglong options,
|
||||
for (uint kp=0; kp < pos->loosescan_picker.loosescan_parts; kp++)
|
||||
keylen += tab->table->key_info[keyno].key_part[kp].store_length;
|
||||
|
||||
tab->loosescan_key= keyno;
|
||||
tab->loosescan_key_len= keylen;
|
||||
if (pos->n_sj_tables > 1)
|
||||
tab[pos->n_sj_tables - 1].do_firstmatch= tab;
|
||||
@ -4163,16 +4170,46 @@ int setup_semijoin_dups_elimination(JOIN *join, ulonglong options,
|
||||
}
|
||||
case SJ_OPT_FIRST_MATCH:
|
||||
{
|
||||
JOIN_TAB *j, *jump_to= tab-1;
|
||||
JOIN_TAB *j;
|
||||
JOIN_TAB *jump_to= tab-1;
|
||||
|
||||
bool complex_range= FALSE;
|
||||
table_map tables_in_range= table_map(0);
|
||||
|
||||
for (j= tab; j != tab + pos->n_sj_tables; j++)
|
||||
{
|
||||
/*
|
||||
NOTE: this loop probably doesn't do the right thing for the case
|
||||
where FirstMatch's duplicate-generating range is interleaved with
|
||||
"unrelated" tables (as specified in WL#3750, section 2.2).
|
||||
*/
|
||||
tables_in_range |= j->table->map;
|
||||
if (!j->emb_sj_nest)
|
||||
jump_to= tab;
|
||||
{
|
||||
/*
|
||||
Got a table that's not within any semi-join nest. This is a case
|
||||
like this:
|
||||
|
||||
SELECT * FROM ot1, nt1 WHERE ot1.col IN (SELECT expr FROM it1, it2)
|
||||
|
||||
with a join order of
|
||||
|
||||
+----- FirstMatch range ----+
|
||||
| |
|
||||
ot1 it1 nt1 nt2 it2 it3 ...
|
||||
| ^
|
||||
| +-------- 'j' points here
|
||||
+------------- SJ_OPT_FIRST_MATCH was set for this table as
|
||||
it's the first one that produces duplicates
|
||||
|
||||
*/
|
||||
DBUG_ASSERT(j != tab); /* table ntX must have an itX before it */
|
||||
|
||||
/*
|
||||
If the table right before us is an inner table (like it1 in the
|
||||
picture), it should be set to jump back to previous outer-table
|
||||
*/
|
||||
if (j[-1].emb_sj_nest)
|
||||
j[-1].do_firstmatch= jump_to;
|
||||
|
||||
jump_to= j; /* Jump back to us */
|
||||
complex_range= TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
j->first_sj_inner_tab= tab;
|
||||
@ -4182,6 +4219,9 @@ int setup_semijoin_dups_elimination(JOIN *join, ulonglong options,
|
||||
j[-1].do_firstmatch= jump_to;
|
||||
i+= pos->n_sj_tables;
|
||||
pos+= pos->n_sj_tables;
|
||||
|
||||
if (complex_range)
|
||||
join->complex_firstmatch_tables|= tables_in_range;
|
||||
break;
|
||||
}
|
||||
case SJ_OPT_NONE:
|
||||
|
@ -627,7 +627,12 @@ static bool matching_cond(bool max_fl, TABLE_REF *ref, KEY *keyinfo,
|
||||
if (!cond)
|
||||
DBUG_RETURN(TRUE);
|
||||
Field *field= field_part->field;
|
||||
if (!(cond->used_tables() & field->table->map))
|
||||
if (cond->used_tables() & OUTER_REF_TABLE_BIT)
|
||||
{
|
||||
DBUG_RETURN(FALSE);
|
||||
}
|
||||
if (!(cond->used_tables() & field->table->map) &&
|
||||
test(cond->used_tables() & ~PSEUDO_TABLE_BITS))
|
||||
{
|
||||
/* Condition doesn't restrict the used table */
|
||||
DBUG_RETURN(!cond->const_item());
|
||||
|
@ -2927,9 +2927,8 @@ pthread_handler_t handle_slave_io(void *arg)
|
||||
if (init_slave_thread(thd, SLAVE_THD_IO))
|
||||
{
|
||||
mysql_cond_broadcast(&mi->start_cond);
|
||||
mysql_mutex_unlock(&mi->run_lock);
|
||||
sql_print_error("Failed during slave I/O thread initialization");
|
||||
goto err;
|
||||
goto err_during_init;
|
||||
}
|
||||
mysql_mutex_lock(&LOCK_thread_count);
|
||||
threads.append(thd);
|
||||
@ -3232,6 +3231,7 @@ err:
|
||||
thd_proc_info(thd, "Waiting for slave mutex on exit");
|
||||
mysql_mutex_lock(&mi->run_lock);
|
||||
|
||||
err_during_init:
|
||||
/* Forget the relay log's format */
|
||||
delete mi->rli.relay_log.description_event_for_queue;
|
||||
mi->rli.relay_log.description_event_for_queue= 0;
|
||||
@ -3357,10 +3357,9 @@ pthread_handler_t handle_slave_sql(void *arg)
|
||||
will be stuck if we fail here
|
||||
*/
|
||||
mysql_cond_broadcast(&rli->start_cond);
|
||||
mysql_mutex_unlock(&rli->run_lock);
|
||||
rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR,
|
||||
"Failed during slave thread initialization");
|
||||
goto err;
|
||||
goto err_during_init;
|
||||
}
|
||||
thd->init_for_queries();
|
||||
thd->temporary_tables = rli->save_temporary_tables; // restore temp tables
|
||||
@ -3613,6 +3612,7 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \
|
||||
thd->reset_db(NULL, 0);
|
||||
thd_proc_info(thd, "Waiting for slave mutex on exit");
|
||||
mysql_mutex_lock(&rli->run_lock);
|
||||
err_during_init:
|
||||
/* We need data_lock, at least to wake up any waiting master_pos_wait() */
|
||||
mysql_mutex_lock(&rli->data_lock);
|
||||
DBUG_ASSERT(rli->slave_running == 1); // tracking buffer overrun
|
||||
|
@ -8399,22 +8399,9 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
|
||||
ulong client_capabilities= uint2korr(net->read_pos);
|
||||
if (client_capabilities & CLIENT_PROTOCOL_41)
|
||||
{
|
||||
if (pkt_len < 32)
|
||||
if (pkt_len < 4)
|
||||
return packet_error;
|
||||
client_capabilities|= ((ulong) uint2korr(net->read_pos+2)) << 16;
|
||||
thd->max_client_packet_length= uint4korr(net->read_pos+4);
|
||||
DBUG_PRINT("info", ("client_character_set: %d", (uint) net->read_pos[8]));
|
||||
if (thd_init_client_charset(thd, (uint) net->read_pos[8]))
|
||||
return packet_error;
|
||||
thd->update_charset();
|
||||
end= (char*) net->read_pos + 32;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pkt_len < 5)
|
||||
return packet_error;
|
||||
thd->max_client_packet_length= uint3korr(net->read_pos+2);
|
||||
end= (char*) net->read_pos+5;
|
||||
}
|
||||
|
||||
/* Disable those bits which are not supported by the client. */
|
||||
@ -8446,6 +8433,28 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
|
||||
}
|
||||
}
|
||||
|
||||
if (client_capabilities & CLIENT_PROTOCOL_41)
|
||||
{
|
||||
if (pkt_len < 32)
|
||||
return packet_error;
|
||||
thd->max_client_packet_length= uint4korr(net->read_pos+4);
|
||||
DBUG_PRINT("info", ("client_character_set: %d", (uint) net->read_pos[8]));
|
||||
if (thd_init_client_charset(thd, (uint) net->read_pos[8]))
|
||||
return packet_error;
|
||||
thd->update_charset();
|
||||
end= (char*) net->read_pos+32;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pkt_len < 5)
|
||||
return packet_error;
|
||||
thd->max_client_packet_length= uint3korr(net->read_pos+2);
|
||||
end= (char*) net->read_pos+5;
|
||||
}
|
||||
|
||||
if (end >= (char*) net->read_pos+ pkt_len +2)
|
||||
return packet_error;
|
||||
|
||||
if (thd->client_capabilities & CLIENT_IGNORE_SPACE)
|
||||
thd->variables.sql_mode|= MODE_IGNORE_SPACE;
|
||||
if (thd->client_capabilities & CLIENT_INTERACTIVE)
|
||||
|
@ -1923,14 +1923,15 @@ TABLE_LIST* find_dup_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list,
|
||||
t_name= table->table_name;
|
||||
t_alias= table->alias;
|
||||
|
||||
retry:
|
||||
DBUG_PRINT("info", ("real table: %s.%s", d_name, t_name));
|
||||
for (;;)
|
||||
for (TABLE_LIST *tl= table_list;;)
|
||||
{
|
||||
/*
|
||||
Table is unique if it is present only once in the global list
|
||||
of tables and once in the list of table locks.
|
||||
*/
|
||||
if (! (res= find_table_in_global_list(table_list, d_name, t_name)))
|
||||
if (! (res= find_table_in_global_list(tl, d_name, t_name)))
|
||||
break;
|
||||
|
||||
/* Skip if same underlying table. */
|
||||
@ -1961,10 +1962,23 @@ TABLE_LIST* find_dup_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list,
|
||||
(exclude_from_table_unique_test) or prelocking placeholder.
|
||||
*/
|
||||
next:
|
||||
table_list= res->next_global;
|
||||
tl= res->next_global;
|
||||
DBUG_PRINT("info",
|
||||
("found same copy of table or table which we should skip"));
|
||||
}
|
||||
if (res && res->belong_to_derived)
|
||||
{
|
||||
/* Try to fix */
|
||||
TABLE_LIST *derived= res->belong_to_derived;
|
||||
if (derived->is_merged_derived())
|
||||
{
|
||||
DBUG_PRINT("info",
|
||||
("convert merged to materialization to resolve the conflict"));
|
||||
derived->change_refs_to_fields();
|
||||
derived->set_materialized_derived();
|
||||
}
|
||||
goto retry;
|
||||
}
|
||||
DBUG_RETURN(res);
|
||||
}
|
||||
|
||||
@ -7363,11 +7377,16 @@ mark_common_columns(THD *thd, TABLE_LIST *table_ref_1, TABLE_LIST *table_ref_2,
|
||||
if (!(eq_cond= new Item_func_eq(item_ident_1, item_ident_2)))
|
||||
goto err; /* Out of memory. */
|
||||
|
||||
if (field_1 && field_1->vcol_info)
|
||||
field_1->table->mark_virtual_col(field_1);
|
||||
if (field_2 && field_2->vcol_info)
|
||||
field_2->table->mark_virtual_col(field_2);
|
||||
|
||||
/*
|
||||
Add the new equi-join condition to the ON clause. Notice that
|
||||
fix_fields() is applied to all ON conditions in setup_conds()
|
||||
so we don't do it here.
|
||||
*/
|
||||
*/
|
||||
add_join_on((table_ref_1->outer_join & JOIN_TYPE_RIGHT ?
|
||||
table_ref_1 : table_ref_2),
|
||||
eq_cond);
|
||||
@ -8085,7 +8104,8 @@ bool setup_tables(THD *thd, Name_resolution_context *context,
|
||||
while ((table_list= ti++))
|
||||
{
|
||||
TABLE *table= table_list->table;
|
||||
table->pos_in_table_list= table_list;
|
||||
if (table)
|
||||
table->pos_in_table_list= table_list;
|
||||
if (first_select_table &&
|
||||
table_list->top_table() == first_select_table)
|
||||
{
|
||||
@ -8098,7 +8118,7 @@ bool setup_tables(THD *thd, Name_resolution_context *context,
|
||||
{
|
||||
table_list->jtbm_table_no= tablenr;
|
||||
}
|
||||
else
|
||||
else if (table)
|
||||
{
|
||||
table->pos_in_table_list= table_list;
|
||||
setup_table_map(table, table_list, tablenr);
|
||||
|
@ -1463,10 +1463,10 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d",
|
||||
In case the wait time can't be determined there is an upper limit which
|
||||
causes try_lock() to abort with a time out.
|
||||
|
||||
The 'TRUE' parameter indicate that the lock is allowed to timeout
|
||||
The 'TIMEOUT' parameter indicate that the lock is allowed to timeout
|
||||
|
||||
*/
|
||||
if (try_lock(thd, Query_cache::WAIT))
|
||||
if (try_lock(thd, Query_cache::TIMEOUT))
|
||||
DBUG_VOID_RETURN;
|
||||
if (query_cache_size == 0)
|
||||
{
|
||||
@ -1674,6 +1674,17 @@ Query_cache::send_result_to_client(THD *thd, char *org_sql, uint query_length)
|
||||
if (is_disabled() || thd->locked_tables_mode ||
|
||||
thd->variables.query_cache_type == 0)
|
||||
goto err;
|
||||
|
||||
/*
|
||||
The following can only happen for prepared statements that was found
|
||||
during parsing or later that the query was not cacheable.
|
||||
*/
|
||||
if (!thd->lex->safe_to_cache_query)
|
||||
{
|
||||
DBUG_PRINT("qcache", ("SELECT is non-cacheable"));
|
||||
goto err;
|
||||
}
|
||||
|
||||
DBUG_ASSERT(query_cache_size != 0); // otherwise cache would be disabled
|
||||
|
||||
thd->query_cache_is_applicable= 1;
|
||||
@ -1959,6 +1970,7 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d",
|
||||
faster.
|
||||
*/
|
||||
thd->query_cache_is_applicable= 0; // Query can't be cached
|
||||
thd->lex->safe_to_cache_query= 0; // For prepared statements
|
||||
BLOCK_UNLOCK_RD(query_block);
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
@ -1975,6 +1987,7 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d",
|
||||
table_list.db, table_list.alias));
|
||||
unlock();
|
||||
thd->query_cache_is_applicable= 0; // Query can't be cached
|
||||
thd->lex->safe_to_cache_query= 0; // For prepared statements
|
||||
BLOCK_UNLOCK_RD(query_block);
|
||||
DBUG_RETURN(-1); // Privilege error
|
||||
}
|
||||
@ -1984,6 +1997,7 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d",
|
||||
table_list.db, table_list.alias));
|
||||
BLOCK_UNLOCK_RD(query_block);
|
||||
thd->query_cache_is_applicable= 0; // Query can't be cached
|
||||
thd->lex->safe_to_cache_query= 0; // For prepared statements
|
||||
goto err_unlock; // Parse query
|
||||
}
|
||||
#endif /*!NO_EMBEDDED_ACCESS_CHECKS*/
|
||||
@ -2007,7 +2021,13 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d",
|
||||
table->key_length());
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
As this can change from call to call, don't reset set
|
||||
thd->lex->safe_to_cache_query
|
||||
*/
|
||||
thd->query_cache_is_applicable= 0; // Query can't be cached
|
||||
}
|
||||
/* End the statement transaction potentially started by engine. */
|
||||
trans_rollback_stmt(thd);
|
||||
goto err_unlock; // Parse query
|
||||
@ -3901,6 +3921,7 @@ Query_cache::process_and_count_tables(THD *thd, TABLE_LIST *tables_used,
|
||||
DBUG_PRINT("qcache", ("Don't cache statement as it refers to "
|
||||
"tables with column privileges."));
|
||||
thd->query_cache_is_applicable= 0; // Query can't be cached
|
||||
thd->lex->safe_to_cache_query= 0; // For prepared statements
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
#endif
|
||||
@ -4037,6 +4058,10 @@ my_bool Query_cache::ask_handler_allowance(THD *thd,
|
||||
{
|
||||
DBUG_PRINT("qcache", ("Handler does not allow caching for %s.%s",
|
||||
tables_used->db, tables_used->alias));
|
||||
/*
|
||||
As this can change from call to call, don't reset set
|
||||
thd->lex->safe_to_cache_query
|
||||
*/
|
||||
thd->query_cache_is_applicable= 0; // Query can't be cached
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
@ -443,8 +443,8 @@ protected:
|
||||
uint def_query_hash_size = QUERY_CACHE_DEF_QUERY_HASH_SIZE,
|
||||
uint def_table_hash_size = QUERY_CACHE_DEF_TABLE_HASH_SIZE);
|
||||
|
||||
bool is_disabled(void) { return m_cache_status != OK; }
|
||||
bool is_disable_in_progress(void)
|
||||
inline bool is_disabled(void) { return m_cache_status != OK; }
|
||||
inline bool is_disable_in_progress(void)
|
||||
{ return m_cache_status == DISABLE_REQUEST; }
|
||||
|
||||
/* initialize cache (mutex) */
|
||||
|
@ -585,12 +585,15 @@ typedef struct system_status_var
|
||||
ulong ha_read_prev_count;
|
||||
ulong ha_read_rnd_count;
|
||||
ulong ha_read_rnd_next_count;
|
||||
ulong ha_read_rnd_deleted_count;
|
||||
/*
|
||||
This number doesn't include calls to the default implementation and
|
||||
calls made by range access. The intent is to count only calls made by
|
||||
BatchedKeyAccess.
|
||||
*/
|
||||
ulong ha_multi_range_read_init_count;
|
||||
ulong ha_mrr_extra_key_sorts;
|
||||
ulong ha_mrr_extra_rowid_sorts;
|
||||
|
||||
ulong ha_rollback_count;
|
||||
ulong ha_update_count;
|
||||
@ -4217,10 +4220,17 @@ inline int handler::ha_ft_read(uchar *buf)
|
||||
inline int handler::ha_rnd_next(uchar *buf)
|
||||
{
|
||||
MYSQL_READ_ROW_START(table_share->db.str, table_share->table_name.str, TRUE);
|
||||
increment_statistics(&SSV::ha_read_rnd_next_count);
|
||||
int error= rnd_next(buf);
|
||||
if (!error)
|
||||
{
|
||||
update_rows_read();
|
||||
increment_statistics(&SSV::ha_read_rnd_next_count);
|
||||
}
|
||||
else if (error == HA_ERR_RECORD_DELETED)
|
||||
increment_statistics(&SSV::ha_read_rnd_deleted_count);
|
||||
else
|
||||
increment_statistics(&SSV::ha_read_rnd_next_count);
|
||||
|
||||
table->status=error ? STATUS_NOT_FOUND: 0;
|
||||
MYSQL_READ_ROW_DONE(error);
|
||||
return error;
|
||||
|
@ -76,7 +76,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
|
||||
if (mysql_handle_list_of_derived(thd->lex, table_list, DT_PREPARE))
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
if (!table_list->updatable)
|
||||
if (!table_list->single_table_updatable())
|
||||
{
|
||||
my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "DELETE");
|
||||
DBUG_RETURN(TRUE);
|
||||
@ -476,7 +476,8 @@ int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds)
|
||||
setup_conds(thd, table_list, select_lex->leaf_tables, conds) ||
|
||||
setup_ftfuncs(select_lex))
|
||||
DBUG_RETURN(TRUE);
|
||||
if (!table_list->updatable || check_key_in_view(thd, table_list))
|
||||
if (!table_list->single_table_updatable() ||
|
||||
check_key_in_view(thd, table_list))
|
||||
{
|
||||
my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "DELETE");
|
||||
DBUG_RETURN(TRUE);
|
||||
@ -572,7 +573,7 @@ int mysql_multi_delete_prepare(THD *thd)
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
||||
if (!target_tbl->correspondent_table->updatable ||
|
||||
if (!target_tbl->correspondent_table->single_table_updatable() ||
|
||||
check_key_in_view(thd, target_tbl->correspondent_table))
|
||||
{
|
||||
my_error(ER_NON_UPDATABLE_TABLE, MYF(0),
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user