[MDEV-24542] JSON_REMOVE returns wrong result and ER_JSON_EOS after not finding element to remove Created: 2021-01-07  Updated: 2023-04-27

Status: Open
Project: MariaDB Server
Component/s: JSON
Affects Version/s: 10.2, 10.3, 10.4, 10.5
Fix Version/s: 10.4, 10.5

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Rucha Deodhar
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Duplicate
duplicates MDEV-22141 JSON_REMOVE returns NULL on valid arg... Confirmed

 Description   

10.5 1b12e251

MariaDB [test]> SELECT JSON_REMOVE('{"a":"b"}','$[0][1].a');
+--------------------------------------+
| JSON_REMOVE('{"a":"b"}','$[0][1].a') |
+--------------------------------------+
| NULL                                 |
+--------------------------------------+
1 row in set, 1 warning (0.000 sec)
 
MariaDB [test]> SHOW WARNINGS;
+---------+------+---------------------------------------------------------------------+
| Level   | Code | Message                                                             |
+---------+------+---------------------------------------------------------------------+
| Warning | 4037 | Unexpected end of JSON text in argument 1 to function 'json_remove' |
+---------+------+---------------------------------------------------------------------+
1 row in set (0.000 sec)

MySQL returns the untouched JSON document instead:

MySQL [test]> SELECT JSON_REMOVE('{"a":"b"}','$[0][1].a');
+--------------------------------------+
| JSON_REMOVE('{"a":"b"}','$[0][1].a') |
+--------------------------------------+
| {"a": "b"}                           |
+--------------------------------------+
1 row in set (0.000 sec)


Generated at Thu Feb 08 09:30:46 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.