Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-29381

JSON paths containing dashes are reported as syntax errors in procedures

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • 10.9.1
    • 10.9.5
    • JSON
    • EndeavorOS but with MariaDB 10.9.2 from Dockerhub container

    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
      

      Attachments

        Issue Links

          Activity

            Caused by

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

            serg Sergei Golubchik added a comment - Caused by commit dfcbb30a92c2f1d33ceefb56a1d3fa13f8d0ce67 Date: Mon Nov 22 22:59:30 2021 +0530   MDEV-22224: Support JSON Path negative index

            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

            Francis.Dupont Francis Dupont added a comment - 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
            rucha174 Rucha Deodhar added a comment - - edited Patch (submitted as contribution) : https://github.com/MariaDB/server/commit/0225159a8d0e1260bfec7219b584523097a74d4b

            People

              rucha174 Rucha Deodhar
              andrei-pavel Andrei Pavel
              Votes:
              3 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.