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

Wrong result for BETWEEN predicate involving bitwise negation and implicit type conversion

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.11, 11.4, 11.8, 12.3, 11.4.11
    • 10.11, 11.4, 11.8, 12.3
    • Optimizer
    • MariaDB version: 11.4.11-MariaDB-ubu2404
      Docker image: mariadb:11.4
      Host OS: Windows 11
      Runtime environment: Docker Desktop with WSL2 backend

    Description

      When a query uses a BETWEEN predicate involving a bitwise negation expression (~ TRUE) and mixed-type comparisons between string and numeric values, the predicate may evaluate inconsistently between WHERE filtering and SELECT expression evaluation.

      In this case, the WHERE clause incorrectly returns an empty result set, while evaluating the same predicate as a SELECT expression indicates that one row satisfies the condition.

      CREATE TABLE t448 (c1 VARCHAR (54));
      INSERT INTO t448 (c1) VALUES ('jnbF3LETSTP');
      SELECT t448.c1 FROM t448 JOIN t448 AS ta1 WHERE (('' BETWEEN (~ TRUE) AND t448.c1) IS FALSE);
      --empty set
      SELECT SUM(count) FROM (SELECT (('' BETWEEN (~ TRUE) AND t448.c1) IS FALSE) IS TRUE AS count FROM t448 JOIN t448 AS ta1) AS ta_norec;
      --1
      

      Attachments

        Activity

          People

            psergei Sergei Petrunia
            ss Songsong Wang
            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.