Skip to content

Commit a8da66f

Browse files
committed
Bug #28499924: INCORRECT BEHAVIOR WITH UNION IN SUBQUERY
test case
1 parent b20d94d commit a8da66f

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

mysql-test/r/subselect2.result

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,3 +394,25 @@ select null in (select a from t1 where a < out3.a union select a from t2 where
394394
(select a from t3) +1 < out3.a+1) from t3 out3;
395395
ERROR 21000: Subquery returns more than 1 row
396396
drop table t1, t2, t3;
397+
CREATE TABLE t1(
398+
q11 int, q12 int, q13 int, q14 int, q15 int, q16 int, q17 int, q18 int, q19 int,
399+
q21 int, q22 int, q23 int, q24 int, q25 int, q26 int, q27 int, q28 int, q29 int,
400+
f1 int
401+
);
402+
CREATE TABLE t2(f2 int, f21 int, f3 timestamp, f4 int, f5 int, f6 int);
403+
INSERT INTO t1 (f1) VALUES (1),(1),(2),(2);
404+
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);
405+
SELECT f1,
406+
(SELECT t.f21 from t2 t where max(
407+
q11+q12+q13+q14+q15+q16+q17+q18+q19+
408+
q21+q22+q23+q24+q25+q26+q27+q28+q29) = t.f2 UNION
409+
SELECT t.f3 FROM t2 AS t WHERE t1.f1=t.f2 AND t.f3=MAX(t1.f1) UNION
410+
SELECT 1 LIMIT 1) AS test
411+
FROM t1 GROUP BY f1;
412+
f1 test
413+
1 1
414+
2 1
415+
Warnings:
416+
Warning 1292 Incorrect datetime value: '1'
417+
Warning 1292 Incorrect datetime value: '2'
418+
DROP TABLE t1,t2;

mysql-test/t/subselect2.test

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,3 +411,23 @@ insert into t3 select a from t1;
411411
select null in (select a from t1 where a < out3.a union select a from t2 where
412412
(select a from t3) +1 < out3.a+1) from t3 out3;
413413
drop table t1, t2, t3;
414+
415+
#
416+
# Bug #28499924: INCORRECT BEHAVIOR WITH UNION IN SUBQUERY
417+
#
418+
CREATE TABLE t1(
419+
q11 int, q12 int, q13 int, q14 int, q15 int, q16 int, q17 int, q18 int, q19 int,
420+
q21 int, q22 int, q23 int, q24 int, q25 int, q26 int, q27 int, q28 int, q29 int,
421+
f1 int
422+
);
423+
CREATE TABLE t2(f2 int, f21 int, f3 timestamp, f4 int, f5 int, f6 int);
424+
INSERT INTO t1 (f1) VALUES (1),(1),(2),(2);
425+
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);
426+
SELECT f1,
427+
(SELECT t.f21 from t2 t where max(
428+
q11+q12+q13+q14+q15+q16+q17+q18+q19+
429+
q21+q22+q23+q24+q25+q26+q27+q28+q29) = t.f2 UNION
430+
SELECT t.f3 FROM t2 AS t WHERE t1.f1=t.f2 AND t.f3=MAX(t1.f1) UNION
431+
SELECT 1 LIMIT 1) AS test
432+
FROM t1 GROUP BY f1;
433+
DROP TABLE t1,t2;

0 commit comments

Comments
 (0)