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

Unexcepted result in SELECT ... CASE WHEN ... ELSE NULL ... #11102

Closed
lovewin99 opened this issue Jul 5, 2019 · 1 comment
Closed

Unexcepted result in SELECT ... CASE WHEN ... ELSE NULL ... #11102

lovewin99 opened this issue Jul 5, 2019 · 1 comment
Labels
type/bug The issue is confirmed as a bug.

Comments

@lovewin99
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?
    If possible, provide a recipe for reproducing the error.
create table kankan1(id int, name text);

insert into kankan1 values(1, 'a');

insert into kankan1 values(2, 'a');

create table kankan2(id int, h1 text);

insert into kankan2 values(2, 'z');

select * from (
select
t1.id,
t2.h1,
	case 
	when t1.name='b' then 'case2'
	when t1.name='a' then 'case1'
	else null end as 'flag' 
from kankan1 t1
left join kankan2 t2 on t1.id = t2.id 
 ) t3 
where t3.flag = 'case1' order by t3.id;
  1. What did you expect to see?
+------+------+-------+
| id   | h1   | flag  |
+------+------+-------+
|    1 | NULL | case1 |
|    2 | z    | case1 |
+------+------+-------+
  1. What did you see instead?
+------+------+-------+
| id   | h1   | flag  |
+------+------+-------+
|    2 | z    | case1 |
+------+------+-------+
  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?
Release Version: v3.0.0-rc.1-290-g21d2590ac
Git Commit Hash: 21d2590ac37bf53e5e687b8a341d50105ddbffe8
Git Branch: my-master
UTC Build Time: 2019-07-05 10:20:45
GoVersion: go version go1.12.5 darwin/amd64
Race Enabled: false
TiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e
Check Table Before Drop: false
@lovewin99 lovewin99 added the type/bug The issue is confirmed as a bug. label Jul 5, 2019
lovewin99 pushed a commit to lovewin99/tidb that referenced this issue Jul 5, 2019
Unexcepted result in `SELECT ... CASE WHEN ... ELSE NULL...`
lovewin99 pushed a commit to lovewin99/tidb that referenced this issue Jul 5, 2019
                                                            Unexcepted result in `SELECT ... CASE WHEN ... ELSE NULL...`
lovewin99 added a commit to lovewin99/tidb that referenced this issue Jul 5, 2019
                                                            Unexcepted result in `SELECT ... CASE WHEN ... ELSE NULL...`
lovewin99 added a commit to lovewin99/tidb that referenced this issue Jul 6, 2019
                                                            Unexcepted result in `SELECT ... CASE WHEN ... ELSE NULL...`
lovewin99 added a commit to lovewin99/tidb that referenced this issue Jul 9, 2019
                                                            Unexcepted result in `SELECT ... CASE WHEN ... ELSE NULL...`
lovewin99 added a commit to lovewin99/tidb that referenced this issue Jul 9, 2019
                                                            Unexcepted result in `SELECT ... CASE WHEN ... ELSE NULL...`
lovewin99 added a commit to lovewin99/tidb that referenced this issue Jul 10, 2019
                                                            Unexcepted result in `SELECT ... CASE WHEN ... ELSE NULL...`
lovewin99 added a commit to lovewin99/tidb that referenced this issue Jul 15, 2019
                                                            Unexcepted result in `SELECT ... CASE WHEN ... ELSE NULL...`
lovewin99 added a commit to lovewin99/tidb that referenced this issue Jul 19, 2019
                                                            Unexcepted result in `SELECT ... CASE WHEN ... ELSE NULL...`
lovewin99 added a commit to lovewin99/tidb that referenced this issue Jul 19, 2019
                                                            Unexcepted result in `SELECT ... CASE WHEN ... ELSE NULL...`
lovewin99 added a commit to lovewin99/tidb that referenced this issue Jul 19, 2019
                                                            Unexcepted result in `SELECT ... CASE WHEN ... ELSE NULL...`
lovewin99 added a commit to lovewin99/tidb that referenced this issue Jul 22, 2019
handle `CASE WHEN` specially when folding constant during outerJoin Simplification
@zz-jason
Copy link
Member

zz-jason commented Aug 3, 2019

fixed by #11105

@zz-jason zz-jason closed this as completed Aug 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

2 participants