065b979f35
[Bug] behavior of function str_to_date() and date_format() on BE and FE is inconsistent ( #4612 )
...
1. add date range check in `DateLiteral` for `FEFunctions`
2. `select str_to_date(202009,'%Y%m')` and `select str_to_date(str,'%Y%m') from tb where tb.str = '202009'` will return same output `2020-09-00`.
3. add support of zero-date to function `str_to_date()`,`date_format()`
4. fix FE can calculate negative value bug, eg: `select str_to_date('-2020', '%Y')` will return `NULL` instead of date value.
current behavior is same as MySQL **without** sql_mode `NO_ZERO_IN_DATE` and `NO_ZERO_DATE`.
**current behavior**
```
mysql> select siteid,str_to_date(siteid,'%Y%m%d') from table2 order by siteid;
+------------+---------------------------------+
| siteid | str_to_date(`siteid`, '%Y%m%d') |
+------------+---------------------------------+
| 1 | 2001-00-00 |
| 2 | 2002-00-00 |
| 2 | 2002-00-00 |
| 3 | 2003-00-00 |
| 4 | 2004-00-00 |
| 5 | 2005-00-00 |
| 20 | 2020-00-00 |
| 202 | 0202-00-00 |
| 2020 | 2020-00-00 |
| 20209 | 2020-09-00 |
| 202008 | 2020-08-00 |
| 202009 | 2020-09-00 |
| 2020009 | 2020-00-09 |
| 20200009 | 2020-00-09 |
| 20201309 | NULL |
| 2020090909 | 2020-09-09 |
+------------+---------------------------------+
mysql> select str_to_date('2','%Y%m%d'),str_to_date('20','%Y%m%d'),str_to_date('202','%Y%m%d'),str_to_date('2020','%Y%m%d'),str_to_date('20209','%Y%m%d'),str_to_date('202009','%Y%m%d'),str_to_date('2020099','%Y%m%d'),str_to_date('20200909','%Y%m%d'),str_to_date('2020090909','%Y%m%d'),str_to_date('2020009','%Y%m%d'),str_to_date('20200009','%Y%m%d'),str_to_date('20201309','%Y%m%d');
+----------------------------+-----------------------------+------------------------------+-------------------------------+--------------------------------+---------------------------------+----------------------------------+-----------------------------------+-------------------------------------+----------------------------------+-----------------------------------+-----------------------------------+
| str_to_date('2', '%Y%m%d') | str_to_date('20', '%Y%m%d') | str_to_date('202', '%Y%m%d') | str_to_date('2020', '%Y%m%d') | str_to_date('20209', '%Y%m%d') | str_to_date('202009', '%Y%m%d') | str_to_date('2020099', '%Y%m%d') | str_to_date('20200909', '%Y%m%d') | str_to_date('2020090909', '%Y%m%d') | str_to_date('2020009', '%Y%m%d') | str_to_date('20200009', '%Y%m%d') | str_to_date('20201309', '%Y%m%d') |
+----------------------------+-----------------------------+------------------------------+-------------------------------+--------------------------------+---------------------------------+----------------------------------+-----------------------------------+-------------------------------------+----------------------------------+-----------------------------------+-----------------------------------+
| 2002-00-00 | 2020-00-00 | 0202-00-00 | 2020-00-00 | 2020-09-00 | 2020-09-00 | 2020-09-09 | 2020-09-09 | 2020-09-09 | 2020-00-09 | 2020-00-09 | NULL |
+----------------------------+-----------------------------+------------------------------+-------------------------------+--------------------------------+---------------------------------+----------------------------------+-----------------------------------+-------------------------------------+----------------------------------+-----------------------------------+-----------------------------------+
```
2020-09-17 10:10:19 +08:00