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

JSON_OBJECT duplicate keys produce an invalid JSON document (RFC 8259 violation)

    XMLWordPrintable

Details

    Description

      SELECT JSON_OBJECT('a',1,'a',2);
      -- MariaDB: {"a": 1, "a": 2}   <-- duplicate keys, invalid per RFC 8259
      -- MySQL  : {"a": 2}           <-- last value wins, valid
       
      SELECT JSON_VALID(JSON_OBJECT('a',1,'a',2));   -- MariaDB: 1 (invalid document judged valid)
      SELECT JSON_EXTRACT(JSON_OBJECT('a',1,'a',2),'$.a');  -- 1 (first value taken)
      

      Violates RFC 8259 (object keys must be unique), producing a document strict parsers cannot consume;
      JSON_VALID returns 1 for the duplicate-key document (verification distortion; dirty data can enter JSON columns);
      Extraction takes the first value while MySQL semantics is "last value wins" — the same document resolves differently across the two systems (JSON_OBJECT results replicated from MySQL→MariaDB extract different values).

      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.