Commit b135bcab authored by Gleb Shchepa's avatar Gleb Shchepa

automerge 5.0-bugteam --> 5.1-bugteam (bug 39069)

parents a931ac09 334e249f
...@@ -795,6 +795,60 @@ WHERE INNR.varchar_key > 'n{' ...@@ -795,6 +795,60 @@ WHERE INNR.varchar_key > 'n{'
); );
varchar_nokey varchar_nokey
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1), (2), (11);
# 2nd and 3rd columns should be same
SELECT a, ROW(11, 12) = (SELECT a, 22), ROW(11, 12) IN (SELECT a, 22) FROM t1 GROUP BY t1.a;
a ROW(11, 12) = (SELECT a, 22) ROW(11, 12) IN (SELECT a, 22)
1 0 0
2 0 0
11 0 0
SELECT a, ROW(11, 12) = (SELECT a, 12), ROW(11, 12) IN (SELECT a, 12) FROM t1 GROUP BY t1.a;
a ROW(11, 12) = (SELECT a, 12) ROW(11, 12) IN (SELECT a, 12)
1 0 0
2 0 0
11 1 1
SELECT a, ROW(11, 12) = (SELECT a, 22), ROW(11, 12) IN (SELECT a, 22) FROM t1;
a ROW(11, 12) = (SELECT a, 22) ROW(11, 12) IN (SELECT a, 22)
1 0 0
2 0 0
11 0 0
SELECT a, ROW(11, 12) = (SELECT a, 12), ROW(11, 12) IN (SELECT a, 12) FROM t1;
a ROW(11, 12) = (SELECT a, 12) ROW(11, 12) IN (SELECT a, 12)
1 0 0
2 0 0
11 1 1
SELECT a AS x, ROW(11, 12) = (SELECT MAX(x), 22), ROW(11, 12) IN (SELECT MAX(x), 22) FROM t1;
x ROW(11, 12) = (SELECT MAX(x), 22) ROW(11, 12) IN (SELECT MAX(x), 22)
1 0 0
2 0 0
11 0 0
# 2nd and 3rd columns should be same for x == 11 only
SELECT a AS x, ROW(11, 12) = (SELECT MAX(x), 12), ROW(11, 12) IN (SELECT MAX(x), 12) FROM t1;
x ROW(11, 12) = (SELECT MAX(x), 12) ROW(11, 12) IN (SELECT MAX(x), 12)
1 0 1
2 0 1
11 1 1
DROP TABLE t1;
# both columns should be same
SELECT ROW(1,2) = (SELECT NULL, NULL), ROW(1,2) IN (SELECT NULL, NULL);
ROW(1,2) = (SELECT NULL, NULL) ROW(1,2) IN (SELECT NULL, NULL)
NULL NULL
SELECT ROW(1,2) = (SELECT 1, NULL), ROW(1,2) IN (SELECT 1, NULL);
ROW(1,2) = (SELECT 1, NULL) ROW(1,2) IN (SELECT 1, NULL)
NULL NULL
SELECT ROW(1,2) = (SELECT NULL, 2), ROW(1,2) IN (SELECT NULL, 2);
ROW(1,2) = (SELECT NULL, 2) ROW(1,2) IN (SELECT NULL, 2)
NULL NULL
SELECT ROW(1,2) = (SELECT NULL, 1), ROW(1,2) IN (SELECT NULL, 1);
ROW(1,2) = (SELECT NULL, 1) ROW(1,2) IN (SELECT NULL, 1)
0 0
SELECT ROW(1,2) = (SELECT 1, 1), ROW(1,2) IN (SELECT 1, 1);
ROW(1,2) = (SELECT 1, 1) ROW(1,2) IN (SELECT 1, 1)
0 0
SELECT ROW(1,2) = (SELECT 1, 2), ROW(1,2) IN (SELECT 1, 2);
ROW(1,2) = (SELECT 1, 2) ROW(1,2) IN (SELECT 1, 2)
1 1
End of 5.0 tests End of 5.0 tests
create table t0 (a int); create table t0 (a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
......
...@@ -640,6 +640,35 @@ WHERE NULL NOT IN ( ...@@ -640,6 +640,35 @@ WHERE NULL NOT IN (
DROP TABLE t1; DROP TABLE t1;
#
# Bug #39069: <row constructor> IN <table-subquery> seriously messed up
#
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1), (2), (11);
--echo # 2nd and 3rd columns should be same
SELECT a, ROW(11, 12) = (SELECT a, 22), ROW(11, 12) IN (SELECT a, 22) FROM t1 GROUP BY t1.a;
SELECT a, ROW(11, 12) = (SELECT a, 12), ROW(11, 12) IN (SELECT a, 12) FROM t1 GROUP BY t1.a;
SELECT a, ROW(11, 12) = (SELECT a, 22), ROW(11, 12) IN (SELECT a, 22) FROM t1;
SELECT a, ROW(11, 12) = (SELECT a, 12), ROW(11, 12) IN (SELECT a, 12) FROM t1;
# The x alias is used below to workaround bug #40674.
# Regression tests for sum function on outer column in subselect from dual:
SELECT a AS x, ROW(11, 12) = (SELECT MAX(x), 22), ROW(11, 12) IN (SELECT MAX(x), 22) FROM t1;
--echo # 2nd and 3rd columns should be same for x == 11 only
SELECT a AS x, ROW(11, 12) = (SELECT MAX(x), 12), ROW(11, 12) IN (SELECT MAX(x), 12) FROM t1;
DROP TABLE t1;
--echo # both columns should be same
SELECT ROW(1,2) = (SELECT NULL, NULL), ROW(1,2) IN (SELECT NULL, NULL);
SELECT ROW(1,2) = (SELECT 1, NULL), ROW(1,2) IN (SELECT 1, NULL);
SELECT ROW(1,2) = (SELECT NULL, 2), ROW(1,2) IN (SELECT NULL, 2);
SELECT ROW(1,2) = (SELECT NULL, 1), ROW(1,2) IN (SELECT NULL, 1);
SELECT ROW(1,2) = (SELECT 1, 1), ROW(1,2) IN (SELECT 1, 1);
SELECT ROW(1,2) = (SELECT 1, 2), ROW(1,2) IN (SELECT 1, 2);
--echo End of 5.0 tests --echo End of 5.0 tests
# #
......
...@@ -1676,8 +1676,13 @@ JOIN::exec() ...@@ -1676,8 +1676,13 @@ JOIN::exec()
We have to test for 'conds' here as the WHERE may not be constant We have to test for 'conds' here as the WHERE may not be constant
even if we don't have any tables for prepared statements or if even if we don't have any tables for prepared statements or if
conds uses something like 'rand()'. conds uses something like 'rand()'.
If the HAVING clause is either impossible or always true, then
JOIN::having is set to NULL by optimize_cond.
In this case JOIN::exec must check for JOIN::having_value, in the
same way it checks for JOIN::cond_value.
*/ */
if (cond_value != Item::COND_FALSE && if (cond_value != Item::COND_FALSE &&
having_value != Item::COND_FALSE &&
(!conds || conds->val_int()) && (!conds || conds->val_int()) &&
(!having || having->val_int())) (!having || having->val_int()))
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment