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

XOR incorrectly treats a non-integer string operand as FALSE

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 12.3.2
    • 10.11.19, 11.4.13, 11.8.9, 12.3.3, 13.0.2
    • Optimizer, Server
    • None
    • Windows 11 Home 64-bit
      Database Server: MariaDB 12.3.2-MariaDB
      Server Comment: MariaDB Server
    • Not for Release Notes
    • XOR could incorrectly treat non-integer string operands as FALSE, causing rows to be omitted from WHERE results.

    Description

          1. Summary

      MariaDB evaluates the non-integer string `'0.7'` as TRUE in IS TRUE, AND, and OR expressions, but evaluates it as FALSE when it is used as the left operand of XOR.

      This can cause rows to be incorrectly filtered out by a WHERE clause.

          1. Steps to reproduce

      Run the following query:

      ```sql
      SELECT
      '0.7' IS TRUE AS is_true,
      '0.7' AND TRUE AS and_true,
      '0.7' OR FALSE AS or_false,
      '0.7' XOR FALSE AS xor_false,
      '0.7' XOR TRUE AS xor_true;

          1. Expected result
            According to the logical XOR semantics, a non-zero operand is TRUE.
            Therefore:
            '0.7' IS TRUE -> 1
            '0.7' AND TRUE -> 1
            '0.7' OR FALSE -> 1
            '0.7' XOR FALSE -> 1
            '0.7' XOR TRUE -> 0
            The filtering query should return one row:
            -------
            value

            -------

            0.7

            -------

          1. Actual result on MariaDB 12.3.2
            -------------------------------------------
            is_true and_true or_false xor_false xor_true

            -------------------------------------------

            1 1 1 0 1

            -------------------------------------------
            The filtering query returns:Empty set
            Thus, MariaDB treats '0.7' as TRUE for IS TRUE, AND, and OR, but as FALSE for XOR.

      MySQL 8.0.46 and MySQL 8.4.7 return:
      -------------------------------------------

      is_true and_true or_false xor_false xor_true

      -------------------------------------------

      1 1 1 1 0

      -------------------------------------------
      The filtering query also returns one row on both MySQL versions.

      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.