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

Incorrect constant folding for NOT/IN predicate: scalar evaluation returns TRUE but WHERE returns no rows

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Duplicate
    • 12.3.2
    • N/A
    • Optimizer
    • None
    •  Windows 11 64-bit

      Database Server: MariaDB 12.3.2-MariaDB
    • Not for Release Notes
    • An optimizer bug could incorrectly filter rows when a constant predicate containing nested NOT and IN operators is used in a WHERE clause.

    Description

          1. Description

      MariaDB evaluates the following predicate as TRUE when it is selected directly, but treats the same predicate as FALSE when it is used in a WHERE clause.

          1. Reproduction

      ```sql
      SELECT NOT (NOT ((NOT (NOT (0.9632180211473692))) IN (1))) AS value;

      SELECT NOT (NOT ((NOT (NOT (0.9632180211473692))) IN (1))) AS value
      FROM DUAL
      WHERE NOT (NOT ((NOT (NOT (0.9632180211473692))) IN (1)));

          1. Expected result
            Both statements should return one row:
            -------
            value

            -------

            1

            -------

      The expression is constant and evaluates to TRUE, so using it in the WHERE clause should not remove the row.

          1. Actual result
            On MariaDB 12.3.2:
            The first statement returns:
            -------
            value

            -------

            1

            -------

      The second statement returns an empty result set: Empty set
      The same two statements return one row with value 1 on MySQL 8.0.46 and MySQL 8.4.7

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              123 zhang hanshuo
              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.