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

planner, executor: correlated select items should return NULL if the outer table is empty #13749

Closed
fzhedu opened this issue Nov 26, 2019 · 8 comments · Fixed by #20544 or #21902
Closed
Assignees
Labels
priority/P2 The issue has P2 priority. severity/critical sig/execution SIG execution type/bug The issue is confirmed as a bug.
Milestone

Comments

@fzhedu
Copy link
Contributor

fzhedu commented Nov 26, 2019

Description

Bug Report

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?
create table t (a int);
create table s (a int);
insert into t values(1);
insert into s values(1);
select count(t.a), (select count(s.a) from s where s.a > t.a) as field from t;
select count(t.a), (select count(s.a) from s where s.a > t.a) as field from t where t.a=100;
  1. What did you expect to see?
    Results from MySQL:
mysql> select count(t.a), (select count(s.a) from s where s.a > t.a) as field from t;
+------------+-------+
| count(t.a) | field |
+------------+-------+
|          1 |     0 |
+------------+-------+
1 row in set (0.00 sec)

mysql> select count(t.a), (select count(s.a) from s where s.a > t.a) as field from t where t.a=100;
+------------+-------+
| count(t.a) | field |
+------------+-------+
|          0 |  NULL |
+------------+-------+
1 row in set (0.00 sec)

mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.18    |
+-----------+
1 row in set (0.00 sec)
  1. What did you see instead?
    Results from TiDB:
mysql> select count(t.a), (select count(s.a) from s where s.a > t.a) as field from t;
+------------+-------+
| count(t.a) | field |
+------------+-------+
|          1 |     0 |
+------------+-------+
1 row in set (0.00 sec)

mysql> select count(t.a), (select count(s.a) from s where s.a > t.a) as field from t where t.a=100;
+------------+-------+
| count(t.a) | field |
+------------+-------+
|          0 |     0 |
+------------+-------+
1 row in set (0.00 sec)

mysql> select version();
+-----------------------------------------+
| version()                               |
+-----------------------------------------+
| 5.7.25-TiDB-v4.0.0-alpha-959-gaf2a2c532 |
+-----------------------------------------+
1 row in set (0.00 sec)

  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?

5.7.25-TiDB-v4.0.0-alpha-959-gaf2a2c532

SIG slack channel

#sig-exec

Score

  • 300

Mentor

@fzhedu fzhedu added type/bug The issue is confirmed as a bug. sig/planner SIG: Planner sig/execution SIG execution labels Nov 26, 2019
@SunRunAway SunRunAway added the help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. label Jun 1, 2020
@qw4990 qw4990 added the priority/P1 The issue has P1 priority. label Aug 27, 2020
@fzhedu fzhedu self-assigned this Aug 28, 2020
@fzhedu fzhedu added priority/P2 The issue has P2 priority. and removed priority/P1 The issue has P1 priority. labels Aug 28, 2020
@eurekaka eurekaka assigned eurekaka and unassigned fzhedu Oct 19, 2020
@eurekaka eurekaka removed challenge-program difficulty/easy help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. labels Oct 19, 2020
@ti-challenge-bot
Copy link

The issue has been removed from the challenge program.

3 similar comments
@ti-challenge-bot
Copy link

The issue has been removed from the challenge program.

@ti-challenge-bot
Copy link

The issue has been removed from the challenge program.

@ti-challenge-bot
Copy link

The issue has been removed from the challenge program.

@ti-srebot
Copy link
Contributor

Please edit this comment or add a new comment to complete the following information

Not a bug

  1. Remove the 'type/bug' label
  2. Add notes to indicate why it is not a bug

Duplicate bug

  1. Add the 'type/duplicate' label
  2. Add the link to the original bug

Bug

Note: Make Sure that 'component', and 'severity' labels are added
Example for how to fill out the template: #20100

1. Root Cause Analysis (RCA) (optional)

2. Symptom (optional)

3. All Trigger Conditions (optional)

4. Workaround (optional)

5. Affected versions

6. Fixed versions

@eurekaka
Copy link
Contributor

The fix is not complete, reopen this issue first.

@eurekaka eurekaka reopened this Nov 25, 2020
@SunRunAway SunRunAway modified the milestones: v4.0.9, v4.0.10 Nov 25, 2020
@wjhuang2016
Copy link
Member

@eurekaka If the fix is not complete, is the bug still critical?

@eurekaka
Copy link
Contributor

Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority/P2 The issue has P2 priority. severity/critical sig/execution SIG execution type/bug The issue is confirmed as a bug.
Projects
None yet
8 participants