Merge 5.2->5.3 in preparation for the release of mariadb-5.3.4-rc.

This commit is contained in:
Igor Babaev 2012-02-01 15:48:02 -08:00
commit 7b79d8a33f
57 changed files with 1456 additions and 782 deletions

View file

@ -2034,7 +2034,7 @@ dnl Checks for library functions.
AC_FUNC_ALLOCA
AC_PROG_GCC_TRADITIONAL
AC_TYPE_SIGNAL
AC_CHECK_FUNCS(re_comp regcomp strdup)
AC_CHECK_FUNCS(re_comp regcomp strdup strndup)
dnl Sun compilers have their own vis.h that is about something
dnl totally different. So, not to change the libedit source, we

View file

@ -45,8 +45,8 @@
#define MACHINE_TYPE "ia64"
#elif defined(_M_IX86)
#define MACHINE_TYPE "ia32"
#elif defined(_M_ALPHA)
#define MACHINE_TYPE "axp"
#elif defined(_M_X64)
#define MACHINE_TYPE "x64"
#else
#define MACHINE_TYPE "unknown" /* Define to machine type name */
#endif

View file

@ -82,9 +82,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)
{
@ -93,15 +93,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");
}
@ -148,8 +146,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;
}

View file

@ -14,7 +14,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;

View file

@ -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;

View file

@ -1089,7 +1089,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`.`t1` `t` join `test`.`t2` left join `test`.`t3` on((0 <> 0)) 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 +1103,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`.`t1` join `test`.`t2` left join `test`.`t3` on((0 <> 0)) 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 +1117,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`.`t1` join `test`.`t2` left join `test`.`t3` on((0 <> 0)) 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;

View file

@ -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><1,2>(<in_optimizer>((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 `test`.`t1` join `test`.`t2` 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
#
@ -1977,4 +2041,3 @@ set @@optimizer_switch=@save_optimizer_switch;
# Cleanup for BUG#46680
#
DROP TABLE IF EXISTS t1,t2,t3,empty1;
End of 6.0 tests

View file

@ -17,3 +17,11 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL fkey 5 NULL 5 Using index
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.fkey 1 Using where
DROP TABLE t1,t2;
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;

View file

@ -1729,3 +1729,57 @@ select 1 order by max(1) + min(1);
1
1
End of 5.1 tests
#
# 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

View file

@ -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

View file

@ -2782,10 +2782,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.615800023078918
@ -2804,10 +2804,10 @@ max(key1) min(key2)
0.615800023078918 1.37619996070862
select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
max(key1)
0.615800023078918
0.384499996900558
select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
min(key1)
0.376199990510941
0.384499996900558
DROP TABLE t1,t2;
CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL);
INSERT INTO t1 VALUES (10);

View file

@ -2793,10 +2793,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.615800023078918
@ -2815,10 +2815,10 @@ max(key1) min(key2)
0.615800023078918 1.37619996070862
select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
max(key1)
0.615800023078918
0.384499996900558
select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
min(key1)
0.376199990510941
0.384499996900558
DROP TABLE t1,t2;
CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL);
INSERT INTO t1 VALUES (10);

View file

@ -2782,10 +2782,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.615800023078918
@ -2804,10 +2804,10 @@ max(key1) min(key2)
0.615800023078918 1.37619996070862
select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
max(key1)
0.615800023078918
0.384499996900558
select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
min(key1)
0.376199990510941
0.384499996900558
DROP TABLE t1,t2;
CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL);
INSERT INTO t1 VALUES (10);

View file

@ -4567,6 +4567,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
@ -5005,7 +5012,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,
@ -5448,10 +5454,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);
@ -5498,32 +5655,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#11764086: Null left operand to NOT IN in WHERE clause
# behaves differently than real NULL
@ -5573,27 +5704,6 @@ id parent_id
DROP TABLE parent, child;
# End of test for bug#11764086.
#
# 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);
set @tmp_optimizer_switch=@@optimizer_switch;
set optimizer_switch='derived_merge=off,derived_with_keys=off';
EXPLAIN SELECT * FROM (SELECT * FROM t1 WHERE a=7) t;
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 ref a a 5 const 1
set optimizer_switch=@tmp_optimizer_switch;
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 11765699 - 58690: !TABLE || (!TABLE->READ_SET ||
# BITMAP_IS_SET(TABLE->READ_SET, FIELD_INDEX
#
@ -5619,54 +5729,6 @@ GROUP BY b
1
DROP TABLE t1, t2;
#
# BUG#12616253 - WRONG RESULT WITH EXISTS(SUBQUERY) (MISSING ROWS)
#
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');
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
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
DROP TABLE t1,t2;
#
# LP bug #826279: assertion failure with GROUP BY a result of subquery
#
CREATE TABLE t1 (a int);

View file

@ -831,7 +831,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';
@ -922,7 +922,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);
@ -1017,7 +1017,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';
@ -1108,7 +1108,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;

View file

@ -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 `test`.`t1` 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;

View file

@ -4569,6 +4569,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
@ -5007,7 +5014,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,
@ -5449,10 +5455,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);
@ -5499,32 +5654,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#11764086: Null left operand to NOT IN in WHERE clause
# behaves differently than real NULL
@ -5574,27 +5703,6 @@ id parent_id
DROP TABLE parent, child;
# End of test for bug#11764086.
#
# 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);
set @tmp_optimizer_switch=@@optimizer_switch;
set optimizer_switch='derived_merge=off,derived_with_keys=off';
EXPLAIN SELECT * FROM (SELECT * FROM t1 WHERE a=7) t;
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 ref a a 5 const 1
set optimizer_switch=@tmp_optimizer_switch;
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 11765699 - 58690: !TABLE || (!TABLE->READ_SET ||
# BITMAP_IS_SET(TABLE->READ_SET, FIELD_INDEX
#
@ -5620,54 +5728,6 @@ GROUP BY b
1
DROP TABLE t1, t2;
#
# BUG#12616253 - WRONG RESULT WITH EXISTS(SUBQUERY) (MISSING ROWS)
#
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');
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
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
DROP TABLE t1,t2;
#
# LP bug #826279: assertion failure with GROUP BY a result of subquery
#
CREATE TABLE t1 (a int);

View file

@ -4565,6 +4565,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
@ -5003,7 +5010,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,
@ -5445,10 +5451,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);
@ -5495,32 +5650,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#11764086: Null left operand to NOT IN in WHERE clause
# behaves differently than real NULL
@ -5570,27 +5699,6 @@ id parent_id
DROP TABLE parent, child;
# End of test for bug#11764086.
#
# 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);
set @tmp_optimizer_switch=@@optimizer_switch;
set optimizer_switch='derived_merge=off,derived_with_keys=off';
EXPLAIN SELECT * FROM (SELECT * FROM t1 WHERE a=7) t;
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 ref a a 5 const 1
set optimizer_switch=@tmp_optimizer_switch;
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 11765699 - 58690: !TABLE || (!TABLE->READ_SET ||
# BITMAP_IS_SET(TABLE->READ_SET, FIELD_INDEX
#
@ -5616,54 +5724,6 @@ GROUP BY b
1
DROP TABLE t1, t2;
#
# BUG#12616253 - WRONG RESULT WITH EXISTS(SUBQUERY) (MISSING ROWS)
#
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');
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
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
DROP TABLE t1,t2;
#
# LP bug #826279: assertion failure with GROUP BY a result of subquery
#
CREATE TABLE t1 (a int);

View file

@ -4573,6 +4573,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
@ -5011,7 +5018,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,
@ -5454,10 +5460,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);
@ -5504,32 +5661,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#11764086: Null left operand to NOT IN in WHERE clause
# behaves differently than real NULL
@ -5579,27 +5710,6 @@ id parent_id
DROP TABLE parent, child;
# End of test for bug#11764086.
#
# 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);
set @tmp_optimizer_switch=@@optimizer_switch;
set optimizer_switch='derived_merge=off,derived_with_keys=off';
EXPLAIN SELECT * FROM (SELECT * FROM t1 WHERE a=7) t;
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 ref a a 5 const 1
set optimizer_switch=@tmp_optimizer_switch;
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 11765699 - 58690: !TABLE || (!TABLE->READ_SET ||
# BITMAP_IS_SET(TABLE->READ_SET, FIELD_INDEX
#
@ -5625,54 +5735,6 @@ GROUP BY b
1
DROP TABLE t1, t2;
#
# BUG#12616253 - WRONG RESULT WITH EXISTS(SUBQUERY) (MISSING ROWS)
#
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');
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
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
DROP TABLE t1,t2;
#
# LP bug #826279: assertion failure with GROUP BY a result of subquery
#
CREATE TABLE t1 (a int);

View file

@ -4565,6 +4565,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
@ -5003,7 +5010,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,
@ -5445,10 +5451,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);
@ -5495,32 +5650,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#11764086: Null left operand to NOT IN in WHERE clause
# behaves differently than real NULL
@ -5570,27 +5699,6 @@ id parent_id
DROP TABLE parent, child;
# End of test for bug#11764086.
#
# 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);
set @tmp_optimizer_switch=@@optimizer_switch;
set optimizer_switch='derived_merge=off,derived_with_keys=off';
EXPLAIN SELECT * FROM (SELECT * FROM t1 WHERE a=7) t;
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 ref a a 5 const 1
set optimizer_switch=@tmp_optimizer_switch;
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 11765699 - 58690: !TABLE || (!TABLE->READ_SET ||
# BITMAP_IS_SET(TABLE->READ_SET, FIELD_INDEX
#
@ -5616,54 +5724,6 @@ GROUP BY b
1
DROP TABLE t1, t2;
#
# BUG#12616253 - WRONG RESULT WITH EXISTS(SUBQUERY) (MISSING ROWS)
#
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');
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
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
DROP TABLE t1,t2;
#
# LP bug #826279: assertion failure with GROUP BY a result of subquery
#
CREATE TABLE t1 (a int);

View file

@ -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;

View file

@ -48,9 +48,9 @@ ON orgs.org_id=sa_opportunities.org_id
LEFT JOIN bug30243_2 contacts
ON orgs.org_id=contacts.org_id ;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE orgs index NULL org_id 4 NULL 128 Using index
1 SIMPLE sa_opportunities ref org_id org_id 5 test.orgs.org_id 1 Using index
1 SIMPLE contacts ref contacts$org_id contacts$org_id 5 test.orgs.org_id 1 Using index
1 SIMPLE orgs index NULL org_id 4 NULL # Using index
1 SIMPLE sa_opportunities ref org_id org_id 5 test.orgs.org_id # Using index
1 SIMPLE contacts ref contacts$org_id contacts$org_id 5 test.orgs.org_id # Using index
select @@innodb_stats_method;
@@innodb_stats_method
nulls_ignored

View file

@ -140,6 +140,7 @@ analyze table bug30243_3;
# Following query plan shows that we get the correct rows per
# unique value (should be approximately 1 row per value)
--replace_column 9 #
explain SELECT COUNT(*), 0
FROM bug30243_1 orgs
LEFT JOIN bug30243_3 sa_opportunities

View file

@ -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

View file

@ -2788,10 +2788,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.615800023078918
@ -2810,10 +2810,10 @@ max(key1) min(key2)
0.615800023078918 1.37619996070862
select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
max(key1)
0.615800023078918
0.384499996900558
select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
min(key1)
0.376199990510941
0.384499996900558
DROP TABLE t1,t2;
CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL);
INSERT INTO t1 VALUES (10);

View 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;

View 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

View file

@ -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;

View file

@ -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;

View file

@ -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
@ -1292,5 +1339,3 @@ set @@optimizer_switch=@save_optimizer_switch;
--echo #
DROP TABLE IF EXISTS t1,t2,t3,empty1;
###
--echo End of 6.0 tests

View file

@ -24,3 +24,18 @@ SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
WHERE t1.name LIKE 'A%' OR FALSE;
DROP TABLE t1,t2;
#
# 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;

View file

@ -1560,3 +1560,32 @@ DROP TABLE t1;
select 1 order by max(1) + min(1);
--echo End of 5.1 tests
--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

View file

@ -3521,6 +3521,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.
@ -4207,8 +4209,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
#
@ -4568,11 +4568,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 );
@ -4625,32 +4755,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#11764086: Null left operand to NOT IN in WHERE clause
--echo # behaves differently than real NULL
@ -4700,25 +4804,6 @@ DROP TABLE parent, child;
--echo # End of test for bug#11764086.
--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);
--echo
set @tmp_optimizer_switch=@@optimizer_switch;
set optimizer_switch='derived_merge=off,derived_with_keys=off';
EXPLAIN SELECT * FROM (SELECT * FROM t1 WHERE a=7) t;
set optimizer_switch=@tmp_optimizer_switch;
--echo
EXPLAIN SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t1 WHERE a=7);
--echo
DROP TABLE t1;
--echo #
--echo # Bug 11765699 - 58690: !TABLE || (!TABLE->READ_SET ||
--echo # BITMAP_IS_SET(TABLE->READ_SET, FIELD_INDEX
@ -4748,30 +4833,6 @@ SELECT 1 FROM t1 WHERE a =
DROP TABLE t1, t2;
--echo #
--echo # BUG#12616253 - WRONG RESULT WITH EXISTS(SUBQUERY) (MISSING ROWS)
--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');
let $query=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 );
eval $query;
eval explain $query;
DROP TABLE t1,t2;
--echo #
--echo # LP bug #826279: assertion failure with GROUP BY a result of subquery
--echo #

View file

@ -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;

View file

@ -3980,7 +3980,6 @@ drop table t1,t2;
--echo # -----------------------------------------------------------------
--echo # -- End of 5.1 tests.
--echo # -----------------------------------------------------------------
--echo #
--echo # Bug #59696 Optimizer does not use equalities for conditions over view
--echo #

View file

@ -395,133 +395,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

View file

@ -101,14 +101,14 @@ my_bool my_gethwaddr(uchar *to)
uint i;
for (i= 0; res && i < ifc.ifc_len / sizeof(ifr[0]); i++)
{
#ifdef SIOCGIFHWADDR
#ifdef __linux__
if (ioctl(fd, SIOCGIFHWADDR, &ifr[i]) >= 0)
res= memcpy_and_test(to, (uchar *)&ifr[i].ifr_hwaddr.sa_data,
ETHER_ADDR_LEN);
#else
/*
A bug in OpenSolaris prevents non-root from getting a mac address:
http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=4720634
A bug in OpenSolaris used to prevent non-root from getting a mac address:
{no url. Oracle killed the old OpenSolaris bug database}
Thus, we'll use an alternative method and extract the address from the
arp table.

View file

@ -83,27 +83,11 @@ static struct st_mysql_auth socket_auth_handler=
socket_auth
};
mysql_declare_plugin(socket_auth)
{
MYSQL_AUTHENTICATION_PLUGIN,
&socket_auth_handler,
"socket_peercred",
"Sergei Golubchik",
"Unix Socket based authentication",
PLUGIN_LICENSE_GPL,
NULL,
NULL,
0x0100,
NULL,
NULL,
NULL
}
mysql_declare_plugin_end;
maria_declare_plugin(socket_auth)
{
MYSQL_AUTHENTICATION_PLUGIN,
&socket_auth_handler,
"socket_peercred",
"unix_socket",
"Sergei Golubchik",
"Unix Socket based authentication",
PLUGIN_LICENSE_GPL,

View file

@ -290,6 +290,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);

View file

@ -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, &param };
/* 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*) &param;
/*
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",

View file

@ -9168,6 +9168,8 @@ table_map Item_ref_null_helper::used_tables() const
}
#ifndef DBUG_OFF
/* Debugger help function */
static char dbug_item_print_buf[256];
@ -9184,6 +9186,9 @@ const char *dbug_print_item(Item *item)
else
return "Couldn't fit into buffer";
}
#endif /*DBUG_OFF*/
/*****************************************************************************
** Instantiate templates
*****************************************************************************/

View file

@ -1586,7 +1586,6 @@ Item_in_subselect::single_value_transformer(JOIN *join)
(Item**)optimizer->get_cache(),
(char *)"<no matter>",
(char *)in_left_expr_name);
}
DBUG_RETURN(false);
@ -2229,7 +2228,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
@ -2495,6 +2499,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;
@ -3142,6 +3147,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();
/*

View file

@ -582,13 +582,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);

View file

@ -2258,7 +2258,7 @@ extern pthread_mutex_t LOCK_mysql_create_db,LOCK_Acl,LOCK_open, LOCK_lock_db,
LOCK_mapped_file,LOCK_user_locks, LOCK_status,
LOCK_error_log, LOCK_delayed_insert, LOCK_short_uuid_generator,
LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, LOCK_timezone,
LOCK_slave_list, LOCK_active_mi, LOCK_manager, LOCK_global_read_lock,
LOCK_slave_list, LOCK_active_mi, LOCK_global_read_lock,
LOCK_global_system_variables, LOCK_user_conn,
LOCK_prepared_stmt_count,
LOCK_bytes_sent, LOCK_bytes_received, LOCK_connection_count;
@ -2276,7 +2276,7 @@ extern pthread_mutex_t LOCK_stats;
extern int mysqld_server_started;
extern rw_lock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave;
extern rw_lock_t LOCK_system_variables_hash;
extern pthread_cond_t COND_refresh, COND_thread_count, COND_manager;
extern pthread_cond_t COND_refresh, COND_thread_count;
extern pthread_cond_t COND_global_read_lock;
extern pthread_attr_t connection_attrib;
extern I_List<THD> threads;

View file

@ -1588,7 +1588,6 @@ static void clean_up_mutexes()
(void) pthread_mutex_destroy(&LOCK_delayed_insert);
(void) pthread_mutex_destroy(&LOCK_delayed_status);
(void) pthread_mutex_destroy(&LOCK_delayed_create);
(void) pthread_mutex_destroy(&LOCK_manager);
(void) pthread_mutex_destroy(&LOCK_crypt);
(void) pthread_mutex_destroy(&LOCK_bytes_sent);
(void) pthread_mutex_destroy(&LOCK_bytes_received);
@ -1629,7 +1628,6 @@ static void clean_up_mutexes()
(void) pthread_cond_destroy(&COND_global_read_lock);
(void) pthread_cond_destroy(&COND_thread_cache);
(void) pthread_cond_destroy(&COND_flush_thread_cache);
(void) pthread_cond_destroy(&COND_manager);
DBUG_VOID_RETURN;
}
@ -3887,7 +3885,6 @@ static int init_thread_environment()
(void) pthread_mutex_init(&LOCK_delayed_insert,MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_delayed_status,MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_delayed_create,MY_MUTEX_INIT_SLOW);
(void) pthread_mutex_init(&LOCK_manager,MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_crypt,MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_bytes_sent,MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_bytes_received,MY_MUTEX_INIT_FAST);
@ -3927,7 +3924,6 @@ static int init_thread_environment()
(void) pthread_cond_init(&COND_global_read_lock,NULL);
(void) pthread_cond_init(&COND_thread_cache,NULL);
(void) pthread_cond_init(&COND_flush_thread_cache,NULL);
(void) pthread_cond_init(&COND_manager,NULL);
#ifdef HAVE_REPLICATION
(void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST);
(void) pthread_cond_init(&COND_rpl_status, NULL);

View file

@ -623,7 +623,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());

View file

@ -512,7 +512,7 @@ static void libevent_connection_close(THD *thd)
thd->killed= KILL_CONNECTION; // Avoid error messages
if (thd->net.vio->sd >= 0) // not already closed
if (thd->net.vio->type != VIO_CLOSED) // not already closed
{
end_connection(thd);
close_connection(thd, 0, 1);

View file

@ -7197,11 +7197,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);

View file

@ -44,6 +44,7 @@ static struct handler_cb * volatile cb_list;
bool mysql_manager_submit(void (*action)())
{
bool result= FALSE;
DBUG_ASSERT(manager_thread_in_use);
struct handler_cb * volatile *cb;
pthread_mutex_lock(&LOCK_manager);
cb= &cb_list;
@ -75,8 +76,9 @@ pthread_handler_t handle_manager(void *arg __attribute__((unused)))
pthread_detach_this_thread();
manager_thread = pthread_self();
(void) pthread_cond_init(&COND_manager,NULL);
(void) pthread_mutex_init(&LOCK_manager,NULL);
manager_thread_in_use = 1;
for (;;)
{
pthread_mutex_lock(&LOCK_manager);
@ -123,6 +125,8 @@ pthread_handler_t handle_manager(void *arg __attribute__((unused)))
}
}
manager_thread_in_use = 0;
(void) pthread_mutex_destroy(&LOCK_manager);
(void) pthread_cond_destroy(&COND_manager);
DBUG_LEAVE; // Can't use DBUG_RETURN after my_thread_end
my_thread_end();
return (NULL);
@ -149,14 +153,14 @@ void stop_handle_manager()
{
DBUG_ENTER("stop_handle_manager");
abort_manager = true;
pthread_mutex_lock(&LOCK_manager);
if (manager_thread_in_use)
{
pthread_mutex_lock(&LOCK_manager);
DBUG_PRINT("quit", ("initiate shutdown of handle manager thread: 0x%lx",
(ulong)manager_thread));
pthread_cond_signal(&COND_manager);
pthread_cond_signal(&COND_manager);
pthread_mutex_unlock(&LOCK_manager);
}
pthread_mutex_unlock(&LOCK_manager);
DBUG_VOID_RETURN;
}

View file

@ -191,7 +191,8 @@ bool end_active_trans(THD *thd)
if (ha_commit(thd))
error=1;
#ifdef WITH_ARIA_STORAGE_ENGINE
ha_maria::implicit_commit(thd, TRUE);
if (ha_storage_engine_is_enabled(maria_hton))
ha_maria::implicit_commit(thd, TRUE);
#endif
}
thd->options&= ~(OPTION_BEGIN | OPTION_KEEP_LOG);
@ -1231,6 +1232,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
char *beginning_of_next_stmt= (char*) end_of_stmt;
#ifdef WITH_ARIA_STORAGE_ENGINE
if (ha_storage_engine_is_enabled(maria_hton))
ha_maria::implicit_commit(thd, FALSE);
#endif
@ -1608,7 +1610,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
thd->transaction.stmt.reset();
#ifdef WITH_ARIA_STORAGE_ENGINE
ha_maria::implicit_commit(thd, FALSE);
if (ha_storage_engine_is_enabled(maria_hton))
ha_maria::implicit_commit(thd, FALSE);
#endif
if (!(sql_command_flags[thd->lex->sql_command] & CF_CHANGES_DATA))

View file

@ -10332,6 +10332,15 @@ remove_const(JOIN *join,ORDER *first_order, COND *cond,
}
/*
Cleanup to avoid interference of calls of this function for
ORDER BY and GROUP BY
*/
for (JOIN_TAB *tab= join->join_tab + join->const_tables;
tab < join->join_tab + join->table_count;
tab++)
tab->cached_eq_ref_table= FALSE;
prev_ptr= &first_order;
*simple_order= *join->join_tab[join->const_tables].on_expr_ref ? 0 : 1;
@ -18390,7 +18399,6 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order,
table->sort.io_cache= NULL;
select->cleanup(); // filesort did select
tab->select= 0;
table->quick_keys.clear_all(); // as far as we cleanup select->quick
table->intersect_keys.clear_all();
table->sort.io_cache= tablesort_result_cache;

View file

@ -1456,6 +1456,7 @@ public:
virtual ~store_key() {} /** Not actually needed */
virtual enum Type type() const=0;
virtual const char *name() const=0;
virtual bool store_key_is_const() { return false; }
/**
@brief sets ignore truncation warnings mode and calls the real copy method
@ -1609,6 +1610,7 @@ public:
enum Type type() const { return CONST_ITEM_STORE_KEY; }
const char *name() const { return "const"; }
bool store_key_is_const() { return true; }
protected:
enum store_key_result copy_inner()

View file

@ -4481,6 +4481,7 @@ Item *Field_iterator_table::create_item(THD *thd)
{
select->non_agg_fields.push_back(item);
item->marker= select->cur_pos_in_select_list;
select->set_non_agg_field_used(true);
}
return item;
}
@ -5184,6 +5185,9 @@ void st_table::mark_virtual_columns_for_write(bool insert_fl)
Field **vfield_ptr, *tmp_vfield;
bool bitmap_updated= FALSE;
if (!vfield)
return;
for (vfield_ptr= vfield; *vfield_ptr; vfield_ptr++)
{
tmp_vfield= *vfield_ptr;

View file

@ -116,7 +116,7 @@ int get_mysql_service_properties(const wchar_t *bin_path,
wcscat(mysqld_path, L".exe");
if(wcsicmp(file_part, L"mysqld.exe") != 0 &&
wcsicmp(file_part, L"mysqld.exe") != 0 &&
wcsicmp(file_part, L"mysqld-debug.exe") != 0 &&
wcsicmp(file_part, L"mysqld-nt.exe") != 0)
{
/* The service executable is not mysqld. */
@ -244,4 +244,4 @@ int get_mysql_service_properties(const wchar_t *bin_path,
end:
LocalFree((HLOCAL)args);
return retval;
}
}

View file

@ -42,7 +42,7 @@ IF(NOT SOURCE_SUBLIBS)
ADD_DEFINITIONS(-DMYSQL_DYNAMIC_PLUGIN)
ADD_VERSION_INFO(${${engine}_LIB} SHARED ${engine}_SOURCES)
ADD_LIBRARY(${${engine}_LIB} MODULE ${${engine}_SOURCES})
TARGET_LINK_LIBRARIES (${${engine}_LIB} mysqlservices mysqld)
TARGET_LINK_LIBRARIES (${${engine}_LIB} mysqlservices)
IF(${engine}_LIBS)
TARGET_LINK_LIBRARIES(${${engine}_LIB} ${${engine}_LIBS})
ENDIF(${engine}_LIBS)
@ -61,6 +61,8 @@ IF(NOT SOURCE_SUBLIBS)
${CMAKE_SOURCE_DIR}/extra/yassl/include)
IF(${ENGINE_BUILD_TYPE} STREQUAL "STATIC")
ADD_DEFINITIONS(-DWITH_${engine}_STORAGE_ENGINE -DMYSQL_SERVER)
ELSEIF(${ENGINE_BUILD_TYPE} STREQUAL "DYNAMIC")
TARGET_LINK_LIBRARIES (${${engine}_LIB} mysqld)
ENDIF(${ENGINE_BUILD_TYPE} STREQUAL "STATIC")
ENDIF(NOT SOURCE_SUBLIBS)
ENDMACRO(MYSQL_STORAGE_ENGINE)

View file

@ -414,7 +414,7 @@ namespace open_query {
if (record_weight && u != v)
{
typename graph_traits<Graph>::out_edge_iterator ei, ei_end;
for (tie(ei, ei_end)= out_edges(v, g); ei != ei_end; ++ei)
for (boost::tuples::tie(ei, ei_end)= out_edges(v, g); ei != ei_end; ++ei)
{
if (target(*ei, g) == u)
{
@ -479,14 +479,14 @@ namespace open_query
if (in_degree(dest, g) >= out_degree(orig, g))
{
graph_traits<Graph>::out_edge_iterator ei, ei_end;
tie(ei, ei_end)= out_edges(orig, g);
boost::tuples::tie(ei, ei_end)= out_edges(orig, g);
if ((ei= find_if(ei, ei_end, target_equals(dest, g))) != ei_end)
return *ei;
}
else
{
graph_traits<Graph>::in_edge_iterator ei, ei_end;
tie(ei, ei_end)= in_edges(dest, g);
boost::tuples::tie(ei, ei_end)= in_edges(dest, g);
if ((ei= find_if(ei, ei_end, source_equals(orig, g))) != ei_end)
return *ei;
}
@ -727,7 +727,7 @@ namespace open_query
if ((cursor= new (std::nothrow) stack_cursor(share)) && orig)
{
graph_traits<Graph>::out_edge_iterator ei, ei_end;
for (tie(ei, ei_end)= out_edges(*orig, share->g); ei != ei_end; ++ei)
for (boost::tuples::tie(ei, ei_end)= out_edges(*orig, share->g); ei != ei_end; ++ei)
{
Vertex v= target(*ei, share->g);
static_cast<stack_cursor*>(cursor)->
@ -741,7 +741,7 @@ namespace open_query
dest)
{
graph_traits<Graph>::in_edge_iterator ei, ei_end;
for (tie(ei, ei_end)= in_edges(*dest, share->g); ei != ei_end; ++ei)
for (boost::tuples::tie(ei, ei_end)= in_edges(*dest, share->g); ei != ei_end; ++ei)
{
Vertex v= source(*ei, share->g);
static_cast<stack_cursor*>(cursor)->
@ -876,7 +876,7 @@ namespace open_query
switch (ALGORITHM & op)
{
case DIJKSTRAS:
dijkstra_shortest_paths(r, *dest,
dijkstra_shortest_paths(r.m_g, *dest,
weight_map(
share->weightmap
).
@ -1067,7 +1067,7 @@ int edges_cursor::fetch_row(const row &row_info, row &result)
edge_iterator it, end;
reference ref;
size_t count= position;
for (tie(it, end)= edges(share->g); count && it != end; ++it, --count)
for (boost::tuples::tie(it, end)= edges(share->g); count && it != end; ++it, --count)
;
if (it != end)
ref= reference(position+1, *it);

View file

@ -91,7 +91,7 @@ IF(NOT MYSQL_UNIX_ADDR)
SET(MYSQL_UNIX_ADDR "/tmp/mysql.sock")
ENDIF()
IF(NOT COMPILATION_COMMENT)
SET(COMPILATION_COMMENT "Source distribution")
SET(COMPILATION_COMMENT "mariadb.org binary distribution")
ENDIF()