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

Insufficient check for argument validity in JSON functions

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.2(EOL)
    • 10.2.10
    • JSON
    • None
    • 10.2.10

    Description

      Example is for JSON_LENGTH, probably other functions are similarly affected, please keep them consistent.

      JSON_LENGTH does some check on argument validity:

      10.2 (OK)

      MariaDB [test]> select json_length('{{');
      +-------------------+
      | json_length('{{') |
      +-------------------+
      |              NULL |
      +-------------------+
      1 row in set, 1 warning (0.00 sec)
       
      MariaDB [test]> show warnings;
      +---------+------+---------------------------------------------------------------------------------+
      | Level   | Code | Message                                                                         |
      +---------+------+---------------------------------------------------------------------------------+
      | Warning | 4038 | Syntax error in JSON text in argument 1 to function 'json_length' at position 2 |
      +---------+------+---------------------------------------------------------------------------------+
      1 row in set (0.00 sec)
      

      But it does not notice obvious problems in the argument:

      10.2 (not OK)

      MariaDB [test]> select json_length('{}{');
      +--------------------+
      | json_length('{}{') |
      +--------------------+
      |                  0 |
      +--------------------+
      1 row in set (0.00 sec)
      

      MySQL provides decent diagnostics:

      MySQL 5.7

      MySQL [test]> select json_length('{}{');
      ERROR 3141 (22032): Invalid JSON text in argument 1 to function json_length: "The document root must not follow by other values." at position 2.
      

      Attachments

        Activity

          People

            holyfoot Alexey Botchkov
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.