pingcap/tidb
在 GitHub 查看inconsistent result of greatest("2017-02-30", cast("2017-02-02" as date))
Open
#6,740 创建于 2018年6月4日
compatibility-mysql80component/expressionhelp wantedtype/compatibility
描述
Please answer these questions before submitting your issue. Thanks!
-
What did you do?
-
What did you expect to see?
mysql(127.0.0.1)> select greatest(cast("2017-02-02" as date),"2017-02-30");
Field 1: `greatest(cast("2017-02-02" as date),"2017-02-30")`
Catalog: `def`
Database: ``
Table: ``
Org_table: ``
Type: VAR_STRING
Collation: utf8_general_ci (33)
Length: 30
Max_length: 10
Decimals: 31
Flags:
+---------------------------------------------------+
| greatest(cast("2017-02-02" as date),"2017-02-30") |
+---------------------------------------------------+
| 2017-02-30 | <====
+---------------------------------------------------+
mysql(127.0.0.1)> select greatest(cast("2017-02-02" as date),cast("2017-02-03" as date));
Field 1: `greatest(cast("2017-02-02" as date),cast("2017-02-03" as date))`
Catalog: `def`
Database: ``
Table: ``
Org_table: ``
Type: DATE <====
Collation: utf8_general_ci (33)
Length: 9
Max_length: 10
Decimals: 0
Flags:
+-----------------------------------------------------------------+
| greatest(cast("2017-02-02" as date),cast("2017-02-03" as date)) |
+-----------------------------------------------------------------+
| 2017-02-03 |
+-----------------------------------------------------------------+
1 row in set (0.00 sec)
- What did you see instead?
tidb(127.0.0.1)> select greatest(cast("2017-02-02" as date),"2017-02-30");
Field 1: `greatest(cast("2017-02-02" as date),"2017-02-30")`
Catalog: `def`
Database: ``
Table: ``
Org_table: ``
Type: VAR_STRING
Collation: utf8_general_ci (33)
Length: 0
Max_length: 19
Decimals: 31
Flags:
+---------------------------------------------------+
| greatest(cast("2017-02-02" as date),"2017-02-30") |
+---------------------------------------------------+
| 2017-02-02 00:00:00 | <====
+---------------------------------------------------+
1 row in set, 1 warning (0.00 sec)
tidb(127.0.0.1)> select greatest(cast("2017-02-02" as date),cast("2017-02-03" as date));
Field 1: `greatest(cast("2017-02-02" as date),cast("2017-02-03" as date))`
Catalog: `def`
Database: ``
Table: ``
Org_table: ``
Type: VAR_STRING <====
Collation: utf8_general_ci (33)
Length: 0
Max_length: 19
Decimals: 31
Flags:
+-----------------------------------------------------------------+
| greatest(cast("2017-02-02" as date),cast("2017-02-03" as date)) |
+-----------------------------------------------------------------+
| 2017-02-03 00:00:00 |
+-----------------------------------------------------------------+
1 row in set (0.00 sec)
- What version of TiDB are you using (
tidb-server -Vor runselect tidb_version();on TiDB)?
Release Version: v2.0.0-rc.4-273-gf6a3c3f
Git Commit Hash: f6a3c3f0a55abf454d352ffa2089d7983fc18307
Git Branch: master
UTC Build Time: 2018-06-04 03:37:54
GoVersion: go version go1.10.1 darwin/amd64
Race Enabled: false
TiKV Min Version: 2.0.0-rc.4.1