Skip to content

Commit

Permalink
Bug #28499924: INCORRECT BEHAVIOR WITH UNION IN SUBQUERY
Browse files Browse the repository at this point in the history
test case
  • Loading branch information
vuvova committed Jan 23, 2019
1 parent b20d94d commit a8da66f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
22 changes: 22 additions & 0 deletions mysql-test/r/subselect2.result
Original file line number Diff line number Diff line change
Expand Up @@ -394,3 +394,25 @@ select null in (select a from t1 where a < out3.a union select a from t2 where
(select a from t3) +1 < out3.a+1) from t3 out3;
ERROR 21000: Subquery returns more than 1 row
drop table t1, t2, t3;
CREATE TABLE t1(
q11 int, q12 int, q13 int, q14 int, q15 int, q16 int, q17 int, q18 int, q19 int,
q21 int, q22 int, q23 int, q24 int, q25 int, q26 int, q27 int, q28 int, q29 int,
f1 int
);
CREATE TABLE t2(f2 int, f21 int, f3 timestamp, f4 int, f5 int, f6 int);
INSERT INTO t1 (f1) VALUES (1),(1),(2),(2);
INSERT INTO t2 VALUES (1,1,"2004-02-29 11:11:11",0,0,0), (2,2,"2004-02-29 11:11:11",0,0,0);
SELECT f1,
(SELECT t.f21 from t2 t where max(
q11+q12+q13+q14+q15+q16+q17+q18+q19+
q21+q22+q23+q24+q25+q26+q27+q28+q29) = t.f2 UNION
SELECT t.f3 FROM t2 AS t WHERE t1.f1=t.f2 AND t.f3=MAX(t1.f1) UNION
SELECT 1 LIMIT 1) AS test
FROM t1 GROUP BY f1;
f1 test
1 1
2 1
Warnings:
Warning 1292 Incorrect datetime value: '1'
Warning 1292 Incorrect datetime value: '2'
DROP TABLE t1,t2;
20 changes: 20 additions & 0 deletions mysql-test/t/subselect2.test
Original file line number Diff line number Diff line change
Expand Up @@ -411,3 +411,23 @@ insert into t3 select a from t1;
select null in (select a from t1 where a < out3.a union select a from t2 where
(select a from t3) +1 < out3.a+1) from t3 out3;
drop table t1, t2, t3;

#
# Bug #28499924: INCORRECT BEHAVIOR WITH UNION IN SUBQUERY
#
CREATE TABLE t1(
q11 int, q12 int, q13 int, q14 int, q15 int, q16 int, q17 int, q18 int, q19 int,
q21 int, q22 int, q23 int, q24 int, q25 int, q26 int, q27 int, q28 int, q29 int,
f1 int
);
CREATE TABLE t2(f2 int, f21 int, f3 timestamp, f4 int, f5 int, f6 int);
INSERT INTO t1 (f1) VALUES (1),(1),(2),(2);
INSERT INTO t2 VALUES (1,1,"2004-02-29 11:11:11",0,0,0), (2,2,"2004-02-29 11:11:11",0,0,0);
SELECT f1,
(SELECT t.f21 from t2 t where max(
q11+q12+q13+q14+q15+q16+q17+q18+q19+
q21+q22+q23+q24+q25+q26+q27+q28+q29) = t.f2 UNION
SELECT t.f3 FROM t2 AS t WHERE t1.f1=t.f2 AND t.f3=MAX(t1.f1) UNION
SELECT 1 LIMIT 1) AS test
FROM t1 GROUP BY f1;
DROP TABLE t1,t2;

0 comments on commit a8da66f

Please sign in to comment.