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

JSON edit functions' array-index 32-bit wraparound (edit variant of M4 — modifies the wrong position)

    XMLWordPrintable

Details

    Description

      Data-corruption grade: same root cause as M4 (32-bit truncation) but affecting the four edit/check functions JSON_SET/REPLACE/REMOVE/CONTAINS_PATH — modifying data at the wrong position. (Note: negative indices $[-1] counting from the end is a documented MariaDB extension that MySQL rejects — not a bug.)

      SELECT JSON_SET('[10,20,30]', '$[4294967297]', 99);
      -- MariaDB: [10, 99, 30]   <-- 2^32+1 wraps to index 1, value inserted at the wrong position!
      SELECT JSON_REPLACE('[10,20,30]', '$[4294967297]', 99);   -- [10, 99, 30] replaced in the wrong place
      SELECT JSON_REMOVE('[10,20,30]', '$[4294967297]');        -- [10, 30] wrong element deleted
      SELECT JSON_CONTAINS_PATH('[10,20,30]','one','$[4294967297]');  -- 1 (considers it existing)
      -- MySQL: all raise ERROR 3143 Invalid JSON path expression
      

      Attachments

        Issue Links

          Activity

            People

              rucha174 Rucha Deodhar
              chunlingqin chunlingqin
              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.