pingcap / pingcap/tidb

Error occurred while executing function greatest.

Open
#36,280 2 comments 0 reactions 0 assignees View on GitHub
severity/moderate sig/execution type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

Please answer these questions before submitting your issue. Thanks!

### 1. Minimal reproduce step (Required)

```mysql
SET timestamp=UNIX_TIMESTAMP('2011-11-01 17:48:00');
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
pk time(6) NOT NULL DEFAULT '00:00:00.000000',
col_date_not_null date NOT NULL,
PRIMARY KEY (pk)
);
INSERT INTO t1 VALUES ('00:00:00.000000','2001-09-10');
INSERT INTO t1 VALUES ('12:07:41.148239','2000-05-23');
SELECT GREATEST('2004-04-07', COALESCE (pk, col_date_not_null)) FROM t1 ORDER BY 1;
DROP TABLE t1;
SET timestamp=DEFAULT;
```

### 2. What did you expect to see? (Required)
```mysql
mysql> SELECT GREATEST('2004-04-07', COALESCE (pk, col_date_not_null)) FROM t1 ORDER BY 1;
+----------------------------------------------------------+
| GREATEST('2004-04-07', COALESCE (pk, col_date_not_null)) |
+----------------------------------------------------------+
| 2011-11-01 00:00:00.000000 |
| 2011-11-01 12:07:41.148239 |
+----------------------------------------------------------+
2 rows in set (0.00 sec)
```
### 3. What did you see instead (Required)
```mysql
mysql> SELECT GREATEST('2004-04-07', COALESCE (pk, col_date_not_null)) FROM t1 ORDER BY 1;
ERROR 1105 (HY000): strconv.Atoi: parsing "00:": invalid syntax
```
### 4. What is your TiDB version? (Required)

```
tidb_version(): Release Version: v5.5.0-alpha-34-g9cc1b169f
Edition: Community
Git Commit Hash: 9cc1b169f9080b34eda8468d7a974d2a387673dd
Git Branch: master
UTC Build Time: 2022-01-05 19:21:07
GoVersion: go1.17.2
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.