[MDEV-29381] JSON paths containing dashes are reported as syntax errors in procedures Created: 2022-08-25  Updated: 2023-08-24  Resolved: 2023-01-06

Status: Closed
Project: MariaDB Server
Component/s: JSON
Affects Version/s: 10.9.1
Fix Version/s: 10.9.5

Type: Bug Priority: Critical
Reporter: Andrei Pavel Assignee: Rucha Deodhar
Resolution: Fixed Votes: 3
Labels: regression
Environment:

EndeavorOS but with MariaDB 10.9.2 from Dockerhub container


Attachments: HTML File mariadb-patch    
Issue Links:
Duplicate
is duplicated by MDEV-29586 JSON_VALUE and JSON_EXTRACT doesn't h... Closed
is duplicated by MDEV-30060 JSON path expression with dashes does... Closed
Problem/Incident
is caused by MDEV-22224 Support JSON Path negative index Closed
Relates
relates to MDEV-32007 JSON_VALUE and JSON_EXTRACT doesn't h... Closed

 Description   

JSON paths with dashes in them are reported as syntax errors inside procedures. If they are free-standing, they work fine.

DROP PROCEDURE IF EXISTS my_proc;
 
DELIMITER $$
CREATE PROCEDURE my_proc()
BEGIN
DECLARE result TEXT;
SET result = JSON_EXTRACT('{ "my-key": 1 }', '$."my-key"');
END $$
DELIMITER ;
 
CALL my_proc();

--------------
CALL my_proc()
--------------
 
ERROR 4042 (HY000) at line 11: Syntax error in JSON path in argument 2 to function 'json_extract' at position 6

This syntax works in procedures on MariaDB 10.8.4 and prior.

More about the environment:

$ cat /etc/os-release
NAME='EndeavourOS'
PRETTY_NAME='EndeavourOS'
ID=endeavouros
ID_LIKE=arch
BUILD_ID=2021.04.17
ANSI_COLOR="38;2;23;147;209"
HOME_URL='https://endeavouros.com'
DOCUMENTATION_URL='https://discovery.endeavouros.com'
SUPPORT_URL='https://forum.endeavouros.com'
BUG_REPORT_URL='https://forum.endeavouros.com/c/arch-based-related-questions/bug-reports'
LOGO=endeavouros

Dockerized MariaDB:

Server version: 10.9.2-MariaDB-1:10.9.2+maria~ubu2204 mariadb.org binary distribution

$ mysql --version
mysql  Ver 15.1 Distrib 10.8.4-MariaDB, for Linux (x86_64) using readline 5.1

But also tested with the client included in the docker container, same result:

$ docker exec -it 97795998875c bin/mysql --version
bin/mysql  Ver 15.1 Distrib 10.9.2-MariaDB, for debian-linux-gnu (x86_64) using  EditLine wrapper



 Comments   
Comment by Sergei Golubchik [ 2022-08-25 ]

Caused by

commit dfcbb30a92c2f1d33ceefb56a1d3fa13f8d0ce67
Date:   Mon Nov 22 22:59:30 2021 +0530
 
    MDEV-22224: Support JSON Path negative index

Comment by Francis Dupont [ 2022-11-29 ]

Found the source of the bug: the parser transition table for quoted keys has an incorrect entry (JE_SYN i.e. raise a syntax error vs. stay in the same state) for '-'. I attached a fix (diff on 10.10.2 sources) which solves the problem for me.
mariadb-patch

Comment by Rucha Deodhar [ 2022-12-29 ]

Patch (submitted as contribution) : https://github.com/MariaDB/server/commit/0225159a8d0e1260bfec7219b584523097a74d4b

Generated at Thu Feb 08 10:08:07 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.