Skip to content

wrong result for query containing timestamp type #10302

@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> create table t(a int primary key, b timestamp);
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t values(1, '2019-04-29 12:38:15');
Query OK, 1 row affected (0.00 sec)

mysql> select * from t where b = '2019-04-29 12:38:15';
+---+---------------------+
| a | b                   |
+---+---------------------+
| 1 | 2019-04-29 12:38:15 |
+---+---------------------+
1 row in set (0.00 sec)

mysql> select * from t where b = (select max(b) from t);
Empty set (0.00 sec)

mysql> explain select * from t where b = (select max(b) from t);
+----------------------+-------+------+------------------------------------------------------------+
| id                   | count | task | operator info                                              |
+----------------------+-------+------+------------------------------------------------------------+
| TableReader_43       | 0.00  | root | data:Selection_42                                          |
| └─Selection_42       | 0.00  | cop  | eq(test.t.b, 2019-04-29 12:38:15)                          |
|   └─TableScan_41     | 1.00  | cop  | table:t, range:[-inf,+inf], keep order:false, stats:pseudo |
+----------------------+-------+------+------------------------------------------------------------+
3 rows in set (0.00 sec)
  1. What did you expect to see?

Both select queries should return one row.

  1. What did you see instead?

Second select query returns empty result set.

  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?
Release Version: v3.0.0-beta.1-160-gb5890b3cf
Git Commit Hash: b5890b3cf44eaf4faa48aa8478df9ce9506926ff
Git Branch: master
UTC Build Time: 2019-04-29 04:37:16
GoVersion: go version go1.12 darwin/amd64
Race Enabled: false
TiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e
Check Table Before Drop: false

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions