| Bug #120788 | JSON_VALUE RETURNING DATETIME DEFAULT returns a garbage date | ||
|---|---|---|---|
| Submitted: | 26 Jun 11:11 | Modified: | 15 Jul 14:13 |
| Reporter: | Yakir Gibraltar (OCA) | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server: JSON | Severity: | S2 (Serious) |
| Version: | 9.7.0 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
[26 Jun 11:11]
Yakir Gibraltar
[26 Jun 12:13]
Roy Lyseng
Thank you for the bug report. Verified as described.
[26 Jun 14:36]
Yakir Gibraltar
One small sibling case: the same wrong-member pattern also reproduces with RETURNING YEAR DEFAULT.
SELECT CAST(JSON_VALUE('"x"', '$' RETURNING YEAR DEFAULT 2023 ON ERROR) AS DATE);
-- 9.7.1 returns 0083-15-31
This appears to be the same Default_value member issue already verified here, since YEAR stores the default in integer_default while the DATE path reads date_default.
Thank you, Yakir Gibraltar
[26 Jun 20:48]
MySQL Admin
Posted by developer: Bug status updated to 'Patch approved'
[27 Jun 2:48]
MySQL Admin
Posted by developer: Bug status updated to 'Documenting'
[15 Jul 14:13]
Edward Gilmore
Posted by developer:
Added the following note to the MySQL Server 9.7.2 and 26.7.0 release notes:
JSON_VALUE() with RETURNING DATETIME and a DEFAULT value
could return an invalid constant date when the expression was
used in a DATE context, silently affecting predicates and joins.
The datetime value is now extracted before narrowing to a date.
