Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected behavior for case when {false condition} then {subquery...} else {...} end #35706

Open
solotzg opened this issue Jun 24, 2022 · 1 comment
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 affects-6.1 severity/moderate sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@solotzg
Copy link
Contributor

solotzg commented Jun 24, 2022

Bug Report

Please answer these questions before submitting your issue. Thanks!

ref #34217

1. Minimal reproduce step (Required)

DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
create table t1(c1 int);
insert into t1 values(2), (3);

select * from t1 where (case when 0 <> 0 then (select c1 from t1) else 0 end) > 1; 
explain select * from t1 where (case when 0 <> 0 then (select c1 from t1) else 0 end) > 1; 
select * from t1 where (case when (select count(1) from t1) = 0 then (select c1 from t1) else 0 end) > 1; 

2. What did you expect to see? (Required)

MySQL

mysql> select * from t1 where (case when 0 <> 0 then (select c1 from t1) else 0 end) > 1; 
Empty set (0.00 sec)

3. What did you see instead (Required)

MySQL [test]> select * from t1 where (case when 0 <> 0 then (select c1 from t1) else 0 end) > 1; 
ERROR 1242 (21000): Subquery returns more than 1 row

MySQL [test]> explain select * from t1 where (case when 0 <> 0 then (select c1 from t1) else 0 end) > 1; 
ERROR 1242 (21000): Subquery returns more than 1 row

MySQL [test]> select * from t1 where (case when (select count(1) from t1) = 0 then (select c1 from t1) else 0 end) > 1; 
ERROR 1242 (21000): Subquery returns more than 1 row

4. What is your TiDB version? (Required)

= release-4.0

@solotzg solotzg added the type/bug The issue is confirmed as a bug. label Jun 24, 2022
@solotzg
Copy link
Contributor Author

solotzg commented Jun 24, 2022

@zanmato1984 PTAL.

@ti-chi-bot ti-chi-bot added may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.0 may-affects-6.1 labels Jun 26, 2022
@seiya-annie seiya-annie added affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 affects-6.1 sig/planner SIG: Planner severity/moderate and removed may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-6.0 may-affects-6.1 severity/major labels Jun 26, 2022
@seiya-annie seiya-annie added sig/execution SIG execution and removed sig/planner SIG: Planner labels Jun 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 affects-6.1 severity/moderate sig/execution SIG execution type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

3 participants