Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Duplicate
-
10.2.21
-
None
-
Ubuntu 16.04 x64
Description
We have found a serious problem with JSON_VALUE which apparently was partially fixed in 10.2.16. Specifically we're extracting a Date from JSON and if that extraction is in a function it does not work.
ERROR: Truncated incorrect datetime value: '2018-07-26T00:00:00+03:00'
If the extraction is done from the query (ie no function that does it) then it works fine.
Please see the following example:
SET NAMES 'utf8'; |
|
USE import; |
|
DELIMITER $$
|
|
CREATE DEFINER = 'jsupport'@'10.8.0.%' |
FUNCTION J_SON () |
RETURNS date |
BEGIN
|
|
RETURN (SELECT |
date (JSON_VALUE('{"b":"2018-07-26T00:00:00+03:00"}', '$.b'))); |
|
END
|
$$
|
|
DELIMITER ;
|
-- WORKING -> SELECT date (JSON_VALUE('{"b":"2018-07-26T00:00:00+03:00"}', '$.b'));
|
-- BROKEN -> SELECT J_SON(); |
Attachments
Issue Links
- duplicates
-
MDEV-11829 Please add support for datetime with time zone literals (ISO 8601)
-
- Open
-
There is a warning after truncation anyway, but inside the function server returns error.
MariaDB [test]> CREATE or replace FUNCTION f1 () RETURNS date RETURN (select date ("2018-07-26aaa"));
Query OK, 0 rows affected (0.006 sec)
MariaDB [test]> show create function f1;
+----------+-------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+----------------------+----------------------+--------------------+
| Function | sql_mode | Create Function | character_set_client | collation_connection | Database Collation |
+----------+-------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+----------------------+----------------------+--------------------+
| f1 | STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION | CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS date
RETURN (select date ("2018-07-26aaa")) | utf8 | utf8_general_ci | latin1_swedish_ci |
+----------+-------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+----------------------+----------------------+--------------------+
1 row in set (0.001 sec)
MariaDB [test]> SELECT f1();
ERROR 1292 (22007): Truncated incorrect date value: '2018-07-26aaa'
Error (Code 1292): Truncated incorrect date value: '2018-07-26aaa'
Note (Code 4094): At line 2 in test.f1
MariaDB [test]> SELECT date ("2018-07-26aaa");
+------------------------+
| date ("2018-07-26aaa") |
+------------------------+
| 2018-07-26 |
+------------------------+
1 row in set, 1 warning (0.000 sec)
Warning (Code 1292): Truncated incorrect date value: '2018-07-26aaa'
MariaDB [test]> show variables like 'sql_mode';
+---------------+-------------------------------------------------------------------------------------------+
| Variable_name | Value |
+---------------+-------------------------------------------------------------------------------------------+
| sql_mode | STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+---------------+-------------------------------------------------------------------------------------------+
1 row in set (0.001 sec)
MariaDB [test]> set sql_mode='';
Query OK, 0 rows affected (0.000 sec)
MariaDB [test]> CREATE or replace FUNCTION f1 () RETURNS date RETURN (select date ("2018-07-26aaa"));
Query OK, 0 rows affected (0.006 sec)
MariaDB [test]> SELECT f1();
+------------+
| f1() |
+------------+
| 2018-07-26 |
+------------+
1 row in set, 1 warning (0.001 sec)
Warning (Code 1292): Truncated incorrect date value: '2018-07-26aaa'