[MDEV-30471] Inconsistent casting of invalid datetime values Created: 2023-01-25 Updated: 2023-01-31 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | 10.2.24, 10.8.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor |
| Reporter: | Andrei Lurie | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Observing inconsistent behavior when casting invalid datetime values (when zero dates are allowed).
The result of the explicit cast being NULL makes sense, e.g.
What follows is confusing/inconsistent:
It looks as if the explicit cast result is zero when under predicate context and is NULL when under the projection context. Except:
So, the "d = cast(vc as date)" term acts as if result of the cast was '0000-00-00' but the "cast(vc as date) is null" term acts as if result of the cast was NULL. Could someone please shed some light on this? |
| Comments |
| Comment by Andrei Lurie [ 2023-01-31 ] |
|
The reason for this behavior is that Type_handler::Item_send_datetime uses default datetime Options: This leads to make_fuzzy_date() to set the type to MYSQL_TIMESTAMP_NONE (will lead to NULL) in one case and MYSQL_TIMESTAMP_DATETIME (will lead to 0000-00-00) in another. This explains the fuzzy Would a less confusing behavior be to also return 0000-00-00 when sending data, i.e. adding TIME_FUZZY_DATES to the Type_handler::Item_send_datetime? |