pingcap / pingcap/tidb

`TIME` returns zero time instead of NULL for invalid time

Open
#59,432 1 comment 0 reactions 0 assignees View on GitHub
component/expression 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)

### 2. What did you expect to see? (Required)

```
mysql> SELECT TIME('');
+----------+
| TIME('') |
+----------+
| NULL |
+----------+
1 row in set, 1 warning (0.02 sec)

mysql> SELECT TIME('NOT_A_TIME');
+--------------------+
| TIME('NOT_A_TIME') |
+--------------------+
| NULL |
+--------------------+
1 row in set, 1 warning (0.00 sec)
```

### 3. What did you see instead (Required)

```
mysql> SELECT TIME('');
+----------+
| TIME('') |
+----------+
| 00:00:00 |
+----------+
1 row in set, 1 warning (0.00 sec)

mysql> SELECT TIME('NOT_A_TIME');
+--------------------+
| TIME('NOT_A_TIME') |
+--------------------+
| 00:00:00 |
+--------------------+
1 row in set, 1 warning (0.00 sec)
```

### 4. What is your TiDB version? (Required)

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported SELECT TIME('') and SELECT TIME('NOT_A_TIME') cases and compare the actual and expected results. Trace the TIME function implementation and its existing tests; done means invalid inputs return NULL with a warning instead of 00:00:00.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, mysql
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.