pingcap/tidb

unix_timestamp return worng result when input with fractional digits

Open

#6 981 ouverte le 4 juil. 2018

Voir sur GitHub
 (8 commentaires) (0 réactions) (0 assignés)Go (6 186 forks)batch import
component/expressionhelp wantedpriority/P4type/compatibility

Métriques du dépôt

Stars
 (40 090 stars)
Métriques de merge PR
 (Merge moyen 14j 4h) (346 PRs mergées en 30 j)

Description

  1. What did you do? If possible, provide a recipe for reproducing the error.
mysql -P3306 -h127.0.0.1 -uroot -proot --column-type-info test;

mysql> select unix_timestamp('2011:01:01.001');
  1. What did you expect to see?
Field   1:  `unix_timestamp('2011:01:01.001')`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       LONGLONG
Collation:  binary (63)
Length:     11
Max_length: 10
Decimals:   0
Flags:      NOT_NULL BINARY NUM 

+----------------------------------+
| unix_timestamp('2011:01:01.001') |
+----------------------------------+
|                       1293814800 |
+----------------------------------+
1 row in set (0.00 sec)
  1. What did you see instead?
Field   1:  `unix_timestamp('2011:01:01.001')`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       NEWDECIMAL
Collation:  binary (63)
Length:     17
Max_length: 14
Decimals:   3
Flags:      BINARY NUM 


+----------------------------------+
| unix_timestamp('2011:01:01.001') |
+----------------------------------+
|                   1293811200.000 |
+----------------------------------+
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)?
Release Version: v2.1.0-beta-11-g1f6e12cc5
Git Commit Hash: 1f6e12cc55e534bf514eef212f1091a91b8592c9
Git Branch: HEAD
UTC Build Time: 2018-07-04 06:31:26
GoVersion: go version go1.10.1 linux/amd64
Race Enabled: false
TiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e

Guide contributeur