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

Double negation changes the result of ANY subquery comparison

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Duplicate
    • 12.2.2
    • N/A
    • Optimizer
    • None
    • Not for Release Notes

    Description

      A double negation around an ANY subquery comparison changes the result of the expression.
      The following two expressions should be logically equivalent:

      5 <> ANY(SELECT 6)
      

      and:

      NOT (NOT (5 <> ANY(SELECT 6)))
      

      However, MariaDB returns different results. The original expression returns 1, but the double-negated expression returns 0.
      This violates the expected boolean identity NOT (NOT P) = P.

      How to repeat

      SELECT
        5 <> ANY(SELECT 6) AS orig,
        NOT (NOT (5 <> ANY(SELECT 6))) AS double_negated;
       
      SELECT
        5 < ANY(SELECT 6) AS orig,
        NOT (NOT (5 < ANY(SELECT 6))) AS double_negated;
      

      Observed result

      orig  double_negated
      1     0
       
      orig  double_negated
      1     0
      

      Expected result

      orig  double_negated
      1     1
       
      orig  double_negated
      1     1
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              chen7897 cl hl
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.