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

JSON_KEYS does not return error on invalid json doc while documentation says it would

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 10.2, 10.3, 10.4
    • 10.4
    • Documentation, JSON
    • None

    Description

      Documentation for JSON_KEYS makes a distinction between "json_doc argument is not an object" (function should return NULL) and "JSON document is invalid" (function should return error). In reality, there seems to be no such difference, the function returns NULL either way:

      MariaDB [test]> select json_valid('{"foo"}'), json_keys('{"foo"}');
      +-----------------------+----------------------+
      | json_valid('{"foo"}') | json_keys('{"foo"}') |
      +-----------------------+----------------------+
      |                     0 | NULL                 |
      +-----------------------+----------------------+
      1 row in set, 1 warning (0.000 sec)
       
      MariaDB [test]> show warnings;
      +---------+------+-------------------------------------------------------------------------------+
      | Level   | Code | Message                                                                       |
      +---------+------+-------------------------------------------------------------------------------+
      | Warning | 4038 | Syntax error in JSON text in argument 1 to function 'json_keys' at position 6 |
      +---------+------+-------------------------------------------------------------------------------+
      1 row in set (0.000 sec)
      

      Maybe some other case of "JSON document is invalid" was meant, but there is no examples in the documentation or in the MTR test case.

      Possibly it's just a documentation issue.

      Attachments

        Activity

          People

            rucha174 Rucha Deodhar
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

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