Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Not a Bug
    • 11.2.2
    • N/A
    • JSON
    • Linux dev 4.19.0-21-amd64 #1 SMP Debian 4.19.249-2 (2022-06-30) x86_64 GNU/Linux

    Description

      The attached script shows that JSON_SEARCH fails to find an occurrence that does exist.

      I also have examples where JSON_SEARCH 'one' finds something, but 'all' finds nothing at all.

      Attachments

        Issue Links

          Activity

            alice Alice Sherepa added a comment -

            MariaDB returns a warning about json depth and it is probably a reason why it does not find anything:

            MariaDB [test]> SELECT JSON_SEARCH(@json, 'one', '%needle%', null);
            +---------------------------------------------+
            | JSON_SEARCH(@json, 'one', '%needle%', null) |
            +---------------------------------------------+
            | NULL                                        |
            +---------------------------------------------+
            1 row in set, 1 warning (0,003 sec)
             
            Warning (Code 4040): Limit of 32 on JSON nested structures depth is reached in argument 1 to function 'json_search' at position 25847
             
            MariaDB [test]> select JSON_VALID(@json);
            +-------------------+
            | JSON_VALID(@json) |
            +-------------------+
            |                 0 |
            +-------------------+
            1 row in set (0,003 sec)
            

            alice Alice Sherepa added a comment - MariaDB returns a warning about json depth and it is probably a reason why it does not find anything: MariaDB [test]> SELECT JSON_SEARCH(@json, 'one', '%needle%', null); +---------------------------------------------+ | JSON_SEARCH(@json, 'one', '%needle%', null) | +---------------------------------------------+ | NULL | +---------------------------------------------+ 1 row in set, 1 warning (0,003 sec)   Warning (Code 4040): Limit of 32 on JSON nested structures depth is reached in argument 1 to function 'json_search' at position 25847   MariaDB [test]> select JSON_VALID(@json); +-------------------+ | JSON_VALID(@json) | +-------------------+ | 0 | +-------------------+ 1 row in set (0,003 sec)
            akim.demaille Akim Demaille added a comment - - edited

            Hi Alice,
            Thanks a lot for this critical detail. I did not get the warning.

            Would you happen to know it there any way to support deeper structures? My JSON documents are deep, and need to be deep.

            I looked for Code 4040, and found nothing about how to allocate more space for nesting.

            akim.demaille Akim Demaille added a comment - - edited Hi Alice, Thanks a lot for this critical detail. I did not get the warning. Would you happen to know it there any way to support deeper structures? My JSON documents are deep, and need to be deep. I looked for Code 4040, and found nothing about how to allocate more space for nesting.
            akim.demaille Akim Demaille added a comment -

            I have found the definition of the max depth:

            https://github.com/MariaDB/server/blob/711b8671bee306f58a2dcf6ffe8d9c93a32b3171/include/json_lib.h#L10

            but it appears to be hard-coded, and I don't see a way to change that with a configuration file (compile time, nor runtime). Is there a way to enlarge this limit, besides editing the file and recompiling the server by hand?

            akim.demaille Akim Demaille added a comment - I have found the definition of the max depth: https://github.com/MariaDB/server/blob/711b8671bee306f58a2dcf6ffe8d9c93a32b3171/include/json_lib.h#L10 but it appears to be hard-coded, and I don't see a way to change that with a configuration file (compile time, nor runtime). Is there a way to enlarge this limit, besides editing the file and recompiling the server by hand?

            it's already work in progress, see MDEV-32854. Currently planned for the next release.

            serg Sergei Golubchik added a comment - it's already work in progress, see MDEV-32854 . Currently planned for the next release.

            meanwhile I'll close this issue as "not a bug", because the behavior is intentional. It's not a programming mistake that JSON_SEARCH doesn't find matches deeper than a hard-coded limit.

            serg Sergei Golubchik added a comment - meanwhile I'll close this issue as "not a bug", because the behavior is intentional. It's not a programming mistake that JSON_SEARCH doesn't find matches deeper than a hard-coded limit.

            People

              Unassigned Unassigned
              akim.demaille Akim Demaille
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.