Skip to content

IsNull should not be propagated from column equal condition #7834

@eurekaka

Description

@eurekaka

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.
mysql> explain select * from t1 join t2 where t1.a = t2.a and t2.a is null;
+----------------------------+----------+------+-------------------------------------------------------------------------------+
| id                         | count    | task | operator info                                                                 |
+----------------------------+----------+------+-------------------------------------------------------------------------------+
| Projection_7               | 12.50    | root | test.t1.id, test.t1.a, test.t1.b, test.t2.id, test.t2.a, test.t2.b, test.t2.c |
| └─HashLeftJoin_8           | 12.50    | root | inner join, inner:TableReader_15, equal:[eq(test.t2.a, test.t1.a)]            |
|   ├─TableReader_12         | 10.00    | root | data:Selection_11                                                             |
|   │ └─Selection_11         | 10.00    | cop  | isnull(test.t2.a)                                                             |
|   │   └─TableScan_10       | 10000.00 | cop  | table:t2, range:[-inf,+inf], keep order:false, stats:pseudo                   |
|   └─TableReader_15         | 10.00    | root | data:Selection_14                                                             |
|     └─Selection_14         | 10.00    | cop  | isnull(test.t1.a)                                                             |
|       └─TableScan_13       | 10000.00 | cop  | table:t1, range:[-inf,+inf], keep order:false, stats:pseudo                   |
+----------------------------+----------+------+-------------------------------------------------------------------------------+
8 rows in set (0.00 sec)
  1. What did you expect to see?

isnull(test.t1.a) condition should not be derived, since null = null is false

  1. What did you see instead?

isnull(test.t1.a) is derived from isnull(test.t2.a and eq(test.t2.a, test.t1.a)

  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?
mysql> select tidb_version();
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                                                                                   |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v2.1.0-rc.3-8-g5baedaa
Git Commit Hash: 5baedaa21ca6d3584c529f65113a132061892dd7
Git Branch: master
UTC Build Time: 2018-09-12 02:31:43
GoVersion: go version go1.11rc1 linux/amd64
Race Enabled: false
TiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e
Check Table Before Drop: false |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

Metadata

Metadata

Assignees

Labels

sig/plannerSIG: Plannertype/bugThe issue is confirmed as a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions