summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.in2
-rw-r--r--include/config-win.h4
-rw-r--r--libmysql/get_password.c12
-rw-r--r--mysql-test/include/wait_until_connected_again.inc2
-rw-r--r--mysql-test/include/wait_until_disconnected.inc2
-rw-r--r--mysql-test/r/derived_view.result6
-rw-r--r--mysql-test/r/func_group.result65
-rw-r--r--mysql-test/r/join_outer_innodb.result8
-rw-r--r--mysql-test/r/order_by.result54
-rw-r--r--mysql-test/r/ps_11bugs.result4
-rw-r--r--mysql-test/r/select.result8
-rw-r--r--mysql-test/r/select_jcl6.result8
-rw-r--r--mysql-test/r/select_pkeycache.result8
-rw-r--r--mysql-test/r/subselect.result256
-rw-r--r--mysql-test/r/subselect4.result8
-rw-r--r--mysql-test/r/subselect_mat.result2
-rw-r--r--mysql-test/r/subselect_no_mat.result254
-rw-r--r--mysql-test/r/subselect_no_opts.result254
-rw-r--r--mysql-test/r/subselect_no_scache.result256
-rw-r--r--mysql-test/r/subselect_no_semijoin.result254
-rw-r--r--mysql-test/r/sum_distinct.result12
-rw-r--r--mysql-test/suite/innodb_plugin/r/innodb_bug30423.result6
-rw-r--r--mysql-test/suite/innodb_plugin/t/innodb_bug30423.test1
-rw-r--r--mysql-test/suite/pbxt/r/ps_11bugs.result4
-rw-r--r--mysql-test/suite/pbxt/r/select.result8
-rw-r--r--mysql-test/suite/plugins/r/unix_socket.result30
-rw-r--r--mysql-test/suite/plugins/t/unix_socket.test56
-rw-r--r--mysql-test/suite/vcol/r/vcol_select_myisam.result30
-rw-r--r--mysql-test/suite/vcol/t/vcol_select_myisam.test20
-rw-r--r--mysql-test/t/func_group.test49
-rw-r--r--mysql-test/t/join_outer_innodb.test15
-rw-r--r--mysql-test/t/order_by.test29
-rw-r--r--mysql-test/t/subselect.test205
-rw-r--r--mysql-test/t/sum_distinct.test12
-rw-r--r--mysql-test/t/view.test1
-rw-r--r--mysql-test/valgrind.supp128
-rw-r--r--mysys/my_gethwaddr.c6
-rw-r--r--plugin/auth/auth_socket.c18
-rw-r--r--plugin/auth/dialog.c2
-rw-r--r--plugin/auth_pam/auth_pam.c37
-rw-r--r--sql/item.cc5
-rw-r--r--sql/item_subselect.cc11
-rw-r--r--sql/item_sum.cc3
-rw-r--r--sql/mysql_priv.h4
-rw-r--r--sql/mysqld.cc4
-rw-r--r--sql/opt_sum.cc7
-rw-r--r--sql/scheduler.cc2
-rw-r--r--sql/sql_base.cc7
-rw-r--r--sql/sql_manager.cc12
-rw-r--r--sql/sql_parse.cc7
-rw-r--r--sql/sql_select.cc10
-rw-r--r--sql/sql_select.h2
-rw-r--r--sql/table.cc4
-rw-r--r--sql/winservice.c4
-rw-r--r--storage/mysql_storage_engine.cmake4
-rw-r--r--storage/oqgraph/graphcore.cc14
-rw-r--r--win/cmake/mysql_version.cmake2
57 files changed, 1456 insertions, 782 deletions
diff --git a/configure.in b/configure.in
index b3ed594ef70..227b7ba2da5 100644
--- a/configure.in
+++ b/configure.in
@@ -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
diff --git a/include/config-win.h b/include/config-win.h
index c2a00f319ae..da93251ec90 100644
--- a/include/config-win.h
+++ b/include/config-win.h
@@ -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
diff --git a/libmysql/get_password.c b/libmysql/get_password.c
index 747d598d72a..21200acf512 100644
--- a/libmysql/get_password.c
+++ b/libmysql/get_password.c
@@ -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;
}
diff --git a/mysql-test/include/wait_until_connected_again.inc b/mysql-test/include/wait_until_connected_again.inc
index aff92141a8b..96240e36db7 100644
--- a/mysql-test/include/wait_until_connected_again.inc
+++ b/mysql-test/include/wait_until_connected_again.inc
@@ -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;
diff --git a/mysql-test/include/wait_until_disconnected.inc b/mysql-test/include/wait_until_disconnected.inc
index c274fbbe089..71361682442 100644
--- a/mysql-test/include/wait_until_disconnected.inc
+++ b/mysql-test/include/wait_until_disconnected.inc
@@ -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;
diff --git a/mysql-test/r/derived_view.result b/mysql-test/r/derived_view.result
index e853f5ac526..3f51c73b248 100644
--- a/mysql-test/r/derived_view.result
+++ b/mysql-test/r/derived_view.result
@@ -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;
diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result
index d5ea7311cc4..9660640baaa 100644
--- a/mysql-test/r/func_group.result
+++ b/mysql-test/r/func_group.result
@@ -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
diff --git a/mysql-test/r/join_outer_innodb.result b/mysql-test/r/join_outer_innodb.result
index 56e557ec881..7ea314f5c87 100644
--- a/mysql-test/r/join_outer_innodb.result
+++ b/mysql-test/r/join_outer_innodb.result
@@ -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;
diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result
index e73ff62366c..c0a54817b4c 100644
--- a/mysql-test/r/order_by.result
+++ b/mysql-test/r/order_by.result
@@ -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
diff --git a/mysql-test/r/ps_11bugs.result b/mysql-test/r/ps_11bugs.result
index f9f0525646d..56894302505 100644
--- a/mysql-test/r/ps_11bugs.result
+++ b/mysql-test/r/ps_11bugs.result
@@ -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
diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result
index 9648860619b..9e06f2d3841 100644
--- a/mysql-test/r/select.result
+++ b/mysql-test/r/select.result
@@ -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);
diff --git a/mysql-test/r/select_jcl6.result b/mysql-test/r/select_jcl6.result
index 88411e3482f..5b36791024f 100644
--- a/mysql-test/r/select_jcl6.result
+++ b/mysql-test/r/select_jcl6.result
@@ -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);
diff --git a/mysql-test/r/select_pkeycache.result b/mysql-test/r/select_pkeycache.result
index 9648860619b..9e06f2d3841 100644
--- a/mysql-test/r/select_pkeycache.result
+++ b/mysql-test/r/select_pkeycache.result
@@ -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);
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index 7dfcad074fe..47dcafc663b 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -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);
diff --git a/mysql-test/r/subselect4.result b/mysql-test/r/subselect4.result
index 6c942bca31a..4e3247e9da8 100644
--- a/mysql-test/r/subselect4.result
+++ b/mysql-test/r/subselect4.result
@@ -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;
diff --git a/mysql-test/r/subselect_mat.result b/mysql-test/r/subselect_mat.result
index bb30bfaf7f1..009510276b5 100644
--- a/mysql-test/r/subselect_mat.result
+++ b/mysql-test/r/subselect_mat.result
@@ -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;
diff --git a/mysql-test/r/subselect_no_mat.result b/mysql-test/r/subselect_no_mat.result
index c7d9fd96e5d..ea832b7f7ce 100644
--- a/mysql-test/r/subselect_no_mat.result
+++ b/mysql-test/r/subselect_no_mat.result
@@ -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);
diff --git a/mysql-test/r/subselect_no_opts.result b/mysql-test/r/subselect_no_opts.result
index 3d6efa28e19..f86955eadcd 100644
--- a/mysql-test/r/subselect_no_opts.result
+++ b/mysql-test/r/subselect_no_opts.result
@@ -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);
diff --git a/mysql-test/r/subselect_no_scache.result b/mysql-test/r/subselect_no_scache.result
index 602905dd5b8..fa8342da223 100644
--- a/mysql-test/r/subselect_no_scache.result
+++ b/mysql-test/r/subselect_no_scache.result
@@ -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);
diff --git a/mysql-test/r/subselect_no_semijoin.result b/mysql-test/r/subselect_no_semijoin.result
index 9b2370efd61..985f840f7c2 100644
--- a/mysql-test/r/subselect_no_semijoin.result
+++ b/mysql-test/r/subselect_no_semijoin.result
@@ -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);
diff --git a/mysql-test/r/sum_distinct.result b/mysql-test/r/sum_distinct.result
index c615817f52d..2746f5a09f4 100644
--- a/mysql-test/r/sum_distinct.result
+++ b/mysql-test/r/sum_distinct.result
@@ -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;
diff --git a/mysql-test/suite/innodb_plugin/r/innodb_bug30423.result b/mysql-test/suite/innodb_plugin/r/innodb_bug30423.result
index a19809366ae..6071587e888 100644
--- a/mysql-test/suite/innodb_plugin/r/innodb_bug30423.result
+++ b/mysql-test/suite/innodb_plugin/r/innodb_bug30423.result
@@ -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
diff --git a/mysql-test/suite/innodb_plugin/t/innodb_bug30423.test b/mysql-test/suite/innodb_plugin/t/innodb_bug30423.test
index 458c2967e19..da490589400 100644
--- a/mysql-test/suite/innodb_plugin/t/innodb_bug30423.test
+++ b/mysql-test/suite/innodb_plugin/t/innodb_bug30423.test
@@ -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
diff --git a/mysql-test/suite/pbxt/r/ps_11bugs.result b/mysql-test/suite/pbxt/r/ps_11bugs.result
index dd09e9d14f3..5a2743436e1 100644
--- a/mysql-test/suite/pbxt/r/ps_11bugs.result
+++ b/mysql-test/suite/pbxt/r/ps_11bugs.result
@@ -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
diff --git a/mysql-test/suite/pbxt/r/select.result b/mysql-test/suite/pbxt/r/select.result
index 58a1a326f6b..a32f06da7df 100644
--- a/mysql-test/suite/pbxt/r/select.result
+++ b/mysql-test/suite/pbxt/r/select.result
@@ -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);
diff --git a/mysql-test/suite/plugins/r/unix_socket.result b/mysql-test/suite/plugins/r/unix_socket.result
new file mode 100644
index 00000000000..45bf608cc93
--- /dev/null
+++ b/mysql-test/suite/plugins/r/unix_socket.result
@@ -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;
diff --git a/mysql-test/suite/plugins/t/unix_socket.test b/mysql-test/suite/plugins/t/unix_socket.test
new file mode 100644
index 00000000000..fc2e6c5b3c6
--- /dev/null
+++ b/mysql-test/suite/plugins/t/unix_socket.test
@@ -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
+
diff --git a/mysql-test/suite/vcol/r/vcol_select_myisam.result b/mysql-test/suite/vcol/r/vcol_select_myisam.result
index 3ad15009c76..ea3cbd3bc11 100644
--- a/mysql-test/suite/vcol/r/vcol_select_myisam.result
+++ b/mysql-test/suite/vcol/r/vcol_select_myisam.result
@@ -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;
diff --git a/mysql-test/suite/vcol/t/vcol_select_myisam.test b/mysql-test/suite/vcol/t/vcol_select_myisam.test
index 855e02ac113..c14faba576d 100644
--- a/mysql-test/suite/vcol/t/vcol_select_myisam.test
+++ b/mysql-test/suite/vcol/t/vcol_select_myisam.test
@@ -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;
diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test
index de0eac10927..f6091883168 100644
--- a/mysql-test/t/func_group.test
+++ b/mysql-test/t/func_group.test
@@ -1154,6 +1154,53 @@ drop table t1;
--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
--echo #
@@ -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
diff --git a/mysql-test/t/join_outer_innodb.test b/mysql-test/t/join_outer_innodb.test
index 40add7f488f..565bb72b152 100644
--- a/mysql-test/t/join_outer_innodb.test
+++ b/mysql-test/t/join_outer_innodb.test
@@ -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;
diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test
index c7a958b293a..425bef6c679 100644
--- a/mysql-test/t/order_by.test
+++ b/mysql-test/t/order_by.test
@@ -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
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index b92fb6f961c..b4e79416c40 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -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
@@ -4701,25 +4805,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
--echo #
@@ -4749,30 +4834,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 #
diff --git a/mysql-test/t/sum_distinct.test b/mysql-test/t/sum_distinct.test
index c58155a8e25..633a72fddc8 100644
--- a/mysql-test/t/sum_distinct.test
+++ b/mysql-test/t/sum_distinct.test
@@ -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;
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index 821bbe055e6..d4d5f2acc0b 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -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 #
diff --git a/mysql-test/valgrind.supp b/mysql-test/valgrind.supp
index 871bd6e55b8..0c75b4facab 100644
--- a/mysql-test/valgrind.supp
+++ b/mysql-test/valgrind.supp
@@ -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
-}
-
-{
- dlsym memory loss from udf_free on SuSE 11.1 x64 variant 2
- 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: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 can allocate memory for error message, the memory will be
+# freed by dlerror or other dl* function.
+#
{
- dlclose memory loss from plugin variant 8
+ memory "loss" from dlclose error messages
Memcheck:Leak
- fun:calloc
- fun:_dlerror_run
+ fun:*alloc
+ ...
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
diff --git a/mysys/my_gethwaddr.c b/mysys/my_gethwaddr.c
index c96af3f1018..c4ab39dbcf1 100644
--- a/mysys/my_gethwaddr.c
+++ b/mysys/my_gethwaddr.c
@@ -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.
diff --git a/plugin/auth/auth_socket.c b/plugin/auth/auth_socket.c
index cc406dac331..89d24e46f3c 100644
--- a/plugin/auth/auth_socket.c
+++ b/plugin/auth/auth_socket.c
@@ -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,
diff --git a/plugin/auth/dialog.c b/plugin/auth/dialog.c
index 24765c17d1c..6b54096f8ea 100644
--- a/plugin/auth/dialog.c
+++ b/plugin/auth/dialog.c
@@ -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);
diff --git a/plugin/auth_pam/auth_pam.c b/plugin/auth_pam/auth_pam.c
index 45c49975f6e..ee13b37f793 100644
--- a/plugin/auth_pam/auth_pam.c
+++ b/plugin/auth_pam/auth_pam.c
@@ -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",
diff --git a/sql/item.cc b/sql/item.cc
index aaf9b0c2a12..752b2915dca 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -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
*****************************************************************************/
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index d66dbd12436..52a2c2a7d8b 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -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();
/*
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 183f8ccff10..60ec27863bd 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -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);
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 253acff3405..2f5c89cb3a5 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -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;
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index a090448ebae..7a701217bb0 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -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);
diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc
index 08717142aa0..5298c57954d 100644
--- a/sql/opt_sum.cc
+++ b/sql/opt_sum.cc
@@ -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());
diff --git a/sql/scheduler.cc b/sql/scheduler.cc
index 5b83bb4753e..2f8aa2bef11 100644
--- a/sql/scheduler.cc
+++ b/sql/scheduler.cc
@@ -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);
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 558e7b0aa9e..6dd329f8c77 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -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);
diff --git a/sql/sql_manager.cc b/sql/sql_manager.cc
index cf0a73d0ce7..57fe5072dcd 100644
--- a/sql/sql_manager.cc
+++ b/sql/sql_manager.cc
@@ -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;
}
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 1676d4a09f4..24976ff9f1a 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -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))
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 9d03cdd55a2..05fba45792b 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -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;
diff --git a/sql/sql_select.h b/sql/sql_select.h
index 002c5a2df5a..a5fa59a070a 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -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()
diff --git a/sql/table.cc b/sql/table.cc
index 7b417b95319..5fe2d8afc42 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -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;
diff --git a/sql/winservice.c b/sql/winservice.c
index 562f047fa79..3ec91c26835 100644
--- a/sql/winservice.c
+++ b/sql/winservice.c
@@ -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;
-} \ No newline at end of file
+}
diff --git a/storage/mysql_storage_engine.cmake b/storage/mysql_storage_engine.cmake
index cbe9a310d67..cc3659d51c9 100644
--- a/storage/mysql_storage_engine.cmake
+++ b/storage/mysql_storage_engine.cmake
@@ -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)
diff --git a/storage/oqgraph/graphcore.cc b/storage/oqgraph/graphcore.cc
index 0b856ac253f..ba179989ea3 100644
--- a/storage/oqgraph/graphcore.cc
+++ b/storage/oqgraph/graphcore.cc
@@ -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);
diff --git a/win/cmake/mysql_version.cmake b/win/cmake/mysql_version.cmake
index bf623a22462..4ea59f8ac7e 100644
--- a/win/cmake/mysql_version.cmake
+++ b/win/cmake/mysql_version.cmake
@@ -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()