pingcap / pingcap/tidb

Add warnings for data/time/datetime delimiters as well as superfluous characters/spaces.

Open
#57,847 1 comment 1 reaction 0 assignees View on GitHub
compatibility-mysql80 type/compatibility type/enhancement
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Enhancement

Generate warnings if:
- [ ] DATE delimiters are not '-'
- [ ] TIME delimiters are not ':'
- [ ] delimiter between DATE and TIME is not a single space character
- [ ] extra whitespaces prefixes or suffixes

Maybe also check MySQL acceptable formats like '10101.5' (MySQL interpret it as '2010-10-01 05:00:00') or '4.12.3' (MySQL interpret it as '2004-12-03 00:00:00', while '4-12-3' translates to '0004-12-03 00:00:00') or at least make sure there are tests and it is documented (feel free to move this to a separate issue)

From #51742 to have it as a separate issue:
```mysql
mysql-9.0.1> SELECT DATE'2012@12@31';
+------------------+
| DATE'2012@12@31' |
+------------------+
| 2012-12-31 |
+------------------+
1 row in set, 1 warning (0.00 sec)

mysql-9.0.1> SHOW WARNINGS;
+---------+------+-------------------------------------------------------------------------------------------------------------+
| Level | Code | Message |
+---------+------+-------------------------------------------------------------------------------------------------------------+
| Warning | 4095 | Delimiter '@' in position 4 in datetime value '2012@12@31' at row 1 is deprecated. Prefer the standard '-'. |
+---------+------+-------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
tidb> SELECT DATE'2012@12@31';
+------------------+
| DATE'2012@12@31' |
+------------------+
| 2012-12-31 |
+------------------+
1 row in set (0.00 sec)
```

Contributor guide

Open the contributing guide

Research direction

No files, tests, or entry points are named. Start by locating TiDB's DATE, TIME, and DATETIME literal parsing and its existing warning tests; use the listed delimiter and whitespace cases as acceptance criteria, while treating the optional MySQL-format cases as separate scope or documentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, mysql
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.