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

comparison semantics flip after function wrapping (equality result silently inverts)

    XMLWordPrintable

Details

    Description

      JSON comparison semantics are installed only where "the extracted value participates directly in the comparison"; any function wrapping turns it into a plain string item going through sortcmp (quoted text vs bare value, not equal). Rewriting WHERE j->'$.a'='text' into the defensive WHERE COALESCE(j->'$.a','')='text' silently flips the result.

      SELECT '{"a":"text"}'->'$.a' = 'text';                      -- 1  (unquote semantics)
      SELECT COALESCE('{"a":"text"}'->'$.a','x') = 'text';        -- 0  (plain string comparison)
      SELECT IFNULL('{"a":"text"}'->'$.a','x') = 'text';          -- 0
      SELECT CONCAT('{"a":"text"}'->'$.a','') = 'text';           -- 0
      SELECT IF(1, '{"a":"text"}'->'$.a','x') = 'text';           -- 0
      

      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.